ReactOS 0.4.16-dev-297-gc569aee
netif.c File Reference
#include "lwip/opt.h"
#include <string.h>
#include <stdlib.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/priv/raw_priv.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"
Include dependency graph for netif.c:

Go to the source code of this file.

Macros

#define NETIF_STATUS_CALLBACK(n)
 
#define NETIF_LINK_CALLBACK(n)
 
#define netif_index_to_num(index)   ((index) - 1)
 
#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_noaddr (struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
 
struct netifnetif_add (struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
 
static void netif_do_ip_addr_changed (const ip_addr_t *old_addr, const ip_addr_t *new_addr)
 
void netif_remove (struct netif *netif)
 
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)
 
u8_t netif_name_to_index (const char *name)
 
charnetif_index_to_name (u8_t idx, char *name)
 
struct netifnetif_get_by_index (u8_t idx)
 
struct netifnetif_find (const char *name)
 

Variables

struct netifnetif_list
 
struct netifnetif_default
 
static u8_t netif_num
 

Detailed Description

lwIP network interface abstraction

Definition in file netif.c.

Macro Definition Documentation

◆ netif_index_to_num

#define netif_index_to_num (   index)    ((index) - 1)

Definition at line 117 of file netif.c.

◆ NETIF_LINK_CALLBACK

#define NETIF_LINK_CALLBACK (   n)

Definition at line 105 of file netif.c.

◆ NETIF_REPORT_TYPE_IPV4

#define NETIF_REPORT_TYPE_IPV4   0x01

Definition at line 124 of file netif.c.

◆ NETIF_REPORT_TYPE_IPV6

#define NETIF_REPORT_TYPE_IPV6   0x02

Definition at line 125 of file netif.c.

◆ NETIF_STATUS_CALLBACK

#define NETIF_STATUS_CALLBACK (   n)

Definition at line 99 of file netif.c.

Function Documentation

◆ netif_do_ip_addr_changed()

static void netif_do_ip_addr_changed ( const ip_addr_t old_addr,
const ip_addr_t new_addr 
)
static

Definition at line 459 of file netif.c.

460{
461#if LWIP_TCP
462 tcp_netif_ip_addr_changed(old_addr, new_addr);
463#endif /* LWIP_TCP */
464#if LWIP_UDP
465 udp_netif_ip_addr_changed(old_addr, new_addr);
466#endif /* LWIP_UDP */
467#if LWIP_RAW
468 raw_netif_ip_addr_changed(old_addr, new_addr);
469#endif /* LWIP_RAW */
470}

Referenced by netif_remove().

◆ netif_init()

void netif_init ( void  )

Definition at line 188 of file netif.c.

189{
190#if LWIP_HAVE_LOOPIF
191#if LWIP_IPV4
192#define LOOPIF_ADDRINIT &loop_ipaddr, &loop_netmask, &loop_gw,
193 ip4_addr_t loop_ipaddr, loop_netmask, loop_gw;
194 IP4_ADDR(&loop_gw, 127, 0, 0, 1);
195 IP4_ADDR(&loop_ipaddr, 127, 0, 0, 1);
196 IP4_ADDR(&loop_netmask, 255, 0, 0, 0);
197#else /* LWIP_IPV4 */
198#define LOOPIF_ADDRINIT
199#endif /* LWIP_IPV4 */
200
201#if NO_SYS
202 netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, ip_input);
203#else /* NO_SYS */
204 netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, tcpip_input);
205#endif /* NO_SYS */
206
207#if LWIP_IPV6
208 IP_ADDR6_HOST(loop_netif.ip6_addr, 0, 0, 0, 0x00000001UL);
209 loop_netif.ip6_addr_state[0] = IP6_ADDR_VALID;
210#endif /* LWIP_IPV6 */
211
212 netif_set_link_up(&loop_netif);
213 netif_set_up(&loop_netif);
214
215#endif /* LWIP_HAVE_LOOPIF */
216}
#define NULL
Definition: types.h:112
err_t tcpip_input(struct pbuf *p, struct netif *inp)
Definition: tcpip.c:288
struct netif * netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
Definition: netif.c:287
void netif_set_link_up(struct netif *netif)
Definition: netif.c:1018
void netif_set_up(struct netif *netif)
Definition: netif.c:871
#define IP_ADDR6_HOST(ipaddr, i0, i1, i2, i3)
Definition: ip_addr.h:358

Referenced by lwip_init(), and main().

◆ 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

Definition at line 902 of file netif.c.

903{
904 LWIP_ASSERT("netif_issue_reports: invalid netif", netif != NULL);
905
906 /* Only send reports when both link and admin states are up */
907 if (!(netif->flags & NETIF_FLAG_LINK_UP) ||
908 !(netif->flags & NETIF_FLAG_UP)) {
909 return;
910 }
911
912#if LWIP_IPV4
914 !ip4_addr_isany_val(*netif_ip4_addr(netif))) {
915#if LWIP_ARP && !LWIP_ACD
916 /* For Ethernet network interfaces:
917 * we would like to send a "gratuitous ARP".
918 * Only needs to be done here if ACD isn't configured.
919 */
920 if (netif->flags & (NETIF_FLAG_ETHARP)) {
921 etharp_gratuitous(netif);
922 }
923#endif /* LWIP_ARP */
924
925#if LWIP_IGMP
926 /* resend IGMP memberships */
927 if (netif->flags & NETIF_FLAG_IGMP) {
928 igmp_report_groups(netif);
929 }
930#endif /* LWIP_IGMP */
931 }
932#endif /* LWIP_IPV4 */
933
934#if LWIP_IPV6
936#if LWIP_IPV6_MLD
937 /* send mld memberships */
938 mld6_report_groups(netif);
939#endif /* LWIP_IPV6_MLD */
940 }
941#endif /* LWIP_IPV6 */
942}
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
#define NETIF_FLAG_LINK_UP
Definition: netif.h:93
#define NETIF_FLAG_ETHARP
Definition: netif.h:97
#define NETIF_FLAG_UP
Definition: netif.h:84
#define NETIF_FLAG_IGMP
Definition: netif.h:104
#define NETIF_REPORT_TYPE_IPV4
Definition: netif.c:124
#define NETIF_REPORT_TYPE_IPV6
Definition: netif.c:125
Definition: netif.h:269
u8_t flags
Definition: netif.h:354
report_type
Definition: winetest.h:46

Referenced by netif_set_link_up(), and netif_set_up().

Variable Documentation

◆ netif_default

◆ netif_list

◆ netif_num

u8_t netif_num
static

Definition at line 118 of file netif.c.

Referenced by netif_add().