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