Nut/OS  5.0.5
API Reference
UDP

RFC 768 user datagram protocol. More...

Collaboration diagram for UDP:

Functions

int NutUdpInput (NUTDEVICE *dev, NETBUF *nb)
 Handle incoming UDP packets.
int NutUdpOutput (UDPSOCKET *sock, uint32_t daddr, uint16_t port, NETBUF *nb)
 Send a UDP packet.

Detailed Description

RFC 768 user datagram protocol.

UDP only provides checksumming of data and multiplexing by port number. Therefore, an application program must deal directly with end-to-end communication problems like retransmission, flow control etc., if required.

Applications should call the UDP Socket API when using this protocol.


Function Documentation

int NutUdpInput ( NUTDEVICE dev,
NETBUF nb 
)

Handle incoming UDP packets.

Note:
This routine is called by the IP layer on incoming UDP packets. Applications typically do not call this function.
Parameters:
nbNetwork buffer structure containing the UDP packet.

References ICMP_UNREACH, ICMP_UNREACH_PORT, _NETBUF::nb_ap, _NETBUF::nb_flags, _NETBUF::nb_next, _NETBUF::nb_tp, NBAF_UNICAST, NULL, NutEventPost(), NutIcmpResponse(), NutNetBufFree(), NutUdpFindSocket(), udp_socket::so_rx_bsz, udp_socket::so_rx_cnt, udp_socket::so_rx_nb, udp_socket::so_rx_rdy, _NBDATA::sz, udphdr::uh_dport, and _NBDATA::vp.

Referenced by NutUdpCreateSocket().

Here is the call graph for this function:

int NutUdpOutput ( UDPSOCKET sock,
uint32_t  daddr,
uint16_t  port,
NETBUF nb 
)

Send a UDP packet.

Parameters:
sockSocket descriptor. This pointer must have been retrieved by calling NutUdpCreateSocket().
daddrIP address of the remote host in network byte order.
portRemote port number in host byte order.
nbNetwork buffer structure containing the datagram. This buffer will be released if the function returns an error.
Note:
Applications typically do not call this function but use the UDP socket interface.
Returns:
0 on success, -1 otherwise.

References _NUTDEVICE::dev_icb, htons, ifnet::if_local_ip, IPPROTO_UDP, _NETBUF::nb_ap, _NETBUF::nb_tp, NBAF_TRANSPORT, NutIpChkSum(), NutIpChkSumPartial(), NutIpOutput(), NutIpPseudoChkSumPartial(), NutIpRouteQuery(), NutNetBufAlloc(), udp_socket::so_local_port, _NBDATA::sz, udphdr::uh_dport, udphdr::uh_sport, udphdr::uh_sum, udphdr::uh_ulen, and _NBDATA::vp.

Referenced by NutUdpSendTo().

Here is the call graph for this function: