00001 // Filename: datagramUDPHeader.h 00002 // Created by: drose (08Feb00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef DATAGRAMUDPHEADER_H 00016 #define DATAGRAMUDPHEADER_H 00017 00018 #include "pandabase.h" 00019 00020 #include "netDatagram.h" 00021 00022 #include "datagramIterator.h" 00023 #include "numeric_types.h" 00024 00025 static const int datagram_udp_header_size = sizeof(PN_uint16); 00026 00027 class NetDatagram; 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : DatagramUDPHeader 00031 // Description : A class that encapsulates the extra bytes that are 00032 // sent in front of each datagram to identify it when it 00033 // is sent on UDP. Like NetDatagram, this class 00034 // automatically handles converting its data to and from 00035 // the network byte ordering. 00036 //////////////////////////////////////////////////////////////////// 00037 class EXPCL_PANDA_NET DatagramUDPHeader { 00038 public: 00039 DatagramUDPHeader(const NetDatagram &datagram); 00040 DatagramUDPHeader(const void *data); 00041 00042 INLINE int get_datagram_checksum() const; 00043 INLINE string get_header() const; 00044 00045 bool verify_datagram(const NetDatagram &datagram) const; 00046 00047 private: 00048 // The actual data for the header is stored (somewhat recursively) 00049 // in its own NetDatagram object. This is just for convenience of 00050 // packing and unpacking the header. 00051 NetDatagram _header; 00052 }; 00053 00054 #include "datagramUDPHeader.I" 00055 00056 #endif 00057 00058