mac_print(const void *ip, const struct xt_entry_match *match, int numeric)
{
const struct xt_mac_info *info = (void *)match->data;
+
printf(" MAC");
if (info->invert)
printf(" !");
-
+
print_mac(info->srcaddr);
}
print_mac(info->srcaddr);
}
+static void print_mac_xlate(const unsigned char *macaddress,
+ struct xt_buf *buf)
+{
+ unsigned int i;
+
+ xt_buf_add(buf, "%02x", macaddress[0]);
+ for (i = 1; i < ETH_ALEN; ++i)
+ xt_buf_add(buf, ":%02x", macaddress[i]);
+ xt_buf_add(buf, " ");
+}
+
+static int mac_xlate(const struct xt_entry_match *match,
+ struct xt_buf *buf, int numeric)
+{
+ const struct xt_mac_info *info = (void *)match->data;
+
+ xt_buf_add(buf, "ether saddr%s ", info->invert ? " !=" : "");
+ print_mac_xlate(info->srcaddr, buf);
+
+ return 1;
+}
+
static struct xtables_match mac_match = {
.family = NFPROTO_UNSPEC,
- .name = "mac",
+ .name = "mac",
.version = XTABLES_VERSION,
.size = XT_ALIGN(sizeof(struct xt_mac_info)),
.userspacesize = XT_ALIGN(sizeof(struct xt_mac_info)),
.print = mac_print,
.save = mac_save,
.x6_options = mac_opts,
+ .xlate = mac_xlate,
};
void _init(void)