Prusa MINI Firmware overview
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"

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_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_SET_CHECKSUM_CTRL(netif, chksumflags)
 
#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)
 
#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_HWADDRHINT(netif, hint)
 

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)
 

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 (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)
 

Variables

struct netifnetif_list
 
struct netifnetif_default
 

Detailed Description

netif API (to be used from TCPIP thread)

Macro Definition Documentation

◆ ENABLE_LOOPBACK

#define ENABLE_LOOPBACK   (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)

◆ 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.

◆ NETIF_SET_CHECKSUM_CTRL

#define NETIF_SET_CHECKSUM_CTRL (   netif,
  chksumflags 
)

◆ IF__NETIF_CHECKSUM_ENABLED

#define IF__NETIF_CHECKSUM_ENABLED (   netif,
  chksumflag 
)

◆ 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

◆ NETIF_SET_HWADDRHINT

#define NETIF_SET_HWADDRHINT (   netif,
  hint 
)

Typedef Documentation

◆ 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

◆ 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

◆ 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)

◆ netif_status_callback_fn

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

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

Enumeration Type Documentation

◆ lwip_internal_netif_client_data_index

Enumerator
LWIP_NETIF_CLIENT_DATA_INDEX_MAX 
108 {
109 #if LWIP_DHCP
110  LWIP_NETIF_CLIENT_DATA_INDEX_DHCP,
111 #endif
112 #if LWIP_AUTOIP
113  LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
114 #endif
115 #if LWIP_IGMP
116  LWIP_NETIF_CLIENT_DATA_INDEX_IGMP,
117 #endif
118 #if LWIP_IPV6_MLD
119  LWIP_NETIF_CLIENT_DATA_INDEX_MLD6,
120 #endif
122 };

◆ 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

143  {
144  /** Delete a filter entry */
146  /** Add a filter entry */
148 };

Function Documentation

◆ netif_init()

void netif_init ( void  )
164 {
165 #if LWIP_HAVE_LOOPIF
166 #if LWIP_IPV4
167 #define LOOPIF_ADDRINIT &loop_ipaddr, &loop_netmask, &loop_gw,
168  ip4_addr_t loop_ipaddr, loop_netmask, loop_gw;
169  IP4_ADDR(&loop_gw, 127,0,0,1);
170  IP4_ADDR(&loop_ipaddr, 127,0,0,1);
171  IP4_ADDR(&loop_netmask, 255,0,0,0);
172 #else /* LWIP_IPV4 */
173 #define LOOPIF_ADDRINIT
174 #endif /* LWIP_IPV4 */
175 
176 #if NO_SYS
177  netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, ip_input);
178 #else /* NO_SYS */
179  netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, tcpip_input);
180 #endif /* NO_SYS */
181 
182 #if LWIP_IPV6
183  IP_ADDR6_HOST(loop_netif.ip6_addr, 0, 0, 0, 0x00000001UL);
184  loop_netif.ip6_addr_state[0] = IP6_ADDR_VALID;
185 #endif /* LWIP_IPV6 */
186 
187  netif_set_link_up(&loop_netif);
188  netif_set_up(&loop_netif);
189 
190 #endif /* LWIP_HAVE_LOOPIF */
191 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netif_input()

err_t netif_input ( struct pbuf p,
struct netif inp 
)

Forwards a received packet for input processing with ethernet_input() or ip_input() depending on netif flags. Don't call directly, pass to netif_add() and call netif->input(). Only works if the netif driver correctly sets NETIF_FLAG_ETHARP and/or NETIF_FLAG_ETHERNET flag!

204 {
205 #if LWIP_ETHERNET
207  return ethernet_input(p, inp);
208  } else
209 #endif /* LWIP_ETHERNET */
210  return ip_input(p, inp);
211 }

Variable Documentation

◆ netif_list

struct netif* netif_list

The list of network interfaces.

◆ netif_default

struct netif* netif_default

The default network interface.

netif_set_up
void netif_set_up(struct netif *netif)
Definition: netif.c:624
NETIF_FLAG_ETHARP
#define NETIF_FLAG_ETHARP
Definition: netif.h:91
netif::flags
u8_t flags
Definition: netif.h:305
NETIF_DEL_MAC_FILTER
Definition: netif.h:145
NULL
#define NULL
Definition: usbd_def.h:53
NETIF_ADD_MAC_FILTER
Definition: netif.h:147
tcpip_input
err_t tcpip_input(struct pbuf *p, struct netif *inp)
Definition: tcpip.c:212
netif_add
struct netif * netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
Definition: netif.c:241
NETIF_FLAG_ETHERNET
#define NETIF_FLAG_ETHERNET
Definition: netif.h:95
netif_set_link_up
void netif_set_link_up(struct netif *netif)
Definition: netif.c:735
LWIP_NETIF_CLIENT_DATA_INDEX_MAX
Definition: netif.h:121
IP_ADDR6_HOST
#define IP_ADDR6_HOST(ipaddr, i0, i1, i2, i3)
Definition: ip_addr.h:303