xref: /openbsd/regress/sys/netinet6/rh0/rh0_final.py (revision 73471bf0)
1#!/usr/local/bin/python3
2# send a ping6 packet with routing header type 0
3# the address pointer is at the final destination
4# we expect a parameter problem from header scanning
5
6print("send ping6 packet with routing header type 0 to the final destination")
7
8import os
9from addr import *
10from scapy.all import *
11
12eid=os.getpid() & 0xffff
13payload=b"ABCDEFGHIJKLMNOP"
14packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\
15    IPv6ExtHdrRouting(addresses=[OTHER_FAKE1_ADDR6, OTHER_FAKE2_ADDR6], \
16    segleft=0)/\
17    ICMPv6EchoRequest(id=eid, data=payload)
18eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet
19
20if os.fork() == 0:
21	time.sleep(1)
22	sendp(eth, iface=LOCAL_IF)
23	os._exit(0)
24
25ans=sniff(iface=LOCAL_IF, timeout=3, filter=
26    "ip6 and dst "+LOCAL_ADDR6+" and icmp6")
27for a in ans:
28	if a and a.type == ETH_P_IPV6 and \
29	    ipv6nh[a.payload.nh] == 'ICMPv6' and \
30	    icmp6types[a.payload.payload.type] == 'Parameter problem':
31		pprob=a.payload.payload
32		code=pprob.code
33		print("code=%#d" % (code))
34		if code != 0:
35			print("WRONG PARAMETER PROBLEM CODE")
36			exit(2)
37		ptr=pprob.ptr
38		print("ptr=%#d" % (ptr))
39		if ptr != 42:
40			print("WRONG PARAMETER PROBLEM POINTER")
41			exit(2)
42		exit(0)
43print("NO ICMP6 PARAMETER PROBLEM")
44exit(1)
45