Panda3D
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. More...
 
 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. More...
 
int get_datagram_checksum () const
 Returns the checksum appropriate for the indicated datagram. More...
 
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. More...
 
bool verify_datagram (const NetDatagram &datagram) const
 Verifies that the indicated datagram has the appropriate length and checksum. More...
 

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 26 of file datagramUDPHeader.cxx.

References Datagram::add_uint16(), 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 44 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 18 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 28 of file datagramUDPHeader.I.

References Datagram::get_message().

◆ 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 52 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: