case Q_IP:
b0 = gen_linktype(cstate, ETHERTYPE_IP);
+ /*
+ * Belt and braces: if other code works correctly, any host
+ * bits are clear and mask == 0 means addr == 0. In this case
+ * the call to gen_hostop() would produce an "always true"
+ * instruction block and ANDing it with the link type check
+ * would be a no-op.
+ */
+ if (mask == 0 && addr == 0)
+ return b0;
b1 = gen_hostop(cstate, addr, mask, dir, 12, 16);
gen_and(b0, b1);
return b1;
case Q_RARP:
b0 = gen_linktype(cstate, ETHERTYPE_REVARP);
+ // Same as for Q_IP above.
+ if (mask == 0 && addr == 0)
+ return b0;
b1 = gen_hostop(cstate, addr, mask, dir, 14, 24);
gen_and(b0, b1);
return b1;
case Q_ARP:
b0 = gen_linktype(cstate, ETHERTYPE_ARP);
+ // Same as for Q_IP above.
+ if (mask == 0 && addr == 0)
+ return b0;
b1 = gen_hostop(cstate, addr, mask, dir, 14, 24);
gen_and(b0, b1);
return b1;
DLT => 'RAW',
snaplen => 2000,
aliases => ['ip dst net 0.0.0.0/0'],
- opt => '
+ unopt => '
(000) ldb [0]
(001) and #0xf0
(002) jeq #0x40 jt 3 jf 4
(003) ret #2000
(004) ret #0
',
- unopt => '
- (000) ldb [0]
- (001) and #0xf0
- (002) jeq #0x40 jt 3 jf 6
- (003) ld #0x0
- (004) jeq #0x0 jt 5 jf 6
- (005) ret #2000
- (006) ret #0
- ',
}, # ip_dst_net_addr_0
{
name => 'ip_dst_net_addr_8',