use tcpip_input instead of ethernet_input
=> With NO_SYS=0, netif->input must be set to tcpip_input for all netif types (whether ethernet, PPP, slipif, etc.)
This commit is contained in:
parent
3f2d9a2405
commit
5c9ef35170
1 changed files with 52 additions and 50 deletions
102
kernel/init.c
102
kernel/init.c
|
@ -48,8 +48,6 @@
|
|||
void echo_init(void);
|
||||
void ping_init(void);
|
||||
|
||||
static volatile int done = 0;
|
||||
|
||||
/*
|
||||
* Note that linker symbols are not variables, they have no memory allocated for
|
||||
* maintaining a value, rather their address is their value.
|
||||
|
@ -70,17 +68,42 @@ int lowlevel_init(void)
|
|||
}
|
||||
|
||||
#if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK))
|
||||
static tid_t netid;
|
||||
static struct netif* default_netif = NULL;
|
||||
static volatile uint32_t lwip_initialized = 0;
|
||||
|
||||
int STDCALL network_task(void* arg)
|
||||
static void tcp_init_ok(void* e)
|
||||
{
|
||||
struct netif netif;
|
||||
kputs("TCP/IP init COMPLETE!!\n");
|
||||
lwip_initialized = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int network_init(void)
|
||||
{
|
||||
#if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK))
|
||||
struct ip_addr ipaddr;
|
||||
struct ip_addr netmask;
|
||||
struct ip_addr gw;
|
||||
|
||||
kputs("Network task is started\n");
|
||||
kputs("Initialize network...\n");
|
||||
|
||||
// Initialize lwIP modules
|
||||
tcpip_init(tcp_init_ok, NULL);
|
||||
|
||||
while(!lwip_initialized) {
|
||||
reschedule();
|
||||
}
|
||||
|
||||
// Set up the lwIP network interface
|
||||
// Allocate and configure netif
|
||||
default_netif = (struct netif *) mem_malloc(sizeof(struct netif));
|
||||
if(default_netif == NULL)
|
||||
{
|
||||
kprintf("ERROR: Out of memory for default netif\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memset(default_netif, 0x00, sizeof(struct netif));
|
||||
#ifdef CONFIG_ROCKCREEK
|
||||
/* Set network address variables */
|
||||
IP4_ADDR(&gw, 192,168,4,254);
|
||||
|
@ -88,7 +111,7 @@ int STDCALL network_task(void* arg)
|
|||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
|
||||
/* Bring up the network interface */
|
||||
if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, rckemacif_init, ethernet_input)) {
|
||||
if (!netif_add(default_netif, &ipaddr, &netmask, &gw, NULL, rckemacif_init, tcpip_input)) {
|
||||
#else
|
||||
/* Clear network address because we use DHCP to get an ip address */
|
||||
IP4_ADDR(&gw, 0,0,0,0);
|
||||
|
@ -96,82 +119,61 @@ int STDCALL network_task(void* arg)
|
|||
IP4_ADDR(&netmask, 0,0,0,0);
|
||||
|
||||
/* Bring up the network interface */
|
||||
if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, ethernet_input)) {
|
||||
if (!netif_add(default_netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, tcpip_input)) {
|
||||
#endif
|
||||
kputs("Unable to add network interface\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
netif_set_default(&netif);
|
||||
netif_set_up(&netif);
|
||||
netif_set_default(default_netif);
|
||||
netif_set_up(default_netif);
|
||||
|
||||
/* test if interface is really up */
|
||||
if (!netif_is_up(&netif)) {
|
||||
if (!netif_is_up(default_netif)) {
|
||||
kputs("network interface is not up\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_ROCKCREEK
|
||||
kprintf("Starting DHCPCD...\n");
|
||||
dhcp_start(&netif);
|
||||
dhcp_start(default_netif);
|
||||
|
||||
int mscnt = 0;
|
||||
/* wait for ip address */
|
||||
while(!netif.ip_addr.addr) {
|
||||
rtl8139if_wait(&netif, 1);
|
||||
reschedule();
|
||||
while(!default_netif->ip_addr.addr) {
|
||||
sys_msleep(DHCP_FINE_TIMER_MSECS);
|
||||
dhcp_fine_tmr();
|
||||
mscnt += DHCP_FINE_TIMER_MSECS;
|
||||
if (mscnt >= DHCP_COARSE_TIMER_SECS*1000) {
|
||||
dhcp_coarse_tmr();
|
||||
mscnt = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
mmnif_open();
|
||||
//mmnif_open();
|
||||
#endif
|
||||
|
||||
// start echo and ping server
|
||||
echo_init();
|
||||
ping_init();
|
||||
|
||||
while(!done) {
|
||||
#ifdef CONFIG_PCI
|
||||
rtl8139if_wait(&netif, 0);
|
||||
#elif defined(CONFIG_ROCKCREEK)
|
||||
rckemacif_wait(&netif, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef CONFIG_ROCKCREEK
|
||||
dhcp_release(&netif);
|
||||
dhcp_stop(&netif);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int network_shutdown(void)
|
||||
{
|
||||
#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK)
|
||||
mmnif_close();
|
||||
//mmnif_close();
|
||||
#elif defined(CONFIG_LWIP) && defined(CONFIG_PCI)
|
||||
dhcp_release(default_netif);
|
||||
dhcp_stop(default_netif);
|
||||
#endif
|
||||
done = 1;
|
||||
|
||||
mem_free(default_netif);
|
||||
default_netif = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tcp_init_ok(void* e)
|
||||
{
|
||||
kprintf("TCP/IP init COMPLETE!!");
|
||||
}
|
||||
|
||||
int network_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
#if defined(CONFIG_LWIP)
|
||||
// Initialize lwIP modules
|
||||
tcpip_init(tcp_init_ok, NULL);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK))
|
||||
ret = create_kernel_task(&netid, network_task, NULL);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue