lwIP  2.1.2
Lightweight IP stack
ip.h File Reference
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
#include "lwip/err.h"
#include "lwip/netif.h"
#include "lwip/ip4.h"
#include "lwip/ip6.h"
#include "lwip/prot/ip.h"

Data Structures

struct  ip_globals
 

Macros

#define LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p)   LWIP_ASSERT("p->ref == 1", (p)->ref == 1)
 
#define IP_PCB
 
#define ip_current_netif()   (ip_data.current_netif)
 
#define ip_current_input_netif()   (ip_data.current_input_netif)
 
#define ip_current_header_tot_len()   (ip_data.current_ip_header_tot_len)
 
#define ip_current_src_addr()   (&ip_data.current_iphdr_src)
 
#define ip_current_dest_addr()   (&ip_data.current_iphdr_dest)
 
#define ip4_current_header()   ip_data.current_ip4_header
 
#define ip_current_is_v6()   0
 
#define ip_current_header_proto()   IPH_PROTO(ip4_current_header())
 
#define ip_next_header_ptr()   ((const void*)((const u8_t*)ip4_current_header() + ip_current_header_tot_len()))
 
#define ip4_current_src_addr()   (&ip_data.current_iphdr_src)
 
#define ip4_current_dest_addr()   (&ip_data.current_iphdr_dest)
 
#define ip_current_src_addr()   (&ip_data.current_iphdr_src)
 
#define ip_current_dest_addr()   (&ip_data.current_iphdr_dest)
 
#define ip_get_option(pcb, opt)   ((pcb)->so_options & (opt))
 
#define ip_set_option(pcb, opt)   ((pcb)->so_options = (u8_t)((pcb)->so_options | (opt)))
 
#define ip_reset_option(pcb, opt)   ((pcb)->so_options = (u8_t)((pcb)->so_options & ~(opt)))
 

Variables

struct ip_globals ip_data
 

Detailed Description

IP API

Macro Definition Documentation

◆ ip4_current_dest_addr

#define ip4_current_dest_addr ( )    (&ip_data.current_iphdr_dest)

Destination IP4 address of current_header

◆ ip4_current_header

#define ip4_current_header ( )    ip_data.current_ip4_header

Get the IPv4 header of the current packet. This function must only be called from a receive callback (udp_recv, raw_recv, tcp_accept). It will return NULL otherwise.

◆ ip4_current_src_addr

#define ip4_current_src_addr ( )    (&ip_data.current_iphdr_src)

Source IP4 address of current_header

◆ ip_current_dest_addr [1/2]

#define ip_current_dest_addr ( )    (&ip_data.current_iphdr_dest)

Destination IP address of current_header

Union destination address of current_header

◆ ip_current_dest_addr [2/2]

#define ip_current_dest_addr ( )    (&ip_data.current_iphdr_dest)

Destination IP address of current_header

Union destination address of current_header

◆ ip_current_header_proto

#define ip_current_header_proto ( )    IPH_PROTO(ip4_current_header())

Get the transport layer protocol

◆ ip_current_header_tot_len

#define ip_current_header_tot_len ( )    (ip_data.current_ip_header_tot_len)

Total header length of ip(6)_current_header() (i.e. after this, the UDP/TCP header starts)

◆ ip_current_input_netif

#define ip_current_input_netif ( )    (ip_data.current_input_netif)

Get the interface that received the current packet. This function must only be called from a receive callback (udp_recv, raw_recv, tcp_accept). It will return NULL otherwise.

◆ ip_current_is_v6

#define ip_current_is_v6 ( )    0

Always returns FALSE when only supporting IPv4 only

◆ ip_current_netif

#define ip_current_netif ( )    (ip_data.current_netif)

Get the interface that accepted the current packet. This may or may not be the receiving netif, depending on your netif/network setup. This function must only be called from a receive callback (udp_recv, raw_recv, tcp_accept). It will return NULL otherwise.

◆ ip_current_src_addr [1/2]

#define ip_current_src_addr ( )    (&ip_data.current_iphdr_src)

Source IP address of current_header

Union source address of current_header

◆ ip_current_src_addr [2/2]

#define ip_current_src_addr ( )    (&ip_data.current_iphdr_src)

Source IP address of current_header

Union source address of current_header

◆ ip_get_option

#define ip_get_option (   pcb,
  opt 
)    ((pcb)->so_options & (opt))

Gets an IP pcb option (SOF_* flags)

◆ ip_next_header_ptr

#define ip_next_header_ptr ( )    ((const void*)((const u8_t*)ip4_current_header() + ip_current_header_tot_len()))

Get the transport layer header

◆ IP_PCB

#define IP_PCB
Value:
/* ip addresses in network byte order */ \
ip_addr_t local_ip; \
ip_addr_t remote_ip; \
/* Bound netif index */ \
u8_t netif_idx; \
/* Socket options */ \
u8_t so_options; \
/* Type Of Service */ \
u8_t tos; \
/* Time To Live */ \
u8_t ttl \
/* link layer address resolution hint */ \
IP_PCB_NETIFHINT

This is the common part of all PCB types. It needs to be at the beginning of a PCB type definition. It is located here so that changes to this common part are made in one location instead of having to change all PCB structs.

◆ ip_reset_option

#define ip_reset_option (   pcb,
  opt 
)    ((pcb)->so_options = (u8_t)((pcb)->so_options & ~(opt)))

Resets an IP pcb option (SOF_* flags)

◆ ip_set_option

#define ip_set_option (   pcb,
  opt 
)    ((pcb)->so_options = (u8_t)((pcb)->so_options | (opt)))

Sets an IP pcb option (SOF_* flags)

◆ LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX

#define LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX (   p)    LWIP_ASSERT("p->ref == 1", (p)->ref == 1)

pbufs passed to IP must have a ref-count of 1 as their payload pointer gets altered as the packet is passed down the stack

Variable Documentation

◆ ip_data

struct ip_globals ip_data

Global data for both IPv4 and IPv6