Panda3D

Loading...
Searching...
No Matches
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
DatagramUDPHeader::get_header
std::string get_header() const
Returns a pointer to a block of data of length datagram_udp_header_size, which can be written to the ...
Definition datagramUDPHeader.I:28
DatagramUDPHeader::DatagramUDPHeader
DatagramUDPHeader(const NetDatagram &datagram)
This constructor creates a header based on an already-constructed NetDatagram.
Definition datagramUDPHeader.cxx:26
DatagramUDPHeader::get_datagram_checksum
int get_datagram_checksum() const
Returns the checksum appropriate for the indicated datagram.
Definition datagramUDPHeader.I:18
DatagramUDPHeader::verify_datagram
bool verify_datagram(const NetDatagram &datagram) const
Verifies that the indicated datagram has the appropriate length and checksum.
Definition datagramUDPHeader.cxx:52
NetDatagram
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition netDatagram.h:40
datagramIterator.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
datagramUDPHeader.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
netDatagram.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
numeric_types.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.