summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2007-04-30 17:39:30 +0000
committermaxim <maxim@FreeBSD.org>2007-04-30 17:39:30 +0000
commit185e6bdacbf602696d724b2a2ec619e9d1b70a39 (patch)
tree568d7a724ce38d428d5c8e6e138bb4bae98e6a11 /sbin
parentd85104099ad40c33148426adb779741c366c2f19 (diff)
downloadFreeBSD-src-185e6bdacbf602696d724b2a2ec619e9d1b70a39.zip
FreeBSD-src-185e6bdacbf602696d724b2a2ec619e9d1b70a39.tar.gz
o Make ipfw(8) show rules with mac/mac-type options correctly.
Before: $ ipfw -n add 100 count icmp from any to any mac-type 0x01 00100 count icmp 0x0001 $ ipfw -n add 100 count icmp from any to any mac any any 00100 count icmp MAC any any any After: $ ipfw -n add 100 count icmp from any to any mac-type 0x01 00100 count icmp from any to any mac-type 0x0001 $ ipfw -n add 100 count icmp from any to any mac any any 00100 count icmp from any to any MAC any any PR: bin/112244 Submitted by: Andrey V. Elsukov MFC after: 1 month
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ipfw/ipfw2.c53
1 files changed, 17 insertions, 36 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 3423e0f..14c707c 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -1400,10 +1400,8 @@ print_ext6hdr( ipfw_insn *cmd )
#define HAVE_PROTO 0x0001
#define HAVE_SRCIP 0x0002
#define HAVE_DSTIP 0x0004
-#define HAVE_MAC 0x0008
-#define HAVE_MACTYPE 0x0010
-#define HAVE_PROTO4 0x0040
-#define HAVE_PROTO6 0x0080
+#define HAVE_PROTO4 0x0008
+#define HAVE_PROTO6 0x0010
#define HAVE_OPTIONS 0x8000
#define HAVE_IP (HAVE_PROTO | HAVE_SRCIP | HAVE_DSTIP)
@@ -1415,16 +1413,6 @@ show_prerequisites(int *flags, int want, int cmd)
if ( (*flags & HAVE_IP) == HAVE_IP)
*flags |= HAVE_OPTIONS;
- if ( (*flags & (HAVE_MAC|HAVE_MACTYPE|HAVE_OPTIONS)) == HAVE_MAC &&
- cmd != O_MAC_TYPE) {
- /*
- * mac-type was optimized out by the compiler,
- * restore it
- */
- printf(" any");
- *flags |= HAVE_MACTYPE | HAVE_OPTIONS;
- return;
- }
if ( !(*flags & HAVE_OPTIONS)) {
if ( !(*flags & HAVE_PROTO) && (want & HAVE_PROTO))
if ( (*flags & HAVE_PROTO4))
@@ -1680,28 +1668,6 @@ show_ipfw(struct ip_fw *rule, int pcwidth, int bcwidth)
case O_PROBE_STATE:
break; /* no need to print anything here */
- case O_MACADDR2: {
- ipfw_insn_mac *m = (ipfw_insn_mac *)cmd;
-
- if ((cmd->len & F_OR) && !or_block)
- printf(" {");
- if (cmd->len & F_NOT)
- printf(" not");
- printf(" MAC");
- flags |= HAVE_MAC;
- print_mac(m->addr, m->mask);
- print_mac(m->addr + 6, m->mask + 6);
- }
- break;
-
- case O_MAC_TYPE:
- if ((cmd->len & F_OR) && !or_block)
- printf(" {");
- print_newports((ipfw_insn_u16 *)cmd, IPPROTO_ETHERTYPE,
- (flags & HAVE_OPTIONS) ? cmd->opcode : 0);
- flags |= HAVE_MAC | HAVE_MACTYPE | HAVE_OPTIONS;
- break;
-
case O_IP_SRC:
case O_IP_SRC_LOOKUP:
case O_IP_SRC_MASK:
@@ -1809,6 +1775,21 @@ show_ipfw(struct ip_fw *rule, int pcwidth, int bcwidth)
if (cmd->len & F_NOT && cmd->opcode != O_IN)
printf(" not");
switch(cmd->opcode) {
+ case O_MACADDR2: {
+ ipfw_insn_mac *m = (ipfw_insn_mac *)cmd;
+
+ printf(" MAC");
+ print_mac(m->addr, m->mask);
+ print_mac(m->addr + 6, m->mask + 6);
+ }
+ break;
+
+ case O_MAC_TYPE:
+ print_newports((ipfw_insn_u16 *)cmd,
+ IPPROTO_ETHERTYPE, cmd->opcode);
+ break;
+
+
case O_FRAG:
printf(" frag");
break;
OpenPOWER on IntegriCloud