+#define MAX_IPv6_STR_LEN INET6_ADDRSTRLEN
+static void
+bridge_mac_nat(int s, const char *prefix)
+{
+ char *buf;
+ unsigned int count;
+ struct ether_addr ea;
+ unsigned int i;
+ struct ifbrmnelist mnl;
+ char *scan;
+
+ bzero(&mnl, sizeof(mnl));
+ if (do_cmd(s, BRDGGMACNATLIST, &mnl, sizeof(mnl), 0) < 0) {
+ /* err(1, "unable to get mac nat list"); */
+ return;
+ }
+ if (mnl.ifbml_len == 0) {
+ return;
+ }
+ printf("\tMAC NAT list:\n");
+ if (mnl.ifbml_elsize == 0) {
+ err(1, "kernel reported zero length element size");
+ }
+ if (mnl.ifbml_elsize < sizeof(struct ifbrmne)) {
+ err(1, "struct element size too small, kernel mismatch");
+ }
+ buf = malloc(mnl.ifbml_len);
+ if (buf == NULL) {
+ err(1, "unable to allocate mac nat list buffer");
+ }
+ mnl.ifbml_buf = buf;
+ if (do_cmd(s, BRDGGMACNATLIST, &mnl, sizeof(mnl), 0) < 0) {
+ err(1, "unable to get mac nat list");
+ }
+ count = mnl.ifbml_len / mnl.ifbml_elsize;
+ for (i = 0, scan = buf; i < count; i++, scan += mnl.ifbml_elsize) {
+ struct ifbrmne *ifbmne = (struct ifbrmne *)scan;
+ char ntopbuf[INET6_ADDRSTRLEN];
+
+ memcpy(ea.octet, ifbmne->ifbmne_mac,
+ sizeof(ea.octet));
+ inet_ntop(ifbmne->ifbmne_af, &ifbmne->ifbmne_ip,
+ ntopbuf, sizeof(ntopbuf));
+ printf("%s%s %s %s %lu\n",
+ prefix, ifbmne->ifbmne_ifname, ntopbuf, ether_ntoa(&ea),
+ (unsigned long)ifbmne->ifbmne_expire);
+ }
+ free(buf);
+}
+