39 |
#include "lwip/opt.h" |
#include "lwip/opt.h" |
40 |
|
|
41 |
#include "lwip/def.h" |
#include "lwip/def.h" |
|
#include "lwip/mem.h" |
|
42 |
#include "lwip/netif.h" |
#include "lwip/netif.h" |
43 |
#include "lwip/ip_addr.h" |
#include "lwip/ip_addr.h" |
44 |
#include "lwip/tcp.h" |
#include "lwip/tcp.h" |
60 |
* @return netif, or NULL if failed. |
* @return netif, or NULL if failed. |
61 |
*/ |
*/ |
62 |
struct netif * |
struct netif * |
63 |
netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask, |
netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask, |
64 |
struct ip_addr *gw, |
struct ip_addr *gw, |
65 |
void *state, |
void *state, |
66 |
err_t (* init)(struct netif *netif), |
err_t (* init)(struct netif *netif), |
67 |
err_t (* input)(struct pbuf *p, struct netif *netif)) |
err_t (* input)(struct pbuf *p, struct netif *netif)) |
68 |
{ |
{ |
|
struct netif *netif; |
|
69 |
static int netifnum = 0; |
static int netifnum = 0; |
70 |
|
|
71 |
/* allocate netif structure */ |
|
|
netif = mem_malloc(sizeof(struct netif)); |
|
|
|
|
|
if (netif == NULL) { |
|
|
LWIP_DEBUGF(NETIF_DEBUG, ("netif_add(): out of memory for netif\n")); |
|
|
return NULL; |
|
|
} |
|
72 |
#if LWIP_DHCP |
#if LWIP_DHCP |
73 |
/* netif not under DHCP control by default */ |
/* netif not under DHCP control by default */ |
74 |
netif->dhcp = NULL; |
netif->dhcp = NULL; |
82 |
|
|
83 |
/* call user specified initialization function for netif */ |
/* call user specified initialization function for netif */ |
84 |
if (init(netif) != ERR_OK) { |
if (init(netif) != ERR_OK) { |
|
mem_free(netif); |
|
85 |
return NULL; |
return NULL; |
86 |
} |
} |
87 |
|
|
133 |
/* reset default netif */ |
/* reset default netif */ |
134 |
netif_default = NULL; |
netif_default = NULL; |
135 |
LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") ); |
LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") ); |
|
mem_free( netif ); |
|
136 |
} |
} |
137 |
|
|
138 |
struct netif * |
struct netif * |