1#!/usr/local/bin/python2.7 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 6import os 7from addr import * 8from scapy.all import * 9 10pid=os.getpid() & 0xffff 11payload="ABCDEFGHIJKLMNOP" 12packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ 13 IPv6ExtHdrRouting(addresses=[])/\ 14 ICMPv6EchoRequest(id=pid, data=payload) 15eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet 16 17if os.fork() == 0: 18 time.sleep(1) 19 sendp(eth, iface=SRC_IF) 20 os._exit(0) 21 22ans=sniff(iface=SRC_IF, timeout=3, filter= 23 "ip6 and dst "+SRC_OUT6+" and icmp6") 24for a in ans: 25 if a and a.type == ETH_P_IPV6 and \ 26 ipv6nh[a.payload.nh] == 'ICMPv6' and \ 27 icmp6types[a.payload.payload.type] == 'Parameter problem': 28 pprob=a.payload.payload 29 code=pprob.code 30 print "code=%#d" % (code) 31 if code != 0: 32 print "WRONG PARAMETER PROBLEM CODE" 33 exit(2) 34 ptr=pprob.ptr 35 print "ptr=%#d" % (ptr) 36 if ptr != 42: 37 print "WRONG PARAMETER PROBLEM POINTER" 38 exit(2) 39 exit(0) 40print "NO ICMP6 PARAMETER PROBLEM" 41exit(1) 42