ReactOS  0.4.14-dev-114-gc8cbd56
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 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
 

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)
 
#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_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

◆ ENABLE_LOOPBACK

#define ENABLE_LOOPBACK   (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)

Definition at line 37 of file netif.h.

◆ NETIF_FLAG_BROADCAST

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

◆ NETIF_FLAG_DHCP

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

◆ NETIF_FLAG_ETHARP

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

◆ NETIF_FLAG_ETHERNET

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

◆ NETIF_FLAG_IGMP

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

◆ NETIF_FLAG_LINK_UP

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

◆ NETIF_FLAG_POINTTOPOINT

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

◆ NETIF_FLAG_UP

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

◆ NETIF_INIT_SNMP

#define NETIF_INIT_SNMP (   netif,
  type,
  speed 
)

Definition at line 248 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 294 of file netif.h.

◆ netif_is_up

#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 282 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

Definition at line 61 of file netif.h.

◆ NETIF_SET_HWADDRHINT

#define NETIF_SET_HWADDRHINT (   netif,
  hint 
)

Definition at line 321 of file netif.h.

Typedef Documentation

◆ netif_igmp_mac_filter_fn

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.

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

Definition at line 109 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 126 of file netif.h.

◆ netif_output_fn

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.

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

Function Documentation

◆ netif_add()

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

141 {
142 
143  LWIP_ASSERT("No init function given", init != NULL);
144 
145  /* reset new interface configuration state */
149  netif->flags = 0;
150 #if LWIP_DHCP
151  /* netif not under DHCP control by default */
152  netif->dhcp = NULL;
153 #endif /* LWIP_DHCP */
154 #if LWIP_AUTOIP
155  /* netif not under AutoIP control by default */
156  netif->autoip = NULL;
157 #endif /* LWIP_AUTOIP */
158 #if LWIP_NETIF_STATUS_CALLBACK
159  netif->status_callback = NULL;
160 #endif /* LWIP_NETIF_STATUS_CALLBACK */
161 #if LWIP_NETIF_LINK_CALLBACK
162  netif->link_callback = NULL;
163 #endif /* LWIP_NETIF_LINK_CALLBACK */
164 #if LWIP_IGMP
165  netif->igmp_mac_filter = NULL;
166 #endif /* LWIP_IGMP */
167 #if ENABLE_LOOPBACK
168  netif->loop_first = NULL;
169  netif->loop_last = NULL;
170 #endif /* ENABLE_LOOPBACK */
171 
172  /* remember netif specific state information data */
173  netif->state = state;
174  netif->num = netif_num++;
175  netif->input = input;
177 #if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS
178  netif->loop_cnt_current = 0;
179 #endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */
180 
181  netif_set_addr(netif, ipaddr, netmask, gw);
182 
183  /* call user specified initialization function for netif */
184  if (init(netif) != ERR_OK) {
185  return NULL;
186  }
187 
188  /* add this netif to the list */
189  netif->next = netif_list;
190  netif_list = netif;
191  snmp_inc_iflist();
192 
193 #if LWIP_IGMP
194  /* start IGMP processing */
195  if (netif->flags & NETIF_FLAG_IGMP) {
196  igmp_start(netif);
197  }
198 #endif /* LWIP_IGMP */
199 
200  LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ",
201  netif->name[0], netif->name[1]));
203  LWIP_DEBUGF(NETIF_DEBUG, (" netmask "));
205  LWIP_DEBUGF(NETIF_DEBUG, (" gw "));
207  LWIP_DEBUGF(NETIF_DEBUG, ("\n"));
208  return netif;
209 }
struct netif * netif_list
Definition: netif.c:75
#define NETIF_DEBUG
Definition: opt.h:1905
u8_t num
Definition: netif.h:196
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:66
static int init
Definition: wintirpc.c:33
smooth NULL
Definition: ftsmooth.c:416
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
#define ip_addr_set_zero(ipaddr)
Definition: ip_addr.h:168
ip_addr_t gw
Definition: netif.h:143
#define ERR_OK
Definition: err.h:52
struct netif * next
Definition: netif.h:138
#define NETIF_SET_HWADDRHINT(netif, hint)
Definition: netif.h:321
u8_t flags
Definition: netif.h:192
#define ip_addr_debug_print(debug, ipaddr)
Definition: ip_addr.h:212
Definition: netif.h:136
#define NETIF_FLAG_IGMP
Definition: netif.h:95
ip_addr_t ip_addr
Definition: netif.h:141
static u8_t netif_num
Definition: netif.c:78
static int state
Definition: maze.c:121
#define snmp_inc_iflist()
Definition: snmp.h:253
GLenum GLenum GLenum input
Definition: glext.h:9031
void * state
Definition: netif.h:172
netif_input_fn input
Definition: netif.h:147
char name[2]
Definition: netif.h:194
ip_addr_t netmask
Definition: netif.h:142
void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)
Definition: netif.c:221

Referenced by netif_init(), and TCPRegisterInterface().

◆ netif_find()

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

291 {
292  struct netif *netif;
293  u8_t num;
294 
295  if (name == NULL) {
296  return NULL;
297  }
298 
299  num = name[2] - '0';
300 
301  for(netif = netif_list; netif != NULL; netif = netif->next) {
302  if (num == netif->num &&
303  name[0] == netif->name[0] &&
304  name[1] == netif->name[1]) {
305  LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1]));
306  return netif;
307  }
308  }
309  LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1]));
310  return NULL;
311 }
struct netif * netif_list
Definition: netif.c:75
#define NETIF_DEBUG
Definition: opt.h:1905
u8_t num
Definition: netif.h:196
smooth NULL
Definition: ftsmooth.c:416
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
struct netif * next
Definition: netif.h:138
Definition: netif.h:136
GLuint GLuint num
Definition: glext.h:9618
unsigned char u8_t
Definition: cc.h:23
char name[2]
Definition: netif.h:194
Definition: name.c:36

◆ netif_init()

void netif_init ( void  )

Definition at line 106 of file netif.c.

107 {
108 #if LWIP_HAVE_LOOPIF
109  ip_addr_t loop_ipaddr, loop_netmask, loop_gw;
110  IP4_ADDR(&loop_gw, 127,0,0,1);
111  IP4_ADDR(&loop_ipaddr, 127,0,0,1);
112  IP4_ADDR(&loop_netmask, 255,0,0,0);
113 
114 #if NO_SYS
115  netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, ip_input);
116 #else /* NO_SYS */
117  netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input);
118 #endif /* NO_SYS */
119  netif_set_up(&loop_netif);
120 
121 #endif /* LWIP_HAVE_LOOPIF */
122 }
err_t ip_input(struct pbuf *p, struct netif *inp)
Definition: ip.c:305
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
Definition: ip_addr.h:64
#define IP4_ADDR(ipaddr, a, b, c, d)
Definition: ip_addr.h:139
void netif_set_up(struct netif *netif)
Definition: netif.c:453
smooth NULL
Definition: ftsmooth.c:416
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)
Definition: netif.c:139
err_t tcpip_input(struct pbuf *p, struct netif *inp)
Definition: tcpip.c:162

Referenced by lwip_init().

◆ netif_remove()

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

236 {
237  if (netif == NULL) {
238  return;
239  }
240 
241 #if LWIP_IGMP
242  /* stop IGMP processing */
243  if (netif->flags & NETIF_FLAG_IGMP) {
244  igmp_stop(netif);
245  }
246 #endif /* LWIP_IGMP */
247  if (netif_is_up(netif)) {
248  /* set netif down before removing (call callback function) */
250  }
251 
253 
254  /* is it the first netif? */
255  if (netif_list == netif) {
256  netif_list = netif->next;
257  } else {
258  /* look for netif further down the list */
259  struct netif * tmpNetif;
260  for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
261  if (tmpNetif->next == netif) {
262  tmpNetif->next = netif->next;
263  break;
264  }
265  }
266  if (tmpNetif == NULL)
267  return; /* we didn't find any netif today */
268  }
269  snmp_dec_iflist();
270  /* this netif is default? */
271  if (netif_default == netif) {
272  /* reset default netif */
274  }
275 #if LWIP_NETIF_REMOVE_CALLBACK
276  if (netif->remove_callback) {
277  netif->remove_callback(netif);
278  }
279 #endif /* LWIP_NETIF_REMOVE_CALLBACK */
280  LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") );
281 }
struct netif * netif_list
Definition: netif.c:75
struct netif * netif_default
Definition: netif.c:76
#define NETIF_DEBUG
Definition: opt.h:1905
void netif_set_default(struct netif *netif)
Definition: netif.c:430
#define snmp_dec_iflist()
Definition: snmp.h:254
smooth NULL
Definition: ftsmooth.c:416
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
#define snmp_delete_ipaddridx_tree(ni)
Definition: snmp.h:279
struct netif * next
Definition: netif.h:138
u8_t flags
Definition: netif.h:192
Definition: netif.h:136
#define NETIF_FLAG_IGMP
Definition: netif.h:95
void netif_set_down(struct netif *netif)
Definition: netif.c:490
#define netif_is_up(netif)
Definition: netif.h:282

Referenced by TCPUnregisterInterface().

◆ netif_set_addr()

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

223 {
224  netif_set_ipaddr(netif, ipaddr);
227 }
void netif_set_gw(struct netif *netif, ip_addr_t *gw)
Definition: netif.c:388
ip_addr_t gw
Definition: netif.h:143
Definition: netif.h:136
void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)
Definition: netif.c:323
void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)
Definition: netif.c:409
ip_addr_t netmask
Definition: netif.h:142

Referenced by netif_add(), and TCPUpdateInterfaceIPInformation().

◆ netif_set_default()

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

431 {
432  if (netif == NULL) {
433  /* remove default route */
435  } else {
436  /* install default route */
438  }
440  LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
441  netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
442 }
struct netif * netif_default
Definition: netif.c:76
#define NETIF_DEBUG
Definition: opt.h:1905
smooth NULL
Definition: ftsmooth.c:416
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
#define snmp_insert_iprteidx_tree(dflt, ni)
Definition: snmp.h:280
Definition: netif.h:136
#define snmp_delete_iprteidx_tree(dflt, ni)
Definition: snmp.h:281
char name[2]
Definition: netif.h:194

Referenced by netif_remove(), and TCPUpdateInterfaceIPInformation().

◆ netif_set_down()

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

491 {
492  if (netif->flags & NETIF_FLAG_UP) {
494 #if LWIP_SNMP
496 #endif
497 
498 #if LWIP_ARP
499  if (netif->flags & NETIF_FLAG_ETHARP) {
500  etharp_cleanup_netif(netif);
501  }
502 #endif /* LWIP_ARP */
504  }
505 }
#define NETIF_FLAG_UP
Definition: netif.h:69
#define snmp_get_sysuptime(value)
Definition: snmp.h:239
#define NETIF_STATUS_CALLBACK(n)
Definition: netif.c:66
#define NETIF_FLAG_ETHARP
Definition: netif.h:88
u8_t flags
Definition: netif.h:192
Definition: netif.h:136

Referenced by netif_remove(), and TCPUpdateInterfaceIPInformation().

◆ netif_set_gw()

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

389 {
390  ip_addr_set(&(netif->gw), gw);
391  LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
392  netif->name[0], netif->name[1],
393  ip4_addr1_16(&netif->gw),
394  ip4_addr2_16(&netif->gw),
395  ip4_addr3_16(&netif->gw),
396  ip4_addr4_16(&netif->gw)));
397 }
#define ip4_addr1_16(ipaddr)
Definition: ip_addr.h:226
#define NETIF_DEBUG
Definition: opt.h:1905
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
ip_addr_t gw
Definition: netif.h:143
#define ip4_addr2_16(ipaddr)
Definition: ip_addr.h:227
#define U16_F
Definition: cc.h:36
Definition: netif.h:136
#define ip4_addr3_16(ipaddr)
Definition: ip_addr.h:228
#define ip4_addr4_16(ipaddr)
Definition: ip_addr.h:229
#define ip_addr_set(dest, src)
Definition: ip_addr.h:164
#define LWIP_DBG_TRACE
Definition: debug.h:57
char name[2]
Definition: netif.h:194
#define LWIP_DBG_STATE
Definition: debug.h:59

Referenced by netif_set_addr().

◆ netif_set_ipaddr()

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

324 {
325  /* TODO: Handling of obsolete pcbs */
326  /* See: http://mail.gnu.org/archive/html/lwip-users/2003-03/msg00118.html */
327 #if LWIP_TCP
328  struct tcp_pcb *pcb;
329  struct tcp_pcb_listen *lpcb;
330 
331  /* address is actually being changed? */
332  if (ipaddr && (ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0) {
333  /* extern struct tcp_pcb *tcp_active_pcbs; defined by tcp.h */
334  LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n"));
335  pcb = tcp_active_pcbs;
336  while (pcb != NULL) {
337  /* PCB bound to current local interface address? */
338  if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))
339 #if LWIP_AUTOIP
340  /* connections to link-local addresses must persist (RFC3927 ch. 1.9) */
341  && !ip_addr_islinklocal(&(pcb->local_ip))
342 #endif /* LWIP_AUTOIP */
343  ) {
344  /* this connection must be aborted */
345  struct tcp_pcb *next = pcb->next;
346  LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: aborting TCP pcb %p\n", (void *)pcb));
347  tcp_abort(pcb);
348  pcb = next;
349  } else {
350  pcb = pcb->next;
351  }
352  }
353  for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
354  /* PCB bound to current local interface address? */
355  if ((!(ip_addr_isany(&(lpcb->local_ip)))) &&
356  (ip_addr_cmp(&(lpcb->local_ip), &(netif->ip_addr)))) {
357  /* The PCB is listening to the old ipaddr and
358  * is set to listen to the new one instead */
359  ip_addr_set(&(lpcb->local_ip), ipaddr);
360  }
361  }
362  }
363 #endif
366  /* set new IP address to netif */
367  ip_addr_set(&(netif->ip_addr), ipaddr);
370 
371  LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
372  netif->name[0], netif->name[1],
377 }
#define ip_addr_islinklocal(addr1)
Definition: ip_addr.h:210
#define ip4_addr1_16(ipaddr)
Definition: ip_addr.h:226
#define NETIF_DEBUG
Definition: opt.h:1905
smooth NULL
Definition: ftsmooth.c:416
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
#define ip4_addr2_16(ipaddr)
Definition: ip_addr.h:227
#define U16_F
Definition: cc.h:36
#define snmp_delete_ipaddridx_tree(ni)
Definition: snmp.h:279
#define snmp_insert_iprteidx_tree(dflt, ni)
Definition: snmp.h:280
#define snmp_insert_ipaddridx_tree(ni)
Definition: snmp.h:278
Definition: netif.h:136
ip_addr_t ip_addr
Definition: netif.h:141
#define ip4_addr3_16(ipaddr)
Definition: ip_addr.h:228
#define LWIP_AUTOIP
Definition: opt.h:701
#define ip4_addr4_16(ipaddr)
Definition: ip_addr.h:229
static unsigned __int64 next
Definition: rand_nt.c:6
#define ip_addr_set(dest, src)
Definition: ip_addr.h:164
#define ip_addr_isany(addr1)
Definition: ip_addr.h:200
#define ip_addr_cmp(addr1, addr2)
Definition: ip_addr.h:198
#define snmp_delete_iprteidx_tree(dflt, ni)
Definition: snmp.h:281
#define LWIP_DBG_TRACE
Definition: debug.h:57
char name[2]
Definition: netif.h:194
#define LWIP_DBG_STATE
Definition: debug.h:59

Referenced by netif_set_addr().

◆ netif_set_link_down()

void netif_set_link_down ( struct netif netif)

Called by a driver when its link goes down

Definition at line 574 of file netif.c.

575 {
576  if (netif->flags & NETIF_FLAG_LINK_UP) {
579  }
580 }
#define NETIF_FLAG_LINK_UP
Definition: netif.h:84
u8_t flags
Definition: netif.h:192
Definition: netif.h:136
#define NETIF_LINK_CALLBACK(n)
Definition: netif.c:72

Referenced by TCPUpdateInterfaceLinkStatus().

◆ netif_set_link_up()

void netif_set_link_up ( struct netif netif)

Called by a driver when its link goes up

Definition at line 535 of file netif.c.

536 {
537  if (!(netif->flags & NETIF_FLAG_LINK_UP)) {
539 
540 #if LWIP_DHCP
541  if (netif->dhcp) {
542  dhcp_network_changed(netif);
543  }
544 #endif /* LWIP_DHCP */
545 
546 #if LWIP_AUTOIP
547  if (netif->autoip) {
548  autoip_network_changed(netif);
549  }
550 #endif /* LWIP_AUTOIP */
551 
552  if (netif->flags & NETIF_FLAG_UP) {
553 #if LWIP_ARP
554  /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */
555  if (netif->flags & NETIF_FLAG_ETHARP) {
556  etharp_gratuitous(netif);
557  }
558 #endif /* LWIP_ARP */
559 
560 #if LWIP_IGMP
561  /* resend IGMP memberships */
562  if (netif->flags & NETIF_FLAG_IGMP) {
563  igmp_report_groups( netif);
564  }
565 #endif /* LWIP_IGMP */
566  }
568  }
569 }
#define NETIF_FLAG_UP
Definition: netif.h:69
#define NETIF_FLAG_LINK_UP
Definition: netif.h:84
#define NETIF_FLAG_ETHARP
Definition: netif.h:88
u8_t flags
Definition: netif.h:192
Definition: netif.h:136
#define NETIF_FLAG_IGMP
Definition: netif.h:95
#define NETIF_LINK_CALLBACK(n)
Definition: netif.c:72

Referenced by TCPUpdateInterfaceLinkStatus().

◆ netif_set_netmask()

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

410 {
412  /* set new netmask to netif */
413  ip_addr_set(&(netif->netmask), netmask);
415  LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
416  netif->name[0], netif->name[1],
421 }
#define ip4_addr1_16(ipaddr)
Definition: ip_addr.h:226
#define NETIF_DEBUG
Definition: opt.h:1905
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:95
#define ip4_addr2_16(ipaddr)
Definition: ip_addr.h:227
#define U16_F
Definition: cc.h:36
#define snmp_insert_iprteidx_tree(dflt, ni)
Definition: snmp.h:280
Definition: netif.h:136
#define ip4_addr3_16(ipaddr)
Definition: ip_addr.h:228
#define ip4_addr4_16(ipaddr)
Definition: ip_addr.h:229
#define ip_addr_set(dest, src)
Definition: ip_addr.h:164
#define snmp_delete_iprteidx_tree(dflt, ni)
Definition: snmp.h:281
#define LWIP_DBG_TRACE
Definition: debug.h:57
char name[2]
Definition: netif.h:194
#define LWIP_DBG_STATE
Definition: debug.h:59
ip_addr_t netmask
Definition: netif.h:142

Referenced by netif_set_addr().

◆ netif_set_up()

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

454 {
455  if (!(netif->flags & NETIF_FLAG_UP)) {
457 
458 #if LWIP_SNMP
460 #endif /* LWIP_SNMP */
461 
463 
464  if (netif->flags & NETIF_FLAG_LINK_UP) {
465 #if LWIP_ARP
466  /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */
467  if (netif->flags & (NETIF_FLAG_ETHARP)) {
468  etharp_gratuitous(netif);
469  }
470 #endif /* LWIP_ARP */
471 
472 #if LWIP_IGMP
473  /* resend IGMP memberships */
474  if (netif->flags & NETIF_FLAG_IGMP) {
475  igmp_report_groups( netif);
476  }
477 #endif /* LWIP_IGMP */
478  }
479  }
480 }
#define NETIF_FLAG_UP
Definition: netif.h:69
#define snmp_get_sysuptime(value)
Definition: snmp.h:239
#define NETIF_FLAG_LINK_UP
Definition: netif.h:84
#define NETIF_STATUS_CALLBACK(n)
Definition: netif.c:66
#define NETIF_FLAG_ETHARP
Definition: netif.h:88
u8_t flags
Definition: netif.h:192
Definition: netif.h:136
#define NETIF_FLAG_IGMP
Definition: netif.h:95

Referenced by netif_init(), and TCPUpdateInterfaceIPInformation().

Variable Documentation

◆ netif_default

struct netif* netif_default

The default network interface.

Definition at line 76 of file netif.c.

Referenced by ip_route(), netif_remove(), netif_set_default(), tcp_oos_teardown(), and tcp_teardown().

◆ netif_list

struct netif* netif_list

The list of network interfaces.

Definition at line 75 of file netif.c.

Referenced by ip_input(), ip_route(), netif_add(), netif_find(), netif_remove(), tcp_oos_teardown(), tcp_teardown(), and test_tcp_init_netif().