datagramUDPHeader.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Filename: datagramUDPHeader.h
  2. // Created by: drose (08Feb00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef DATAGRAMUDPHEADER_H
  15. #define DATAGRAMUDPHEADER_H
  16. #include "pandabase.h"
  17. #include "netDatagram.h"
  18. #include "datagramIterator.h"
  19. #include "numeric_types.h"
  20. static const int datagram_udp_header_size = sizeof(PN_uint16);
  21. class NetDatagram;
  22. ////////////////////////////////////////////////////////////////////
  23. // Class : DatagramUDPHeader
  24. // Description : A class that encapsulates the extra bytes that are
  25. // sent in front of each datagram to identify it when it
  26. // is sent on UDP. Like NetDatagram, this class
  27. // automatically handles converting its data to and from
  28. // the network byte ordering.
  29. ////////////////////////////////////////////////////////////////////
  30. class EXPCL_PANDA_NET DatagramUDPHeader {
  31. public:
  32. DatagramUDPHeader(const NetDatagram &datagram);
  33. DatagramUDPHeader(const void *data);
  34. INLINE int get_datagram_checksum() const;
  35. INLINE string get_header() const;
  36. bool verify_datagram(const NetDatagram &datagram) const;
  37. private:
  38. // The actual data for the header is stored (somewhat recursively)
  39. // in its own NetDatagram object. This is just for convenience of
  40. // packing and unpacking the header.
  41. NetDatagram _header;
  42. };
  43. #include "datagramUDPHeader.I"
  44. #endif