#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 */
}
#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;
for(;;)
asm volatile("hlt");
}
+#endif
/*
* Network-specific initialization
static void network_init(void)
{
struct bootp_t *bp = (struct bootp_t *)trackbuf;
+ int err;
int pkt_len;
int i;
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 */
((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
}
/*
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);
* 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));
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],
((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;