|
| UDPPacket (OS_FIFO *pFifo, TickTimeout timeout) |
| Constructor to create a UDP Packet object from a UDP FIFO entry.
|
|
| UDPPacket (int sock) |
| Constructor to create a UDP Packet object from an open UDP socket.
|
|
| UDPPacket (PoolPtr p) |
| Constructor to create a UDP packet from a system pool buffer.
|
|
| UDPPacket (UDPPacket &pkt) |
| Constructor to create a new UDP packet from an existing UDP packet.
|
|
| ~UDPPacket () |
| UDP packet object destructor. Frees any associated memory.
|
|
void | SetSourcePort (uint16_t port) |
| Set the source port number of a UDP Packet object.
|
|
uint16_t | GetSourcePort (void) const |
| Get the source port number of a UDP Packet object.
|
|
MACADR | GetMacSource () |
| Get the source MAC address a UDP Packet object.
|
|
IPADDR | GetSourceAddress (void) |
| Get the source IP address a UDP Packet object.
|
|
IPADDR | GetDestinationAddress (void) |
| Get the destination IP address a UDP Packet object.
|
|
bool | bIsIPV6 () |
| Check if the IPADDR holds an IPv6 IP address.
|
|
void | SetDestinationPort (uint16_t port) |
| Set the destination port number of a UDP Packet object.
|
|
uint16_t | GetDestinationPort (void) const |
| Get the destination port number of a UDP Packet object.
|
|
uint16_t | GetPacketId (void) |
| Get UDP packet ID.
|
|
puint8_t | GetDataBuffer (bool bReAllocateIfNeeded=false) |
| Get a pointer to the UDP Packet object's data buffer.
|
|
void | SetDataSize (uint16_t numBytes) |
| Set the UDP Packet data size.
|
|
uint16_t | GetDataSize (void) const |
| Get the UDP Packet object data size.
|
|
void | AddData (puint8_t pData, uint16_t len) |
| Add a number of data bytes to a UDP Packet object.
|
|
void | AddData (PCSTR pData) |
| Add data to a UDP Packet object as a NULL terminated ASCII string.
|
|
void | AddDataWord (uint16_t w) |
| Add a 16-bit unsigned integer to a UDP Packet object.
|
|
void | AddDataByte (uint8_t b) |
| Add an 8-bit unsigned integer to a UDP Packet object.
|
|
BOOL | Validate (void) |
| Verify a received UDP packet is valid.
|
|
void | ResetData (void) |
| Set the data size of a UDP Packet object to 0.
|
|
void | SendAndKeep (const IPADDR &to, uint8_t ttl=0) |
| Make a copy of a UDP Packet and send it. The original packet will remain intact.
|
|
void | Send (const IPADDR &to, uint8_t ttl=0) |
| Send the UDP Packet and free the pool buffer.
|
|
void | SendAndKeepViaInterfaceNum (const IPADDR &to, int interface, uint8_t ttl=0) |
| Make a copy of a UDP Packet and send it using the specified network interface. The original packet will remain intact.
|
|
void | SendViaInterfaceNum (const IPADDR &to, int interface, uint8_t ttl=0) |
| Send the UDP Packet using the specified network interface and free the pool buffer.
|
|
void | SendAndKeepViaIfAddr (const IPADDR &to, const IPADDR &from_ip, uint8_t ttl=0) |
| Make a copy of a UDP Packet and send it through the network interface specified by the from_ip IP address parameter. If more than one interface has the same IP address, the lower interface number will be used. The original packet will remain intact.
|
|
void | SendViaIfAddr (const IPADDR &to, const IPADDR &from_ip, uint8_t ttl=0) |
| Send a UDP packet through the network interface specified by the from_ip IP address parameter. If more than one interface has the same IP address, the lower interface number will be used. The UDP pool buffer will be freed.
|
|
UDP Packet Class.
This class holds PoolBuffers and treats them as UDP Packets. The process for sending a UDP packet is as follows:
myUdpPacket.SetDestinatioPort(456);
UDP Packet Class.
Definition udp.h:81
void SetSourcePort(uint16_t port)
Set the source port number of a UDP Packet object.
Data can be put in the packet two ways:
- Obtain a pointer to the object's data buffer and copy the data in. Be certain to set the data length.
uint16_t len = siprintf( myUdpPacket.
GetDataBuffer(),
"Using sprintf() to copy data at time = %ld", TickCount );
void SetDataSize(uint16_t numBytes)
Set the UDP Packet data size.
puint8_t GetDataBuffer(bool bReAllocateIfNeeded=false)
Get a pointer to the UDP Packet object's data buffer.
- Copy the data directly to the packet buffer:
AddData(
"This is the data to add");
void AddData(puint8_t pData, uint16_t len)
Add a number of data bytes to a UDP Packet object.
When the UDP packet has been configured it can be sent two ways:
- Send and keep the packet and keep the constructed pool buffer:
SendAndKeep(IPADDR destinationIP);
. You must free the buffer manually.
- Send and automatically free the pool buffer (recommended and more efficient):
Send(IPADDR4 destinationIP);
There are many UDP examples, and we recommend reviewing them to determine the best method to use for your application.