lwIP
2.1.0
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_TCP_INPACKET_PCB(pcb, hdr, optlen, opt1len, opt2, p) |
#define | LWIP_HOOK_TCP_OUT_TCPOPT_LENGTH(pcb, internal_len) |
#define | LWIP_HOOK_TCP_OUT_ADD_TCPOPTS(p, hdr, pcb, opts) |
#define | LWIP_HOOK_IP4_INPUT(pbuf, input_netif) |
#define | LWIP_HOOK_IP4_ROUTE() |
#define | LWIP_HOOK_IP4_ROUTE_SRC(src, dest) |
#define | LWIP_HOOK_IP4_CANFORWARD(src, dest) |
#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) |
#define | LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, state, msg, msg_type, options_len_ptr) |
#define | LWIP_HOOK_DHCP_PARSE_OPTION(netif, dhcp, state, msg, msg_type, option, len, pbuf, offset) |
#define | LWIP_HOOK_DHCP6_APPEND_OPTIONS(netif, dhcp6, state, msg, msg_type, options_len_ptr, max_len) |
#define | LWIP_HOOK_SOCKETS_SETSOCKOPT(s, sock, level, optname, optval, optlen, err) |
#define | LWIP_HOOK_SOCKETS_GETSOCKOPT(s, sock, level, optname, optval, optlen, err) |
#define | LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE(name, addr, addrtype, err) |
Hooks are undefined by default, define them to a function if you need them.
#define LWIP_HOOK_DHCP6_APPEND_OPTIONS | ( | netif, | |
dhcp6, | |||
state, | |||
msg, | |||
msg_type, | |||
options_len_ptr, | |||
max_len | |||
) |
LWIP_HOOK_DHCP6_APPEND_OPTIONS(netif, dhcp6, state, msg, msg_type, options_len_ptr, max_len): Called from various dhcp6 functions when sending a DHCP6 message. This hook is called just before the DHCP6 message is sent, so the options are at the end of a DHCP6 message. Signature:
Arguments:
Options need to appended like this: u8_t *options = (u8_t *)(msg + 1); LWIP_ASSERT("dhcp option overflow", sizeof(struct dhcp6_msg) + *options_len_ptr + newoptlen <= max_len); options[(*options_len_ptr)++] = <option_data>; [...]
#define LWIP_HOOK_DHCP_APPEND_OPTIONS | ( | netif, | |
dhcp, | |||
state, | |||
msg, | |||
msg_type, | |||
options_len_ptr | |||
) |
LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, state, msg, msg_type, options_len_ptr): Called from various dhcp functions when sending a DHCP message. This hook is called just before the DHCP message trailer is added, so the options are at the end of a DHCP message. Signature:
Arguments:
Options need to appended like this: LWIP_ASSERT("dhcp option overflow", *options_len_ptr + option_len + 2 <= DHCP_OPTIONS_LEN); msg->options[(*options_len_ptr)++] = <option_number>; msg->options[(*options_len_ptr)++] = <option_len>; msg->options[(*options_len_ptr)++] = <option_bytes>; [...]
#define LWIP_HOOK_DHCP_PARSE_OPTION | ( | netif, | |
dhcp, | |||
state, | |||
msg, | |||
msg_type, | |||
option, | |||
len, | |||
pbuf, | |||
offset | |||
) |
LWIP_HOOK_DHCP_PARSE_OPTION(netif, dhcp, state, msg, msg_type, option, len, pbuf, option_value_offset): Called from dhcp_parse_reply when receiving a DHCP message. This hook is called for every option in the received message that is not handled internally. Signature:
Arguments:
A nice way to get the option contents is pbuf_get_contiguous(): u8_t buf[32]; u8_t ptr = (u8_t)pbuf_get_contiguous(p, buf, sizeof(buf), LWIP_MIN(option_len, sizeof(buf)), offset);
#define LWIP_HOOK_ETHARP_GET_GW | ( | netif, | |
dest | |||
) |
LWIP_HOOK_ETHARP_GET_GW(netif, dest): Called from etharp_output() (IPv4) Signature:
Arguments:
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.
#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.
#define LWIP_HOOK_IP4_CANFORWARD | ( | src, | |
dest | |||
) |
LWIP_HOOK_IP4_CANFORWARD(src, dest): Check if an IPv4 can be forwarded - called from: ip4_input() -> ip4_forward() -> ip4_canforward() (IPv4)
#define LWIP_HOOK_IP4_INPUT | ( | pbuf, | |
input_netif | |||
) |
LWIP_HOOK_IP4_INPUT(pbuf, input_netif): Called from ip_input() (IPv4) Signature:
Arguments:
#define LWIP_HOOK_IP4_ROUTE | ( | ) |
LWIP_HOOK_IP4_ROUTE(dest): Called from ip_route() (IPv4) Signature:
Arguments:
#define LWIP_HOOK_IP4_ROUTE_SRC | ( | src, | |
dest | |||
) |
LWIP_HOOK_IP4_ROUTE_SRC(src, dest): Source-based routing for IPv4 - called from ip_route() (IPv4) Signature:
Arguments:
#define LWIP_HOOK_IP6_INPUT | ( | pbuf, | |
input_netif | |||
) |
LWIP_HOOK_IP6_INPUT(pbuf, input_netif): Called from ip6_input() (IPv6) Signature:
Arguments:
#define LWIP_HOOK_IP6_ROUTE | ( | src, | |
dest | |||
) |
LWIP_HOOK_IP6_ROUTE(src, dest): Called from ip_route() (IPv6) Signature:
Arguments:
#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 Signature:
#define LWIP_HOOK_ND6_GET_GW | ( | netif, | |
dest | |||
) |
LWIP_HOOK_ND6_GET_GW(netif, dest): Called from nd6_get_next_hop_entry() (IPv6) Signature:
Arguments:
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.
#define LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE | ( | name, | |
addr, | |||
addrtype, | |||
err | |||
) |
LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE(name, addr, addrtype, err) Called from netconn APIs (not usable with callback apps) allowing an external DNS resolver (which uses sequential API) to handle the query. Signature:
Arguments:
err must also be checked to determine if the hook consumed the query, but the query failed
#define LWIP_HOOK_SOCKETS_GETSOCKOPT | ( | s, | |
sock, | |||
level, | |||
optname, | |||
optval, | |||
optlen, | |||
err | |||
) |
LWIP_HOOK_SOCKETS_GETSOCKOPT(s, sock, level, optname, optval, optlen, err) Called from socket API to implement getsockopt() for options not provided by lwIP. Core lock is held when this hook is called. Signature:
Arguments:
#define LWIP_HOOK_SOCKETS_SETSOCKOPT | ( | s, | |
sock, | |||
level, | |||
optname, | |||
optval, | |||
optlen, | |||
err | |||
) |
LWIP_HOOK_SOCKETS_SETSOCKOPT(s, sock, level, optname, optval, optlen, err) Called from socket API to implement setsockopt() for options not provided by lwIP. Core lock is held when this hook is called. Signature:
Arguments:
#define LWIP_HOOK_TCP_INPACKET_PCB | ( | pcb, | |
hdr, | |||
optlen, | |||
opt1len, | |||
opt2, | |||
p | |||
) |
LWIP_HOOK_TCP_INPACKET_PCB: Hook for intercepting incoming packets before they are passed to a pcb. This allows updating some state or even dropping a packet. Signature:
Arguments:
ATTENTION: don't call any tcp api functions that might change tcp state (pcb state or any pcb lists) from this callback!
#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:
#define LWIP_HOOK_TCP_OUT_ADD_TCPOPTS | ( | p, | |
hdr, | |||
pcb, | |||
opts | |||
) |
LWIP_HOOK_TCP_OUT_ADD_TCPOPTS: Hook for adding custom options to outgoing tcp segments. Space for these custom options has to be reserved via LWIP_HOOK_TCP_OUT_TCPOPT_LENGTH. Signature:
Arguments:
ATTENTION: don't call any tcp api functions that might change tcp state (pcb state or any pcb lists) from this callback!
#define LWIP_HOOK_TCP_OUT_TCPOPT_LENGTH | ( | pcb, | |
internal_len | |||
) |
LWIP_HOOK_TCP_OUT_TCPOPT_LENGTH: Hook for increasing the size of the options allocated with a tcp header. Together with LWIP_HOOK_TCP_OUT_ADD_TCPOPTS, this can be used to add custom options to outgoing tcp segments. Signature:
Arguments:
ATTENTION: don't call any tcp api functions that might change tcp state (pcb state or any pcb lists) from this callback!
LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif): Called from ethernet_input() when an unknown eth type is encountered. Signature:
Arguments:
Payload points to ethernet header!
LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr): Called from ethernet_input() if VLAN support is enabled Signature:
Arguments:
#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:
Arguments:
Return values: