lwIP  2.0.2
Lightweight IP stack

Macros

#define LWIP_HOOK_FILENAME   "path/to/my/lwip_hooks.h"
 
#define LWIP_HOOK_TCP_ISN(local_ip, local_port, remote_ip, remote_port)
 
#define LWIP_HOOK_IP4_INPUT(pbuf, input_netif)
 
#define LWIP_HOOK_IP4_ROUTE()
 
#define LWIP_HOOK_IP4_ROUTE_SRC(dest, src)
 
#define LWIP_HOOK_ETHARP_GET_GW(netif, dest)
 
#define LWIP_HOOK_IP6_INPUT(pbuf, input_netif)
 
#define LWIP_HOOK_IP6_ROUTE(src, dest)
 
#define LWIP_HOOK_ND6_GET_GW(netif, dest)
 
#define LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr)
 
#define LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type)
 
#define LWIP_HOOK_MEMP_AVAILABLE(memp_t_type)
 
#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif)
 

Detailed Description

Hooks are undefined by default, define them to a function if you need them.

Macro Definition Documentation

◆ LWIP_HOOK_ETHARP_GET_GW

#define LWIP_HOOK_ETHARP_GET_GW (   netif,
  dest 
)

LWIP_HOOK_ETHARP_GET_GW(netif, dest):

  • called from etharp_output() (IPv4)
  • netif: the netif used for sending
  • dest: the destination IPv4 address Returns the IPv4 address of the gateway to handle the specified destination IPv4 address. If NULL is returned, the netif's default gateway is used. The returned address MUST be directly reachable on the specified netif! This function is meant to implement advanced IPv4 routing together with LWIP_HOOK_IP4_ROUTE(). The actual routing/gateway table implementation is not part of lwIP but can e.g. be hidden in the netif's state argument.

◆ LWIP_HOOK_FILENAME

#define LWIP_HOOK_FILENAME   "path/to/my/lwip_hooks.h"

LWIP_HOOK_FILENAME: Custom filename to #include in files that provide hooks. Declare your hook function prototypes in there, you may also #include all headers providing data types that are need in this file.

◆ LWIP_HOOK_IP4_INPUT

#define LWIP_HOOK_IP4_INPUT (   pbuf,
  input_netif 
)

LWIP_HOOK_IP4_INPUT(pbuf, input_netif):

  • called from ip_input() (IPv4)
  • pbuf: received struct pbuf passed to ip_input()
  • input_netif: struct netif on which the packet has been received Return values:
  • 0: Hook has not consumed the packet, packet is processed as normal
  • != 0: Hook has consumed the packet. If the hook consumed the packet, 'pbuf' is in the responsibility of the hook (i.e. free it when done).

◆ LWIP_HOOK_IP4_ROUTE

#define LWIP_HOOK_IP4_ROUTE ( )

LWIP_HOOK_IP4_ROUTE(dest):

  • called from ip_route() (IPv4)
  • dest: destination IPv4 address Returns the destination netif or NULL if no destination netif is found. In that case, ip_route() continues as normal.

◆ LWIP_HOOK_IP4_ROUTE_SRC

#define LWIP_HOOK_IP4_ROUTE_SRC (   dest,
  src 
)

LWIP_HOOK_IP4_ROUTE_SRC(dest, src):

◆ LWIP_HOOK_IP6_INPUT

#define LWIP_HOOK_IP6_INPUT (   pbuf,
  input_netif 
)

LWIP_HOOK_IP6_INPUT(pbuf, input_netif):

  • called from ip6_input() (IPv6)
  • pbuf: received struct pbuf passed to ip6_input()
  • input_netif: struct netif on which the packet has been received Return values:
  • 0: Hook has not consumed the packet, packet is processed as normal
  • != 0: Hook has consumed the packet. If the hook consumed the packet, 'pbuf' is in the responsibility of the hook (i.e. free it when done).

◆ LWIP_HOOK_IP6_ROUTE

#define LWIP_HOOK_IP6_ROUTE (   src,
  dest 
)

LWIP_HOOK_IP6_ROUTE(src, dest):

  • called from ip6_route() (IPv6)
  • src: sourc IPv6 address
  • dest: destination IPv6 address Returns the destination netif or NULL if no destination netif is found. In that case, ip6_route() continues as normal.

◆ LWIP_HOOK_MEMP_AVAILABLE

#define LWIP_HOOK_MEMP_AVAILABLE (   memp_t_type)

LWIP_HOOK_MEMP_AVAILABLE(memp_t_type):

  • called from memp_free() when a memp pool was empty and an item is now available

◆ LWIP_HOOK_ND6_GET_GW

#define LWIP_HOOK_ND6_GET_GW (   netif,
  dest 
)

LWIP_HOOK_ND6_GET_GW(netif, dest):

  • called from nd6_get_next_hop_entry() (IPv6)
  • netif: the netif used for sending
  • dest: the destination IPv6 address Returns the IPv6 address of the next hop to handle the specified destination IPv6 address. If NULL is returned, a NDP-discovered router is used instead. The returned address MUST be directly reachable on the specified netif! This function is meant to implement advanced IPv6 routing together with LWIP_HOOK_IP6_ROUTE(). The actual routing/gateway table implementation is not part of lwIP but can e.g. be hidden in the netif's state argument.

◆ LWIP_HOOK_TCP_ISN

#define LWIP_HOOK_TCP_ISN (   local_ip,
  local_port,
  remote_ip,
  remote_port 
)

LWIP_HOOK_TCP_ISN: Hook for generation of the Initial Sequence Number (ISN) for a new TCP connection. The default lwIP ISN generation algorithm is very basic and may allow for TCP spoofing attacks. This hook provides the means to implement the standardized ISN generation algorithm from RFC 6528 (see contrib/adons/tcp_isn), or any other desired algorithm as a replacement. Called from tcp_connect() and tcp_listen_input() when an ISN is needed for a new TCP connection, if TCP support (LWIP_TCP) is enabled.
Signature: u32_t my_hook_tcp_isn(const ip_addr_t* local_ip, u16_t local_port, const ip_addr_t* remote_ip, u16_t remote_port);

  • it may be necessary to use "struct ip_addr" (ip4_addr, ip6_addr) instead of "ip_addr_t" in function declarations
    Arguments:
  • local_ip: pointer to the local IP address of the connection
  • local_port: local port number of the connection (host-byte order)
  • remote_ip: pointer to the remote IP address of the connection
  • remote_port: remote port number of the connection (host-byte order)
    Return value:
  • the 32-bit Initial Sequence Number to use for the new TCP connection.

◆ LWIP_HOOK_UNKNOWN_ETH_PROTOCOL

#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL (   pbuf,
  netif 
)

LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif): Called from ethernet_input() when an unknown eth type is encountered. Return ERR_OK if packet is accepted, any error code otherwise. Payload points to ethernet header!

◆ LWIP_HOOK_VLAN_CHECK

#define LWIP_HOOK_VLAN_CHECK (   netif,
  eth_hdr,
  vlan_hdr 
)

LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr):

  • called from ethernet_input() if VLAN support is enabled
  • netif: struct netif on which the packet has been received
  • eth_hdr: struct eth_hdr of the packet
  • vlan_hdr: struct eth_vlan_hdr of the packet Return values:
  • 0: Packet must be dropped.
  • != 0: Packet must be accepted.

◆ LWIP_HOOK_VLAN_SET

#define LWIP_HOOK_VLAN_SET (   netif,
  p,
  src,
  dst,
  eth_type 
)

LWIP_HOOK_VLAN_SET: Hook can be used to set prio_vid field of vlan_hdr. If you need to store data on per-netif basis to implement this callback, see Client data handling. Called from ethernet_output() if VLAN support (ETHARP_SUPPORT_VLAN) is enabled.
Signature: s32_t my_hook_vlan_set(struct netif* netif, struct pbuf* pbuf, const struct eth_addr* src, const struct eth_addr* dst, u16_t eth_type);
Arguments:

  • netif: struct netif that the packet will be sent through
  • p: struct pbuf packet to be sent
  • src: source eth address
  • dst: destination eth address
  • eth_type: ethernet type to packet to be sent

Return values:

  • <0: Packet shall not contain VLAN header.
  • 0 <= return value <= 0xFFFF: Packet shall contain VLAN header. Return value is prio_vid in host byte order.