Panda3D
datagramUDPHeader.h
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 
15 #ifndef DATAGRAMUDPHEADER_H
16 #define DATAGRAMUDPHEADER_H
17 
18 #include "pandabase.h"
19 
20 #include "netDatagram.h"
21 
22 #include "datagramIterator.h"
23 #include "numeric_types.h"
24 
25 static const int datagram_udp_header_size = sizeof(PN_uint16);
26 
27 class NetDatagram;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : DatagramUDPHeader
31 // Description : A class that encapsulates the extra bytes that are
32 // sent in front of each datagram to identify it when it
33 // is sent on UDP. Like NetDatagram, this class
34 // automatically handles converting its data to and from
35 // the network byte ordering.
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_PANDA_NET DatagramUDPHeader {
38 public:
39  DatagramUDPHeader(const NetDatagram &datagram);
40  DatagramUDPHeader(const void *data);
41 
42  INLINE int get_datagram_checksum() const;
43  INLINE string get_header() const;
44 
45  bool verify_datagram(const NetDatagram &datagram) const;
46 
47 private:
48  // The actual data for the header is stored (somewhat recursively)
49  // in its own NetDatagram object. This is just for convenience of
50  // packing and unpacking the header.
51  NetDatagram _header;
52 };
53 
54 #include "datagramUDPHeader.I"
55 
56 #endif
57 
58 
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition: netDatagram.h:43
A class that encapsulates the extra bytes that are sent in front of each datagram to identify it when...