lwIP 2.0.0  lwIP 2.0.0
LightweightIPstack
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"

Data Structures

struct  ip_globals
 

Macros

#define IP_HDR_GET_VERSION(ptr)    ((*(u8_t*)(ptr)) >> 4)
 
#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()    ((const struct ip_hdr*)(ip_data.current_ip4_header))
 
#define ip6_current_header()    ((const struct ip6_hdr*)(ip_data.current_ip6_header))
 
#define ip_current_is_v6()    (ip6_current_header() != NULL)
 
#define ip6_current_src_addr()    (ip_2_ip6(&ip_data.current_iphdr_src))
 
#define ip6_current_dest_addr()    (ip_2_ip6(&ip_data.current_iphdr_dest))
 
#define ip_current_header_proto()
 
#define ip_next_header_ptr()
 
#define ip4_current_src_addr()    (ip_2_ip4(&ip_data.current_iphdr_src))
 
#define ip4_current_dest_addr()    (ip_2_ip4(&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 |= (opt))
 
#define ip_reset_option(pcb, opt)   ((pcb)->so_options &= ~(opt))
 
#define ip_output(p, src, dest, ttl, tos, proto)
 
#define ip_output_if(p, src, dest, ttl, tos, proto, netif)
 
#define ip_output_if_src(p, src, dest, ttl, tos, proto, netif)
 
#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint)
 
#define ip_route(src, dest)
 
#define ip_netif_get_local_ip(netif, dest)
 

Functions

err_t ip_input (struct pbuf *p, struct netif *inp)
 

Variables

struct ip_globals ip_data
 

Detailed Description

IP API

Macro Definition Documentation

#define ip4_current_dest_addr ( )    (ip_2_ip4(&ip_data.current_iphdr_dest))

Destination IP4 address of current_header

#define ip4_current_header ( )    ((const struct ip_hdr*)(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.

#define ip4_current_src_addr ( )    (ip_2_ip4(&ip_data.current_iphdr_src))

Source IP4 address of current_header

#define ip6_current_dest_addr ( )    (ip_2_ip6(&ip_data.current_iphdr_dest))

Destination IPv6 address of current_header

#define ip6_current_header ( )    ((const struct ip6_hdr*)(ip_data.current_ip6_header))

Get the IPv6 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.

#define ip6_current_src_addr ( )    (ip_2_ip6(&ip_data.current_iphdr_src))

Source IPv6 address of current_header

#define ip_current_dest_addr ( )    (&ip_data.current_iphdr_dest)

Destination IP address of current_header

Union destination address of current_header

#define ip_current_dest_addr ( )    (&ip_data.current_iphdr_dest)

Destination IP address of current_header

Union destination address of current_header

#define ip_current_header_proto ( )
Value:
IP6H_NEXTH(ip6_current_header()) :\
IPH_PROTO(ip4_current_header()))
#define ip4_current_header()
Definition: ip.h:160
#define ip6_current_header()
Definition: ip.h:164
#define ip_current_is_v6()
Definition: ip.h:166

Get the transport layer protocol

#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)

#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.

#define ip_current_is_v6 ( )    (ip6_current_header() != NULL)

Returns TRUE if the current IP input packet is IPv6, FALSE if it is IPv4

#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.

#define ip_current_src_addr ( )    (&ip_data.current_iphdr_src)

Source IP address of current_header

Union source address of current_header

#define ip_current_src_addr ( )    (&ip_data.current_iphdr_src)

Source IP address of current_header

Union source address of current_header

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

Gets an IP pcb option (SOF_* flags)

#define IP_HDR_GET_VERSION (   ptr)    ((*(u8_t*)(ptr)) >> 4)

This operates on a void* by loading the first byte

#define ip_netif_get_local_ip (   netif,
  dest 
)
Value:
(IP_IS_V6(dest) ? \
ip6_netif_get_local_ip(netif, ip_2_ip6(dest)) : \
ip4_netif_get_local_ip(netif))
#define IP_IS_V6(ipaddr)
Definition: ip_addr.h:88
#define ip_2_ip6(ipaddr)
Definition: ip_addr.h:100
Definition: netif.h:197

Get netif for IP.

#define ip_next_header_ptr ( )
Value:
((const void*)((ip_current_is_v6() ? \
(const u8_t*)ip6_current_header() : (const u8_t*)ip4_current_header()) + ip_current_header_tot_len()))
#define ip_current_header_tot_len()
Definition: ip.h:150
#define ip4_current_header()
Definition: ip.h:160
#define ip6_current_header()
Definition: ip.h:164
#define ip_current_is_v6()
Definition: ip.h:166

Get the transport layer header

#define ip_output (   p,
  src,
  dest,
  ttl,
  tos,
  proto 
)
Value:
(IP_IS_V6(dest) ? \
ip6_output(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto) : \
ip4_output(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto))
#define IP_IS_V6(ipaddr)
Definition: ip_addr.h:88
#define ip_2_ip6(ipaddr)
Definition: ip_addr.h:100
err_t ip4_output(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto)
Definition: ip4.c:967
#define ip_2_ip4(ipaddr)
Definition: ip_addr.h:104

Output IP packet, netif is selected by source address

#define ip_output_hinted (   p,
  src,
  dest,
  ttl,
  tos,
  proto,
  addr_hint 
)
Value:
(IP_IS_V6(dest) ? \
ip6_output_hinted(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, addr_hint) : \
ip4_output_hinted(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, addr_hint))
#define IP_IS_V6(ipaddr)
Definition: ip_addr.h:88
#define ip_2_ip6(ipaddr)
Definition: ip_addr.h:100
#define ip_2_ip4(ipaddr)
Definition: ip_addr.h:104

Output IP packet with addr_hint

#define ip_output_if (   p,
  src,
  dest,
  ttl,
  tos,
  proto,
  netif 
)
Value:
(IP_IS_V6(dest) ? \
ip6_output_if(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \
ip4_output_if(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, netif))
#define IP_IS_V6(ipaddr)
Definition: ip_addr.h:88
#define ip_2_ip6(ipaddr)
Definition: ip_addr.h:100
Definition: netif.h:197
err_t ip4_output_if(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif)
Definition: ip4.c:740
#define ip_2_ip4(ipaddr)
Definition: ip_addr.h:104

Output IP packet to specified interface

#define ip_output_if_src (   p,
  src,
  dest,
  ttl,
  tos,
  proto,
  netif 
)
Value:
(IP_IS_V6(dest) ? \
ip6_output_if_src(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \
ip4_output_if_src(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, netif))
#define IP_IS_V6(ipaddr)
Definition: ip_addr.h:88
#define ip_2_ip6(ipaddr)
Definition: ip_addr.h:100
Definition: netif.h:197
err_t ip4_output_if_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif)
Definition: ip4.c:780
#define ip_2_ip4(ipaddr)
Definition: ip_addr.h:104

Output IP packet to interface specifying source address

#define IP_PCB
Value:
/* ip addresses in network byte order */ \
ip_addr_t local_ip; \
ip_addr_t remote_ip; \
/* 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_ADDRHINT

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.

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

Resets an IP pcb option (SOF_* flags)

#define ip_route (   src,
  dest 
)
Value:
(IP_IS_V6(dest) ? \
ip6_route(ip_2_ip6(src), ip_2_ip6(dest)) : \
struct netif * ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src)
Definition: ip4.c:123
#define IP_IS_V6(ipaddr)
Definition: ip_addr.h:88
#define ip_2_ip6(ipaddr)
Definition: ip_addr.h:100
#define ip_2_ip4(ipaddr)
Definition: ip_addr.h:104

Get netif for address combination. See ip6_route and ip4_route

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

Sets an IP pcb option (SOF_* flags)

#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

struct ip_globals ip_data

Global data for both IPv4 and IPv6