]> git.sur5r.net Git - freertos/commitdiff
Improve DCHP handling by removing the yiaddr field from outgoing DHCP packets and...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 7 Oct 2013 11:49:17 +0000 (11:49 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 7 Oct 2013 11:49:17 +0000 (11:49 +0000)
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

FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_DHCP.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOSIPConfigDefaults.h
FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOS_UDP_IP.h
FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/portable/NetworkInterface/WinPCap/NetworkInterface.c

index f2226726b36acfd0ded648984df8036aab0a845b..aab435bda52da6674a6f42d3deff2bef022f414d 100644 (file)
@@ -135,10 +135,12 @@ made up of the length byte, and minimum one byte value. */
        #define dhcpCLIENT_PORT 0x4400\r
        #define dhcpSERVER_PORT 0x4300\r
        #define dhcpCOOKIE              0x63538263\r
+       #define dhcpBROADCAST   0x0080\r
 #else\r
        #define dhcpCLIENT_PORT 0x0044\r
        #define dhcpSERVER_PORT 0x0043\r
        #define dhcpCOOKIE              0x63825363\r
+       #define dhcpBROADCAST   0x8000\r
 #endif /* ipconfigBYTE_ORDER */\r
 \r
 #include "pack_struct_start.h"\r
@@ -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. */\r
                                                #if ipconfigFREERTOS_PLUS_NABTO == 1\r
                                                {\r
-                                                       vStartNabtoTask();\r
+                                                       /* Return value is used in configASSERT() inside the \r
+                                                       function. */\r
+                                                       ( void ) xStartNabtoTask();\r
                                                }\r
                                                #endif /* ipconfigFREERTOS_PLUS_NABTO */\r
 \r
@@ -324,10 +328,13 @@ void vDHCPProcess( portBASE_TYPE xReset, xMACAddress_t *pxMACAddress, uint32_t *
                                }\r
                                #endif\r
 \r
-                               /* Static configuration is being used, so the network is now up. */\r
+                               /* Static configuration is being used, so the network is now \r
+                               up. */\r
                                #if ipconfigFREERTOS_PLUS_NABTO == 1\r
                                {\r
-                                       vStartNabtoTask();\r
+                                       /* Return value is used in configASSERT() inside the \r
+                                       function. */\r
+                                       ( void ) xStartNabtoTask();\r
                                }\r
                                #endif /* ipconfigFREERTOS_PLUS_NABTO */\r
 \r
@@ -640,8 +647,8 @@ uint8_t *pucUDPPayloadBuffer;
        pxDHCPMessage->ucAddressType = dhcpADDRESS_TYPE_ETHERNET;\r
        pxDHCPMessage->ucAddressLength = dhcpETHERNET_ADDRESS_LENGTH;\r
        pxDHCPMessage->ulTransactionID = ulTransactionId;\r
-       pxDHCPMessage->ulYourIPAddress_yiaddr = ulOfferedIPAddress;\r
        pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE;\r
+       pxDHCPMessage->usFlags = dhcpBROADCAST;\r
        memcpy( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress[ 0 ] ), ( void * ) pxMACAddress, sizeof( xMACAddress_t ) );\r
 \r
        /* Copy in the const part of the options options. */\r
index 9d70bb1addd4e77fda2bb6c54f55b050da3af6de..a490e481e91e8dfa98473be69a506de6b09ed3fb 100644 (file)
@@ -1355,7 +1355,7 @@ static void prvProcessNetworkDownEvent( void )
                /* The first network down event is generated by the IP stack\r
                itself to initialise the network hardware, so do not call the\r
                network down event the first time through. */\r
-               if( xCallEventHook == pdFALSE )\r
+               if( xCallEventHook == pdTRUE )\r
                {\r
                        vApplicationIPNetworkEventHook( eNetworkDown );\r
                }\r
@@ -1398,7 +1398,9 @@ static void prvProcessNetworkDownEvent( void )
                        /* Static configuration is being used, so the network is now up. */\r
                        #if ipconfigFREERTOS_PLUS_NABTO == 1\r
                        {\r
-                               vStartNabtoTask();\r
+                               /* Return value is used in configASSERT() inside the \r
+                               function. */\r
+                               ( void ) xStartNabtoTask();\r
                        }\r
                        #endif /* ipconfigFREERTOS_PLUS_NABTO */\r
                }\r
index 9e7bd407be27a562470b2b09181d6b0cf09fdb6a..913cb4947fd41139644fa8c3cf64943990891911 100644 (file)
@@ -139,4 +139,12 @@ from the FreeRTOSIPConfig.h configuration header file. */
        #define ipconfigFREERTOS_PLUS_NABTO 0\r
 #endif\r
 \r
+#ifndef ipconfigNABTO_TASK_STACK_SIZE\r
+       #define ipconfigNABTO_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )\r
+#endif\r
+\r
+#ifndef ipconfigNABTO_TASK_PRIORITY\r
+       #define ipconfigNABTO_TASK_PRIORITY      ( ipconfigUDP_TASK_PRIORITY + 1 )\r
+#endif\r
+\r
 #endif /* FREERTOS_DEFAULT_IP_CONFIG_H */\r
index a7cc748c4618907192e0e78c2f1c952337bd78a8..83f39788644e3cc97aeccc71697e81778fea8eb4 100644 (file)
@@ -106,6 +106,10 @@ void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifie
 void FreeRTOS_ReleaseUDPPayloadBuffer( void *pvBuffer );\r
 uint8_t * FreeRTOS_GetMACAddress( void );\r
 \r
+#if ( ipconfigFREERTOS_PLUS_NABTO == 1 )\r
+       portBASE_TYPE xStartNabtoTask( void );\r
+#endif\r
+\r
 #endif /* FREERTOS_IP_H */\r
 \r
 \r
index dc0a57f149a3f880ddd184b9658722e90254049b..d5cb0753cc37ad07f1d141b70bd0e01f9c71944f 100644 (file)
@@ -203,6 +203,10 @@ pcap_if_t *pxAllNetworkInterfaces;
                                vNetworkBufferRelease( pxNetworkBuffer );\r
                                iptraceETHERNET_RX_EVENT_LOST();\r
                        }\r
+                       else\r
+                       {\r
+                               iptraceNETWORK_INTERFACE_RECEIVE();\r
+                       }\r
                }\r
                else\r
                {\r
@@ -436,6 +440,10 @@ eFrameProcessingResult_t eResult;
                                                        vNetworkBufferRelease( pxNetworkBuffer );\r
                                                        iptraceETHERNET_RX_EVENT_LOST();\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       iptraceNETWORK_INTERFACE_RECEIVE();\r
+                                               }\r
                                        }\r
                                        else\r
                                        {\r