Panda3D

Loading...
Searching...
No Matches
Public Member Functions | List of all members
DatagramUDPHeader Class Reference

A class that encapsulates the extra bytes that are sent in front of each datagram to identify it when it is sent on UDP. More...

`#include "datagramUDPHeader.h"`

## Public Member Functions
| DatagramUDPHeader (const NetDatagram &datagram)
| This constructor creates a header based on an already-constructed NetDatagram.
| DatagramUDPHeader (const void *data)
| This constructor decodes a header from a block of data of length datagram_udp_header_size, presumably just read from a socket.
int | get_datagram_checksum () const
| Returns the checksum appropriate for the indicated datagram.
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 network as the header information.
bool | verify_datagram (const NetDatagram &datagram) const
| Verifies that the indicated datagram has the appropriate length and checksum.

## Detailed Description

A class that encapsulates the extra bytes that are sent in front of each datagram to identify it when it is sent on UDP.

Like NetDatagram, this class automatically handles converting its data to and from the network byte ordering.

Definition at line 34 of file datagramUDPHeader.h.

## Constructor & Destructor Documentation

## ◆ DatagramUDPHeader() [1/2]

DatagramUDPHeader::DatagramUDPHeader | ( | const NetDatagram & | datagram | ) |

This constructor creates a header based on an already-constructed NetDatagram.

Definition at line 25 of file datagramUDPHeader.cxx.

References Datagram::get_data(), and Datagram::get_length().

## ◆ DatagramUDPHeader() [2/2]

DatagramUDPHeader::DatagramUDPHeader | ( | const void * | data | ) |

This constructor decodes a header from a block of data of length datagram_udp_header_size, presumably just read from a socket.

Definition at line 43 of file datagramUDPHeader.cxx.

## Member Function Documentation

## ◆ get_datagram_checksum()

int DatagramUDPHeader::get_datagram_checksum | ( |  | ) | const
| inline

Returns the checksum appropriate for the indicated datagram.

Definition at line 17 of file datagramUDPHeader.I.

References DatagramIterator::get_uint16().

Referenced by verify_datagram().

## ◆ get_header()

std::string DatagramUDPHeader::get_header | ( |  | ) | const
| inline

Returns a pointer to a block of data of length datagram_udp_header_size, which can be written to the network as the header information.

Definition at line 27 of file datagramUDPHeader.I.

## ◆ verify_datagram()

bool DatagramUDPHeader::verify_datagram | ( | const NetDatagram & | datagram | ) | const

Verifies that the indicated datagram has the appropriate length and checksum.

Returns true if it matches, false otherwise.

Definition at line 51 of file datagramUDPHeader.cxx.

References Datagram::dump_hex(), Datagram::get_data(), get_datagram_checksum(), and Datagram::get_length().

The documentation for this class was generated from the following files:

- panda/src/net/datagramUDPHeader.h
- panda/src/net/datagramUDPHeader.cxx
- panda/src/net/datagramUDPHeader.I