igmp.py 448 B

123456789101112131415161718
  1. """Internet Group Management Protocol."""
  2. from pypacker import pypacker, checksum
  3. class IGMP(pypacker.Packet):
  4. __hdr__ = (
  5. ("type", "B", 0),
  6. ("maxresp", "B", 0),
  7. ("sum", "H", 0),
  8. ("group", "I", 0)
  9. )
  10. def bin(self, update_auto_fields=True):
  11. if update_auto_fields and self._changed():
  12. self.sum = 0
  13. self.sum = checksum.in_cksum(pypacker.Packet.bin(self))
  14. return pypacker.Packet.bin(self, update_auto_fields=update_auto_fields)