]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_DHCP.c
Change version numbers ready for V8.0.0 release candidate 1 tag.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-UDP / FreeRTOS_DHCP.c
index f113e56e1b90f36e7fbd1c2f48f75fac6177cda2..8c3d78fcf6854e844cf6d81eb874f4b683e02c78 100644 (file)
@@ -1,25 +1,30 @@
 /*\r
- * FreeRTOS+UDP V1.0.0 (C) 2013 Real Time Engineers ltd.\r
+ * FreeRTOS+UDP V1.0.3 (C) 2014 Real Time Engineers ltd.\r
+ * All rights reserved\r
  *\r
- * FreeRTOS+UDP is an add-on component to FreeRTOS.  It is not, in itself, part\r
- * of the FreeRTOS kernel.  FreeRTOS+UDP is licensed separately from FreeRTOS,\r
- * and uses a different license to FreeRTOS.  FreeRTOS+UDP uses a dual license\r
- * model, information on which is provided below:\r
+ * This file is part of the FreeRTOS+UDP distribution.  The FreeRTOS+UDP license\r
+ * terms are different to the FreeRTOS license terms.\r
+ *\r
+ * FreeRTOS+UDP uses a dual license model that allows the software to be used\r
+ * under a standard GPL open source license, or a commercial license.  The\r
+ * standard GPL license (unlike the modified GPL license under which FreeRTOS\r
+ * itself is distributed) requires that all software statically linked with\r
+ * FreeRTOS+UDP is also distributed under the same GPL V2 license terms.\r
+ * Details of both license options follow:\r
  *\r
  * - Open source licensing -\r
- * FreeRTOS+UDP is a free download and may be used, modified and distributed\r
- * without charge provided the user adheres to version two of the GNU General\r
- * Public license (GPL) and does not remove the copyright notice or this text.\r
- * The GPL V2 text is available on the gnu.org web site, and on the following\r
- * URL: http://www.FreeRTOS.org/gpl-2.0.txt\r
+ * FreeRTOS+UDP is a free download and may be used, modified, evaluated and\r
+ * distributed without charge provided the user adheres to version two of the\r
+ * GNU General Public License (GPL) and does not remove the copyright notice or\r
+ * this text.  The GPL V2 text is available on the gnu.org web site, and on the\r
+ * following URL: http://www.FreeRTOS.org/gpl-2.0.txt.\r
  *\r
  * - Commercial licensing -\r
- * Businesses and individuals who wish to incorporate FreeRTOS+UDP into\r
- * proprietary software for redistribution in any form must first obtain a\r
- * (very) low cost commercial license - and in-so-doing support the maintenance,\r
- * support and further development of the FreeRTOS+UDP product.  Commercial\r
- * licenses can be obtained from http://shop.freertos.org and do not require any\r
- * source files to be changed.\r
+ * Businesses and individuals that for commercial or other reasons cannot comply\r
+ * with the terms of the GPL V2 license must obtain a commercial license before\r
+ * incorporating FreeRTOS+UDP into proprietary software for distribution in any\r
+ * form.  Commercial licenses can be purchased from http://shop.freertos.org/udp\r
+ * and do not require any source files to be changed.\r
  *\r
  * FreeRTOS+UDP is distributed in the hope that it will be useful.  You cannot\r
  * use FreeRTOS+UDP unless you agree that you use the software 'as is'.\r
@@ -131,10 +136,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
@@ -283,18 +290,21 @@ void vDHCPProcess( portBASE_TYPE xReset, xMACAddress_t *pxMACAddress, uint32_t *
                                                eDHCPState = eNotUsingLeasedAddress;\r
                                                xTimerStop( xDHCPTimer, ( portTickType ) 0 );\r
 \r
-                                               #if ipconfigFREERTOS_PLUS_NABTO == 1\r
-                                               {\r
-                                                       vStartNabtoTask();\r
-                                               }\r
-                                               #endif /* ipconfigFREERTOS_PLUS_NABTO */\r
-\r
                                                #if ipconfigUSE_NETWORK_EVENT_HOOK == 1\r
                                                {\r
                                                        vApplicationIPNetworkEventHook( eNetworkUp );\r
                                                }\r
                                                #endif\r
 \r
+                                               /* Static configuration is being used, so the network is now up. */\r
+                                               #if ipconfigFREERTOS_PLUS_NABTO == 1\r
+                                               {\r
+                                                       /* Return value is used in configASSERT() inside the\r
+                                                       function. */\r
+                                                       ( void ) xStartNabtoTask();\r
+                                               }\r
+                                               #endif /* ipconfigFREERTOS_PLUS_NABTO */\r
+\r
                                                /* Close socket to ensure packets don't queue on it. */\r
                                                FreeRTOS_closesocket( xDHCPSocket );\r
                                                xDHCPSocket = NULL;\r
@@ -313,18 +323,22 @@ void vDHCPProcess( portBASE_TYPE xReset, xMACAddress_t *pxMACAddress, uint32_t *
                                *pulIPAddress = ulOfferedIPAddress;\r
                                eDHCPState = eLeasedAddress;\r
 \r
-                               #if ipconfigFREERTOS_PLUS_NABTO == 1\r
-                               {\r
-                                       vStartNabtoTask();\r
-                               }\r
-                               #endif /* ipconfigFREERTOS_PLUS_NABTO */\r
-\r
                                #if ipconfigUSE_NETWORK_EVENT_HOOK == 1\r
                                {\r
                                        vApplicationIPNetworkEventHook( eNetworkUp );\r
                                }\r
                                #endif\r
 \r
+                               /* Static configuration is being used, so the network is now\r
+                               up. */\r
+                               #if ipconfigFREERTOS_PLUS_NABTO == 1\r
+                               {\r
+                                       /* Return value is used in configASSERT() inside the\r
+                                       function. */\r
+                                       ( void ) xStartNabtoTask();\r
+                               }\r
+                               #endif /* ipconfigFREERTOS_PLUS_NABTO */\r
+\r
                                /* Close socket to ensure packets don't queue on it. */\r
                                FreeRTOS_closesocket( xDHCPSocket );\r
                                xDHCPSocket = NULL;\r
@@ -437,7 +451,7 @@ extern void vIPFunctionsTimerCallback( xTimerHandle xTimer );
 \r
        if( xDHCPTimer == NULL )\r
        {\r
-               xDHCPTimer = xTimerCreate( ( const signed char * const ) "DHCP", dhcpINITIAL_TIMER_PERIOD, pdTRUE, ( void * ) eDHCPEvent, vIPFunctionsTimerCallback );\r
+               xDHCPTimer = xTimerCreate( "DHCP", dhcpINITIAL_TIMER_PERIOD, pdTRUE, ( void * ) eDHCPEvent, vIPFunctionsTimerCallback );\r
                configASSERT( xDHCPTimer );\r
                xTimerStart( xDHCPTimer, portMAX_DELAY );\r
        }\r
@@ -570,7 +584,7 @@ const uint32_t ulMandatoryOptions = 2; /* DHCP server address, and the correct D
                                                                (*1000) then ticks (/portTICK_RATE_MS). */\r
                                                                ulLeaseTime *= ( 1000UL / portTICK_RATE_MS );\r
 \r
-                                                               /* Divide the lease time to ensure a renew \r
+                                                               /* Divide the lease time to ensure a renew\r
                                                                request is sent before the lease actually\r
                                                                expires. */\r
                                                                ulLeaseTime >>= 1UL;\r
@@ -634,8 +648,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