From: richardbarry Date: Mon, 7 Oct 2013 11:49:17 +0000 (+0000) Subject: Improve DCHP handling by removing the yiaddr field from outgoing DHCP packets and... X-Git-Tag: V7.5.3~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=94ff5932cc88f3486f78d4067774d06aab2b0da1;p=freertos Improve DCHP handling by removing the yiaddr field from outgoing DHCP packets and adding the broadcast bit in the flags field. Correct the check to ensure the application network event hook is not called when the first network down event is sent. Add in defaults for the Nabto task stack and priority. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2050 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_DHCP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_DHCP.c index f2226726b..aab435bda 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_DHCP.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_DHCP.c @@ -135,10 +135,12 @@ made up of the length byte, and minimum one byte value. */ #define dhcpCLIENT_PORT 0x4400 #define dhcpSERVER_PORT 0x4300 #define dhcpCOOKIE 0x63538263 + #define dhcpBROADCAST 0x0080 #else #define dhcpCLIENT_PORT 0x0044 #define dhcpSERVER_PORT 0x0043 #define dhcpCOOKIE 0x63825363 + #define dhcpBROADCAST 0x8000 #endif /* ipconfigBYTE_ORDER */ #include "pack_struct_start.h" @@ -296,7 +298,9 @@ void vDHCPProcess( portBASE_TYPE xReset, xMACAddress_t *pxMACAddress, uint32_t * /* Static configuration is being used, so the network is now up. */ #if ipconfigFREERTOS_PLUS_NABTO == 1 { - vStartNabtoTask(); + /* Return value is used in configASSERT() inside the + function. */ + ( void ) xStartNabtoTask(); } #endif /* ipconfigFREERTOS_PLUS_NABTO */ @@ -324,10 +328,13 @@ void vDHCPProcess( portBASE_TYPE xReset, xMACAddress_t *pxMACAddress, uint32_t * } #endif - /* Static configuration is being used, so the network is now up. */ + /* Static configuration is being used, so the network is now + up. */ #if ipconfigFREERTOS_PLUS_NABTO == 1 { - vStartNabtoTask(); + /* Return value is used in configASSERT() inside the + function. */ + ( void ) xStartNabtoTask(); } #endif /* ipconfigFREERTOS_PLUS_NABTO */ @@ -640,8 +647,8 @@ uint8_t *pucUDPPayloadBuffer; pxDHCPMessage->ucAddressType = dhcpADDRESS_TYPE_ETHERNET; pxDHCPMessage->ucAddressLength = dhcpETHERNET_ADDRESS_LENGTH; pxDHCPMessage->ulTransactionID = ulTransactionId; - pxDHCPMessage->ulYourIPAddress_yiaddr = ulOfferedIPAddress; pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; + pxDHCPMessage->usFlags = dhcpBROADCAST; memcpy( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress[ 0 ] ), ( void * ) pxMACAddress, sizeof( xMACAddress_t ) ); /* Copy in the const part of the options options. */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c index 9d70bb1ad..a490e481e 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c @@ -1355,7 +1355,7 @@ static void prvProcessNetworkDownEvent( void ) /* The first network down event is generated by the IP stack itself to initialise the network hardware, so do not call the network down event the first time through. */ - if( xCallEventHook == pdFALSE ) + if( xCallEventHook == pdTRUE ) { vApplicationIPNetworkEventHook( eNetworkDown ); } @@ -1398,7 +1398,9 @@ static void prvProcessNetworkDownEvent( void ) /* Static configuration is being used, so the network is now up. */ #if ipconfigFREERTOS_PLUS_NABTO == 1 { - vStartNabtoTask(); + /* Return value is used in configASSERT() inside the + function. */ + ( void ) xStartNabtoTask(); } #endif /* ipconfigFREERTOS_PLUS_NABTO */ } diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOSIPConfigDefaults.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOSIPConfigDefaults.h index 9e7bd407b..913cb4947 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOSIPConfigDefaults.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOSIPConfigDefaults.h @@ -139,4 +139,12 @@ from the FreeRTOSIPConfig.h configuration header file. */ #define ipconfigFREERTOS_PLUS_NABTO 0 #endif +#ifndef ipconfigNABTO_TASK_STACK_SIZE + #define ipconfigNABTO_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) +#endif + +#ifndef ipconfigNABTO_TASK_PRIORITY + #define ipconfigNABTO_TASK_PRIORITY ( ipconfigUDP_TASK_PRIORITY + 1 ) +#endif + #endif /* FREERTOS_DEFAULT_IP_CONFIG_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOS_UDP_IP.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOS_UDP_IP.h index a7cc748c4..83f397886 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOS_UDP_IP.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOS_UDP_IP.h @@ -106,6 +106,10 @@ void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifie void FreeRTOS_ReleaseUDPPayloadBuffer( void *pvBuffer ); uint8_t * FreeRTOS_GetMACAddress( void ); +#if ( ipconfigFREERTOS_PLUS_NABTO == 1 ) + portBASE_TYPE xStartNabtoTask( void ); +#endif + #endif /* FREERTOS_IP_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/WinPCap/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/WinPCap/NetworkInterface.c index dc0a57f14..d5cb0753c 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/WinPCap/NetworkInterface.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/WinPCap/NetworkInterface.c @@ -203,6 +203,10 @@ pcap_if_t *pxAllNetworkInterfaces; vNetworkBufferRelease( pxNetworkBuffer ); iptraceETHERNET_RX_EVENT_LOST(); } + else + { + iptraceNETWORK_INTERFACE_RECEIVE(); + } } else { @@ -436,6 +440,10 @@ eFrameProcessingResult_t eResult; vNetworkBufferRelease( pxNetworkBuffer ); iptraceETHERNET_RX_EVENT_LOST(); } + else + { + iptraceNETWORK_INTERFACE_RECEIVE(); + } } else {