summaryrefslogtreecommitdiff
path: root/nuttx/examples/uip/main.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-01 18:06:15 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-01 18:06:15 +0000
commit5d303ec17efc511d8cfe0919a790b44e24a8aad9 (patch)
tree76c519b5903e6d1e2880f7fb0d403838f7acddac /nuttx/examples/uip/main.c
parent0cab5d84f146c0f6105192db5593aa4019edcdcf (diff)
downloadpx4-nuttx-5d303ec17efc511d8cfe0919a790b44e24a8aad9.tar.gz
px4-nuttx-5d303ec17efc511d8cfe0919a790b44e24a8aad9.tar.bz2
px4-nuttx-5d303ec17efc511d8cfe0919a790b44e24a8aad9.zip
Added support for socket descriptors
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@318 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/uip/main.c')
-rw-r--r--nuttx/examples/uip/main.c30
1 files changed, 15 insertions, 15 deletions
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 <stdio.h>
+#include <unistd.h>
#include <time.h>
#include <net/uip/uip.h>
@@ -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");