updated netif init functions to return err_t
This commit is contained in:
parent
a8d105875b
commit
489fc69cce
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
void delif_init(struct netif *netif);
|
||||
void delif_init_thread(struct netif *netif);
|
||||
err_t delif_init(struct netif *netif);
|
||||
err_t delif_init_thread(struct netif *netif);
|
||||
|
||||
#endif /* __DELIF_H__ */
|
||||
|
|
|
@ -36,6 +36,6 @@
|
|||
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
void dropif_init(struct netif *netif);
|
||||
err_t dropif_init(struct netif *netif);
|
||||
|
||||
#endif /* __DROPIF_H__ */
|
||||
|
|
|
@ -34,6 +34,6 @@
|
|||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void pcapif_init(struct netif *netif);
|
||||
err_t pcapif_init(struct netif *netif);
|
||||
|
||||
#endif /* __PCAPIF_H__ */
|
||||
|
|
|
@ -34,6 +34,6 @@
|
|||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void tapif_init(struct netif *netif);
|
||||
err_t tapif_init(struct netif *netif);
|
||||
|
||||
#endif /* __TAPIF_H__ */
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
void tunif_init(struct netif *netif);
|
||||
void tunif_init_thread(struct netif *netif);
|
||||
err_t tunif_init(struct netif *netif);
|
||||
|
||||
#endif /* __TUNIF_H__ */
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void unixif_init_server(struct netif *netif);
|
||||
void unixif_init_client(struct netif *netif);
|
||||
err_t unixif_init_server(struct netif *netif);
|
||||
err_t unixif_init_client(struct netif *netif);
|
||||
|
||||
#endif /* __UNIXIF_H__ */
|
||||
|
|
|
@ -235,18 +235,24 @@ delif_input(struct pbuf *p, struct netif *inp)
|
|||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
err_t
|
||||
delif_init(struct netif *netif)
|
||||
{
|
||||
struct delif *del;
|
||||
|
||||
del = malloc(sizeof(struct delif));
|
||||
if (!del)
|
||||
return ERR_MEM;
|
||||
netif->state = del;
|
||||
netif->name[0] = 'd';
|
||||
netif->name[1] = 'e';
|
||||
netif->output = delif_output;
|
||||
|
||||
del->netif = malloc(sizeof(struct netif));
|
||||
if (!del->netif) {
|
||||
free(del);
|
||||
return ERR_MEM;
|
||||
}
|
||||
#ifdef linux
|
||||
/* tapif_init(del->netif);*/
|
||||
tunif_init(del->netif);
|
||||
|
@ -257,6 +263,7 @@ delif_init(struct netif *netif)
|
|||
del->netif->input = delif_input;
|
||||
sys_timeout(DELIF_TIMEOUT, delif_input_timeout, netif);
|
||||
sys_timeout(DELIF_TIMEOUT, delif_output_timeout, netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
@ -282,7 +289,7 @@ delif_thread(void *arg)
|
|||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
err_t
|
||||
delif_init_thread(struct netif *netif)
|
||||
{
|
||||
struct delif *del;
|
||||
|
@ -290,18 +297,25 @@ delif_init_thread(struct netif *netif)
|
|||
DEBUGF(DELIF_DEBUG, ("delif_init_thread\n"));
|
||||
|
||||
del = malloc(sizeof(struct delif));
|
||||
if (!del)
|
||||
return ERR_MEM;
|
||||
netif->state = del;
|
||||
netif->name[0] = 'd';
|
||||
netif->name[1] = 'e';
|
||||
netif->output = delif_output;
|
||||
|
||||
del->netif = malloc(sizeof(struct netif));
|
||||
if (!del->netif) {
|
||||
free(del);
|
||||
return ERR_MEM;
|
||||
}
|
||||
del->netif->ip_addr = netif->ip_addr;
|
||||
del->netif->gw = netif->gw;
|
||||
del->netif->netmask = netif->netmask;
|
||||
del->input = netif->input;
|
||||
del->netif->input = delif_input;
|
||||
sys_thread_new(delif_thread, netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -186,12 +186,14 @@ pcapif_thread(void *arg)
|
|||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
err_t
|
||||
pcapif_init(struct netif *netif)
|
||||
{
|
||||
struct pcapif *p;
|
||||
|
||||
p = malloc(sizeof(struct pcapif));
|
||||
if (p == NULL)
|
||||
return ERR_MEM;
|
||||
netif->state = p;
|
||||
netif->name[0] = 'p';
|
||||
netif->name[1] = 'c';
|
||||
|
@ -200,7 +202,7 @@ pcapif_init(struct netif *netif)
|
|||
p->pd = pcap_open_offline("pcapdump", errbuf);
|
||||
if(p->pd == NULL) {
|
||||
printf("pcapif_init: failed %s\n", errbuf);
|
||||
return;
|
||||
return ERR_IF;
|
||||
}
|
||||
|
||||
p->sem = sys_sem_new(0);
|
||||
|
@ -208,6 +210,7 @@ pcapif_init(struct netif *netif)
|
|||
p->lasttime = 0;
|
||||
|
||||
sys_thread_new(pcapif_thread, netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#endif /* linux */
|
||||
|
|
|
@ -339,12 +339,14 @@ arp_timer(void *arg)
|
|||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
err_t
|
||||
tapif_init(struct netif *netif)
|
||||
{
|
||||
struct tapif *tapif;
|
||||
|
||||
tapif = mem_malloc(sizeof(struct tapif));
|
||||
if (!tapif)
|
||||
return ERR_MEM;
|
||||
netif->state = tapif;
|
||||
netif->name[0] = IFNAME0;
|
||||
netif->name[1] = IFNAME1;
|
||||
|
@ -357,5 +359,6 @@ tapif_init(struct netif *netif)
|
|||
etharp_init();
|
||||
|
||||
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL);
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -281,12 +281,14 @@ tunif_input(struct netif *netif)
|
|||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
err_t
|
||||
tunif_init(struct netif *netif)
|
||||
{
|
||||
struct tunif *tunif;
|
||||
|
||||
tunif = mem_malloc(sizeof(struct tunif));
|
||||
if (!tunif)
|
||||
return ERR_MEM;
|
||||
netif->state = tunif;
|
||||
netif->name[0] = IFNAME0;
|
||||
netif->name[1] = IFNAME1;
|
||||
|
@ -294,5 +296,6 @@ tunif_init(struct netif *netif)
|
|||
|
||||
|
||||
low_level_init(netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -414,7 +414,7 @@ unixif_output_timeout(void *arg)
|
|||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
err_t
|
||||
unixif_init_server(struct netif *netif)
|
||||
{
|
||||
int fd, fd2;
|
||||
|
@ -431,6 +431,8 @@ unixif_init_server(struct netif *netif)
|
|||
DEBUGF(UNIXIF_DEBUG, ("unixif_server: fd %d\n", fd));
|
||||
|
||||
unixif = malloc(sizeof(struct unixif));
|
||||
if (!unixif)
|
||||
return ERR_MEM;
|
||||
netif->state = unixif;
|
||||
netif->name[0] = 'u';
|
||||
netif->name[1] = 'n';
|
||||
|
@ -452,13 +454,16 @@ unixif_init_server(struct netif *netif)
|
|||
unixif->sem = sys_sem_new(0);
|
||||
sys_thread_new(unixif_thread, netif);
|
||||
sys_thread_new(unixif_thread2, netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
err_t
|
||||
unixif_init_client(struct netif *netif)
|
||||
{
|
||||
struct unixif *unixif;
|
||||
unixif = malloc(sizeof(struct unixif));
|
||||
if (!unixif)
|
||||
return ERR_MEM;
|
||||
netif->state = unixif;
|
||||
netif->name[0] = 'u';
|
||||
netif->name[1] = 'n';
|
||||
|
@ -473,6 +478,7 @@ unixif_init_client(struct netif *netif)
|
|||
unixif->sem = sys_sem_new(0);
|
||||
sys_thread_new(unixif_thread, netif);
|
||||
sys_thread_new(unixif_thread2, netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue