X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/8154331da60ac08b0e2b09ca67008ec4a8c7698b..aca7863350509a1f390eda93ac0150378d8cd16c:/Projects/Webserver/Lib/DHCPClientApp.c diff --git a/Projects/Webserver/Lib/DHCPClientApp.c b/Projects/Webserver/Lib/DHCPClientApp.c index 09bae7368..1af90ad19 100644 --- a/Projects/Webserver/Lib/DHCPClientApp.c +++ b/Projects/Webserver/Lib/DHCPClientApp.c @@ -28,25 +28,22 @@ this software. */ +#if defined(ENABLE_DHCP_CLIENT) || defined(__DOXYGEN__) + /** \file * * DHCP Client Application. When connected to the uIP stack, this will retrieve IP configuration settings from the * DHCP server on the network. */ +#define INCLUDE_FROM_DHCPCLIENTAPP_C #include "DHCPClientApp.h" -#if defined(ENABLE_DHCP_CLIENT) || defined(__DOXYGEN__) - /** Initialization function for the DHCP client. */ void DHCPClientApp_Init(void) { - /* Create an IP address to the broadcast network address */ - uip_ipaddr_t DHCPServerIPAddress; - uip_ipaddr(&DHCPServerIPAddress, 255, 255, 255, 255); - /* 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)); + struct uip_udp_conn* Connection = uip_udp_new(&uip_broadcast_addr, HTONS(DHCPC_SERVER_PORT)); /* If the connection was successfully created, bind it to the local DHCP client port */ if (Connection != NULL) @@ -160,7 +157,10 @@ void DHCPClientApp_Callback(void) uip_setnetmask((uip_ipaddr_t*)&AppState->DHCPClient.DHCPOffer_Data.Netmask); uip_setdraddr((uip_ipaddr_t*)&AppState->DHCPClient.DHCPOffer_Data.GatewayIP); - AppState->DHCPClient.CurrentState = DHCP_STATE_AddressLeased; + /* Indicate to the user that we now have a valid IP configuration */ + HaveIPConfiguration = true; + + AppState->DHCPClient.CurrentState = DHCP_STATE_AddressLeased; } break; @@ -176,7 +176,7 @@ void DHCPClientApp_Callback(void) * * \return Size in bytes of the created DHCP packet */ -uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState) +static uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState) { /* Erase existing packet data so that we start will all 0x00 DHCP header data */ memset(DHCPHeader, 0, sizeof(DHCP_Header_t)); @@ -215,7 +215,7 @@ uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMes * * \return Number of bytes added to the DHCP packet */ -uint8_t DHCPClientApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* OptionData) +static uint8_t DHCPClientApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* OptionData) { /* Skip through the DHCP options list until the terminator option is found */ while (*DHCPOptionList != DHCP_OPTION_END) @@ -239,7 +239,7 @@ uint8_t DHCPClientApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t * * \return Boolean true if the option was found in the DHCP packet's options list, false otherwise */ -bool DHCPClientApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination) +static bool DHCPClientApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination) { /* Look through the incoming DHCP packet's options list for the requested option */ while (*DHCPOptionList != DHCP_OPTION_END)