Fix DHCPClient init code in the Webserver project writing to the incorrect application state location (thanks to Mike Alexander).

Dean Camera 15 years ago
parent a71820b259
commit 41ef05a6e5
  1. 16
      Projects/Webserver/Lib/DHCPClientApp.c
  2. 1
      Projects/Webserver/Lib/uip/uipopt.h
  3. 1
      Projects/Webserver/makefile

@ -43,17 +43,19 @@ struct timer DHCPTimer;
/** Initialization function for the DHCP client. */ /** Initialization function for the DHCP client. */
void DHCPClientApp_Init(void) void DHCPClientApp_Init(void)
{ {
uip_udp_appstate_t* const AppState = &uip_udp_conn->appstate; /* Create an IP address to the broadcast network address */
/* Create a new UDP connection to the DHCP server port for the DHCP solicitation */
uip_ipaddr_t DHCPServerIPAddress; uip_ipaddr_t DHCPServerIPAddress;
uip_ipaddr(&DHCPServerIPAddress, 255, 255, 255, 255); uip_ipaddr(&DHCPServerIPAddress, 255, 255, 255, 255);
AppState->DHCPClient.Connection = uip_udp_new(&DHCPServerIPAddress, HTONS(DHCPC_SERVER_PORT));
/* Create a new UDP connection to the DHCP server port for the DHCP solicitation */
struct uip_udp_conn* Connection = uip_udp_new(&DHCPServerIPAddress, HTONS(DHCPC_SERVER_PORT));
/* If the connection was successfully created, bind it to the local DHCP client port */ /* If the connection was successfully created, bind it to the local DHCP client port */
if(AppState->DHCPClient.Connection != NULL) if (Connection != NULL)
{ {
uip_udp_bind(AppState->DHCPClient.Connection, HTONS(DHCPC_CLIENT_PORT)); uip_udp_appstate_t* const AppState = &Connection->appstate;
uip_udp_bind(Connection, HTONS(DHCPC_CLIENT_PORT));
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover; AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;
} }
@ -194,7 +196,7 @@ uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMes
memcpy(&DHCPHeader->ClientHardwareAddress, &MACAddress, sizeof(struct uip_eth_addr)); memcpy(&DHCPHeader->ClientHardwareAddress, &MACAddress, sizeof(struct uip_eth_addr));
DHCPHeader->Cookie = DHCP_MAGIC_COOKIE; DHCPHeader->Cookie = DHCP_MAGIC_COOKIE;
/* Add a DHCP type and terminator options to the start of the DHCP options field */ /* Add a DHCP message type and terminator options to the start of the DHCP options field */
DHCPHeader->Options[0] = DHCP_OPTION_MSG_TYPE; DHCPHeader->Options[0] = DHCP_OPTION_MSG_TYPE;
DHCPHeader->Options[1] = 1; DHCPHeader->Options[1] = 1;
DHCPHeader->Options[2] = DHCPMessageType; DHCPHeader->Options[2] = DHCPMessageType;

@ -717,7 +717,6 @@ typedef union
struct struct
{ {
uint8_t CurrentState; uint8_t CurrentState;
struct uip_udp_conn* Connection;
struct struct
{ {

@ -119,6 +119,7 @@ LUFA_PATH = ../../
LUFA_OPTS = -D FIXED_CONTROL_ENDPOINT_SIZE=8 LUFA_OPTS = -D FIXED_CONTROL_ENDPOINT_SIZE=8
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
LUFA_OPTS += -D FAST_STREAM_TRANSFERS
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"

Loading…
Cancel
Save