/[lwip]/lwip/src/core/netif.c
ViewVC logotype

Diff of /lwip/src/core/netif.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28.2.4 by likewise, Fri Nov 14 09:42:51 2003 UTC revision 1.28.2.5 by jani, Mon Nov 24 08:23:54 2003 UTC
# Line 39  Line 39 
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"
# Line 61  struct netif *netif_default = NULL; Line 60  struct netif *netif_default = NULL;
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;
# Line 90  netif_add(struct ip_addr *ipaddr, struct Line 82  netif_add(struct ip_addr *ipaddr, struct
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    
# Line 142  void netif_remove(struct netif * netif) Line 133  void netif_remove(struct netif * netif)
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 *

Legend:
Removed from v.1.28.2.4  
changed lines
  Added in v.1.28.2.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26