Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Network interface (NETIF)

Network interface (NETIF)
["raw" APIs]

Data Structures

union  netif_ext_callback_args_t
 Argument supplied to netif_ext_callback_fn. More...

Modules

 IPv4 address handling
 IPv6 address handling
 Client data handling
 

Store data (void*) on a netif for application usage.


 Flags
 MIB2 statistics

Typedefs

typedef u16_t netif_nsc_reason_t
 Extended netif status callback (NSC) reasons flags.
typedef void(* netif_ext_callback_fn )(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)
 Function used for extended netif status callbacks Note: When parsing reason argument, keep in mind that more reasons may be added in the future!

Functions

struct netifnetif_add_noaddr (struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
 Add a network interface to the list of lwIP netifs.
struct netifnetif_add (struct netif *netif,#if LWIP_IPV4 const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,#endifvoid *state, netif_init_fn init, netif_input_fn input)
 Add a network interface to the list of lwIP netifs.
void netif_remove (struct netif *netif)
 Remove a network interface from the list of lwIP netifs.
void netif_set_default (struct netif *netif)
 Set a network interface as the default network interface (used to output all packets for which no specific route is found)
bool netif_check_default (struct netif *netif)
 Checks if network interface is the default network interface.
void netif_set_up (struct netif *netif)
 Bring an interface up, available for processing traffic.
void netif_set_down (struct netif *netif)
 Bring an interface down, disabling any traffic processing.
void netif_set_status_callback (struct netif *netif, netif_status_callback_fn status_callback)
 Set callback to be called when interface is brought up/down or address is changed while up.
void netif_set_remove_callback (struct netif *netif, netif_status_callback_fn remove_callback)
 Set callback to be called when the interface has been removed.
void netif_set_link_up (struct netif *netif)
 Called by a driver when its link goes up.
void netif_set_link_down (struct netif *netif)
 Called by a driver when its link goes down.
void netif_set_link_callback (struct netif *netif, netif_status_callback_fn link_callback)
 Set callback to be called when link is brought up/down.
err_t netif_loop_output (struct netif *netif, struct pbuf *p)
 Send an IP packet to be received on the same netif (loopif-like).
u8_t netif_name_to_index (const char *name)
 Return the interface index for the netif with name or NETIF_NO_INDEX if not found/on error.
char * netif_index_to_name (u8_t idx, char *name)
 Return the interface name for the netif matching index or NULL if not found/on error.
struct netifnetif_get_by_index (u8_t idx)
 Return the interface for the netif index.
struct netifnetif_find (const char *name)
 Find a network interface by searching for its name.
const char * netif_get_name (struct netif *netif)
 Get a network interface name.
void netif_add_ext_callback (netif_ext_callback_t *callback, netif_ext_callback_fn fn)
 Add extended netif events listener.
void netif_remove_ext_callback (netif_ext_callback_t *callback)
 Remove extended netif events listener.

Typedef Documentation

typedef void(* netif_ext_callback_fn)(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)

Function used for extended netif status callbacks Note: When parsing reason argument, keep in mind that more reasons may be added in the future!

Parameters:
netifnetif that is affected by change
reasonchange reason
argsdepends on reason, see reason description

Definition at line 653 of file netif.h.

typedef u16_t netif_nsc_reason_t

Extended netif status callback (NSC) reasons flags.

May be extended in the future!

Definition at line 573 of file netif.h.


Function Documentation

struct netif* netif_add ( struct netif netif,
#if LWIP_IPV4 const ip4_addr_t ipaddr,
const ip4_addr_t netmask,
const ip4_addr_t gw,
#endif void *  state,
netif_init_fn  init,
netif_input_fn  input 
) [read]

Add a network interface to the list of lwIP netifs.

Parameters:
netifa pre-allocated netif structure
ipaddrIP address for the new netif
netmasknetwork mask for the new netif
gwdefault gateway IP address for the new netif
stateopaque data passed to the new netif
initcallback function that initializes the interface
inputcallback function that is called to pass ingress packets up in the protocol layer stack.
It is recommended to use a function that passes the input directly to the stack (netif_input(), NO_SYS=1 mode) or via sending a message to TCPIP thread (tcpip_input(), NO_SYS=0 mode).
These functions use netif flags NETIF_FLAG_ETHARP and NETIF_FLAG_ETHERNET to decide whether to forward to ethernet_input() or ip_input(). In other words, the functions only work when the netif driver is implemented correctly!
Most members of struct netif should be be initialized by the netif init function = netif driver (init parameter of this function).
IPv6: Don't forget to call netif_create_ip6_linklocal_address() after setting the MAC address in struct netif.hwaddr (IPv6 requires a link-local address).
Returns:
netif, or NULL if failed.

Definition at line 277 of file lwip_netif.c.

void netif_add_ext_callback ( netif_ext_callback_t *  callback,
netif_ext_callback_fn  fn 
)

Add extended netif events listener.

Parameters:
callbackpointer to listener structure
fncallback function

Definition at line 1772 of file lwip_netif.c.

struct netif* netif_add_noaddr ( struct netif netif,
void *  state,
netif_init_fn  init,
netif_input_fn  input 
) [read]

Add a network interface to the list of lwIP netifs.

Same as netif_add but without IPv4 addresses

Definition at line 240 of file lwip_netif.c.

bool netif_check_default ( struct netif netif )

Checks if network interface is the default network interface.

Parameters:
netifthe default network interface
Returns:
true if netif is set to default one otherwise return false

Definition at line 847 of file lwip_netif.c.

struct netif* netif_find ( const char *  name ) [read]

Find a network interface by searching for its name.

Parameters:
namethe name of the netif (like netif->name) plus concatenated number in ascii representation (e.g. 'en0')

Definition at line 1722 of file lwip_netif.c.

struct netif* netif_get_by_index ( u8_t  idx ) [read]

Return the interface for the netif index.

Parameters:
idxindex of netif to find

Definition at line 1697 of file lwip_netif.c.

const char* netif_get_name ( struct netif netif )

Get a network interface name.

Parameters:
netif
Returns:
name the name of the netif (like netif->name) plus concatenated number in ascii representation (e.g. 'en0')

Definition at line 1755 of file lwip_netif.c.

char* netif_index_to_name ( u8_t  idx,
char *  name 
)

Return the interface name for the netif matching index or NULL if not found/on error.

Parameters:
idxthe interface index of the netif
namechar buffer of at least NETIF_NAMESIZE bytes

Definition at line 1677 of file lwip_netif.c.

err_t netif_loop_output ( struct netif netif,
struct pbuf p 
)

Send an IP packet to be received on the same netif (loopif-like).

The pbuf is simply copied and handed back to netif->input. In multithreaded mode, this is done directly since netif->input must put the packet on a queue. In callback mode, the packet is put on an internal queue and is fed to netif->input by netif_poll().

Parameters:
netifthe lwip network interface structure
pthe (IP) packet to 'send'
Returns:
ERR_OK if the packet has been sent ERR_MEM if the pbuf used to copy the packet couldn't be allocated

Definition at line 1098 of file lwip_netif.c.

u8_t netif_name_to_index ( const char *  name )

Return the interface index for the netif with name or NETIF_NO_INDEX if not found/on error.

Parameters:
namethe name of the netif

Definition at line 1658 of file lwip_netif.c.

void netif_remove ( struct netif netif )

Remove a network interface from the list of lwIP netifs.

Parameters:
netifthe network interface to remove

Definition at line 738 of file lwip_netif.c.

void netif_remove_ext_callback ( netif_ext_callback_t *  callback )

Remove extended netif events listener.

Parameters:
callbackpointer to listener structure

Definition at line 1789 of file lwip_netif.c.

void netif_set_default ( struct netif netif )

Set a network interface as the default network interface (used to output all packets for which no specific route is found)

Parameters:
netifthe default network interface

Definition at line 823 of file lwip_netif.c.

void netif_set_down ( struct netif netif )

Bring an interface down, disabling any traffic processing.

Definition at line 940 of file lwip_netif.c.

void netif_set_link_callback ( struct netif netif,
netif_status_callback_fn  link_callback 
)

Set callback to be called when link is brought up/down.

Definition at line 1072 of file lwip_netif.c.

void netif_set_link_down ( struct netif netif )

Called by a driver when its link goes down.

Definition at line 1047 of file lwip_netif.c.

void netif_set_link_up ( struct netif netif )

Called by a driver when its link goes up.

Definition at line 1009 of file lwip_netif.c.

void netif_set_remove_callback ( struct netif netif,
netif_status_callback_fn  remove_callback 
)

Set callback to be called when the interface has been removed.

Definition at line 994 of file lwip_netif.c.

void netif_set_status_callback ( struct netif netif,
netif_status_callback_fn  status_callback 
)

Set callback to be called when interface is brought up/down or address is changed while up.

Definition at line 978 of file lwip_netif.c.

void netif_set_up ( struct netif netif )

Bring an interface up, available for processing traffic.

Definition at line 865 of file lwip_netif.c.