scapy.contrib.igmp

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=”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
classmethod dispatch_hook(_pkt=None, *args, **kargs)
fields_desc
IGMP fields

type

ByteEnumField

17

mrcode

ByteField

20

chksum

XShortField

None

gaddr

IPField

'0.0.0.0'

igmpize()

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'}
mysummary()

Display a summary of the IGMP object.

post_build(p, pay)

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

Parameters
  • The instantiation of an IGMP class (self) –

  • The IGMP message in hex in network byte order (p) –

  • Additional payload for the IGMP message (pay) –

scapy.contrib.igmp.isValidMCAddr(ip)

convert dotted quad string to long and check the first octet