lwIP 2.1.1 Lightweight IP stack

Data Structures | Typedefs | Functions
udp.h File Reference
`#include "lwip/opt.h"`
`#include "lwip/pbuf.h"`
`#include "lwip/netif.h"`
`#include "lwip/ip_addr.h"`
`#include "lwip/ip.h"`
`#include "lwip/ip6_addr.h"`
`#include "lwip/prot/udp.h"`

## Data Structures
struct | udp_pcb

## Typedefs
typedef void(* | udp_recv_fn) (void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)

## Functions
struct udp_pcb * | udp_new (void)
struct udp_pcb * | udp_new_ip_type (u8_t type)
void | udp_remove (struct udp_pcb *pcb)
err_t | udp_bind (struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
void | udp_bind_netif (struct udp_pcb *pcb, const struct netif *netif)
err_t | udp_connect (struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
void | udp_disconnect (struct udp_pcb *pcb)
void | udp_recv (struct udp_pcb *pcb, udp_recv_fn recv, void *recv_arg)
err_t | udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif)
err_t | udp_sendto_if_src (struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif, const ip_addr_t *src_ip)
err_t | udp_sendto (struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, u16_t dst_port)
err_t | udp_send (struct udp_pcb *pcb, struct pbuf *p)
void | udp_input (struct pbuf *p, struct netif *inp)
void | udp_init (void)
void | udp_netif_ip_addr_changed (const ip_addr_t *old_addr, const ip_addr_t *new_addr)

## Detailed Description

UDP API (to be used from TCPIP thread)
See also UDP

## Typedef Documentation

## ◆ udp_recv_fn

typedef void(* udp_recv_fn) (void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)

Function prototype for udp pcb receive callback functions addr and port are in same byte order as in the pcb The callback is responsible for freeing the pbuf if it's not used any more.

ATTENTION: Be aware that 'addr' might point into the pbuf 'p' so freeing this pbuf can make 'addr' invalid, too.

Parameters

  arg | user supplied argument (udp_pcb.recv_arg)
  pcb | the udp_pcb which received data
  p | the packet buffer that was received
  addr | the remote IP address from which the packet was received
  port | the remote port from which the packet was received

## Function Documentation

## ◆ udp_init()

void udp_init | ( | void |  | ) |

Initialize this module.

## ◆ udp_input()

void udp_input | ( | struct pbuf * | p,
|  | struct netif * | inp
| ) |  |

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.

Parameters

  p | pbuf to be demultiplexed to a UDP PCB (p->payload pointing to the UDP header)
  inp | network interface on which the datagram was received.

## ◆ udp_netif_ip_addr_changed()

void udp_netif_ip_addr_changed | ( | const ip_addr_t * | old_addr,
|  | const ip_addr_t * | new_addr
| ) |  |

This function is called from netif.c when address is changed

Parameters

  old_addr | IP address of the netif before change
  new_addr | IP address of the netif after change