From 8027ff2a0e96c2f93dc8dcc669dfed129c80dcfe Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 11 Dec 2007 22:07:18 +0000 Subject: [PATCH] DHCPC logic changes - should now handle case with multiple DHCP servers git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@446 42af7a65-404d-4744-a932-0658087f49c3 --- include/net/uip/dhcpc.h | 2 +- netutils/dhcpc/dhcpc.c | 271 ++++++++++++++++++++++++++++------------ netutils/dhcpd/dhcpd.c | 4 +- 3 files changed, 195 insertions(+), 82 deletions(-) diff --git a/include/net/uip/dhcpc.h b/include/net/uip/dhcpc.h index 606d818b0c..a5d86da9db 100644 --- a/include/net/uip/dhcpc.h +++ b/include/net/uip/dhcpc.h @@ -55,7 +55,7 @@ struct dhcpc_state { uint16 lease_time[2]; - uint8 serverid[4]; + struct in_addr serverid; struct in_addr ipaddr; struct in_addr netmask; struct in_addr dnsaddr; diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c index e0ee702c22..539ee60cca 100644 --- a/netutils/dhcpc/dhcpc.c +++ b/netutils/dhcpc/dhcpc.c @@ -61,9 +61,8 @@ ****************************************************************************/ #define STATE_INITIAL 0 -#define STATE_SENDING 1 -#define STATE_OFFER_RECEIVED 2 -#define STATE_CONFIG_RECEIVED 3 +#define STATE_HAVE_OFFER 1 +#define STATE_HAVE_LEASE 2 #define BOOTP_BROADCAST 0x8000 @@ -127,6 +126,7 @@ struct dhcpc_state_s const void *ds_macaddr; int ds_maclen; int sockfd; + struct in_addr serverid; struct dhcp_msg packet; }; @@ -141,7 +141,11 @@ static const uint8 magic_cookie[4] = {99, 130, 83, 99}; * Private Functions ****************************************************************************/ -static uint8 *add_msg_type(uint8 *optptr, uint8 type) +/**************************************************************************** + * Name: dhcpc_add