ReactOS 0.4.16-dev-311-g9382aa2
netif.h File Reference
#include "lwip/opt.h"
#include "lwip/err.h"
#include "lwip/ip_addr.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/stats.h"
Include dependency graph for netif.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  netif
 
union  netif_ext_callback_args_t
 
struct  netif_ext_callback_args_t::link_changed_s
 
struct  netif_ext_callback_args_t::status_changed_s
 
struct  netif_ext_callback_args_t::ipv4_changed_s
 
struct  netif_ext_callback_args_t::ipv6_set_s
 
struct  netif_ext_callback_args_t::ipv6_addr_state_changed_s
 

Macros

#define ENABLE_LOOPBACK   (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
 
#define NETIF_MAX_HWADDR_LEN   6U
 
#define NETIF_NAMESIZE   6
 
#define NETIF_FLAG_UP   0x01U
 
#define NETIF_FLAG_BROADCAST   0x02U
 
#define NETIF_FLAG_LINK_UP   0x04U
 
#define NETIF_FLAG_ETHARP   0x08U
 
#define NETIF_FLAG_ETHERNET   0x10U
 
#define NETIF_FLAG_IGMP   0x20U
 
#define NETIF_FLAG_MLD6   0x40U
 
#define NETIF_ADDR_IDX_MAX   0x7F
 
#define LWIP_NETIF_USE_HINTS   0
 
#define NETIF_CHECKSUM_ENABLED(netif, chksumflag)   0
 
#define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags)
 
#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)
 
#define NETIF_FOREACH(netif)   for ((netif) = netif_list; (netif) != NULL; (netif) = (netif)->next)
 
#define netif_set_flags(netif, set_flags)   do { (netif)->flags = (u8_t)((netif)->flags | (set_flags)); } while(0)
 
#define netif_clear_flags(netif, clr_flags)   do { (netif)->flags = (u8_t)((netif)->flags & (u8_t)(~(clr_flags) & 0xff)); } while(0)
 
#define netif_is_flag_set(netif, flag)   (((netif)->flags & (flag)) != 0)
 
#define netif_is_up(netif)   (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
 
#define netif_is_link_up(netif)   (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)
 
#define NETIF_SET_HINTS(netif, netifhint)
 
#define NETIF_RESET_HINTS(netif)
 
#define netif_get_index(netif)   ((u8_t)((netif)->num + 1))
 
#define NETIF_NO_INDEX   (0)
 
#define LWIP_NSC_NONE   0x0000
 
#define LWIP_NSC_NETIF_ADDED   0x0001
 
#define LWIP_NSC_NETIF_REMOVED   0x0002
 
#define LWIP_NSC_LINK_CHANGED   0x0004
 
#define LWIP_NSC_STATUS_CHANGED   0x0008
 
#define LWIP_NSC_IPV4_ADDRESS_CHANGED   0x0010
 
#define LWIP_NSC_IPV4_GATEWAY_CHANGED   0x0020
 
#define LWIP_NSC_IPV4_NETMASK_CHANGED   0x0040
 
#define LWIP_NSC_IPV4_SETTINGS_CHANGED   0x0080
 
#define LWIP_NSC_IPV6_SET   0x0100
 
#define LWIP_NSC_IPV6_ADDR_STATE_CHANGED   0x0200
 
#define LWIP_NSC_IPV4_ADDR_VALID   0x0400
 
#define NETIF_DECLARE_EXT_CALLBACK(name)
 
#define netif_add_ext_callback(callback, fn)
 
#define netif_remove_ext_callback(callback)
 
#define netif_invoke_ext_callback(netif, reason, args)
 

Typedefs

typedef err_t(* netif_init_fn) (struct netif *netif)
 
typedef err_t(* netif_input_fn) (struct pbuf *p, struct netif *inp)
 
typedef err_t(* netif_linkoutput_fn) (struct netif *netif, struct pbuf *p)
 
typedef void(* netif_status_callback_fn) (struct netif *netif)
 
typedef u8_t netif_addr_idx_t
 
typedef u16_t netif_nsc_reason_t
 
typedef void(* netif_ext_callback_fn) (struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)
 

Enumerations

enum  lwip_internal_netif_client_data_index { LWIP_NETIF_CLIENT_DATA_INDEX_MAX }
 
enum  netif_mac_filter_action { NETIF_DEL_MAC_FILTER = 0 , NETIF_ADD_MAC_FILTER = 1 }
 

Functions

void netif_init (void)
 
struct netifnetif_add_noaddr (struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
 
struct netifnetif_add (struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
 
void netif_remove (struct netif *netif)
 
struct netifnetif_find (const char *name)
 
void netif_set_default (struct netif *netif)
 
void netif_set_up (struct netif *netif)
 
void netif_set_down (struct netif *netif)
 
void netif_set_link_up (struct netif *netif)
 
void netif_set_link_down (struct netif *netif)
 
err_t netif_input (struct pbuf *p, struct netif *inp)
 
u8_t netif_name_to_index (const char *name)
 
charnetif_index_to_name (u8_t idx, char *name)
 
struct netifnetif_get_by_index (u8_t idx)
 

Variables

struct netifnetif_list
 
struct netifnetif_default
 

Detailed Description

netif API (to be used from TCPIP thread)

Definition in file netif.h.

Macro Definition Documentation

◆ ENABLE_LOOPBACK

#define ENABLE_LOOPBACK   (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)

Definition at line 42 of file netif.h.

◆ IF__NETIF_CHECKSUM_ENABLED

#define IF__NETIF_CHECKSUM_ENABLED (   netif,
  chksumflag 
)

Definition at line 416 of file netif.h.

◆ LWIP_NETIF_USE_HINTS

#define LWIP_NETIF_USE_HINTS   0

Definition at line 263 of file netif.h.

◆ LWIP_NSC_IPV4_ADDR_VALID

#define LWIP_NSC_IPV4_ADDR_VALID   0x0400

IPv4 settings: valid address set, application may start to communicate

Definition at line 613 of file netif.h.

◆ LWIP_NSC_IPV4_ADDRESS_CHANGED

#define LWIP_NSC_IPV4_ADDRESS_CHANGED   0x0010

IPv4 address has changed

Definition at line 601 of file netif.h.

◆ LWIP_NSC_IPV4_GATEWAY_CHANGED

#define LWIP_NSC_IPV4_GATEWAY_CHANGED   0x0020

IPv4 gateway has changed

Definition at line 603 of file netif.h.

◆ LWIP_NSC_IPV4_NETMASK_CHANGED

#define LWIP_NSC_IPV4_NETMASK_CHANGED   0x0040

IPv4 netmask has changed

Definition at line 605 of file netif.h.

◆ LWIP_NSC_IPV4_SETTINGS_CHANGED

#define LWIP_NSC_IPV4_SETTINGS_CHANGED   0x0080

called AFTER IPv4 address/gateway/netmask changes have been applied

Definition at line 607 of file netif.h.

◆ LWIP_NSC_IPV6_ADDR_STATE_CHANGED

#define LWIP_NSC_IPV6_ADDR_STATE_CHANGED   0x0200

IPv6 address state has changed

Definition at line 611 of file netif.h.

◆ LWIP_NSC_IPV6_SET

#define LWIP_NSC_IPV6_SET   0x0100

IPv6 address was added

Definition at line 609 of file netif.h.

◆ LWIP_NSC_LINK_CHANGED

#define LWIP_NSC_LINK_CHANGED   0x0004

link changed

Definition at line 595 of file netif.h.

◆ LWIP_NSC_NETIF_ADDED

#define LWIP_NSC_NETIF_ADDED   0x0001

netif was added. arg: NULL. Called AFTER netif was added.

Definition at line 591 of file netif.h.

◆ LWIP_NSC_NETIF_REMOVED

#define LWIP_NSC_NETIF_REMOVED   0x0002

netif was removed. arg: NULL. Called BEFORE netif is removed.

Definition at line 593 of file netif.h.

◆ LWIP_NSC_NONE

#define LWIP_NSC_NONE   0x0000

Definition at line 589 of file netif.h.

◆ LWIP_NSC_STATUS_CHANGED

#define LWIP_NSC_STATUS_CHANGED   0x0008

netif administrative status changed.
up is called AFTER netif is set up.
down is called BEFORE the netif is actually set down.

Definition at line 599 of file netif.h.

◆ netif_add_ext_callback

#define netif_add_ext_callback (   callback,
  fn 
)

Definition at line 684 of file netif.h.

◆ NETIF_ADDR_IDX_MAX

#define NETIF_ADDR_IDX_MAX   0x7F

Definition at line 248 of file netif.h.

◆ NETIF_CHECKSUM_ENABLED

#define NETIF_CHECKSUM_ENABLED (   netif,
  chksumflag 
)    0

Definition at line 414 of file netif.h.

◆ netif_clear_flags

#define netif_clear_flags (   netif,
  clr_flags 
)    do { (netif)->flags = (u8_t)((netif)->flags & (u8_t)(~(clr_flags) & 0xff)); } while(0)

Definition at line 471 of file netif.h.

◆ NETIF_DECLARE_EXT_CALLBACK

#define NETIF_DECLARE_EXT_CALLBACK (   name)

Definition at line 683 of file netif.h.

◆ NETIF_FOREACH

#define NETIF_FOREACH (   netif)    for ((netif) = netif_list; (netif) != NULL; (netif) = (netif)->next)

Definition at line 424 of file netif.h.

◆ netif_get_index

#define netif_get_index (   netif)    ((u8_t)((netif)->num + 1))

Definition at line 578 of file netif.h.

◆ netif_invoke_ext_callback

#define netif_invoke_ext_callback (   netif,
  reason,
  args 
)

Definition at line 686 of file netif.h.

◆ netif_is_flag_set

#define netif_is_flag_set (   netif,
  flag 
)    (((netif)->flags & (flag)) != 0)

Definition at line 472 of file netif.h.

◆ netif_is_link_up

#define netif_is_link_up (   netif)    (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)

Ask if a link is up

Definition at line 491 of file netif.h.

◆ NETIF_MAX_HWADDR_LEN

#define NETIF_MAX_HWADDR_LEN   6U

Must be the maximum of all used hardware address lengths across all types of interfaces in use. This does not have to be changed, normally.

Definition at line 63 of file netif.h.

◆ NETIF_NAMESIZE

#define NETIF_NAMESIZE   6

The size of a fully constructed netif name which the netif can be identified by in APIs. Composed of 2 chars, 3 (max) digits, and 1 \0

Definition at line 70 of file netif.h.

◆ NETIF_NO_INDEX

#define NETIF_NO_INDEX   (0)

Definition at line 579 of file netif.h.

◆ netif_remove_ext_callback

#define netif_remove_ext_callback (   callback)

Definition at line 685 of file netif.h.

◆ NETIF_RESET_HINTS

#define NETIF_RESET_HINTS (   netif)

Definition at line 570 of file netif.h.

◆ NETIF_SET_CHECKSUM_CTRL

#define NETIF_SET_CHECKSUM_CTRL (   netif,
  chksumflags 
)

Definition at line 415 of file netif.h.

◆ netif_set_flags

#define netif_set_flags (   netif,
  set_flags 
)    do { (netif)->flags = (u8_t)((netif)->flags | (set_flags)); } while(0)

Definition at line 470 of file netif.h.

◆ NETIF_SET_HINTS

#define NETIF_SET_HINTS (   netif,
  netifhint 
)

Definition at line 569 of file netif.h.

Typedef Documentation

◆ netif_addr_idx_t

Definition at line 247 of file netif.h.

◆ netif_init_fn

typedef err_t(* netif_init_fn) (struct netif *netif)

Function prototype for netif init functions. Set up flags and output/linkoutput callback functions in this function.

Parameters
netifThe netif to initialize

Definition at line 171 of file netif.h.

◆ netif_input_fn

typedef err_t(* netif_input_fn) (struct pbuf *p, struct netif *inp)

Function prototype for netif->input functions. This function is saved as 'input' callback function in the netif struct. Call it when a packet has been received.

Parameters
pThe received packet, copied into a pbuf
inpThe netif which received the packet
Returns
ERR_OK if the packet was handled != ERR_OK is the packet was NOT handled, in this case, the caller has to free the pbuf

Definition at line 181 of file netif.h.

◆ netif_linkoutput_fn

typedef err_t(* netif_linkoutput_fn) (struct netif *netif, struct pbuf *p)

Function prototype for netif->linkoutput functions. Only used for ethernet netifs. This function is called by ARP when a packet shall be sent.

Parameters
netifThe netif which shall send a packet
pThe packet to send (raw ethernet packet)

Definition at line 215 of file netif.h.

◆ netif_status_callback_fn

typedef void(* netif_status_callback_fn) (struct netif *netif)

Function prototype for netif status- or link-callback functions.

Definition at line 217 of file netif.h.

Enumeration Type Documentation

◆ lwip_internal_netif_client_data_index

Enumerator
LWIP_NETIF_CLIENT_DATA_INDEX_MAX 

Definition at line 113 of file netif.h.

114{
115#if LWIP_IPV4
116#if LWIP_DHCP
117 LWIP_NETIF_CLIENT_DATA_INDEX_DHCP,
118#endif
119#if LWIP_AUTOIP
120 LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
121#endif
122#if LWIP_ACD
123 LWIP_NETIF_CLIENT_DATA_INDEX_ACD,
124#endif
125#if LWIP_IGMP
126 LWIP_NETIF_CLIENT_DATA_INDEX_IGMP,
127#endif
128#endif /* LWIP_IPV4 */
129#if LWIP_IPV6
130#if LWIP_IPV6_DHCP6
131 LWIP_NETIF_CLIENT_DATA_INDEX_DHCP6,
132#endif
133#if LWIP_IPV6_MLD
134 LWIP_NETIF_CLIENT_DATA_INDEX_MLD6,
135#endif
136#endif /* LWIP_IPV6 */
138};
@ LWIP_NETIF_CLIENT_DATA_INDEX_MAX
Definition: netif.h:137

◆ netif_mac_filter_action

MAC Filter Actions, these are passed to a netif's igmp_mac_filter or mld_mac_filter callback function.

Enumerator
NETIF_DEL_MAC_FILTER 

Delete a filter entry

NETIF_ADD_MAC_FILTER 

Add a filter entry

Definition at line 159 of file netif.h.

159 {
164};
@ NETIF_ADD_MAC_FILTER
Definition: netif.h:163
@ NETIF_DEL_MAC_FILTER
Definition: netif.h:161

Function Documentation

◆ netif_init()

void netif_init ( void  )

Definition at line 188 of file netif.c.

189{
190#if LWIP_HAVE_LOOPIF
191#if LWIP_IPV4
192#define LOOPIF_ADDRINIT &loop_ipaddr, &loop_netmask, &loop_gw,
193 ip4_addr_t loop_ipaddr, loop_netmask, loop_gw;
194 IP4_ADDR(&loop_gw, 127, 0, 0, 1);
195 IP4_ADDR(&loop_ipaddr, 127, 0, 0, 1);
196 IP4_ADDR(&loop_netmask, 255, 0, 0, 0);
197#else /* LWIP_IPV4 */
198#define LOOPIF_ADDRINIT
199#endif /* LWIP_IPV4 */
200
201#if NO_SYS
202 netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, ip_input);
203#else /* NO_SYS */
204 netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, tcpip_input);
205#endif /* NO_SYS */
206
207#if LWIP_IPV6
208 IP_ADDR6_HOST(loop_netif.ip6_addr, 0, 0, 0, 0x00000001UL);
209 loop_netif.ip6_addr_state[0] = IP6_ADDR_VALID;
210#endif /* LWIP_IPV6 */
211
212 netif_set_link_up(&loop_netif);
213 netif_set_up(&loop_netif);
214
215#endif /* LWIP_HAVE_LOOPIF */
216}
#define NULL
Definition: types.h:112
err_t tcpip_input(struct pbuf *p, struct netif *inp)
Definition: tcpip.c:288
struct netif * netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
Definition: netif.c:287
void netif_set_link_up(struct netif *netif)
Definition: netif.c:1018
void netif_set_up(struct netif *netif)
Definition: netif.c:871
#define IP_ADDR6_HOST(ipaddr, i0, i1, i2, i3)
Definition: ip_addr.h:358

Referenced by lwip_init(), and main().

Variable Documentation

◆ netif_default

◆ netif_list