#include "lwip/opt.h"
#include "lwip/udp.h"
#include "lwip/def.h"
#include "lwip/memp.h"
#include "lwip/inet.h"
#include "lwip/inet_chksum.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/icmp.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "arch/perf.h"
#include "lwip/dhcp.h"
#include <string.h>
Go to the source code of this file.
Defines | |
#define | UDP_LOCAL_PORT_RANGE_START 4096 |
#define | UDP_LOCAL_PORT_RANGE_END 0x7fff |
Functions | |
void | udp_input (struct pbuf *p, struct netif *inp) |
err_t | udp_send (struct udp_pcb *pcb, struct pbuf *p) |
err_t | udp_sendto (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port) |
err_t | udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port, struct netif *netif) |
err_t | udp_bind (struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) |
err_t | udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) |
void | udp_disconnect (struct udp_pcb *pcb) |
void | udp_recv (struct udp_pcb *pcb, void(*recv)(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port), void *recv_arg) |
void | udp_remove (struct udp_pcb *pcb) |
struct udp_pcb * | udp_new (void) |
Variables | |
struct udp_pcb * | udp_pcbs |
User Datagram Protocol module
Definition in file udp.c.
Bind an UDP PCB.
pcb | UDP PCB to be bound with a local address ipaddr and port. | |
ipaddr | local IP address to bind with. Use IP_ADDR_ANY to bind to all local interfaces. | |
port | local UDP port to bind with. Use 0 to automatically bind to a random port between UDP_LOCAL_PORT_RANGE_START and UDP_LOCAL_PORT_RANGE_END. |
ipaddr & port are expected to be in the same byte order as in the pcb.
Definition at line 579 of file udp.c.
Connect an UDP PCB.
This will associate the UDP PCB with the remote address.
pcb | UDP PCB to be connected with remote address ipaddr and port. | |
ipaddr | remote IP address to connect with. | |
port | remote UDP port to connect with. |
ipaddr & port are expected to be in the same byte order as in the pcb.
The udp pcb is bound to a random local port if not already bound.
TODO: this functionality belongs in upper layers
Definition at line 679 of file udp.c.
void udp_disconnect | ( | struct udp_pcb * | pcb | ) |
Process an incoming UDP datagram.
Given an incoming UDP datagram (as a chain of pbufs) this function finds a corresponding UDP PCB and hands over the pbuf to the pcbs recv function. If no pcb is found or the datagram is incorrect, the pbuf is freed.
p | pbuf to be demultiplexed to a UDP PCB. | |
inp | network interface on which the datagram was received. |
Definition at line 85 of file udp.c.
struct udp_pcb* udp_new | ( | void | ) | [read] |
Create a UDP PCB.
Definition at line 805 of file udp.c.
void udp_recv | ( | struct udp_pcb * | pcb, | |
void(*)(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port) | recv, | |||
void * | recv_arg | |||
) |
Set a receive callback for a UDP PCB
This callback will be called when receiving a datagram for the pcb.
pcb | the pcb for wich to set the recv callback | |
recv | function pointer of the callback function | |
recv_arg | additional argument to pass to the callback function |
void udp_remove | ( | struct udp_pcb * | pcb | ) |
Send data using UDP.
pcb | UDP PCB used to send the data. | |
p | chain of pbuf's to be sent. |
The datagram will be sent to the current remote_ip & remote_port stored in pcb. If the pcb is not bound to a port, it will automatically be bound to a random port.
Definition at line 336 of file udp.c.
Send data to a specified address using UDP.
pcb | UDP PCB used to send the data. | |
p | chain of pbuf's to be sent. | |
dst_ip | Destination IP address. | |
dst_port | Destination UDP port. |
dst_ip & dst_port are expected to be in the same byte order as in the pcb.
If the PCB already has a remote address association, it will be restored after the data is sent.
Definition at line 360 of file udp.c.
err_t udp_sendto_if | ( | struct udp_pcb * | pcb, | |
struct pbuf * | p, | |||
struct ip_addr * | dst_ip, | |||
u16_t | dst_port, | |||
struct netif * | netif | |||
) |
Send data to a specified address using UDP. The netif used for sending can be specified.
This function exists mainly for DHCP, to be able to send UDP packets on a netif that is still down.
pcb | UDP PCB used to send the data. | |
p | chain of pbuf's to be sent. | |
dst_ip | Destination IP address. | |
dst_port | Destination UDP port. | |
netif | the netif used for sending. |
dst_ip & dst_port are expected to be in the same byte order as in the pcb.
Definition at line 403 of file udp.c.