27 const unsigned char *begin = (
const unsigned char *)datagram.
get_data();
28 const unsigned char *end = begin + datagram.
get_length();
29 uint16_t checksum = 0;
30 for (
const unsigned char *p = begin; p != end; ++p) {
31 checksum += (uint16_t)(uint8_t)*p;
36 nassertv((
int)_header.
get_length() == datagram_udp_header_size);
53 const unsigned char *begin = (
const unsigned char *)datagram.
get_data();
54 const unsigned char *end = begin + datagram.
get_length();
55 uint16_t checksum = 0;
56 for (
const unsigned char *p = begin; p != end; ++p) {
57 checksum += (uint16_t)(uint8_t)*p;
64 if (net_cat.is_debug()) {
66 <<
"Invalid datagram!\n";
69 <<
" checksum is " << checksum <<
", header reports " 76 std::ostringstream hex;
79 net_cat.debug(
false) << hex.str();
A specific kind of Datagram, especially for sending across or receiving from a network.
void dump_hex(std::ostream &out, unsigned int indent=0) const
Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
size_t get_length() const
Returns the number of bytes in the datagram.
const void * get_data() const
Returns a pointer to the beginning of the datagram's data.