Prusa MINI Firmware overview
netif.c File Reference
#include "lwip/opt.h"
#include <string.h>
#include "lwip/def.h"
#include "lwip/ip_addr.h"
#include "lwip/ip6_addr.h"
#include "lwip/netif.h"
#include "lwip/priv/tcp_priv.h"
#include "lwip/udp.h"
#include "lwip/raw.h"
#include "lwip/snmp.h"
#include "lwip/igmp.h"
#include "lwip/etharp.h"
#include "lwip/stats.h"
#include "lwip/sys.h"
#include "lwip/ip.h"
#include "netif/ethernet.h"

Macros

#define NETIF_STATUS_CALLBACK(n)
 
#define NETIF_LINK_CALLBACK(n)
 
#define NETIF_REPORT_TYPE_IPV4   0x01
 
#define NETIF_REPORT_TYPE_IPV6   0x02
 

Functions

static void netif_issue_reports (struct netif *netif, u8_t report_type)
 
void netif_init (void)
 
err_t netif_input (struct pbuf *p, struct netif *inp)
 
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)
 

Variables

struct netifnetif_list
 
struct netifnetif_default
 
static u8_t netif_num
 

Detailed Description

lwIP network interface abstraction

Macro Definition Documentation

◆ NETIF_STATUS_CALLBACK

#define NETIF_STATUS_CALLBACK (   n)

◆ NETIF_LINK_CALLBACK

#define NETIF_LINK_CALLBACK (   n)

◆ NETIF_REPORT_TYPE_IPV4

#define NETIF_REPORT_TYPE_IPV4   0x01

◆ NETIF_REPORT_TYPE_IPV6

#define NETIF_REPORT_TYPE_IPV6   0x02

Function Documentation

◆ netif_issue_reports()

static void netif_issue_reports ( struct netif netif,
u8_t  report_type 
)
static

Send ARP/IGMP/MLD/RS events, e.g. on link-up/netif-up or addr-change

643 {
644 #if LWIP_IPV4
645  if ((report_type & NETIF_REPORT_TYPE_IPV4) &&
646  !ip4_addr_isany_val(*netif_ip4_addr(netif))) {
647 #if LWIP_ARP
648  /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */
649  if (netif->flags & (NETIF_FLAG_ETHARP)) {
650  etharp_gratuitous(netif);
651  }
652 #endif /* LWIP_ARP */
653 
654 #if LWIP_IGMP
655  /* resend IGMP memberships */
656  if (netif->flags & NETIF_FLAG_IGMP) {
657  igmp_report_groups(netif);
658  }
659 #endif /* LWIP_IGMP */
660  }
661 #endif /* LWIP_IPV4 */
662 
663 #if LWIP_IPV6
664  if (report_type & NETIF_REPORT_TYPE_IPV6) {
665 #if LWIP_IPV6_MLD
666  /* send mld memberships */
667  mld6_report_groups(netif);
668 #endif /* LWIP_IPV6_MLD */
669 #if LWIP_IPV6_SEND_ROUTER_SOLICIT
670  /* Send Router Solicitation messages. */
672 #endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */
673  }
674 #endif /* LWIP_IPV6 */
675 }
Here is the caller graph for this function:

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

u8_t netif_num
static
NETIF_FLAG_IGMP
#define NETIF_FLAG_IGMP
Definition: netif.h:98
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_REPORT_TYPE_IPV4
#define NETIF_REPORT_TYPE_IPV4
Definition: netif.c:113
NULL
#define NULL
Definition: usbd_def.h:53
tcpip_input
err_t tcpip_input(struct pbuf *p, struct netif *inp)
Definition: tcpip.c:212
netif
Definition: netif.h:225
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
LWIP_ND6_MAX_MULTICAST_SOLICIT
#define LWIP_ND6_MAX_MULTICAST_SOLICIT
Definition: opt.h:2319
netif_set_link_up
void netif_set_link_up(struct netif *netif)
Definition: netif.c:735
NETIF_REPORT_TYPE_IPV6
#define NETIF_REPORT_TYPE_IPV6
Definition: netif.c:114
IP_ADDR6_HOST
#define IP_ADDR6_HOST(ipaddr, i0, i1, i2, i3)
Definition: ip_addr.h:303