mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 03:35:38 +00:00
make netif->init return err_t instead of void.Patch from David Le Corfec
This commit is contained in:
parent
35ef1e1b86
commit
cc31bb9358
@ -55,7 +55,7 @@ struct netif *
|
||||
netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||
struct ip_addr *gw,
|
||||
void *state,
|
||||
void (* init)(struct netif *netif),
|
||||
err_t (* init)(struct netif *netif),
|
||||
err_t (* input)(struct pbuf *p, struct netif *netif))
|
||||
{
|
||||
struct netif *netif;
|
||||
@ -74,8 +74,11 @@ netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||
ip_addr_set(&(netif->netmask), netmask);
|
||||
ip_addr_set(&(netif->gw), gw);
|
||||
|
||||
init(netif);
|
||||
|
||||
if (init(netif) != ERR_OK) {
|
||||
mem_free(netif);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
netif->next = netif_list;
|
||||
netif_list = netif;
|
||||
#if NETIF_DEBUG
|
||||
|
@ -58,6 +58,7 @@ typedef s8_t err_t;
|
||||
|
||||
#define ERR_USE -10 /* Address in use. */
|
||||
|
||||
#define ERR_IF -11 /* Low-level netif error */
|
||||
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
|
@ -114,7 +114,7 @@ void netif_init(void);
|
||||
struct netif *netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||
struct ip_addr *gw,
|
||||
void *state,
|
||||
void (* init)(struct netif *netif),
|
||||
err_t (* init)(struct netif *netif),
|
||||
err_t (* input)(struct pbuf *p, struct netif *netif));
|
||||
|
||||
void netif_remove(struct netif * netif);
|
||||
|
@ -34,6 +34,6 @@
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void loopif_init(struct netif *netif);
|
||||
err_t loopif_init(struct netif *netif);
|
||||
|
||||
#endif /* __NETIF_LOOPIF_H__ */
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void slipif_init(struct netif * netif);
|
||||
err_t slipif_init(struct netif * netif);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -67,12 +67,13 @@ loopif_output(struct netif *netif, struct pbuf *p,
|
||||
return ERR_MEM;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
err_t
|
||||
loopif_init(struct netif *netif)
|
||||
{
|
||||
netif->name[0] = 'l';
|
||||
netif->name[1] = 'o';
|
||||
netif->output = loopif_output;
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -197,7 +197,7 @@ slipif_loop(void *nf)
|
||||
* Call the arch specific sio_open and remember
|
||||
* the opened device in the state field of the netif.
|
||||
*/
|
||||
void
|
||||
err_t
|
||||
slipif_init(struct netif *netif)
|
||||
{
|
||||
|
||||
@ -209,6 +209,9 @@ slipif_init(struct netif *netif)
|
||||
netif->mtu = 1500;
|
||||
|
||||
netif->state = sio_open(netif->num);
|
||||
if (!netif->state)
|
||||
return ERR_IF;
|
||||
|
||||
sys_thread_new(slipif_loop, netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user