summaryrefslogtreecommitdiff
path: root/regress/sys/net/pf_opts/icmp6_mld_ra.py
blob: a156796eb0356d1b7ff988f9602e4d48c7e7fe01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/local/bin/python3

print("send icmp6 multicast listener discovery with router alert")

import os
import sys
from struct import pack
from addr import *
from scapy.all import *

if len(sys.argv) != 2:
	print("usage: icmp6_mld_ra.py Nn")
	exit(2)

N=sys.argv[1]
IF=eval("IF_"+N);
ADDR6=eval("ADDR6_"+N);

pid=os.getpid()
eid=pid & 0xffff
packet=IPv6(src=ADDR6, dst=ADDR6)/ \
    IPv6ExtHdrHopByHop(options=RouterAlert())/ \
    ICMPv6MLQuery()

# send does not work for some reason, add the bpf loopback layer manually
#send(packet)
bpf=pack('!I', 24) + bytes(packet)
sendp(bpf, iface=IF)