X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/1d433d4506113c95285f633e3553ff62d4cfd05d..49148fef9b5d74e5db607c6e39ad1c08f62b9b58:/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c index 6bd920fd0..37f4e7762 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2011. + Copyright (C) Dean Camera, 2016. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2016 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted @@ -18,7 +18,7 @@ advertising or publicity pertaining to distribution of the software without specific, written prior permission. - The author disclaim all warranties with regard to this + The author disclaims all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the author be liable for any special, indirect or consequential damages or any damages @@ -54,12 +54,12 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart, DHCP_Header_t* DHCPHeaderIN = (DHCP_Header_t*)DHCPHeaderInStart; DHCP_Header_t* DHCPHeaderOUT = (DHCP_Header_t*)DHCPHeaderOutStart; - uint8_t* DHCPOptionsINStart = (uint8_t*)(DHCPHeaderInStart + sizeof(DHCP_Header_t)); - uint8_t* DHCPOptionsOUTStart = (uint8_t*)(DHCPHeaderOutStart + sizeof(DHCP_Header_t)); + uint8_t* DHCPOptionsINStart = ((uint8_t*)DHCPHeaderInStart + sizeof(DHCP_Header_t)); + uint8_t* DHCPOptionsOUTStart = ((uint8_t*)DHCPHeaderOutStart + sizeof(DHCP_Header_t)); DecodeDHCPHeader(DHCPHeaderInStart); - /* Zero out the response DHCP packet, as much of it legacy and left at 0 */ + /* Zero out the response DHCP packet, as much of it is legacy and left at 0 */ memset(DHCPHeaderOUT, 0, sizeof(DHCP_Header_t)); /* Fill out the response DHCP packet */ @@ -95,12 +95,20 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart, : DHCP_MESSAGETYPE_ACK; *(DHCPOptionsOUTStart++) = DHCP_OPTION_SUBNETMASK; - *(DHCPOptionsOUTStart++) = 4; + *(DHCPOptionsOUTStart++) = sizeof(IP_Address_t); *(DHCPOptionsOUTStart++) = 0xFF; *(DHCPOptionsOUTStart++) = 0xFF; *(DHCPOptionsOUTStart++) = 0xFF; *(DHCPOptionsOUTStart++) = 0x00; + *(DHCPOptionsOUTStart++) = DHCP_OPTION_LEASETIME; + *(DHCPOptionsOUTStart++) = sizeof(uint32_t); + /* Lease Time 86400s (ONE_DAY) */ + *(DHCPOptionsOUTStart++) = 0x00; + *(DHCPOptionsOUTStart++) = 0x01; + *(DHCPOptionsOUTStart++) = 0x51; + *(DHCPOptionsOUTStart++) = 0x80; + *(DHCPOptionsOUTStart++) = DHCP_OPTION_DHCPSERVER; *(DHCPOptionsOUTStart++) = sizeof(IP_Address_t); memcpy(DHCPOptionsOUTStart, &ServerIPAddress, sizeof(IP_Address_t)); @@ -108,7 +116,7 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart, *(DHCPOptionsOUTStart++) = DHCP_OPTION_END; - return (sizeof(DHCP_Header_t) + 12 + sizeof(IP_Address_t)); + return (sizeof(DHCP_Header_t) + 18 + sizeof(IP_Address_t)); } }