60 |
{ |
{ |
61 |
struct netif *netif; |
struct netif *netif; |
62 |
static int netifnum = 0; |
static int netifnum = 0; |
63 |
|
|
64 |
|
/* allocate netif structure */ |
65 |
netif = mem_malloc(sizeof(struct netif)); |
netif = mem_malloc(sizeof(struct netif)); |
66 |
|
|
67 |
if(netif == NULL) { |
if(netif == NULL) { |
68 |
|
DEBUGF(NETIF_DEBUG, ("netif_add(): out of memory for netif\n")); |
69 |
return NULL; |
return NULL; |
70 |
} |
} |
71 |
|
|
72 |
|
/* remember netif specific state information data */ |
73 |
netif->state = state; |
netif->state = state; |
74 |
netif->num = netifnum++; |
netif->num = netifnum++; |
75 |
netif->input = input; |
netif->input = input; |
76 |
|
|
77 |
netif_set_addr(netif, ipaddr, netmask, gw); |
netif_set_addr(netif, ipaddr, netmask, gw); |
78 |
|
|
79 |
|
/* call user specified initialization function for netif */ |
80 |
if (init(netif) != ERR_OK) { |
if (init(netif) != ERR_OK) { |
81 |
mem_free(netif); |
mem_free(netif); |
82 |
return NULL; |
return NULL; |
83 |
} |
} |
84 |
|
|
85 |
|
/* add this netif to the list */ |
86 |
netif->next = netif_list; |
netif->next = netif_list; |
87 |
netif_list = netif; |
netif_list = netif; |
88 |
#if NETIF_DEBUG |
#if NETIF_DEBUG |