scapy.contrib.igmp module

class scapy.contrib.igmp.IGMP

Bases: scapy.packet.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=””) c=IGMP(type=0x12, gaddr=””) x = a/b/c x[IGMP].igmpize() sendp(a/b/c, iface=”en0”)

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

aliastypes = [<class 'scapy.contrib.igmp.IGMP'>, <class 'scapy.packet.Packet'>]
classmethod dispatch_hook(_pkt=None, *args, **kargs)
fields_desc = [<Field (IGMP).type>, <Field (IGMP).mrcode>, <Field (IGMP).chksum>, <Field (IGMP).gaddr>]

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 (all systems) 2. Send Leave Group to (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

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'}

Display a summary of the IGMP object.

post_build(p, pay)

Called implicitly before a packet is sent to compute and place IGMP checksum.

  • The instantiation of an IGMP class (self) –
  • The IGMP message in hex in network byte order (p) –
  • Additional payload for the IGMP message (pay) –

convert dotted quad string to long and check the first octet