ospf.py 579 B

1234567891011121314151617181920212223242526
  1. """Open Shortest Path First."""
  2. from pypacker import pypacker, checksum
  3. AUTH_NONE = 0
  4. AUTH_PASSWORD = 1
  5. AUTH_CRYPTO = 2
  6. class OSPF(pypacker.Packet):
  7. __hdr__ = (
  8. ("v", "B", 0),
  9. ("type", "B", 0),
  10. ("len", "H", 0),
  11. ("router", "I", 0),
  12. ("area", "I", 0),
  13. ("sum", "H", 0), # _sum = sum
  14. ("atype", "H", 0),
  15. ("auth", "8s", b"")
  16. )
  17. def bin(self, update_auto_fields=True):
  18. if update_auto_fields and self._changed():
  19. self.sum = 0
  20. self.sum = checksum.in_cksum(pypacker.Packet.bin(self))
  21. return pypacker.Packet.bin(self, update_auto_fields=update_auto_fields)