rh0_empty.py revision 1.6
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
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="ABCDEFGHIJKLMNOP"
14packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\
15    IPv6ExtHdrRouting(addresses=[])/\
16    ICMPv6EchoRequest(id=eid, data=payload)
17eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet
18
19if os.fork() == 0:
20	time.sleep(1)
21	sendp(eth, iface=SRC_IF)
22	os._exit(0)
23
24ans=sniff(iface=SRC_IF, timeout=3, filter=
25    "ip6 and dst "+SRC_OUT6+" 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