uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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"

Go to the source code of this file.

Classes

struct  netif
 

Macros

#define ENABLE_LOOPBACK   (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
 
#define NETIF_MAX_HWADDR_LEN   6U
 
#define NETIF_FLAG_UP   0x01U
 
#define NETIF_FLAG_BROADCAST   0x02U
 
#define NETIF_FLAG_POINTTOPOINT   0x04U
 
#define NETIF_FLAG_DHCP   0x08U
 
#define NETIF_FLAG_LINK_UP   0x10U
 
#define NETIF_FLAG_ETHARP   0x20U
 
#define NETIF_FLAG_ETHERNET   0x40U
 
#define NETIF_FLAG_IGMP   0x80U
 
#define NETIF_INIT_SNMP(netif, type, speed)
 
#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)
 

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_output_fn )(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr)
 
typedef err_t(* netif_linkoutput_fn )(struct netif *netif, struct pbuf *p)
 
typedef void(* netif_status_callback_fn )(struct netif *netif)
 
typedef err_t(* netif_igmp_mac_filter_fn )(struct netif *netif, ip_addr_t *group, u8_t action)
 

Functions

void netif_init (void)
 
struct netifnetif_add (struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input)
 
void netif_set_addr (struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)
 
void netif_remove (struct netif *netif)
 
struct netifnetif_find (char *name)
 
void netif_set_default (struct netif *netif)
 
void netif_set_ipaddr (struct netif *netif, ip_addr_t *ipaddr)
 
void netif_set_netmask (struct netif *netif, ip_addr_t *netmask)
 
void netif_set_gw (struct netif *netif, ip_addr_t *gw)
 
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)
 

Variables

struct netifnetif_list
 
struct netifnetif_default
 

Macro Definition Documentation

#define ENABLE_LOOPBACK   (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)

Definition at line 37 of file netif.h.

#define NETIF_FLAG_BROADCAST   0x02U

If set, the netif has broadcast capability. Set by the netif driver in its init function.

Definition at line 72 of file netif.h.

#define NETIF_FLAG_DHCP   0x08U

If set, the interface is configured using DHCP. Set by the DHCP code when starting or stopping DHCP.

Definition at line 78 of file netif.h.

#define NETIF_FLAG_ETHARP   0x20U

If set, the netif is an ethernet device using ARP. Set by the netif driver in its init function. Used to check input packet types and use of DHCP.

Definition at line 88 of file netif.h.

#define NETIF_FLAG_ETHERNET   0x40U

If set, the netif is an ethernet device. It might not use ARP or TCP/IP if it is used for PPPoE only.

Definition at line 92 of file netif.h.

#define NETIF_FLAG_IGMP   0x80U

If set, the netif has IGMP capability. Set by the netif driver in its init function.

Definition at line 95 of file netif.h.

#define NETIF_FLAG_LINK_UP   0x10U

If set, the interface has an active link (set by the network interface driver). Either set by the netif driver in its init function (if the link is up at that time) or at a later point once the link comes up (if link detection is supported by the hardware).

Definition at line 84 of file netif.h.

#define NETIF_FLAG_POINTTOPOINT   0x04U

If set, the netif is one end of a point-to-point connection. Set by the netif driver in its init function.

Definition at line 75 of file netif.h.

#define NETIF_FLAG_UP   0x01U

Whether the network interface is 'up'. This is a software flag used to control whether this network interface is enabled and processes traffic. It is set by the startup code (for static IP configuration) or by dhcp/autoip when an address has been assigned.

Definition at line 69 of file netif.h.

#define NETIF_INIT_SNMP (   netif,
  type,
  speed 
)

Definition at line 244 of file netif.h.

#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 287 of file netif.h.

#define netif_is_up (   netif)    (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)

Ask if an interface is up

Definition at line 278 of file netif.h.

#define NETIF_MAX_HWADDR_LEN   6U

must be the maximum of all used hardware address lengths across all types of interfaces in use

Definition at line 61 of file netif.h.

Typedef Documentation

typedef err_t(* netif_igmp_mac_filter_fn)(struct netif *netif, ip_addr_t *group, u8_t action)

Function prototype for netif igmp_mac_filter functions

Definition at line 130 of file netif.h.

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 102 of file netif.h.

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

Definition at line 109 of file netif.h.

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 126 of file netif.h.

typedef err_t(* netif_output_fn)(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr)

Function prototype for netif->output functions. Called by lwIP when a packet shall be sent. For ethernet netif, set this to 'etharp_output' and set 'linkoutput'.

Parameters
netifThe netif which shall send a packet
pThe packet to send (p->payload points to IP header)
ipaddrThe IP address to which the packet shall be sent

Definition at line 118 of file netif.h.

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

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

Definition at line 128 of file netif.h.

Function Documentation

struct netif* netif_add ( struct netif netif,
ip_addr_t ipaddr,
ip_addr_t netmask,
ip_addr_t gw,
void *  state,
netif_init_fn  init,
netif_input_fn  input 
)

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.
Returns
netif, or NULL if failed.

Definition at line 137 of file netif.c.

struct netif* netif_find ( char *  name)

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 286 of file netif.c.

void netif_init ( void  )

Definition at line 104 of file 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 236 of file netif.c.

void netif_set_addr ( struct netif netif,
ip_addr_t ipaddr,
ip_addr_t netmask,
ip_addr_t gw 
)

Change IP address configuration for a network interface (including netmask and default gateway).

Parameters
netifthe network interface to change
ipaddrthe new IP address
netmaskthe new netmask
gwthe new default gateway

Definition at line 222 of file 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 426 of file netif.c.

void netif_set_down ( struct netif netif)

Bring an interface down, disabling any traffic processing.

Note
: Enabling DHCP on a down interface will make it come up once configured.
See Also
dhcp_start()

Definition at line 486 of file netif.c.

void netif_set_gw ( struct netif netif,
ip_addr_t gw 
)

Change the default gateway for a network interface

Parameters
netifthe network interface to change
gwthe new default gateway
Note
call netif_set_addr() if you also want to change ip address and netmask

Definition at line 384 of file netif.c.

void netif_set_ipaddr ( struct netif netif,
ip_addr_t ipaddr 
)

Change the IP address of a network interface

Parameters
netifthe network interface to change
ipaddrthe new IP address
Note
call netif_set_addr() if you also want to change netmask and default gateway

Definition at line 319 of file netif.c.

void netif_set_link_down ( struct netif netif)

Called by a driver when its link goes down

Definition at line 552 of file netif.c.

void netif_set_link_up ( struct netif netif)

Called by a driver when its link goes up

Definition at line 513 of file netif.c.

void netif_set_netmask ( struct netif netif,
ip_addr_t netmask 
)

Change the netmask of a network interface

Parameters
netifthe network interface to change
netmaskthe new netmask
Note
call netif_set_addr() if you also want to change ip address and default gateway

Definition at line 405 of file netif.c.

void netif_set_up ( struct netif netif)

Bring an interface up, available for processing traffic.

Note
: Enabling DHCP on a down interface will make it come up once configured.
See Also
dhcp_start()

Definition at line 449 of file netif.c.

Variable Documentation

struct netif* netif_default

The default network interface.

Definition at line 76 of file netif.c.

struct netif* netif_list

The list of network interfaces.

Definition at line 75 of file netif.c.