UDP (User Datagram Protocol) More...
Go to the source code of this file.
Data Structures | |
struct | UdpRxCallbackEntry |
UDP receive callback entry. More... | |
Macros | |
#define | UDP_SUPPORT ENABLED |
#define | UDP_CALLBACK_TABLE_SIZE 10 |
#define | UDP_RX_QUEUE_SIZE 4 |
Typedefs | |
typedef void(* | UdpRxCallback) (NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *header, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary, void *param) |
UDP receive callback. More... | |
Functions | |
error_t | udpInit (void) |
UDP related initialization. More... | |
uint16_t | udpGetDynamicPort (void) |
Get an ephemeral port number. More... | |
error_t | udpProcessDatagram (NetInterface *interface, const IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary) |
Incoming UDP datagram processing. More... | |
error_t | udpSendDatagram (Socket *socket, const SocketMsg *message, uint_t flags) |
Send a UDP datagram. More... | |
error_t | udpSendBuffer (NetInterface *interface, const IpAddr *srcIpAddr, uint16_t srcPort, const IpAddr *destIpAddr, uint16_t destPort, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary) |
Send a UDP datagram. More... | |
error_t | udpReceiveDatagram (Socket *socket, SocketMsg *message, uint_t flags) |
Receive data from a UDP socket. More... | |
NetBuffer * | udpAllocBuffer (size_t length, size_t *offset) |
Allocate a buffer to hold a UDP packet. More... | |
void | udpUpdateEvents (Socket *socket) |
Update UDP related events. More... | |
error_t | udpAttachRxCallback (NetInterface *interface, uint16_t port, UdpRxCallback callback, void *param) |
Register user callback. More... | |
error_t | udpDetachRxCallback (NetInterface *interface, uint16_t port) |
Unregister user callback. More... | |
error_t | udpInvokeRxCallback (NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *header, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary) |
Invoke user callback. More... | |
void | udpDumpHeader (const UdpHeader *datagram) |
Dump UDP header for debugging purpose. More... | |
Variables | |
typedef | __packed_struct |
UDP header. More... | |
uint16_t | destPort |
uint16_t | length |
uint16_t | checksum |
uint8_t | data [] |
UdpHeader | |
UdpRxCallbackEntry | udpCallbackTable [UDP_CALLBACK_TABLE_SIZE] |
Detailed Description
UDP (User Datagram Protocol)
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.4.4
Definition in file udp.h.
Macro Definition Documentation
◆ UDP_CALLBACK_TABLE_SIZE
◆ UDP_RX_QUEUE_SIZE
◆ UDP_SUPPORT
Typedef Documentation
◆ UdpRxCallback
typedef void(* UdpRxCallback) (NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *header, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary, void *param) |
Function Documentation
◆ udpAllocBuffer()
NetBuffer* udpAllocBuffer | ( | size_t | length, |
size_t * | offset | ||
) |
◆ udpAttachRxCallback()
error_t udpAttachRxCallback | ( | NetInterface * | interface, |
uint16_t | port, | ||
UdpRxCallback | callback, | ||
void * | param | ||
) |
◆ udpDetachRxCallback()
error_t udpDetachRxCallback | ( | NetInterface * | interface, |
uint16_t | port | ||
) |
◆ udpDumpHeader()
void udpDumpHeader | ( | const UdpHeader * | datagram | ) |
◆ udpGetDynamicPort()
uint16_t udpGetDynamicPort | ( | void | ) |
◆ udpInit()
error_t udpInit | ( | void | ) |
◆ udpInvokeRxCallback()
error_t udpInvokeRxCallback | ( | NetInterface * | interface, |
const IpPseudoHeader * | pseudoHeader, | ||
const UdpHeader * | header, | ||
const NetBuffer * | buffer, | ||
size_t | offset, | ||
const NetRxAncillary * | ancillary | ||
) |
Invoke user callback.
- Parameters
-
[in] interface Underlying network interface [in] pseudoHeader UDP pseudo header [in] header UDP header [in] buffer Multi-part buffer containing the payload [in] offset Offset to the first byte of the payload [in] ancillary Additional options passed to the stack along with the packet
- Returns
- Error code
◆ udpProcessDatagram()
error_t udpProcessDatagram | ( | NetInterface * | interface, |
const IpPseudoHeader * | pseudoHeader, | ||
const NetBuffer * | buffer, | ||
size_t | offset, | ||
const NetRxAncillary * | ancillary | ||
) |
Incoming UDP datagram processing.
- Parameters
-
[in] interface Underlying network interface [in] pseudoHeader UDP pseudo header [in] buffer Multi-part buffer containing the incoming UDP datagram [in] offset Offset to the first byte of the UDP header [in] ancillary Additional options passed to the stack along with the packet
- Returns
- Error code
◆ udpReceiveDatagram()
◆ udpSendBuffer()
error_t udpSendBuffer | ( | NetInterface * | interface, |
const IpAddr * | srcIpAddr, | ||
uint16_t | srcPort, | ||
const IpAddr * | destIpAddr, | ||
uint16_t | destPort, | ||
NetBuffer * | buffer, | ||
size_t | offset, | ||
NetTxAncillary * | ancillary | ||
) |
Send a UDP datagram.
- Parameters
-
[in] interface Underlying network interface [in] srcIpAddr Source IP address (optional parameter) [in] srcPort Source port [in] destIpAddr IP address of the target host [in] destPort Target port number [in] buffer Multi-part buffer containing the payload [in] offset Offset to the first payload byte [in] ancillary Additional options passed to the stack along with the packet
- Returns
- Error code
◆ udpSendDatagram()
◆ udpUpdateEvents()
void udpUpdateEvents | ( | Socket * | socket | ) |
Variable Documentation
◆ __packed_struct
typedef __packed_struct |
◆ checksum
◆ data
◆ destPort
◆ length
◆ udpCallbackTable
|
extern |