@@ -4174,14 +4174,163 @@ my %accept_blocks = (
41744174 (011) ret #0
41754175 ' ,
41764176 }, # proto
4177+ ip_protochain => {
4178+ skip => skip_config_def1 (' NO_PROTOCHAIN' ),
4179+ DLT => ' RAW' ,
4180+ expr => ' ip protochain \udp' ,
4181+ aliases => [' ip protochain 17' ],
4182+ unopt => '
4183+ (000) ldb [0]
4184+ (001) and #0xf0
4185+ (002) jeq #0x40 jt 3 jf 24
4186+ (003) ldb [9]
4187+ (004) ldxb 4*([0]&0xf)
4188+ (005) jeq #0x11 jt 21 jf 6
4189+ (006) jeq #0x3b jt 21 jf 7
4190+ (007) add #0
4191+ (008) jeq #0x33 jt 9 jf 21
4192+ (009) txa
4193+ (010) ldb [x + 0]
4194+ (011) st M[0]
4195+ (012) txa
4196+ (013) add #1
4197+ (014) tax
4198+ (015) ldb [x + 0]
4199+ (016) add #2
4200+ (017) mul #4
4201+ (018) tax
4202+ (019) ld M[0]
4203+ (020) ja 5
4204+ (021) add #0
4205+ (022) jeq #0x11 jt 23 jf 24
4206+ (023) ret #262144
4207+ (024) ret #0
4208+ ' ,
4209+ }, # ip_protochain
4210+ ip6_protochain => {
4211+ skip => skip_config_def1 (' NO_PROTOCHAIN' ),
4212+ DLT => ' RAW' ,
4213+ expr => ' ip6 protochain \udp' ,
4214+ aliases => [' ip6 protochain 17' ],
4215+ unopt => '
4216+ (000) ldb [0]
4217+ (001) and #0xf0
4218+ (002) jeq #0x60 jt 3 jf 36
4219+ (003) ldb [6]
4220+ (004) ldx #0x28
4221+ (005) jeq #0x11 jt 33 jf 6
4222+ (006) jeq #0x3b jt 33 jf 7
4223+ (007) jeq #0x0 jt 11 jf 8
4224+ (008) jeq #0x3c jt 11 jf 9
4225+ (009) jeq #0x2b jt 11 jf 10
4226+ (010) jeq #0x2c jt 11 jf 20
4227+ (011) ldb [x + 0]
4228+ (012) st M[0]
4229+ (013) ldb [x + 1]
4230+ (014) add #1
4231+ (015) mul #8
4232+ (016) add x
4233+ (017) tax
4234+ (018) ld M[0]
4235+ (019) ja 5
4236+ (020) jeq #0x33 jt 21 jf 33
4237+ (021) txa
4238+ (022) ldb [x + 0]
4239+ (023) st M[0]
4240+ (024) txa
4241+ (025) add #1
4242+ (026) tax
4243+ (027) ldb [x + 0]
4244+ (028) add #2
4245+ (029) mul #4
4246+ (030) tax
4247+ (031) ld M[0]
4248+ (032) ja 5
4249+ (033) add #0
4250+ (034) jeq #0x11 jt 35 jf 36
4251+ (035) ret #262144
4252+ (036) ret #0
4253+ ' ,
4254+ }, # ip6_protochain
4255+ protochain => {
4256+ skip => skip_config_def1 (' NO_PROTOCHAIN' ),
4257+ DLT => ' RAW' ,
4258+ expr => ' protochain \udp' ,
4259+ aliases => [' protochain 17' ],
4260+ unopt => '
4261+ (000) ldb [0]
4262+ (001) and #0xf0
4263+ (002) jeq #0x40 jt 3 jf 23
4264+ (003) ldb [9]
4265+ (004) ldxb 4*([0]&0xf)
4266+ (005) jeq #0x11 jt 21 jf 6
4267+ (006) jeq #0x3b jt 21 jf 7
4268+ (007) add #0
4269+ (008) jeq #0x33 jt 9 jf 21
4270+ (009) txa
4271+ (010) ldb [x + 0]
4272+ (011) st M[1]
4273+ (012) txa
4274+ (013) add #1
4275+ (014) tax
4276+ (015) ldb [x + 0]
4277+ (016) add #2
4278+ (017) mul #4
4279+ (018) tax
4280+ (019) ld M[1]
4281+ (020) ja 5
4282+ (021) add #0
4283+ (022) jeq #0x11 jt 58 jf 23
4284+ (023) ldb [0]
4285+ (024) and #0xf0
4286+ (025) jeq #0x60 jt 26 jf 59
4287+ (026) ldb [6]
4288+ (027) ldx #0x28
4289+ (028) jeq #0x11 jt 56 jf 29
4290+ (029) jeq #0x3b jt 56 jf 30
4291+ (030) jeq #0x0 jt 34 jf 31
4292+ (031) jeq #0x3c jt 34 jf 32
4293+ (032) jeq #0x2b jt 34 jf 33
4294+ (033) jeq #0x2c jt 34 jf 43
4295+ (034) ldb [x + 0]
4296+ (035) st M[1]
4297+ (036) ldb [x + 1]
4298+ (037) add #1
4299+ (038) mul #8
4300+ (039) add x
4301+ (040) tax
4302+ (041) ld M[1]
4303+ (042) ja 28
4304+ (043) jeq #0x33 jt 44 jf 56
4305+ (044) txa
4306+ (045) ldb [x + 0]
4307+ (046) st M[1]
4308+ (047) txa
4309+ (048) add #1
4310+ (049) tax
4311+ (050) ldb [x + 0]
4312+ (051) add #2
4313+ (052) mul #4
4314+ (053) tax
4315+ (054) ld M[1]
4316+ (055) ja 28
4317+ (056) add #0
4318+ (057) jeq #0x11 jt 58 jf 59
4319+ (058) ret #262144
4320+ (059) ret #0
4321+ ' ,
4322+ }, # protochain
41774323 ip_host => {
41784324 # For this and some other single-stack qualifiers below use DLT_RAW to
41794325 # verify that the bytecode does not try to match the other protocol too.
41804326 DLT => ' RAW' ,
41814327 snaplen => 2000,
41824328 expr => ' ip host 192.168.170.211' ,
41834329 aliases => [
4330+ ' ip src or dst 192.168.170.211' ,
4331+ ' ip src or dst host 192.168.170.211' ,
41844332 ' host 192.168.170.211' ,
4333+ ' src or dst 192.168.170.211' ,
41854334 ' src or dst host 192.168.170.211' ,
41864335 ],
41874336 opt => '
@@ -4331,11 +4480,11 @@ my %accept_blocks = (
43314480 (005) ret #0
43324481 ' ,
43334482 }, # igmp
4334- igrp => {
4335- # "igrp" uses IPPROTO_IGRP, which FreeBSD and its derivatives define, but
4336- # other supported OSes don't (thus libpcap uses its own value, which is
4337- # different from FreeBSD). Skip the test until it is clear how to resolve
4338- # this discrepancy.
4483+ # " igrp" uses IPPROTO_IGRP, which FreeBSD and its derivatives define, but
4484+ # other supported OSes don't (thus libpcap uses its own value, which is
4485+ # different from FreeBSD). Test each case separately.
4486+ # this discrepancy.
4487+ igrp_9 => {
43394488 skip => (skip_os (' freebsd' ) or skip_os (' darwin' ) or skip_os (' dragonfly' )),
43404489 DLT => ' EN10MB' ,
43414490 expr => ' igrp' ,
@@ -4348,7 +4497,23 @@ my %accept_blocks = (
43484497 (004) ret #262144
43494498 (005) ret #0
43504499 ' ,
4351- }, # igrp
4500+ }, # igrp_9
4501+ igrp_88 => {
4502+ skip => skip_os_not (' freebsd' ) && skip_os_not (' darwin' ) && skip_os_not (' dragonfly' ),
4503+ DLT => ' EN10MB' ,
4504+ expr => ' igrp' ,
4505+ aliases => [
4506+ ' ip proto 88' ,
4507+ ],
4508+ unopt => '
4509+ (000) ldh [12]
4510+ (001) jeq #0x800 jt 2 jf 5
4511+ (002) ldb [23]
4512+ (003) jeq #0x58 jt 4 jf 5
4513+ (004) ret #262144
4514+ (005) ret #0
4515+ ' ,
4516+ }, # igrp_88
43524517 icmp6 => {
43534518 DLT => ' EN10MB' ,
43544519 expr => ' icmp6' ,
@@ -6389,6 +6554,11 @@ my %reject_tests = (
63896554 expr => ' ip broadcast' ,
63906555 errstr => " netmask not known, so 'ip broadcast' not supported" ,
63916556 },
6557+ arp_protochain => {
6558+ DLT => ' EN10MB' ,
6559+ expr => ' arp protochain 17' ,
6560+ errstr => ' bad protocol applied for \' protochain\' ' ,
6561+ },
63926562 # In the tests below the hostname normally should not matter because the
63936563 # lookup would be made not in the IPv4/IPv6 space, or not at all. Still
63946564 # use a hostname that does not exist on the Internet, just in case.
0 commit comments