aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2011-04-12 00:05:58 -0700
committerEric W. Biederman <ebiederm@xmission.com>2011-04-12 14:41:24 -0700
commit7a4d7ed51f4440cbcf8dfa6a75f0c74f9bd12856 (patch)
treef6d10c9c6b4af2f60df4dd1724d539888338c864
parentd4c8170ad3d62cdb1bf7df845d6baaa2659a0586 (diff)
downloadsyslinux-devel-7a4d7ed51f4440cbcf8dfa6a75f0c74f9bd12856.tar.gz
syslinux-devel-7a4d7ed51f4440cbcf8dfa6a75f0c74f9bd12856.tar.xz
syslinux-devel-7a4d7ed51f4440cbcf8dfa6a75f0c74f9bd12856.zip
lwip: Clean up the initialization sequence
Implement an initialization sequence for lwip that is essentially sane, and remove the previous udp stack support. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r--core/fs/pxe/pxe.c44
-rw-r--r--core/fs/pxe/pxe.h3
-rw-r--r--core/lwip/src/netif/undiif.c22
3 files changed, 24 insertions, 45 deletions
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index 50f205f7..47f89762 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -8,6 +8,7 @@
#include "pxe.h"
#include <lwip/api.h>
#include <lwip/dns.h>
+#include <lwip/tcpip.h>
static uint16_t real_base_mem; /* Amount of DOS memory after freeing */
@@ -1027,24 +1028,6 @@ static void gpxe_init(void)
}
#if 0
-/*
- * Initialize UDP stack
- *
- */
-static void udp_init(void)
-{
- int err;
- static __lowmem struct s_PXENV_UDP_OPEN udp_open;
- udp_open.src_ip = IPInfo.myip;
- err = pxe_call(PXENV_UDP_OPEN, &udp_open);
- if (err || udp_open.status) {
- printf("Failed to initialize UDP stack ");
- printf("%d\n", udp_open.status);
- kaboom();
- }
-}
-#endif
-
static void undi_clear_stats(void)
{
static __lowmem t_PXENV_UNDI_CLEAR_STATISTICS clear;
@@ -1165,6 +1148,7 @@ static void lwip_test(void)
for(;;)
asm volatile("hlt");
}
+#endif
/*
* Network-specific initialization
@@ -1172,6 +1156,7 @@ static void lwip_test(void)
static void network_init(void)
{
struct bootp_t *bp = (struct bootp_t *)trackbuf;
+ int err;
int pkt_len;
int i;
@@ -1229,14 +1214,15 @@ static void network_init(void)
if ((DHCPMagic & 1) == 0)
DHCPMagic = 0;
-#if 1 /* new stuff */
- dprintf("undi_tcpip_start...\n");
- extern err_t undi_tcpip_start(struct ip_addr *ipaddr,
- struct ip_addr *netmask,
- struct ip_addr *gw);
- undi_tcpip_start((struct ip_addr *)&IPInfo.myip,
- (struct ip_addr *)&IPInfo.netmask,
- (struct ip_addr *)&IPInfo.gateway);
+ /* Initialize lwip */
+ tcpip_init(NULL, NULL);
+
+ /* Start up the undi driver for lwip */
+ err = undiif_start(IPInfo.myip, IPInfo.netmask, IPInfo.gateway);
+ if (err) {
+ printf("undiif driver failed to start: %d\n", err);
+ kaboom();
+ }
for (i = 0; i < DNS_MAX_SERVERS; i++) {
/* Transfer the DNS information to lwip */
@@ -1248,12 +1234,6 @@ static void network_init(void)
((uint8_t *)&dns_server[i])[3]);
dns_setserver(i, (struct ip_addr *)&dns_server[i]);
}
-
- dprintf("lwip_test...\n");
- lwip_test();
-#else
- udp_init();
-#endif
}
/*
diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h
index 810646ea..9236b109 100644
--- a/core/fs/pxe/pxe.h
+++ b/core/fs/pxe/pxe.h
@@ -255,6 +255,9 @@ extern __lowmem char packet_buf[PKTBUF_SIZE] __aligned(16);
const char *parse_dotquad(const char *ip_str, uint32_t *res);
int pxe_getc(struct inode *inode);
+/* undiif.c */
+int undiif_start(uint32_t ip, uint32_t netmask, uint32_t gw);
+
/* dhcp_options.c */
void parse_dhcp(int);
diff --git a/core/lwip/src/netif/undiif.c b/core/lwip/src/netif/undiif.c
index 9d8a84da..a2787f2f 100644
--- a/core/lwip/src/netif/undiif.c
+++ b/core/lwip/src/netif/undiif.c
@@ -1250,7 +1250,7 @@ void undiif_input(t_PXENV_UNDI_ISR *isr)
* ERR_MEM if private data couldn't be allocated
* any other err_t on error
*/
-err_t
+static err_t
undiif_init(struct netif *netif)
{
LWIP_ASSERT("netif != NULL", (netif != NULL));
@@ -1278,22 +1278,17 @@ undiif_init(struct netif *netif)
return ERR_OK;
}
-err_t undi_tcpip_start(struct ip_addr *ipaddr,
- struct ip_addr *netmask,
- struct ip_addr *gw)
+int undiif_start(uint32_t ip, uint32_t netmask, uint32_t gw)
{
err_t err;
- // Start the TCP/IP thread & init stuff
- tcpip_init(NULL, NULL);
-
// This should be done *after* the threading system and receive thread
// have both been started.
dprintf("undi_netif: ip %d.%d.%d.%d netmask %d.%d.%d.%d gw %d.%d.%d.%d\n",
- ((uint8_t *)ipaddr)[0],
- ((uint8_t *)ipaddr)[1],
- ((uint8_t *)ipaddr)[2],
- ((uint8_t *)ipaddr)[3],
+ ((uint8_t *)ip)[0],
+ ((uint8_t *)ip)[1],
+ ((uint8_t *)ip)[2],
+ ((uint8_t *)ip)[3],
((uint8_t *)netmask)[0],
((uint8_t *)netmask)[1],
((uint8_t *)netmask)[2],
@@ -1302,8 +1297,9 @@ err_t undi_tcpip_start(struct ip_addr *ipaddr,
((uint8_t *)gw)[1],
((uint8_t *)gw)[2],
((uint8_t *)gw)[3]);
- err = netifapi_netif_add(&undi_netif, ipaddr, netmask, gw, NULL,
- undiif_init, ip_input);
+ err = netifapi_netif_add(&undi_netif,
+ (struct ip_addr *)&ip, (struct ip_addr *)&netmask, (struct ip_addr *)gw,
+ NULL, undiif_init, ip_input);
if (err)
return err;