\r
if( xDHCPData.xDHCPTxPeriod <= ipconfigMAXIMUM_DISCOVER_TX_PERIOD )\r
{\r
- xDHCPData.ulTransactionId = ipconfigRAND32( );\r
-\r
- if( 0 != xDHCPData.ulTransactionId )\r
- {\r
- xDHCPData.xDHCPTxTime = xTaskGetTickCount( );\r
- xDHCPData.xUseBroadcast = !xDHCPData.xUseBroadcast;\r
- prvSendDHCPDiscover( );\r
- FreeRTOS_debug_printf( ( "vDHCPProcess: timeout %lu ticks\n", xDHCPData.xDHCPTxPeriod ) );\r
- }\r
- else\r
- {\r
- FreeRTOS_debug_printf( ( "vDHCPProcess: failed to generate a random Transaction ID\n" ) );\r
- }\r
+ xDHCPData.ulTransactionId = ipconfigRAND32( );\r
+\r
+ if( 0 != xDHCPData.ulTransactionId )\r
+ {\r
+ xDHCPData.xDHCPTxTime = xTaskGetTickCount( );\r
+ xDHCPData.xUseBroadcast = !xDHCPData.xUseBroadcast;\r
+ prvSendDHCPDiscover( );\r
+ FreeRTOS_debug_printf( ( "vDHCPProcess: timeout %lu ticks\n", xDHCPData.xDHCPTxPeriod ) );\r
+ }\r
+ else\r
+ {\r
+ FreeRTOS_debug_printf( ( "vDHCPProcess: failed to generate a random Transaction ID\n" ) );\r
+ }\r
}\r
else\r
{\r
static void prvInitialiseDHCP( void )\r
{\r
/* Initialise the parameters that will be set by the DHCP process. Per\r
- https://www.ietf.org/rfc/rfc2131.txt, Transaction ID should be a random\r
- value chosen by the client. */\r
- xDHCPData.ulTransactionId = ipconfigRAND32();\r
-\r
- /* Check for random number generator API failure. */\r
- if( 0 != xDHCPData.ulTransactionId )\r
- {\r
- xDHCPData.xUseBroadcast = 0;\r
- xDHCPData.ulOfferedIPAddress = 0UL;\r
- xDHCPData.ulDHCPServerAddress = 0UL;\r
- xDHCPData.xDHCPTxPeriod = dhcpINITIAL_DHCP_TX_PERIOD;\r
-\r
- /* Create the DHCP socket if it has not already been created. */\r
- prvCreateDHCPSocket();\r
- FreeRTOS_debug_printf( ( "prvInitialiseDHCP: start after %lu ticks\n", dhcpINITIAL_TIMER_PERIOD ) );\r
- vIPReloadDHCPTimer( dhcpINITIAL_TIMER_PERIOD );\r
- }\r
+ https://www.ietf.org/rfc/rfc2131.txt, Transaction ID should be a random\r
+ value chosen by the client. */\r
+ xDHCPData.ulTransactionId = ipconfigRAND32();\r
+\r
+ /* Check for random number generator API failure. */\r
+ if( 0 != xDHCPData.ulTransactionId )\r
+ {\r
+ xDHCPData.xUseBroadcast = 0;\r
+ xDHCPData.ulOfferedIPAddress = 0UL;\r
+ xDHCPData.ulDHCPServerAddress = 0UL;\r
+ xDHCPData.xDHCPTxPeriod = dhcpINITIAL_DHCP_TX_PERIOD;\r
+\r
+ /* Create the DHCP socket if it has not already been created. */\r
+ prvCreateDHCPSocket();\r
+ FreeRTOS_debug_printf( ( "prvInitialiseDHCP: start after %lu ticks\n", dhcpINITIAL_TIMER_PERIOD ) );\r
+ vIPReloadDHCPTimer( dhcpINITIAL_TIMER_PERIOD );\r
+ }\r
}\r
/*-----------------------------------------------------------*/\r
\r
\r
/* Sanity check. */\r
if( ( lBytes >= sizeof( DHCPMessage_t ) ) &&\r
- ( pxDHCPMessage->ulDHCPCookie == ( uint32_t ) dhcpCOOKIE ) &&\r
+ ( pxDHCPMessage->ulDHCPCookie == ( uint32_t ) dhcpCOOKIE ) &&\r
( pxDHCPMessage->ucOpcode == ( uint8_t ) dhcpREPLY_OPCODE ) &&\r
( pxDHCPMessage->ulTransactionID == FreeRTOS_htonl( xDHCPData.ulTransactionId ) ) )\r
{\r
- if( memcmp( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress ), \r
- ( void * ) ipLOCAL_MAC_ADDRESS, \r
- sizeof( MACAddress_t ) ) == 0 )\r
+ if( memcmp( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress ),\r
+ ( void * ) ipLOCAL_MAC_ADDRESS,\r
+ sizeof( MACAddress_t ) ) == 0 )\r
{\r
/* None of the essential options have been processed yet. */\r
ulProcessed = 0ul;\r
continue;\r
}\r
\r
- /* Stop if the response is malformed. */\r
- if( pucByte < pucLastByte - 1 )\r
- {\r
- ucLength = pucByte[ 1 ];\r
- pucByte += 2;\r
-\r
- if( pucByte >= pucLastByte - ucLength )\r
- {\r
- break;\r
- }\r
- }\r
- else\r
- {\r
- break;\r
- } \r
+ /* Stop if the response is malformed. */\r
+ if( pucByte < pucLastByte - 1 )\r
+ {\r
+ ucLength = pucByte[ 1 ];\r
+ pucByte += 2;\r
+\r
+ if( pucByte >= pucLastByte - ucLength )\r
+ {\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ break;\r
+ }\r
\r
/* In most cases, a 4-byte network-endian parameter follows,\r
just get it once here and use later. */\r
- if( ucLength >= sizeof( ulParameter ) )\r
- {\r
- memcpy( ( void * ) &( ulParameter ), \r
- ( void * ) pucByte, \r
- ( size_t ) sizeof( ulParameter ) );\r
- }\r
- else\r
- {\r
- ulParameter = 0;\r
- }\r
-\r
- /* Option-specific handling. */\r
+ if( ucLength >= sizeof( ulParameter ) )\r
+ {\r
+ memcpy( ( void * ) &( ulParameter ),\r
+ ( void * ) pucByte,\r
+ ( size_t ) sizeof( ulParameter ) );\r
+ }\r
+ else\r
+ {\r
+ ulParameter = 0;\r
+ }\r
+\r
+ /* Option-specific handling. */\r
switch( ucOptionCode )\r
{\r
case dhcpMESSAGE_TYPE_OPTION_CODE :\r