1#!/usr/local/bin/python3 2# send a ping6 packet with routing header type 0 3# the address list is empty 4# we expect a parameter problem from header scanning 5 6print("send ping6 packet with routing header type 0 but empty address list") 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=[])/\ 16 ICMPv6EchoRequest(id=eid, data=payload) 17eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet 18 19if os.fork() == 0: 20 time.sleep(1) 21 sendp(eth, iface=LOCAL_IF) 22 os._exit(0) 23 24ans=sniff(iface=LOCAL_IF, timeout=3, filter= 25 "ip6 and dst "+LOCAL_ADDR6+" and icmp6") 26for a in ans: 27 if a and a.type == ETH_P_IPV6 and \ 28 ipv6nh[a.payload.nh] == 'ICMPv6' and \ 29 icmp6types[a.payload.payload.type] == 'Parameter problem': 30 pprob=a.payload.payload 31 code=pprob.code 32 print("code=%#d" % (code)) 33 if code != 0: 34 print("WRONG PARAMETER PROBLEM CODE") 35 exit(2) 36 ptr=pprob.ptr 37 print("ptr=%#d" % (ptr)) 38 if ptr != 42: 39 print("WRONG PARAMETER PROBLEM POINTER") 40 exit(2) 41 exit(0) 42print("NO ICMP6 PARAMETER PROBLEM") 43exit(1) 44