scapy.contrib.igmp
- class scapy.contrib.igmp.IGMP(_pkt, /, *, type=17, mrcode=20, chksum=None, gaddr='0.0.0.0')[source]
Bases:
Packet
IGMP Message Class for v1 and v2.
This class is derived from class Packet. You need call “igmpize()” so the packet is transformed according the RFC when sent. a=Ether(src=”00:01:02:03:04:05”) b=IP(src=”1.2.3.4”) c=IGMP(type=0x12, gaddr=”224.2.3.4”) x = a/b/c x[IGMP].igmpize() sendp(a/b/c, iface=”en0”)
- Parameters:
type IGMP type field, 0x11, 0x12, 0x16 or 0x17 mrcode Maximum Response time (zero for v1) gaddr Multicast Group Address 224.x.x.x/4
See RFC2236, Section 2. Introduction for definitions of proper IGMPv2 message format http://www.faqs.org/rfcs/rfc2236.html
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TYPE | MRCODE | CHKSUM | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | GADDR | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IGMP
IGMP fields type
17
mrcode
20
chksum
None
gaddr
'0.0.0.0'
- igmpize()[source]
Called to explicitly fixup the packet according to the IGMP RFC
The rules are: - General: 1. the Max Response time is meaningful only in Membership Queries and should be zero - IP: 1. Send General Group Query to 224.0.0.1 (all systems) 2. Send Leave Group to 224.0.0.2 (all routers) 3a.Otherwise send the packet to the group address 3b.Send reports/joins to the group address 4. ttl = 1 (RFC 2236, section 2) 5. send the packet with the router alert IP option (RFC 2236, section 2) - Ether: 1. Recalculate destination
- Returns:
- True The tuple ether/ip/self passed all check and represents
a proper IGMP packet.
- False One of more validation checks failed and no fields
were adjusted.
The function will examine the IGMP message to assure proper format. Corrections will be attempted if possible. The IP header is then properly adjusted to ensure correct formatting and assignment. The Ethernet header is then adjusted to the proper IGMP packet format.
- igmptypes = {17: 'Group Membership Query', 18: 'Version 1 - Membership Report', 22: 'Version 2 - Membership Report', 23: 'Leave Group'}