From 4e5e119fd3ebb29efe6a936b6baa83b00e9b5de1 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 11 Dec 2007 22:07:18 +0000 Subject: 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 --- nuttx/include/net/uip/dhcpc.h | 2 +- nuttx/netutils/dhcpc/dhcpc.c | 255 ++++++++++++++++++++++++++++++------------ nuttx/netutils/dhcpd/dhcpd.c | 4 +- 3 files changed, 187 insertions(+), 74 deletions(-) diff --git a/nuttx/include/net/uip/dhcpc.h b/nuttx/include/net/uip/dhcpc.h index 606d818b0..a5d86da9d 100644 --- a/nuttx/include/net/uip/dhcpc.h +++ b/nuttx/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/nuttx/netutils/dhcpc/dhcpc.c b/nuttx/netutils/dhcpc/dhcpc.c index e0ee702c2..539ee60cc 100644 --- a/nuttx/netutils/dhcpc/dhcpc.c +++ b/nuttx/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