From 5d303ec17efc511d8cfe0919a790b44e24a8aad9 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 1 Sep 2007 18:06:15 +0000 Subject: Added support for socket descriptors git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@318 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/examples/uip/main.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'nuttx/examples/uip') diff --git a/nuttx/examples/uip/main.c b/nuttx/examples/uip/main.c index 1f88936a6..367e7e1c1 100644 --- a/nuttx/examples/uip/main.c +++ b/nuttx/examples/uip/main.c @@ -31,11 +31,12 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: main.c,v 1.2 2007-08-30 23:57:58 patacongo Exp $ + * $Id: main.c,v 1.3 2007-09-01 18:06:12 patacongo Exp $ * */ #include +#include #include #include @@ -63,12 +64,11 @@ int user_start(int argc, char *argv[]) { - int i; uip_ipaddr_t ipaddr; #if defined(CONFIG_EXAMPLE_UIP_DHCPC) uint16 mac[6] = {1, 2, 3, 4, 5, 6}; #endif -#ifdef CONFIG_EXAMPLE_UIP_SMTP +#if defined(CONFIG_EXAMPLE_UIP_DHCPC) || defined(CONFIG_EXAMPLE_UIP_SMTP) void *handle; #endif @@ -84,10 +84,20 @@ int user_start(int argc, char *argv[]) #elif defined(CONFIG_EXAMPLE_UIP_TELNETD) telnetd_init(); #elif defined(CONFIG_EXAMPLE_UIP_DHCPC) - dhcpc_init(&mac, 6); + handle = dhcpc_open(&mac, 6); + if (handle) + { + struct dhcpc_state ds; + (void)dhcpc_request(handle, &ds); + uip_sethostaddr(ds.ipaddr); + uip_setnetmask(ds.netmask); + uip_setdraddr(ds.default_router); + resolv_conf(ds.dnsaddr); + dhcpc_close(handle); + } #elif defined(CONFIG_EXAMPLE_UIP_SMTP) uip_ipaddr(ipaddr, 127, 0, 0, 1); - handle = smtp_init(); + handle = smtp_open(); if (handle) { smtp_configure("localhost", ipaddr); @@ -131,16 +141,6 @@ void resolv_found(char *name, uint16 *ipaddr) } } -#ifdef __DHCPC_H__ -void dhcpc_configured(const struct dhcpc_state *s) -{ - uip_sethostaddr(s->ipaddr); - uip_setnetmask(s->netmask); - uip_setdraddr(s->default_router); - resolv_conf(s->dnsaddr); -} -#endif /* __DHCPC_H__ */ - void webclient_closed(void) { printf("Webclient: connection closed\n"); -- cgit v1.2.3