{ "Lc" , no_argument , 0, 4 },
{ "Ln" , no_argument , 0, 5 },
{ "Lx" , no_argument , 0, 6 },
+ { "Lmac2" , no_argument , 0, 12 },
{ "zero" , optional_argument, 0, 'Z' },
{ "flush" , optional_argument, 0, 'F' },
{ "policy" , required_argument, 0, 'P' },
* we use replace.flags, so we can't use the following values:
* 0x01 == OPT_COMMAND, 0x02 == OPT_TABLE, 0x100 == OPT_ZERO
*/
-#define LIST_N 0x04
-#define LIST_C 0x08
-#define LIST_X 0x10
+#define LIST_N 0x04
+#define LIST_C 0x08
+#define LIST_X 0x10
+#define LIST_MAC2 0x20
+
+void print_mac(const char *mac)
+{
+ if (replace.flags & LIST_MAC2) {
+ int j;
+ for (j = 0; j < ETH_ALEN; j++)
+ printf("%02x%s", (unsigned char)mac[j],
+ (j==ETH_ALEN-1) ? "" : ":");
+ } else
+ printf("%s", ether_ntoa((struct ether_addr *) mac));
+}
+
+void print_mac_and_mask(const char *mac, const char *mask)
+{
+ char hlpmsk[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+ print_mac(mac);
+ if (memcmp(mask, hlpmsk, 6)) {
+ printf("/");
+ print_mac(mask);
+ }
+}
+
/*
* helper function for list_rules()
*/
}
}
if (hlp->bitmask & EBT_SOURCEMAC) {
- char hlpmsk[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
printf("-s ");
if (hlp->invflags & EBT_ISOURCE)
printf("! ");
printf("Broadcast");
goto endsrc;
}
- printf("%s", ether_ntoa((struct ether_addr *)
- hlp->sourcemac));
- if (memcmp(hlp->sourcemsk, hlpmsk, 6)) {
- printf("/");
- printf("%s", ether_ntoa((struct ether_addr *)
- hlp->sourcemsk));
- }
+ print_mac_and_mask(hlp->sourcemac, hlp->sourcemsk);
endsrc:
printf(" ");
}
if (hlp->bitmask & EBT_DESTMAC) {
- char hlpmsk[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
printf("-d ");
if (hlp->invflags & EBT_IDEST)
printf("! ");
printf("Broadcast");
goto enddst;
}
- printf("%s", ether_ntoa((struct ether_addr *)
- hlp->destmac));
- if (memcmp(hlp->destmsk, hlpmsk, 6)) {
- printf("/");
- printf("%s", ether_ntoa((struct ether_addr *)
- hlp->destmsk));
- }
+ print_mac_and_mask(hlp->destmac, hlp->destmsk);
enddst:
printf(" ");
}
print_error("--Lx not compatible with --Ln");
replace.flags |= LIST_X;
break;
+ case 12 : /* Lmac2 */
+ check_option(&replace.flags, LIST_MAC2);
+ if (replace.command != 'L')
+ print_error("Use --Lmac2 with -L");
+ replace.flags |= LIST_MAC2;
+ break;
case 8 : /* atomic-commit */
replace.command = c;
if (replace.flags & OPT_COMMAND)
printf("%s ", mask_to_dotted(arpinfo->dmsk));
}
if (arpinfo->bitmask & EBT_ARP_SRC_MAC) {
- int verdict;
printf("--arp-mac-src ");
if (arpinfo->invflags & EBT_ARP_SRC_MAC)
printf("! ");
- for (i = 0; i < 6; i++)
- printf("%x%s", ((unsigned char *)&arpinfo->smaddr)[i],
- (i == 5) ? "" : ":");
- verdict = 0;
- for (i = 0; i < 6; i++)
- verdict = (arpinfo->smmsk[i] ^ 0xFF);
- if (verdict != 0) {
- printf("%s", "/");
- for (i = 0; i < 6; i++)
- printf("%x%s", ((unsigned char *)&arpinfo->smmsk)[i],
- (i == 5) ? "" : ":");
- printf("%s", " ");
- }
+ print_mac_and_mask(arpinfo->smaddr, arpinfo->smmsk);
}
if (arpinfo->bitmask & EBT_ARP_DST_MAC) {
- int verdict;
printf("--arp-mac-dst ");
if (arpinfo->invflags & EBT_ARP_DST_MAC)
printf("! ");
- for (i = 0; i < 6; i++)
- printf("%x%s", ((unsigned char *)&arpinfo->dmaddr)[i],
- (i == 5) ? "" : ":");
- verdict = 0;
- for (i = 0; i < 6; i++)
- verdict = (arpinfo->dmmsk[i] ^ 0xFF);
- if (verdict != 0) {
- printf("%s", "/");
- for (i = 0; i < 6; i++)
- printf("%x%s", ((unsigned char *)&arpinfo->dmmsk)[i],
- (i == 5) ? "" : ":");
- }
+ print_mac_and_mask(arpinfo->dmaddr, arpinfo->dmmsk);
}
}