]> git.sur5r.net Git - freertos/commitdiff
Fix mixed tabs and spaces in the latest TCP patches.
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 30 Aug 2018 18:25:53 +0000 (18:25 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 30 Aug 2018 18:25:53 +0000 (18:25 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2572 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DHCP.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DNS.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_IP.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_UDP_IP.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOSIPConfigDefaults.h
FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_TCP_WIN.h

index eef8ec84814e121f13734f0b434d396d88bdaa9d..8e475bf73810e063e857bff29258660f94289bda 100644 (file)
@@ -359,19 +359,19 @@ BaseType_t xGivingUp = pdFALSE;
 \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
@@ -592,23 +592,23 @@ TickType_t xTimeoutTime = ( TickType_t ) 0;
 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
@@ -633,13 +633,13 @@ const uint32_t ulMandatoryOptions = 2ul; /* DHCP server address, and the correct
 \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
@@ -665,36 +665,36 @@ const uint32_t ulMandatoryOptions = 2ul; /* DHCP server address, and the correct
                                                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
index 894b7240da2ddef9c8c62b6d0c469669e7676d71..1897f408d7528caae02bf29be99e1eaabfb4e5c3 100644 (file)
@@ -96,9 +96,9 @@ name field is an offset to the string, rather than the string itself. */
 the query will be responded to with these flags: */\r
 #define dnsNBNS_QUERY_RESPONSE_FLAGS   ( 0x8500 )\r
 \r
-/* Flag DNS parsing errors in situations where an IPv4 address is the return \r
+/* Flag DNS parsing errors in situations where an IPv4 address is the return\r
 type. */\r
-#define dnsPARSE_ERROR                      0UL\r
+#define dnsPARSE_ERROR                                   0UL\r
 \r
 /*\r
  * Create a socket and bind it to the standard DNS port number.  Return the\r
@@ -146,7 +146,7 @@ static uint32_t prvGetHostByName( const char *pcHostName, TickType_t xIdentifier
        {\r
                uint32_t ulIPAddress;           /* The IP address of an ARP cache entry. */\r
                char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ];  /* The name of the host */\r
-        uint32_t ulTTL; /* Time-to-Live (in seconds) from the DNS server. */\r
+               uint32_t ulTTL; /* Time-to-Live (in seconds) from the DNS server. */\r
                uint32_t ulTimeWhenAddedInSeconds;\r
        } DNSCacheRow_t;\r
 \r
@@ -189,10 +189,10 @@ typedef struct xDNSTail DNSTail_t;
 #include "pack_struct_start.h"\r
 struct xDNSAnswerRecord\r
 {\r
-    uint16_t usType;\r
-    uint16_t usClass;\r
-    uint32_t ulTTL;\r
-    uint16_t usDataLength;\r
+       uint16_t usType;\r
+       uint16_t usClass;\r
+       uint32_t ulTTL;\r
+       uint16_t usDataLength;\r
 }\r
 #include "pack_struct_end.h"\r
 typedef struct xDNSAnswerRecord DNSAnswerRecord_t;\r
@@ -416,67 +416,67 @@ uint32_t ulIPAddress = 0UL;
 TickType_t xReadTimeOut_ms = ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME;\r
 TickType_t xIdentifier = 0;\r
 \r
-    /* If the supplied hostname is IP address, convert it to uint32_t\r
-    and return. */\r
-    #if( ipconfigINCLUDE_FULL_INET_ADDR == 1 )\r
-    {\r
-        ulIPAddress = FreeRTOS_inet_addr( pcHostName );\r
-    }\r
-    #endif /* ipconfigINCLUDE_FULL_INET_ADDR == 1 */\r
-\r
-    /* If a DNS cache is used then check the cache before issuing another DNS\r
-    request. */\r
-    #if( ipconfigUSE_DNS_CACHE == 1 )\r
-    {\r
-        if( ulIPAddress == 0UL )\r
-        {\r
-            ulIPAddress = FreeRTOS_dnslookup( pcHostName );\r
-            if( ulIPAddress != 0 )\r
-            {\r
-                FreeRTOS_debug_printf( ( "FreeRTOS_gethostbyname: found '%s' in cache: %lxip\n", pcHostName, ulIPAddress ) );\r
-            }\r
-            else\r
-            {\r
-                /* prvGetHostByName will be called to start a DNS lookup */\r
-            }\r
-        }\r
-    }\r
-    #endif /* ipconfigUSE_DNS_CACHE == 1 */\r
-\r
-    /* Generate a unique identifier. */\r
-    if( 0 == ulIPAddress )\r
-    {\r
-        xIdentifier = ( TickType_t )ipconfigRAND32( );\r
-    }\r
-\r
-    #if( ipconfigDNS_USE_CALLBACKS != 0 )\r
-    {\r
-        if( pCallback != NULL )\r
-        {\r
-            if( ulIPAddress == 0UL )\r
-            {\r
-                /* The user has provided a callback function, so do not block on recvfrom() */\r
-                if( 0 != xIdentifier )\r
-                {\r
-                    xReadTimeOut_ms = 0;\r
-                    vDNSSetCallBack( pcHostName, pvSearchID, pCallback, xTimeout, ( TickType_t )xIdentifier );\r
-                }\r
-            }\r
-            else\r
-            {\r
-                /* The IP address is known, do the call-back now. */\r
-                pCallback( pcHostName, pvSearchID, ulIPAddress );\r
-            }\r
-        }\r
-    }\r
-    #endif\r
-\r
-    if( ulIPAddress == 0UL && 0 != xIdentifier )\r
-    {\r
-        ulIPAddress = prvGetHostByName( pcHostName, xIdentifier, xReadTimeOut_ms );\r
-    }\r
-\r
-    return ulIPAddress;\r
+       /* If the supplied hostname is IP address, convert it to uint32_t\r
+       and return. */\r
+       #if( ipconfigINCLUDE_FULL_INET_ADDR == 1 )\r
+       {\r
+               ulIPAddress = FreeRTOS_inet_addr( pcHostName );\r
+       }\r
+       #endif /* ipconfigINCLUDE_FULL_INET_ADDR == 1 */\r
+\r
+       /* If a DNS cache is used then check the cache before issuing another DNS\r
+       request. */\r
+       #if( ipconfigUSE_DNS_CACHE == 1 )\r
+       {\r
+               if( ulIPAddress == 0UL )\r
+               {\r
+                       ulIPAddress = FreeRTOS_dnslookup( pcHostName );\r
+                       if( ulIPAddress != 0 )\r
+                       {\r
+                               FreeRTOS_debug_printf( ( "FreeRTOS_gethostbyname: found '%s' in cache: %lxip\n", pcHostName, ulIPAddress ) );\r
+                       }\r
+                       else\r
+                       {\r
+                               /* prvGetHostByName will be called to start a DNS lookup */\r
+                       }\r
+               }\r
+       }\r
+       #endif /* ipconfigUSE_DNS_CACHE == 1 */\r
+\r
+       /* Generate a unique identifier. */\r
+       if( 0 == ulIPAddress )\r
+       {\r
+               xIdentifier = ( TickType_t )ipconfigRAND32( );\r
+       }\r
+\r
+       #if( ipconfigDNS_USE_CALLBACKS != 0 )\r
+       {\r
+               if( pCallback != NULL )\r
+               {\r
+                       if( ulIPAddress == 0UL )\r
+                       {\r
+                               /* The user has provided a callback function, so do not block on recvfrom() */\r
+                               if( 0 != xIdentifier )\r
+                               {\r
+                                       xReadTimeOut_ms = 0;\r
+                                       vDNSSetCallBack( pcHostName, pvSearchID, pCallback, xTimeout, ( TickType_t )xIdentifier );\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The IP address is known, do the call-back now. */\r
+                               pCallback( pcHostName, pvSearchID, ulIPAddress );\r
+                       }\r
+               }\r
+       }\r
+       #endif\r
+\r
+       if( ( ulIPAddress == 0UL ) && ( 0 != xIdentifier ) )\r
+       {\r
+               ulIPAddress = prvGetHostByName( pcHostName, xIdentifier, xReadTimeOut_ms );\r
+       }\r
+\r
+       return ulIPAddress;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -675,71 +675,71 @@ static const DNSMessage_t xDefaultPartDNSHeader =
        static uint8_t *prvReadNameField( uint8_t *pucByte, size_t xSourceLen, char *pcName, size_t xDestLen )\r
        {\r
        size_t xNameLen = 0;\r
-    BaseType_t xCount;\r
+       BaseType_t xCount;\r
 \r
-        if( 0 == xSourceLen )\r
-        {\r
-            return NULL;\r
-        }\r
+               if( 0 == xSourceLen )\r
+               {\r
+                       return NULL;\r
+               }\r
 \r
                /* Determine if the name is the fully coded name, or an offset to the name\r
                elsewhere in the message. */\r
                if( ( *pucByte & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET )\r
                {\r
                        /* Jump over the two byte offset. */\r
-            if( xSourceLen > sizeof( uint16_t ) )\r
-            {\r
-                pucByte += sizeof( uint16_t );\r
-            }\r
-            else\r
-            {\r
-                pucByte = NULL;\r
-            }\r
+                       if( xSourceLen > sizeof( uint16_t ) )\r
+                       {\r
+                               pucByte += sizeof( uint16_t );\r
+                       }\r
+                       else\r
+                       {\r
+                               pucByte = NULL;\r
+                       }\r
                }\r
                else\r
                {\r
                        /* pucByte points to the full name. Walk over the string. */\r
-                       while( NULL != pucByte && *pucByte != 0x00 && xSourceLen > 1 )\r
+                       while( ( NULL != pucByte ) && ( *pucByte != 0x00 ) && ( xSourceLen > 1 ) )\r
                        {\r
-                /* If this is not the first time through the loop, then add a \r
-                separator in the output. */\r
-                if( xNameLen > 0 && xNameLen < xDestLen - 1 )\r
-                {\r
-                    pcName[ xNameLen++ ] = '.';\r
-                }\r
-\r
-                /* Process the first/next sub-string. */\r
+                               /* If this is not the first time through the loop, then add a\r
+                               separator in the output. */\r
+                               if( ( xNameLen > 0 ) && ( xNameLen < ( xDestLen - 1 ) ) )\r
+                               {\r
+                                       pcName[ xNameLen++ ] = '.';\r
+                               }\r
+\r
+                               /* Process the first/next sub-string. */\r
                                for( xCount = *(pucByte++), xSourceLen--;\r
-                     xCount-- && xSourceLen > 1; \r
-                     pucByte++, xSourceLen-- )\r
+                                        xCount-- && xSourceLen > 1;\r
+                                        pucByte++, xSourceLen-- )\r
                                {\r
-                    if( xNameLen < xDestLen - 1 )\r
-                    {\r
-                        pcName[ xNameLen++ ] = *( ( char * )pucByte );\r
-                    }\r
-                    else\r
-                    {\r
-                        /* DNS name is too big for the provided buffer. */\r
-                        pucByte = NULL;\r
-                        break;\r
-                    }\r
+                                       if( xNameLen < xDestLen - 1 )\r
+                                       {\r
+                                               pcName[ xNameLen++ ] = *( ( char * )pucByte );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* DNS name is too big for the provided buffer. */\r
+                                               pucByte = NULL;\r
+                                               break;\r
+                                       }\r
                                }\r
                        }\r
 \r
-            /* Confirm that a fully formed name was found. */\r
-            if( NULL != pucByte )\r
-            {\r
-                if( 0x00 == *pucByte )\r
-                {\r
-                    pucByte++;\r
-                    xSourceLen--;\r
-                    pcName[ xNameLen++ ] = '\0';\r
-                }\r
-                else\r
-                {\r
-                    pucByte = NULL;\r
-                }\r
-            }\r
+                       /* Confirm that a fully formed name was found. */\r
+                       if( NULL != pucByte )\r
+                       {\r
+                               if( 0x00 == *pucByte )\r
+                               {\r
+                                       pucByte++;\r
+                                       xSourceLen--;\r
+                                       pcName[ xNameLen++ ] = '\0';\r
+                               }\r
+                               else\r
+                               {\r
+                                       pucByte = NULL;\r
+                               }\r
+                       }\r
                }\r
 \r
                return pucByte;\r
@@ -749,58 +749,58 @@ static const DNSMessage_t xDefaultPartDNSHeader =
 \r
 static uint8_t *prvSkipNameField( uint8_t *pucByte, size_t xSourceLen )\r
 {\r
-    size_t xChunkLength;\r
+       size_t xChunkLength;\r
 \r
-    if( 0 == xSourceLen )\r
-    {\r
-        return NULL;\r
-    }\r
+       if( 0 == xSourceLen )\r
+       {\r
+               return NULL;\r
+       }\r
 \r
-    /* Determine if the name is the fully coded name, or an offset to the name\r
+       /* Determine if the name is the fully coded name, or an offset to the name\r
        elsewhere in the message. */\r
        if( ( *pucByte & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET )\r
        {\r
                /* Jump over the two byte offset. */\r
-        if( xSourceLen > sizeof( uint16_t ) )\r
-        {\r
-            pucByte += sizeof( uint16_t );\r
-        }\r
-        else\r
-        {\r
-            pucByte = NULL;\r
-        }\r
+               if( xSourceLen > sizeof( uint16_t ) )\r
+               {\r
+                       pucByte += sizeof( uint16_t );\r
+               }\r
+               else\r
+               {\r
+                       pucByte = NULL;\r
+               }\r
        }\r
        else\r
        {\r
                /* pucByte points to the full name. Walk over the string. */\r
-               while( *pucByte != 0x00 && xSourceLen > 1 )\r
+               while( ( *pucByte != 0x00 ) && ( xSourceLen > 1 ) )\r
                {\r
-            xChunkLength = *pucByte + 1;\r
-\r
-            if( xSourceLen > xChunkLength )\r
-            {\r
-                xSourceLen -= xChunkLength;\r
-                pucByte += xChunkLength;\r
-            }\r
-            else\r
-            {\r
-                pucByte = NULL;\r
-                break;\r
-            }\r
+                       xChunkLength = *pucByte + 1;\r
+\r
+                       if( xSourceLen > xChunkLength )\r
+                       {\r
+                               xSourceLen -= xChunkLength;\r
+                               pucByte += xChunkLength;\r
+                       }\r
+                       else\r
+                       {\r
+                               pucByte = NULL;\r
+                               break;\r
+                       }\r
                }\r
 \r
-        /* Confirm that a fully formed name was found. */\r
-        if( NULL != pucByte )\r
-        {\r
-            if( 0x00 == *pucByte )\r
-            {\r
-                pucByte++;\r
-            }\r
-            else\r
-            {\r
-                pucByte = NULL;\r
-            }\r
-        }\r
+               /* Confirm that a fully formed name was found. */\r
+               if( NULL != pucByte )\r
+               {\r
+                       if( 0x00 == *pucByte )\r
+                       {\r
+                               pucByte++;\r
+                       }\r
+                       else\r
+                       {\r
+                               pucByte = NULL;\r
+                       }\r
+               }\r
        }\r
 \r
        return pucByte;\r
@@ -822,12 +822,12 @@ DNSMessage_t *pxDNSMessageHeader;
        pucUDPPayloadBuffer = pxNetworkBuffer->pucEthernetBuffer + sizeof( UDPPacket_t );\r
        pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer;\r
 \r
-    if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t ) )\r
-    {\r
-        prvParseDNSReply( pucUDPPayloadBuffer, \r
-            xPlayloadBufferLength,\r
-            ( uint32_t )pxDNSMessageHeader->usIdentifier );\r
-    }\r
+       if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t ) )\r
+       {\r
+               prvParseDNSReply( pucUDPPayloadBuffer,\r
+                       xPlayloadBufferLength,\r
+                       ( uint32_t )pxDNSMessageHeader->usIdentifier );\r
+       }\r
 \r
        /* The packet was not consumed. */\r
        return pdFAIL;\r
@@ -841,12 +841,12 @@ DNSMessage_t *pxDNSMessageHeader;
        UDPPacket_t *pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer;\r
        uint8_t *pucUDPPayloadBuffer = pxNetworkBuffer->pucEthernetBuffer + sizeof( UDPPacket_t );\r
 \r
-        if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t) )\r
-        {\r
-                   prvTreatNBNS( pucUDPPayloadBuffer, \r
-                          pxNetworkBuffer->xDataLength - sizeof( UDPPacket_t ),\r
-                          pxUDPPacket->xIPHeader.ulSourceIPAddress );\r
-        }\r
+               if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t) )\r
+               {\r
+                       prvTreatNBNS( pucUDPPayloadBuffer,\r
+                                                 pxNetworkBuffer->xDataLength - sizeof( UDPPacket_t ),\r
+                                                 pxUDPPacket->xIPHeader.ulSourceIPAddress );\r
+               }\r
 \r
                /* The packet was not consumed. */\r
                return pdFAIL;\r
@@ -870,27 +870,27 @@ uint16_t x, usDataLength, usQuestions;
        uint16_t usType = 0, usClass = 0;\r
 #endif\r
 #if( ipconfigUSE_DNS_CACHE == 1 )\r
-       char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ] = ""; \r
+       char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ] = "";\r
 #endif\r
 \r
-    /* Ensure that the buffer is of at least minimal DNS message length. */\r
-    if( xBufferLength < sizeof( DNSMessage_t ) )\r
-    {\r
-        return dnsPARSE_ERROR;\r
-    }\r
-    else\r
-    {\r
-        xSourceBytesRemaining = xBufferLength;\r
-    }\r
-\r
-    /* Parse the DNS message header. */\r
+       /* Ensure that the buffer is of at least minimal DNS message length. */\r
+       if( xBufferLength < sizeof( DNSMessage_t ) )\r
+       {\r
+               return dnsPARSE_ERROR;\r
+       }\r
+       else\r
+       {\r
+               xSourceBytesRemaining = xBufferLength;\r
+       }\r
+\r
+       /* Parse the DNS message header. */\r
        pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer;\r
 \r
        if( pxDNSMessageHeader->usIdentifier == ( uint16_t ) xIdentifier )\r
        {\r
                /* Start at the first byte after the header. */\r
                pucByte = pucUDPPayloadBuffer + sizeof( DNSMessage_t );\r
-        xSourceBytesRemaining -= sizeof( DNSMessage_t );\r
+               xSourceBytesRemaining -= sizeof( DNSMessage_t );\r
 \r
                /* Skip any question records. */\r
                usQuestions = FreeRTOS_ntohs( pxDNSMessageHeader->usQuestions );\r
@@ -908,59 +908,59 @@ uint16_t x, usDataLength, usQuestions;
 #if( ipconfigUSE_DNS_CACHE == 1 )\r
                        if( x == 0 )\r
                        {\r
-                               pucByte = prvReadNameField( pucByte, \r
-                                            xSourceBytesRemaining,\r
-                                            pcName, \r
-                                            sizeof( pcName ) );\r
-                \r
-                /* Check for a malformed response. */\r
-                if( NULL == pucByte )\r
-                {\r
-                    return dnsPARSE_ERROR;\r
-                }\r
-                else\r
-                {\r
-                    xSourceBytesRemaining = ( pucUDPPayloadBuffer + xBufferLength ) - pucByte;\r
-                }\r
+                               pucByte = prvReadNameField( pucByte,\r
+                                                                                       xSourceBytesRemaining,\r
+                                                                                       pcName,\r
+                                                                                       sizeof( pcName ) );\r
+\r
+                               /* Check for a malformed response. */\r
+                               if( NULL == pucByte )\r
+                               {\r
+                                       return dnsPARSE_ERROR;\r
+                               }\r
+                               else\r
+                               {\r
+                                       xSourceBytesRemaining = ( pucUDPPayloadBuffer + xBufferLength ) - pucByte;\r
+                               }\r
                        }\r
                        else\r
 #endif /* ipconfigUSE_DNS_CACHE */\r
                        {\r
                                /* Skip the variable length pcName field. */\r
-                               pucByte = prvSkipNameField( pucByte, \r
-                                            xSourceBytesRemaining );\r
-            \r
-                /* Check for a malformed response. */\r
-                if( NULL == pucByte )\r
-                {\r
-                    return dnsPARSE_ERROR;\r
-                }\r
-                else\r
-                {\r
-                    xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte;\r
-                }\r
-            }\r
-\r
-            /* Check the remaining buffer size. */\r
-            if( xSourceBytesRemaining >= sizeof( uint32_t ) )\r
-            {\r
-                #if( ipconfigUSE_LLMNR == 1 )\r
-                {\r
-                    /* usChar2u16 returns value in host endianness */\r
-                    usType = usChar2u16( pucByte );\r
-                    usClass = usChar2u16( pucByte + 2 );\r
-                }\r
-                #endif /* ipconfigUSE_LLMNR */\r
-\r
-                /* Skip the type and class fields. */\r
-                pucByte += sizeof( uint32_t );\r
-                xSourceBytesRemaining -= sizeof( uint32_t );\r
-            }\r
-            else\r
-            {\r
-                /* Malformed response. */\r
-                return dnsPARSE_ERROR;\r
-            }\r
+                               pucByte = prvSkipNameField( pucByte,\r
+                                                                                       xSourceBytesRemaining );\r
+\r
+                               /* Check for a malformed response. */\r
+                               if( NULL == pucByte )\r
+                               {\r
+                                       return dnsPARSE_ERROR;\r
+                               }\r
+                               else\r
+                               {\r
+                                       xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte;\r
+                               }\r
+                       }\r
+\r
+                       /* Check the remaining buffer size. */\r
+                       if( xSourceBytesRemaining >= sizeof( uint32_t ) )\r
+                       {\r
+                               #if( ipconfigUSE_LLMNR == 1 )\r
+                               {\r
+                                       /* usChar2u16 returns value in host endianness */\r
+                                       usType = usChar2u16( pucByte );\r
+                                       usClass = usChar2u16( pucByte + 2 );\r
+                               }\r
+                               #endif /* ipconfigUSE_LLMNR */\r
+\r
+                               /* Skip the type and class fields. */\r
+                               pucByte += sizeof( uint32_t );\r
+                               xSourceBytesRemaining -= sizeof( uint32_t );\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Malformed response. */\r
+                               return dnsPARSE_ERROR;\r
+                       }\r
                }\r
 \r
                /* Search through the answer records. */\r
@@ -971,33 +971,33 @@ uint16_t x, usDataLength, usQuestions;
                        for( x = 0; x < pxDNSMessageHeader->usAnswers; x++ )\r
                        {\r
                                pucByte = prvSkipNameField( pucByte,\r
-                                            xSourceBytesRemaining );\r
-\r
-                /* Check for a malformed response. */\r
-                if( NULL == pucByte )\r
-                {\r
-                    return dnsPARSE_ERROR;\r
-                }\r
-                else\r
-                {\r
-                    xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte;\r
-                }\r
-\r
-                               /* Is there enough data for an IPv4 A record answer and, if so, \r
-                is this an A record? */\r
-                               if( xSourceBytesRemaining >= sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) && \r
-                    usChar2u16( pucByte ) == dnsTYPE_A_HOST )\r
+                                                                                       xSourceBytesRemaining );\r
+\r
+                               /* Check for a malformed response. */\r
+                               if( NULL == pucByte )\r
+                               {\r
+                                       return dnsPARSE_ERROR;\r
+                               }\r
+                               else\r
+                               {\r
+                                       xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte;\r
+                               }\r
+\r
+                               /* Is there enough data for an IPv4 A record answer and, if so,\r
+                               is this an A record? */\r
+                               if( xSourceBytesRemaining >= sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) &&\r
+                                       usChar2u16( pucByte ) == dnsTYPE_A_HOST )\r
                                {\r
                                        /* This is the required record type and is of sufficient size. */\r
-                    pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte;\r
+                                       pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte;\r
 \r
                                        /* Sanity check the data length of an IPv4 answer. */\r
                                        if( FreeRTOS_ntohs( pxDNSAnswerRecord->usDataLength ) == sizeof( uint32_t ) )\r
                                        {\r
                                                /* Copy the IP address out of the record. */\r
-                                               memcpy( &ulIPAddress, \r
-                                pucByte + sizeof( DNSAnswerRecord_t ),\r
-                                sizeof( uint32_t ) );\r
+                                               memcpy( &ulIPAddress,\r
+                                                               pucByte + sizeof( DNSAnswerRecord_t ),\r
+                                                               sizeof( uint32_t ) );\r
 \r
                                                #if( ipconfigUSE_DNS_CACHE == 1 )\r
                                                {\r
@@ -1012,32 +1012,32 @@ uint16_t x, usDataLength, usQuestions;
                                                #endif  /* ipconfigDNS_USE_CALLBACKS != 0 */\r
                                        }\r
 \r
-                    pucByte += sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t );\r
-                    xSourceBytesRemaining -= ( sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) );\r
+                                       pucByte += sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t );\r
+                                       xSourceBytesRemaining -= ( sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) );\r
                                        break;\r
                                }\r
                                else if( xSourceBytesRemaining >= sizeof( DNSAnswerRecord_t ) )\r
                                {\r
-                    /* It's not an A record, so skip it. Get the header location \r
-                    and then jump over the header. */\r
-                    pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte;\r
-                    pucByte += sizeof( DNSAnswerRecord_t );\r
-                    xSourceBytesRemaining -= sizeof( DNSAnswerRecord_t );\r
-                    \r
+                                       /* It's not an A record, so skip it. Get the header location\r
+                                       and then jump over the header. */\r
+                                       pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte;\r
+                                       pucByte += sizeof( DNSAnswerRecord_t );\r
+                                       xSourceBytesRemaining -= sizeof( DNSAnswerRecord_t );\r
+\r
                                        /* Determine the length of the answer data from the header. */\r
                                        usDataLength = FreeRTOS_ntohs( pxDNSAnswerRecord->usDataLength );\r
 \r
                                        /* Jump over the answer. */\r
-                    if( xSourceBytesRemaining >= usDataLength )\r
-                    {\r
-                        pucByte += usDataLength;\r
-                        xSourceBytesRemaining -= usDataLength;\r
-                    }\r
-                    else\r
-                    {\r
-                        /* Malformed response. */\r
-                        return dnsPARSE_ERROR;\r
-                    }\r
+                                       if( xSourceBytesRemaining >= usDataLength )\r
+                                       {\r
+                                               pucByte += usDataLength;\r
+                                               xSourceBytesRemaining -= usDataLength;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* Malformed response. */\r
+                                               return dnsPARSE_ERROR;\r
+                                       }\r
                                }\r
                        }\r
                }\r
@@ -1055,8 +1055,7 @@ uint16_t x, usDataLength, usQuestions;
 \r
                                if( ( xBufferAllocFixedSize == pdFALSE ) && ( pxNetworkBuffer != NULL ) )\r
                                {\r
-                               BaseType_t xDataLength = xBufferLength + sizeof( UDPHeader_t ) +\r
-                                       sizeof( EthernetHeader_t ) + sizeof( IPHeader_t );\r
+                               BaseType_t xDataLength = xBufferLength + sizeof( UDPHeader_t ) + sizeof( EthernetHeader_t ) + sizeof( IPHeader_t );\r
 \r
                                        /* The field xDataLength was set to the length of the UDP payload.\r
                                        The answer (reply) will be longer than the request, so the packet\r
@@ -1130,13 +1129,13 @@ uint16_t x, usDataLength, usQuestions;
                uint8_t ucByte;\r
                uint8_t ucNBNSName[ 17 ];\r
 \r
-        /* Check for minimum buffer size. */\r
-        if( xBufferLength < sizeof( NBNSRequest_t ) )\r
-        {\r
-            return;\r
-        }\r
-        \r
-        /* Read the request flags in host endianness. */\r
+               /* Check for minimum buffer size. */\r
+               if( xBufferLength < sizeof( NBNSRequest_t ) )\r
+               {\r
+                       return;\r
+               }\r
+\r
+               /* Read the request flags in host endianness. */\r
                usFlags = usChar2u16( pucUDPPayloadBuffer + offsetof( NBNSRequest_t, usFlags ) );\r
 \r
                if( ( usFlags & dnsNBNS_FLAGS_OPCODE_MASK ) == dnsNBNS_FLAGS_OPCODE_QUERY )\r
@@ -1303,22 +1302,22 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
                pxIPHeader = &pxUDPPacket->xIPHeader;\r
                pxUDPHeader = &pxUDPPacket->xUDPHeader;\r
                /* HT: started using defines like 'ipSIZE_OF_xxx' */\r
-               pxIPHeader->usLength               = FreeRTOS_htons( lNetLength + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_UDP_HEADER );\r
+               pxIPHeader->usLength                       = FreeRTOS_htons( lNetLength + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_UDP_HEADER );\r
                /* HT:endian: should not be translated, copying from packet to packet */\r
                pxIPHeader->ulDestinationIPAddress = pxIPHeader->ulSourceIPAddress;\r
-               pxIPHeader->ulSourceIPAddress      = *ipLOCAL_IP_ADDRESS_POINTER;\r
-               pxIPHeader->ucTimeToLive           = ipconfigUDP_TIME_TO_LIVE;\r
-               pxIPHeader->usIdentification       = FreeRTOS_htons( usPacketIdentifier );\r
+               pxIPHeader->ulSourceIPAddress      = *ipLOCAL_IP_ADDRESS_POINTER;\r
+               pxIPHeader->ucTimeToLive                   = ipconfigUDP_TIME_TO_LIVE;\r
+               pxIPHeader->usIdentification       = FreeRTOS_htons( usPacketIdentifier );\r
                usPacketIdentifier++;\r
-               pxUDPHeader->usLength              = FreeRTOS_htons( lNetLength + ipSIZE_OF_UDP_HEADER );\r
+               pxUDPHeader->usLength                      = FreeRTOS_htons( lNetLength + ipSIZE_OF_UDP_HEADER );\r
                vFlip_16( pxUDPPacket->xUDPHeader.usSourcePort, pxUDPPacket->xUDPHeader.usDestinationPort );\r
 \r
                #if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 )\r
                {\r
                        /* calculate the IP header checksum */\r
-                       pxIPHeader->usHeaderChecksum       = 0x00;\r
-                       pxIPHeader->usHeaderChecksum       = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER );\r
-                       pxIPHeader->usHeaderChecksum       = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );\r
+                       pxIPHeader->usHeaderChecksum       = 0x00;\r
+                       pxIPHeader->usHeaderChecksum       = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER );\r
+                       pxIPHeader->usHeaderChecksum       = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );\r
 \r
                        /* calculate the UDP checksum for outgoing package */\r
                        usGenerateProtocolChecksum( ( uint8_t* ) pxUDPPacket, lNetLength, pdTRUE );\r
@@ -1341,8 +1340,7 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
        {\r
        BaseType_t x;\r
        BaseType_t xFound = pdFALSE;\r
-    uint32_t ulCurrentTimeSeconds = \r
-        xTaskGetTickCount( ) / portTICK_PERIOD_MS / 1000;\r
+       uint32_t ulCurrentTimeSeconds = ( xTaskGetTickCount() / portTICK_PERIOD_MS ) / 1000;\r
        static BaseType_t xFreeEntry = 0;\r
 \r
                /* For each entry in the DNS cache table. */\r
@@ -1358,24 +1356,22 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
                                /* Is this function called for a lookup or to add/update an IP address? */\r
                                if( xLookUp != pdFALSE )\r
                                {\r
-                    /* Confirm that the record is still fresh. */\r
-                    if( ulCurrentTimeSeconds < \r
-                            xDNSCache[ x ].ulTimeWhenAddedInSeconds + \r
-                            FreeRTOS_ntohl( xDNSCache[ x ].ulTTL ) )\r
-                    {\r
-                        *pulIP = xDNSCache[ x ].ulIPAddress;\r
-                    }\r
-                    else\r
-                    {\r
-                        /* Age out the old cached record. */\r
-                        xDNSCache[ x ].pcName[ 0 ] = 0;\r
-                    }\r
+                                       /* Confirm that the record is still fresh. */\r
+                                       if( ulCurrentTimeSeconds < ( xDNSCache[ x ].ulTimeWhenAddedInSeconds + FreeRTOS_ntohl( xDNSCache[ x ].ulTTL ) ) )\r
+                                       {\r
+                                               *pulIP = xDNSCache[ x ].ulIPAddress;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* Age out the old cached record. */\r
+                                               xDNSCache[ x ].pcName[ 0 ] = 0;\r
+                                       }\r
                                }\r
                                else\r
                                {\r
                                        xDNSCache[ x ].ulIPAddress = *pulIP;\r
-                    xDNSCache[ x ].ulTTL = ulTTL;\r
-                    xDNSCache[ x ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds;\r
+                                       xDNSCache[ x ].ulTTL = ulTTL;\r
+                                       xDNSCache[ x ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds;\r
                                }\r
 \r
                                xFound = pdTRUE;\r
@@ -1392,20 +1388,20 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
                        else\r
                        {\r
                                /* Add or update the item. */\r
-                if( strlen( pcName ) < ipconfigDNS_CACHE_NAME_LENGTH )\r
-                {\r
-                    strcpy( xDNSCache[ xFreeEntry ].pcName, pcName );\r
-\r
-                    xDNSCache[ xFreeEntry ].ulIPAddress = *pulIP;\r
-                    xDNSCache[ xFreeEntry ].ulTTL = ulTTL;\r
-                    xDNSCache[ xFreeEntry ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds;\r
-\r
-                    xFreeEntry++;\r
-                    if( xFreeEntry == ipconfigDNS_CACHE_ENTRIES )\r
-                    {\r
-                        xFreeEntry = 0;\r
-                    }\r
-                }\r
+                               if( strlen( pcName ) < ipconfigDNS_CACHE_NAME_LENGTH )\r
+                               {\r
+                                       strcpy( xDNSCache[ xFreeEntry ].pcName, pcName );\r
+\r
+                                       xDNSCache[ xFreeEntry ].ulIPAddress = *pulIP;\r
+                                       xDNSCache[ xFreeEntry ].ulTTL = ulTTL;\r
+                                       xDNSCache[ xFreeEntry ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds;\r
+\r
+                                       xFreeEntry++;\r
+                                       if( xFreeEntry == ipconfigDNS_CACHE_ENTRIES )\r
+                                       {\r
+                                               xFreeEntry = 0;\r
+                                       }\r
+                               }\r
                        }\r
                }\r
 \r
@@ -1423,5 +1419,6 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
 \r
 /* Provide access to private members for testing. */\r
 #ifdef AMAZON_FREERTOS_ENABLE_UNIT_TESTS\r
-    #include "aws_freertos_tcp_test_access_dns_define.h"\r
+       #include "aws_freertos_tcp_test_access_dns_define.h"\r
 #endif\r
+\r
index fdb8fd11653a277e24cf556bc7689f9089c664b3..996b5283863f8ecbef53c4b082b0356779b1f480 100644 (file)
@@ -357,7 +357,8 @@ struct freertos_sockaddr xAddress;
                /* Wait until there is something to do. If the following call exits\r
                 * due to a time out rather than a message being received, set a\r
                 * 'NoEvent' value. */\r
-               if ( xQueueReceive( xNetworkEventQueue, ( void * ) &xReceivedEvent, xNextIPSleep ) == pdFALSE ) {\r
+               if ( xQueueReceive( xNetworkEventQueue, ( void * ) &xReceivedEvent, xNextIPSleep ) == pdFALSE ) \r
+               {\r
                        xReceivedEvent.eEventType = eNoEvent;\r
                }\r
 \r
@@ -803,9 +804,8 @@ void *pvReturn;
 \r
        if( pxNetworkBuffer != NULL )\r
        {\r
-        /* Set the actual packet size in case a bigger buffer was returned. */\r
-        pxNetworkBuffer->xDataLength = \r
-            sizeof( UDPPacket_t ) + xRequestedSizeBytes;\r
+               /* Set the actual packet size in case a bigger buffer was returned. */\r
+               pxNetworkBuffer->xDataLength = sizeof( UDPPacket_t ) + xRequestedSizeBytes;\r
 \r
                /* Leave space for the UPD header. */\r
                pvReturn = ( void * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] );\r
@@ -831,11 +831,11 @@ NetworkBufferDescriptor_t * pxNewBuffer;
 \r
        if( pxNewBuffer != NULL )\r
        {\r
-        /* Set the actual packet size in case a bigger buffer than requested \r
-        was returned. */\r
-        pxNewBuffer->xDataLength = xNewLength;\r
+               /* Set the actual packet size in case a bigger buffer than requested\r
+               was returned. */\r
+               pxNewBuffer->xDataLength = xNewLength;\r
 \r
-        /* Copy the original packet information. */\r
+               /* Copy the original packet information. */\r
                pxNewBuffer->ulIPAddress = pxNetworkBuffer->ulIPAddress;\r
                pxNewBuffer->usPort = pxNetworkBuffer->usPort;\r
                pxNewBuffer->usBoundPort = pxNetworkBuffer->usBoundPort;\r
@@ -995,13 +995,13 @@ BaseType_t xReturn = pdFALSE;
                        memcpy( ( void * ) ipLOCAL_MAC_ADDRESS, ( void * ) ucMACAddress, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES );\r
 \r
                        /* Prepare the sockets interface. */\r
-            xReturn = vNetworkSocketsInit();\r
-            \r
-            if( pdTRUE == xReturn )\r
-            {\r
-                /* Create the task that processes Ethernet and stack events. */\r
-                xReturn = xTaskCreate( prvIPTask, "IP-task", ( uint16_t )ipconfigIP_TASK_STACK_SIZE_WORDS, NULL, ( UBaseType_t )ipconfigIP_TASK_PRIORITY, &xIPTaskHandle );\r
-            }\r
+                       xReturn = vNetworkSocketsInit();\r
+\r
+                       if( pdTRUE == xReturn )\r
+                       {\r
+                               /* Create the task that processes Ethernet and stack events. */\r
+                               xReturn = xTaskCreate( prvIPTask, "IP-task", ( uint16_t )ipconfigIP_TASK_STACK_SIZE_WORDS, NULL, ( UBaseType_t )ipconfigIP_TASK_PRIORITY, &xIPTaskHandle );\r
+                       }\r
                }\r
                else\r
                {\r
@@ -1350,47 +1350,47 @@ eFrameProcessingResult_t eReturned = eReleaseBuffer;
        configASSERT( pxNetworkBuffer );\r
 \r
        /* Interpret the Ethernet frame. */\r
-    if( pxNetworkBuffer->xDataLength >= sizeof( EthernetHeader_t ) )\r
-    {\r
-        eReturned = ipCONSIDER_FRAME_FOR_PROCESSING( pxNetworkBuffer->pucEthernetBuffer );\r
-        pxEthernetHeader = ( EthernetHeader_t * )( pxNetworkBuffer->pucEthernetBuffer );\r
-\r
-        if( eReturned == eProcessBuffer )\r
-        {\r
-            /* Interpret the received Ethernet packet. */\r
-            switch( pxEthernetHeader->usFrameType )\r
-            {\r
-            case ipARP_FRAME_TYPE:\r
-                /* The Ethernet frame contains an ARP packet. */\r
-                if( pxNetworkBuffer->xDataLength >= sizeof( ARPPacket_t ) )\r
-                {\r
-                    eReturned = eARPProcessPacket( ( ARPPacket_t * )pxNetworkBuffer->pucEthernetBuffer );\r
-                }\r
-                else\r
-                {\r
-                    eReturned = eReleaseBuffer;\r
-                }\r
-                break;\r
-\r
-            case ipIPv4_FRAME_TYPE:\r
-                /* The Ethernet frame contains an IP packet. */\r
-                if( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) )\r
-                {\r
-                    eReturned = prvProcessIPPacket( ( IPPacket_t * )pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer );\r
-                }\r
-                else\r
-                {\r
-                    eReturned = eReleaseBuffer;\r
-                }\r
-                break;\r
-\r
-            default:\r
-                /* No other packet types are handled.  Nothing to do. */\r
-                eReturned = eReleaseBuffer;\r
-                break;\r
-            }\r
-        }\r
-    }\r
+       if( pxNetworkBuffer->xDataLength >= sizeof( EthernetHeader_t ) )\r
+       {\r
+               eReturned = ipCONSIDER_FRAME_FOR_PROCESSING( pxNetworkBuffer->pucEthernetBuffer );\r
+               pxEthernetHeader = ( EthernetHeader_t * )( pxNetworkBuffer->pucEthernetBuffer );\r
+\r
+               if( eReturned == eProcessBuffer )\r
+               {\r
+                       /* Interpret the received Ethernet packet. */\r
+                       switch( pxEthernetHeader->usFrameType )\r
+                       {\r
+                       case ipARP_FRAME_TYPE:\r
+                               /* The Ethernet frame contains an ARP packet. */\r
+                               if( pxNetworkBuffer->xDataLength >= sizeof( ARPPacket_t ) )\r
+                               {\r
+                                       eReturned = eARPProcessPacket( ( ARPPacket_t * )pxNetworkBuffer->pucEthernetBuffer );\r
+                               }\r
+                               else\r
+                               {\r
+                                       eReturned = eReleaseBuffer;\r
+                               }\r
+                               break;\r
+\r
+                       case ipIPv4_FRAME_TYPE:\r
+                               /* The Ethernet frame contains an IP packet. */\r
+                               if( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) )\r
+                               {\r
+                                       eReturned = prvProcessIPPacket( ( IPPacket_t * )pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer );\r
+                               }\r
+                               else\r
+                               {\r
+                                       eReturned = eReleaseBuffer;\r
+                               }\r
+                               break;\r
+\r
+                       default:\r
+                               /* No other packet types are handled.  Nothing to do. */\r
+                               eReturned = eReleaseBuffer;\r
+                               break;\r
+                       }\r
+               }\r
+       }\r
 \r
        /* Perform any actions that resulted from processing the Ethernet frame. */\r
        switch( eReturned )\r
@@ -1513,14 +1513,14 @@ IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader );
 UBaseType_t uxHeaderLength = ( UBaseType_t ) ( ( pxIPHeader->ucVersionHeaderLength & 0x0Fu ) << 2 );\r
 uint8_t ucProtocol;\r
 \r
-    /* Bound the calculated header length: take away the Ethernet header size,\r
-    then check if the IP header is claiming to be longer than the remaining\r
-    total packet size. Also check for minimal header field length. */\r
-    if( uxHeaderLength > pxNetworkBuffer->xDataLength - ipSIZE_OF_ETH_HEADER ||\r
-        uxHeaderLength < ipSIZE_OF_IPv4_HEADER )\r
-    {\r
-        return eReleaseBuffer;\r
-    }\r
+       /* Bound the calculated header length: take away the Ethernet header size,\r
+       then check if the IP header is claiming to be longer than the remaining\r
+       total packet size. Also check for minimal header field length. */\r
+       if( ( uxHeaderLength > ( pxNetworkBuffer->xDataLength - ipSIZE_OF_ETH_HEADER ) ) ||\r
+               ( uxHeaderLength < ipSIZE_OF_IPv4_HEADER ) )\r
+       {\r
+               return eReleaseBuffer;\r
+       }\r
 \r
        ucProtocol = pxIPPacket->xIPHeader.ucProtocol;\r
        /* Check if the IP headers are acceptable and if it has our destination. */\r
@@ -1544,10 +1544,9 @@ uint8_t ucProtocol;
                        memmove( pucTarget, pucSource, xMoveLen );\r
                        pxNetworkBuffer->xDataLength -= optlen;\r
 \r
-            /* Fix-up new version/header length field in IP packet. */\r
-            pxIPHeader->ucVersionHeaderLength =\r
-                ( pxIPHeader->ucVersionHeaderLength & 0xF0 ) | /* High nibble is the version. */\r
-                ( ( ipSIZE_OF_IPv4_HEADER >> 2 ) & 0x0F ); /* Low nibble is the header size, in bytes, divided by four. */\r
+                       /* Fix-up new version/header length field in IP packet. */\r
+                       pxIPHeader->ucVersionHeaderLength = ( pxIPHeader->ucVersionHeaderLength & 0xF0 ) | /* High nibble is the version. */\r
+                                                                                               ( ( ipSIZE_OF_IPv4_HEADER >> 2 ) & 0x0F ); /* Low nibble is the header size, in bytes, divided by four. */\r
                }\r
 \r
                /* Add the IP and MAC addresses to the ARP table if they are not\r
@@ -1573,18 +1572,18 @@ uint8_t ucProtocol;
                                be able to validate what it receives. */\r
                                #if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 )\r
                                {\r
-                    if( pxNetworkBuffer->xDataLength >= sizeof( ICMPPacket_t ) )\r
-                    {\r
-                        ICMPPacket_t *pxICMPPacket = ( ICMPPacket_t * )( pxNetworkBuffer->pucEthernetBuffer );\r
-                        if( pxIPHeader->ulDestinationIPAddress == *ipLOCAL_IP_ADDRESS_POINTER )\r
-                        {\r
-                            eReturn = prvProcessICMPPacket( pxICMPPacket );\r
-                        }\r
-                    }\r
-                    else\r
-                    {\r
-                        eReturn = eReleaseBuffer;\r
-                    }\r
+                                       if( pxNetworkBuffer->xDataLength >= sizeof( ICMPPacket_t ) )\r
+                                       {\r
+                                               ICMPPacket_t *pxICMPPacket = ( ICMPPacket_t * )( pxNetworkBuffer->pucEthernetBuffer );\r
+                                               if( pxIPHeader->ulDestinationIPAddress == *ipLOCAL_IP_ADDRESS_POINTER )\r
+                                               {\r
+                                                       eReturn = prvProcessICMPPacket( pxICMPPacket );\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               eReturn = eReleaseBuffer;\r
+                                       }\r
                                }\r
                                #endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) */\r
                                break;\r
@@ -1594,47 +1593,46 @@ uint8_t ucProtocol;
                                        /* The IP packet contained a UDP frame. */\r
                                        UDPPacket_t *pxUDPPacket = ( UDPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer );\r
 \r
-                    /* Only proceed if the payload length indicated in the header\r
-                    appears to be valid. */\r
-                    if ( pxNetworkBuffer->xDataLength >= sizeof( UDPPacket_t ) )\r
-                    {\r
-                        /* Ensure that downstream UDP packet handling has the lesser\r
-                         * of: the actual network buffer Ethernet frame length, or \r
-                         * the sender's UDP packet header payload length, minus the\r
-                         * size of the UDP header. \r
-                         *\r
-                         * The size of the UDP packet structure in this implementation \r
-                         * includes the size of the Ethernet header, the size of \r
-                         * the IP header, and the size of the UDP header.\r
-                         */\r
-                         \r
-                        pxNetworkBuffer->xDataLength -= sizeof( UDPPacket_t );\r
-                        if( ( FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t ) ) <\r
-                                pxNetworkBuffer->xDataLength )\r
-                        {\r
-                            pxNetworkBuffer->xDataLength = FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - \r
-                                    sizeof( UDPHeader_t );\r
-                        }\r
-\r
-                        /* Fields in pxNetworkBuffer (usPort, ulIPAddress) are network order. */\r
-                        pxNetworkBuffer->usPort = pxUDPPacket->xUDPHeader.usSourcePort;\r
-                        pxNetworkBuffer->ulIPAddress = pxUDPPacket->xIPHeader.ulSourceIPAddress;\r
-\r
-                        /* ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM:\r
-                         * In some cases, the upper-layer checksum has been calculated\r
-                         * by the NIC driver.\r
-                         * \r
-                         * Pass the packet payload to the UDP sockets implementation. */\r
-                        if( xProcessReceivedUDPPacket( pxNetworkBuffer, \r
-                                                       pxUDPPacket->xUDPHeader.usDestinationPort ) == pdPASS )\r
-                        {\r
-                            eReturn = eFrameConsumed;\r
-                        }\r
-                    }\r
-                    else\r
-                    {\r
-                        eReturn = eReleaseBuffer;\r
-                    }\r
+                                       /* Only proceed if the payload length indicated in the header\r
+                                       appears to be valid. */\r
+                                       if ( pxNetworkBuffer->xDataLength >= sizeof( UDPPacket_t ) )\r
+                                       {\r
+                                               /* Ensure that downstream UDP packet handling has the lesser\r
+                                                * of: the actual network buffer Ethernet frame length, or\r
+                                                * the sender's UDP packet header payload length, minus the\r
+                                                * size of the UDP header.\r
+                                                *\r
+                                                * The size of the UDP packet structure in this implementation\r
+                                                * includes the size of the Ethernet header, the size of\r
+                                                * the IP header, and the size of the UDP header.\r
+                                                */\r
+\r
+                                               pxNetworkBuffer->xDataLength -= sizeof( UDPPacket_t );\r
+                                               if( ( FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t ) ) <\r
+                                                               pxNetworkBuffer->xDataLength )\r
+                                               {\r
+                                                       pxNetworkBuffer->xDataLength = FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t );\r
+                                               }\r
+\r
+                                               /* Fields in pxNetworkBuffer (usPort, ulIPAddress) are network order. */\r
+                                               pxNetworkBuffer->usPort = pxUDPPacket->xUDPHeader.usSourcePort;\r
+                                               pxNetworkBuffer->ulIPAddress = pxUDPPacket->xIPHeader.ulSourceIPAddress;\r
+\r
+                                               /* ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM:\r
+                                                * In some cases, the upper-layer checksum has been calculated\r
+                                                * by the NIC driver.\r
+                                                *\r
+                                                * Pass the packet payload to the UDP sockets implementation. */\r
+                                               if( xProcessReceivedUDPPacket( pxNetworkBuffer,\r
+                                                                                                          pxUDPPacket->xUDPHeader.usDestinationPort ) == pdPASS )\r
+                                               {\r
+                                                       eReturn = eFrameConsumed;\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               eReturn = eReleaseBuffer;\r
+                                       }\r
                                }\r
                                break;\r
 \r
@@ -1803,47 +1801,46 @@ uint8_t ucProtocol;
        const char *pcType;\r
 #endif\r
 \r
-    /* Check for minimum packet size. */\r
-    if( uxBufferLength < sizeof( IPPacket_t ) )\r
-    {\r
-        return ipINVALID_LENGTH;\r
-    }\r
+       /* Check for minimum packet size. */\r
+       if( uxBufferLength < sizeof( IPPacket_t ) )\r
+       {\r
+               return ipINVALID_LENGTH;\r
+       }\r
 \r
-    /* Parse the packet length. */\r
+       /* Parse the packet length. */\r
        pxIPPacket = ( const IPPacket_t * ) pucEthernetBuffer;\r
-    \r
-    /* Per https://tools.ietf.org/html/rfc791, the four-bit Internet Header \r
-    Length field contains the length of the internet header in 32-bit words. */\r
-       uxIPHeaderLength = ( UBaseType_t ) \r
-        ( sizeof( uint32_t ) * ( pxIPPacket->xIPHeader.ucVersionHeaderLength & 0x0Fu ) ); \r
-\r
-    /* Check for minimum packet size. */\r
-    if( uxBufferLength < sizeof( IPPacket_t ) + uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER )\r
-    {\r
-        return ipINVALID_LENGTH;\r
-    }\r
-    if( uxBufferLength < FreeRTOS_ntohs( pxIPPacket->xIPHeader.usLength ) )\r
-    {\r
-        return ipINVALID_LENGTH;\r
-    }\r
-\r
-    /* Identify the next protocol. */\r
-    ucProtocol = pxIPPacket->xIPHeader.ucProtocol; \r
-\r
-    /* N.B., if this IP packet header includes Options, then the following \r
-    assignment results in a pointer into the protocol packet with the Ethernet \r
-    and IP headers incorrectly aligned. However, either way, the "third"\r
-    protocol (Layer 3 or 4) header will be aligned, which is the convenience \r
-    of this calculation. */\r
-    pxProtPack = ( ProtocolPacket_t * ) ( pucEthernetBuffer + ( uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ) );\r
-\r
-    /* Switch on the Layer 3/4 protocol. */\r
+\r
+       /* Per https://tools.ietf.org/html/rfc791, the four-bit Internet Header\r
+       Length field contains the length of the internet header in 32-bit words. */\r
+       uxIPHeaderLength = ( UBaseType_t ) ( sizeof( uint32_t ) * ( pxIPPacket->xIPHeader.ucVersionHeaderLength & 0x0Fu ) );\r
+\r
+       /* Check for minimum packet size. */\r
+       if( uxBufferLength < sizeof( IPPacket_t ) + uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER )\r
+       {\r
+               return ipINVALID_LENGTH;\r
+       }\r
+       if( uxBufferLength < FreeRTOS_ntohs( pxIPPacket->xIPHeader.usLength ) )\r
+       {\r
+               return ipINVALID_LENGTH;\r
+       }\r
+\r
+       /* Identify the next protocol. */\r
+       ucProtocol = pxIPPacket->xIPHeader.ucProtocol;\r
+\r
+       /* N.B., if this IP packet header includes Options, then the following\r
+       assignment results in a pointer into the protocol packet with the Ethernet\r
+       and IP headers incorrectly aligned. However, either way, the "third"\r
+       protocol (Layer 3 or 4) header will be aligned, which is the convenience\r
+       of this calculation. */\r
+       pxProtPack = ( ProtocolPacket_t * ) ( pucEthernetBuffer + ( uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ) );\r
+\r
+       /* Switch on the Layer 3/4 protocol. */\r
        if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP )\r
        {\r
-        if( uxBufferLength < uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_UDP_HEADER )\r
-        {\r
-            return ipINVALID_LENGTH;\r
-        }\r
+               if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_UDP_HEADER ) )\r
+               {\r
+                       return ipINVALID_LENGTH;\r
+               }\r
 \r
                pusChecksum = ( uint16_t * ) ( &( pxProtPack->xUDPPacket.xUDPHeader.usChecksum ) );\r
                #if( ipconfigHAS_DEBUG_PRINTF != 0 )\r
@@ -1854,12 +1851,12 @@ uint8_t ucProtocol;
        }\r
        else if( ucProtocol == ( uint8_t ) ipPROTOCOL_TCP )\r
        {\r
-        if( uxBufferLength < uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_TCP_HEADER )\r
-        {\r
-            return ipINVALID_LENGTH;\r
-        }\r
-        \r
-        pusChecksum = ( uint16_t * ) ( &( pxProtPack->xTCPPacket.xTCPHeader.usChecksum ) );\r
+               if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_TCP_HEADER ) )\r
+               {\r
+                       return ipINVALID_LENGTH;\r
+               }\r
+\r
+               pusChecksum = ( uint16_t * ) ( &( pxProtPack->xTCPPacket.xTCPHeader.usChecksum ) );\r
                #if( ipconfigHAS_DEBUG_PRINTF != 0 )\r
                {\r
                        pcType = "TCP";\r
@@ -1869,12 +1866,12 @@ uint8_t ucProtocol;
        else if( ( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) ||\r
                        ( ucProtocol == ( uint8_t ) ipPROTOCOL_IGMP ) )\r
        {\r
-        if( uxBufferLength < uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_ICMP_HEADER )\r
-        {\r
-            return ipINVALID_LENGTH;\r
-        }\r
-        \r
-        pusChecksum = ( uint16_t * ) ( &( pxProtPack->xICMPPacket.xICMPHeader.usChecksum ) );\r
+               if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_ICMP_HEADER ) )\r
+               {\r
+                       return ipINVALID_LENGTH;\r
+               }\r
+\r
+               pusChecksum = ( uint16_t * ) ( &( pxProtPack->xICMPPacket.xICMPHeader.usChecksum ) );\r
                #if( ipconfigHAS_DEBUG_PRINTF != 0 )\r
                {\r
                        if( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP )\r
@@ -1894,8 +1891,8 @@ uint8_t ucProtocol;
                return ipUNHANDLED_PROTOCOL;\r
        }\r
 \r
-    /* The protocol and checksum field have been identified. Check the direction\r
-    of the packet. */\r
+       /* The protocol and checksum field have been identified. Check the direction\r
+       of the packet. */\r
        if( xOutgoingPacket != pdFALSE )\r
        {\r
                /* This is an outgoing packet. Before calculating the checksum, set it\r
@@ -2021,12 +2018,12 @@ uint8_t ucProtocol;
  *\r
  * Arguments:\r
  *   ulSum: This argument provides a value to initialize the progressive summation\r
- *     of the header's values to. It is often 0, but protocols like TCP or UDP\r
- *     can have pseudo-header fields which need to be included in the checksum.\r
+ *      of the header's values to. It is often 0, but protocols like TCP or UDP\r
+ *      can have pseudo-header fields which need to be included in the checksum.\r
  *   pucNextData: This argument contains the address of the first byte which this\r
- *     method should process. The method's memory iterator is initialized to this value.\r
+ *      method should process. The method's memory iterator is initialized to this value.\r
  *   uxDataLengthBytes: This argument contains the number of bytes that this method\r
- *     should process.\r
+ *      should process.\r
  */\r
 uint16_t usGenerateChecksum( uint32_t ulSum, const uint8_t * pucNextData, size_t uxDataLengthBytes )\r
 {\r
@@ -2226,8 +2223,8 @@ uint32_t FreeRTOS_GetNetmask( void )
 \r
 void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ipMAC_ADDRESS_LENGTH_BYTES] )\r
 {\r
-    /* Copy the MAC address at the start of the default packet header fragment. */\r
-    memcpy( ( void * )ipLOCAL_MAC_ADDRESS, ( void * )ucMACAddress, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );\r
+       /* Copy the MAC address at the start of the default packet header fragment. */\r
+       memcpy( ( void * )ipLOCAL_MAC_ADDRESS, ( void * )ucMACAddress, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index 6ad9a86d3e25462231d6d325266689febcfff6ad..896559a3d5f67e3cf8c66c3e13ca7d5f895c469a 100644 (file)
@@ -48,16 +48,16 @@ port number. */
 \r
 /* Test if a socket it bound which means it is either included in\r
 xBoundUDPSocketsList or xBoundTCPSocketsList */\r
-#define socketSOCKET_IS_BOUND( pxSocket )      ( listLIST_ITEM_CONTAINER( & ( pxSocket )->xBoundSocketListItem ) != NULL )\r
+#define socketSOCKET_IS_BOUND( pxSocket )        ( listLIST_ITEM_CONTAINER( & ( pxSocket )->xBoundSocketListItem ) != NULL )\r
 \r
 /* If FreeRTOS_sendto() is called on a socket that is not bound to a port\r
 number then, depending on the FreeRTOSIPConfig.h settings, it might be that a\r
 port number is automatically generated for the socket.  Automatically generated\r
 port numbers will be between socketAUTO_PORT_ALLOCATION_START_NUMBER and\r
-0xffff. \r
+0xffff.\r
 \r
 Per https://tools.ietf.org/html/rfc6056, "the dynamic ports consist of the range\r
-49152-65535. However, ephemeral port selection algorithms should use the whole \r
+49152-65535. However, ephemeral port selection algorithms should use the whole\r
 range 1024-65535" excluding those already in use (inbound or outbound). */\r
 #if !defined( socketAUTO_PORT_ALLOCATION_START_NUMBER )\r
        #define socketAUTO_PORT_ALLOCATION_START_NUMBER ( ( uint16_t ) 0x0400 )\r
@@ -190,15 +190,15 @@ BaseType_t xReturn = pdTRUE;
 \r
 BaseType_t vNetworkSocketsInit( void )\r
 {\r
-    vListInitialise( &xBoundUDPSocketsList );\r
+       vListInitialise( &xBoundUDPSocketsList );\r
 \r
-    #if( ipconfigUSE_TCP == 1 )\r
-    {\r
-        vListInitialise( &xBoundTCPSocketsList );\r
-    }\r
-    #endif  /* ipconfigUSE_TCP == 1 */\r
+       #if( ipconfigUSE_TCP == 1 )\r
+       {\r
+               vListInitialise( &xBoundTCPSocketsList );\r
+       }\r
+       #endif  /* ipconfigUSE_TCP == 1 */\r
 \r
-    return pdTRUE;\r
+       return pdTRUE;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -232,7 +232,7 @@ FreeRTOS_Socket_t *pxSocket;
                        if( xType != FREERTOS_SOCK_DGRAM )\r
                        {\r
                                xReturn = pdFAIL;\r
-                configASSERT( xReturn );\r
+                               configASSERT( xReturn );\r
                        }\r
                        /* In case a UDP socket is created, do not allocate space for TCP data. */\r
                        *pxSocketSize = ( sizeof( *pxSocket ) - sizeof( pxSocket->u ) ) + sizeof( pxSocket->u.xUDP );\r
@@ -243,7 +243,7 @@ FreeRTOS_Socket_t *pxSocket;
                        if( xType != FREERTOS_SOCK_STREAM )\r
                        {\r
                                xReturn = pdFAIL;\r
-                configASSERT( xReturn );\r
+                               configASSERT( xReturn );\r
                        }\r
 \r
                        *pxSocketSize = ( sizeof( *pxSocket ) - sizeof( pxSocket->u ) ) + sizeof( pxSocket->u.xTCP );\r
@@ -252,7 +252,7 @@ FreeRTOS_Socket_t *pxSocket;
                else\r
                {\r
                        xReturn = pdFAIL;\r
-            configASSERT( xReturn );\r
+                       configASSERT( xReturn );\r
                }\r
        }\r
        /* In case configASSERT() is not used */\r
@@ -317,9 +317,9 @@ Socket_t xReturn;
                        listSET_LIST_ITEM_OWNER( &( pxSocket->xBoundSocketListItem ), ( void * ) pxSocket );\r
 \r
                        pxSocket->xReceiveBlockTime = ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME;\r
-                       pxSocket->xSendBlockTime    = ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME;\r
+                       pxSocket->xSendBlockTime        = ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME;\r
                        pxSocket->ucSocketOptions   = ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT;\r
-                       pxSocket->ucProtocol        = ( uint8_t ) xProtocol; /* protocol: UDP or TCP */\r
+                       pxSocket->ucProtocol            = ( uint8_t ) xProtocol; /* protocol: UDP or TCP */\r
 \r
                        #if( ipconfigUSE_TCP == 1 )\r
                        {\r
@@ -327,7 +327,7 @@ Socket_t xReturn;
                                {\r
                                        /* StreamSize is expressed in number of bytes */\r
                                        /* Round up buffer sizes to nearest multiple of MSS */\r
-                                       pxSocket->u.xTCP.usInitMSS    = pxSocket->u.xTCP.usCurMSS = ipconfigTCP_MSS;\r
+                                       pxSocket->u.xTCP.usInitMSS      = pxSocket->u.xTCP.usCurMSS = ipconfigTCP_MSS;\r
                                        pxSocket->u.xTCP.uxRxStreamSize = ( size_t ) ipconfigTCP_RX_BUFFER_LENGTH;\r
                                        pxSocket->u.xTCP.uxTxStreamSize = ( size_t ) FreeRTOS_round_up( ipconfigTCP_TX_BUFFER_LENGTH, ipconfigTCP_MSS );\r
                                        /* Use half of the buffer size of the TCP windows */\r
@@ -1009,11 +1009,11 @@ List_t *pxSocketList;
        {\r
                if( pxAddress->sin_port == 0u )\r
                {\r
-                       pxAddress->sin_port = prvGetPrivatePortNumber( ( BaseType_t )pxSocket->ucProtocol );            \r
-            if( 0 == pxAddress->sin_port )\r
-            {\r
-                return -pdFREERTOS_ERRNO_EADDRNOTAVAIL;\r
-            }\r
+                       pxAddress->sin_port = prvGetPrivatePortNumber( ( BaseType_t )pxSocket->ucProtocol );\r
+                       if( 0 == pxAddress->sin_port )\r
+                       {\r
+                               return -pdFREERTOS_ERRNO_EADDRNOTAVAIL;\r
+                       }\r
                }\r
 \r
                /* If vSocketBind() is called from the API FreeRTOS_bind() it has been\r
@@ -1610,9 +1610,9 @@ FreeRTOS_Socket_t *pxSocket;
 /* Find an available port number per https://tools.ietf.org/html/rfc6056. */\r
 static uint16_t prvGetPrivatePortNumber( BaseType_t xProtocol )\r
 {\r
-const uint16_t usEphemeralPortCount = \r
-    socketAUTO_PORT_ALLOCATION_MAX_NUMBER - socketAUTO_PORT_ALLOCATION_START_NUMBER + 1;\r
-uint16_t usIterations = usEphemeralPortCount; \r
+const uint16_t usEphemeralPortCount =\r
+       socketAUTO_PORT_ALLOCATION_MAX_NUMBER - socketAUTO_PORT_ALLOCATION_START_NUMBER + 1;\r
+uint16_t usIterations = usEphemeralPortCount;\r
 uint32_t ulRandomSeed = 0;\r
 uint16_t usResult = 0;\r
 BaseType_t xGotZeroOnce = pdFALSE;\r
@@ -1632,52 +1632,52 @@ const List_t *pxList;
        /* Avoid compiler warnings if ipconfigUSE_TCP is not defined. */\r
        ( void ) xProtocol;\r
 \r
-    /* Find the next available port using the random seed as a starting \r
-    point. */\r
-    do\r
-    {\r
-        /* Generate a random seed. */\r
-        ulRandomSeed = ipconfigRAND32( );\r
-\r
-        /* Only proceed if the random number generator succeeded. */\r
-        if( 0 == ulRandomSeed )\r
-        {\r
-            if( pdFALSE == xGotZeroOnce )\r
-            {\r
-                xGotZeroOnce = pdTRUE;\r
-                continue;\r
-            }\r
-            else\r
-            {\r
-                break;\r
-            }\r
-        }\r
-\r
-        /* Map the random to a candidate port. */\r
-        usResult =\r
-            socketAUTO_PORT_ALLOCATION_START_NUMBER +\r
-            ( ( ( uint16_t )ulRandomSeed ) % usEphemeralPortCount );\r
-\r
-        /* Check if there's already an open socket with the same protocol\r
-        and port. */\r
-        if( NULL == pxListFindListItemWithValue( \r
-            pxList, \r
-            ( TickType_t )FreeRTOS_htons( usResult ) ) )\r
-        {\r
-            usResult = FreeRTOS_htons( usResult );\r
-            break;\r
-        }\r
-        else\r
-        {\r
-            usResult = 0;\r
-        }\r
-\r
-        usIterations--;\r
-    }\r
-    while( usIterations > 0 );\r
-    \r
-    return usResult;\r
-} \r
+       /* Find the next available port using the random seed as a starting\r
+       point. */\r
+       do\r
+       {\r
+               /* Generate a random seed. */\r
+               ulRandomSeed = ipconfigRAND32( );\r
+\r
+               /* Only proceed if the random number generator succeeded. */\r
+               if( 0 == ulRandomSeed )\r
+               {\r
+                       if( pdFALSE == xGotZeroOnce )\r
+                       {\r
+                               xGotZeroOnce = pdTRUE;\r
+                               continue;\r
+                       }\r
+                       else\r
+                       {\r
+                               break;\r
+                       }\r
+               }\r
+\r
+               /* Map the random to a candidate port. */\r
+               usResult =\r
+                       socketAUTO_PORT_ALLOCATION_START_NUMBER +\r
+                       ( ( ( uint16_t )ulRandomSeed ) % usEphemeralPortCount );\r
+\r
+               /* Check if there's already an open socket with the same protocol\r
+               and port. */\r
+               if( NULL == pxListFindListItemWithValue(\r
+                       pxList,\r
+                       ( TickType_t )FreeRTOS_htons( usResult ) ) )\r
+               {\r
+                       usResult = FreeRTOS_htons( usResult );\r
+                       break;\r
+               }\r
+               else\r
+               {\r
+                       usResult = 0;\r
+               }\r
+\r
+               usIterations--;\r
+       }\r
+       while( usIterations > 0 );\r
+\r
+       return usResult;\r
+}\r
 /*-----------------------------------------------------------*/\r
 \r
 /* pxListFindListItemWithValue: find a list item in a bound socket list\r
@@ -3339,7 +3339,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
                }\r
                else\r
                {\r
-                       FreeRTOS_printf( ( "Prot Port IP-Remote       : Port  R/T Status       Alive  tmout Child\n" ) );\r
+                       FreeRTOS_printf( ( "Prot Port IP-Remote    : Port  R/T Status      Alive  tmout Child\n" ) );\r
                        for( pxIterator  = ( ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList );\r
                                 pxIterator != ( ListItem_t * ) listGET_END_MARKER( &xBoundTCPSocketsList );\r
                                 pxIterator  = ( ListItem_t * ) listGET_NEXT( pxIterator ) )\r
index b8a6be04e75d735820eb1e067dbd7e6af07964eb..400a85556d5131c8b1324d3b239416086c4e7a3a 100644 (file)
@@ -349,14 +349,13 @@ static NetworkBufferDescriptor_t *prvTCPBufferResize( FreeRTOS_Socket_t *pxSocke
        static uint8_t prvWinScaleFactor( FreeRTOS_Socket_t *pxSocket );\r
 #endif\r
 \r
-/* \r
+/*\r
  * Generate a randomized TCP Initial Sequence Number per RFC.\r
  */\r
-extern uint32_t ulApplicationGetNextSequenceNumber(\r
-    uint32_t ulSourceAddress,\r
-    uint16_t usSourcePort,\r
-    uint32_t ulDestinationAddress,\r
-    uint16_t usDestinationPort );\r
+extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,\r
+                                                                                                       uint16_t usSourcePort,\r
+                                                                                                       uint32_t ulDestinationAddress,\r
+                                                                                                       uint16_t usDestinationPort );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -854,8 +853,8 @@ NetworkBufferDescriptor_t xTempBuffer;
                        vFlip_32( pxTCPPacket->xTCPHeader.ulSequenceNumber, pxTCPPacket->xTCPHeader.ulAckNr );\r
                }\r
 \r
-               pxIPHeader->ucTimeToLive           = ( uint8_t ) ipconfigTCP_TIME_TO_LIVE;\r
-               pxIPHeader->usLength               = FreeRTOS_htons( ulLen );\r
+               pxIPHeader->ucTimeToLive                   = ( uint8_t ) ipconfigTCP_TIME_TO_LIVE;\r
+               pxIPHeader->usLength                       = FreeRTOS_htons( ulLen );\r
                if( ( pxSocket == NULL ) || ( *ipLOCAL_IP_ADDRESS_POINTER == 0ul ) )\r
                {\r
                        /* When pxSocket is NULL, this function is called by prvTCPSendReset()\r
@@ -1023,21 +1022,20 @@ uint32_t ulInitialSequenceNumber = 0;
                xReturn = pdFALSE;\r
        }\r
 \r
-    if( xReturn != pdFALSE )\r
-    {\r
-        /* Get a difficult-to-predict initial sequence number for this 4-tuple. */\r
-        ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber( \r
-            *ipLOCAL_IP_ADDRESS_POINTER, \r
-            pxSocket->usLocalPort, \r
-            pxSocket->u.xTCP.ulRemoteIP, \r
-            pxSocket->u.xTCP.usRemotePort );\r
+       if( xReturn != pdFALSE )\r
+       {\r
+               /* Get a difficult-to-predict initial sequence number for this 4-tuple. */\r
+               ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber( *ipLOCAL_IP_ADDRESS_POINTER,\r
+                                                                                                                                         pxSocket->usLocalPort,\r
+                                                                                                                                         pxSocket->u.xTCP.ulRemoteIP,\r
+                                                                                                                                         pxSocket->u.xTCP.usRemotePort );\r
 \r
-        /* Check for a random number generation error. */\r
-        if( 0 == ulInitialSequenceNumber )\r
-        {\r
-            xReturn = pdFALSE;\r
-        }\r
-    }\r
+               /* Check for a random number generation error. */\r
+               if( 0 == ulInitialSequenceNumber )\r
+               {\r
+                       xReturn = pdFALSE;\r
+               }\r
+       }\r
 \r
        if( xReturn != pdFALSE )\r
        {\r
@@ -1152,17 +1150,17 @@ UBaseType_t uxNewMSS;
        pucLast = pucPtr + (((pxTCPHeader->ucTCPOffset >> 4) - 5) << 2);\r
        pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow;\r
 \r
-    /* Validate options size calculation. */\r
-    if( pucLast > ( pxNetworkBuffer->pucEthernetBuffer + pxNetworkBuffer->xDataLength ) )\r
-    {\r
-        return;\r
-    }\r
+       /* Validate options size calculation. */\r
+       if( pucLast > ( pxNetworkBuffer->pucEthernetBuffer + pxNetworkBuffer->xDataLength ) )\r
+       {\r
+               return;\r
+       }\r
 \r
        /* The comparison with pucLast is only necessary in case the option data are\r
        corrupted, we don't like to run into invalid memory and crash. */\r
        while( pucPtr < pucLast )\r
        {\r
-        UBaseType_t xRemainingOptionsBytes = pucLast - pucPtr;\r
+               UBaseType_t xRemainingOptionsBytes = pucLast - pucPtr;\r
 \r
                if( pucPtr[ 0 ] == TCP_OPT_END )\r
                {\r
@@ -1171,26 +1169,25 @@ UBaseType_t uxNewMSS;
                }\r
                if( pucPtr[ 0 ] == TCP_OPT_NOOP)\r
                {\r
-            /* NOP option, inserted to make the length a multiple of 4. */\r
-            pucPtr++;\r
-            continue;\r
+                       /* NOP option, inserted to make the length a multiple of 4. */\r
+                       pucPtr++;\r
+                       continue;\r
                }\r
 \r
-        /* Any other well-formed option must be at least two bytes: the option\r
-        type byte followed by a length byte. */\r
-        if( xRemainingOptionsBytes < 2 )\r
-        { \r
-            break;\r
-        }\r
+               /* Any other well-formed option must be at least two bytes: the option\r
+               type byte followed by a length byte. */\r
+               if( xRemainingOptionsBytes < 2 )\r
+               {\r
+                       break;\r
+               }\r
 #if( ipconfigUSE_TCP_WIN != 0 )\r
                else if( pucPtr[ 0 ] == TCP_OPT_WSOPT )\r
                {\r
-            /* Confirm that the option fits in the remaining buffer space. */\r
-            if( xRemainingOptionsBytes < TCP_OPT_WSOPT_LEN ||\r
-                pucPtr[ 1 ] != TCP_OPT_WSOPT_LEN )\r
-            {\r
-                break;\r
-            }\r
+                       /* Confirm that the option fits in the remaining buffer space. */\r
+                       if( ( xRemainingOptionsBytes < TCP_OPT_WSOPT_LEN ) || ( pucPtr[ 1 ] != TCP_OPT_WSOPT_LEN ) )\r
+                       {\r
+                               break;\r
+                       }\r
 \r
                        pxSocket->u.xTCP.ucPeerWinScaleFactor = pucPtr[ 2 ];\r
                        pxSocket->u.xTCP.bits.bWinScaling = pdTRUE_UNSIGNED;\r
@@ -1199,25 +1196,24 @@ UBaseType_t uxNewMSS;
 #endif /* ipconfigUSE_TCP_WIN */\r
                else if( pucPtr[ 0 ] == TCP_OPT_MSS )\r
                {\r
-            /* Confirm that the option fits in the remaining buffer space. */\r
-            if( xRemainingOptionsBytes < TCP_OPT_MSS_LEN ||\r
-                pucPtr[ 1 ] != TCP_OPT_MSS_LEN )\r
-            {\r
-                break;\r
-            }\r
-            \r
-            /* An MSS option with the correct option length.  FreeRTOS_htons()\r
+                       /* Confirm that the option fits in the remaining buffer space. */\r
+                       if( ( xRemainingOptionsBytes < TCP_OPT_MSS_LEN )|| ( pucPtr[ 1 ] != TCP_OPT_MSS_LEN ) )\r
+                       {\r
+                               break;\r
+                       }\r
+\r
+                       /* An MSS option with the correct option length.  FreeRTOS_htons()\r
                        is not needed here because usChar2u16() already returns a host\r
                        endian number. */\r
                        uxNewMSS = usChar2u16( pucPtr + 2 );\r
 \r
                        if( pxSocket->u.xTCP.usInitMSS != uxNewMSS )\r
                        {\r
-                /* Perform a basic check on the the new MSS. */\r
-                if( uxNewMSS == 0 )\r
-                {\r
-                    break;\r
-                }\r
+                               /* Perform a basic check on the the new MSS. */\r
+                               if( uxNewMSS == 0 )\r
+                               {\r
+                                       break;\r
+                               }\r
 \r
                                FreeRTOS_debug_printf( ( "MSS change %u -> %lu\n", pxSocket->u.xTCP.usInitMSS, uxNewMSS ) );\r
                        }\r
@@ -1253,10 +1249,10 @@ UBaseType_t uxNewMSS;
                        /* All other options have a length field, so that we easily\r
                        can skip past them. */\r
                        unsigned char len = pucPtr[ 1 ];\r
-                       if( len < 2 || len > xRemainingOptionsBytes )\r
+                       if( ( len < 2 ) || ( len > xRemainingOptionsBytes ) )\r
                        {\r
-                               /* If the length field is too small or too big, the options are malformed. \r
-                Don't process them further. */\r
+                               /* If the length field is too small or too big, the options are malformed.\r
+                               Don't process them further. */\r
                                break;\r
                        }\r
 \r
@@ -1394,7 +1390,7 @@ UBaseType_t uxOptionsLength;
                pxTCPHeader->ucOptdata[ uxOptionsLength + 3 ] = 2;      /* 2: length of this option. */\r
                uxOptionsLength += 4u;\r
 \r
-        return uxOptionsLength; /* bytes, not words. */\r
+               return uxOptionsLength; /* bytes, not words. */\r
        }\r
        #endif  /* ipconfigUSE_TCP_WIN == 0 */\r
 }\r
@@ -1639,8 +1635,8 @@ BaseType_t xResize;
 \r
                if( pxReturn != NULL )\r
                {\r
-            /* Set the actual packet size, in case the returned buffer is larger. */\r
-            pxReturn->xDataLength = lNeeded;\r
+                       /* Set the actual packet size, in case the returned buffer is larger. */\r
+                       pxReturn->xDataLength = lNeeded;\r
 \r
                        /* Copy the existing data to the new created buffer. */\r
                        if( pxNetworkBuffer )\r
@@ -2071,7 +2067,7 @@ int32_t lLength, lTCPHeaderLength, lReceiveLength, lUrgentLength;
        The size of the TCP header is given in a multiple of 4-byte words (single\r
        byte, needs no ntoh() translation).  A shift-right 2: is the same as\r
        (offset >> 4) * 4. */\r
-    lTCPHeaderLength = ( BaseType_t ) ( ( pxTCPHeader->ucTCPOffset & VALID_BITS_IN_TCP_OFFSET_BYTE ) >> 2 );\r
+       lTCPHeaderLength = ( BaseType_t ) ( ( pxTCPHeader->ucTCPOffset & VALID_BITS_IN_TCP_OFFSET_BYTE ) >> 2 );\r
 \r
        /* Let pucRecvData point to the first byte received. */\r
        *ppucRecvData = pxNetworkBuffer->pucEthernetBuffer + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + lTCPHeaderLength;\r
@@ -2436,7 +2432,7 @@ int32_t lDistance, lSendResult;
                {\r
                        /* xTCPWindowTxDone returns true when all Tx queues are empty. */\r
                        bRxComplete = xTCPWindowRxEmpty( pxTCPWindow );\r
-                       bTxDone     = xTCPWindowTxDone( pxTCPWindow );\r
+                       bTxDone  = xTCPWindowTxDone( pxTCPWindow );\r
 \r
                        if( ( bRxComplete == 0 ) || ( bTxDone == 0 ) )\r
                        {\r
@@ -2905,24 +2901,23 @@ uint32_t ulRemoteIP;
 uint16_t xRemotePort;\r
 BaseType_t xResult = pdPASS;\r
 \r
-    /* Check for a minimum packet size. */\r
-    if( pxNetworkBuffer->xDataLength >= \r
-        ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER )\r
-    {\r
-        ucTCPFlags = pxTCPPacket->xTCPHeader.ucTCPFlags;\r
-        ulLocalIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulDestinationIPAddress );\r
-        xLocalPort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usDestinationPort );\r
-        ulRemoteIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulSourceIPAddress );\r
-        xRemotePort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usSourcePort );\r
-\r
-        /* Find the destination socket, and if not found: return a socket listing to\r
-        the destination PORT. */\r
-        pxSocket = ( FreeRTOS_Socket_t * )pxTCPSocketLookup( ulLocalIP, xLocalPort, ulRemoteIP, xRemotePort );\r
-    }\r
-    else\r
-    {\r
-        return pdFAIL;\r
-    }\r
+       /* Check for a minimum packet size. */\r
+       if( pxNetworkBuffer->xDataLength >= ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) )\r
+       {\r
+               ucTCPFlags = pxTCPPacket->xTCPHeader.ucTCPFlags;\r
+               ulLocalIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulDestinationIPAddress );\r
+               xLocalPort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usDestinationPort );\r
+               ulRemoteIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulSourceIPAddress );\r
+               xRemotePort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usSourcePort );\r
+\r
+               /* Find the destination socket, and if not found: return a socket listing to\r
+               the destination PORT. */\r
+               pxSocket = ( FreeRTOS_Socket_t * )pxTCPSocketLookup( ulLocalIP, xLocalPort, ulRemoteIP, xRemotePort );\r
+       }\r
+       else\r
+       {\r
+               return pdFAIL;\r
+       }\r
 \r
        if( ( pxSocket == NULL ) || ( prvTCPSocketIsActive( ( UBaseType_t ) pxSocket->u.xTCP.ucTCPState ) == pdFALSE ) )\r
        {\r
@@ -3086,64 +3081,63 @@ TCPPacket_t * pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuff
 FreeRTOS_Socket_t *pxReturn = NULL;\r
 uint32_t ulInitialSequenceNumber;\r
 \r
-    /* Assume that a new Initial Sequence Number will be required. Request \r
-    it now in order to fail out if necessary. */\r
-    ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber(\r
-        *ipLOCAL_IP_ADDRESS_POINTER,\r
-        pxSocket->usLocalPort,\r
-        pxTCPPacket->xIPHeader.ulSourceIPAddress,\r
-        pxTCPPacket->xTCPHeader.usSourcePort );\r
+       /* Assume that a new Initial Sequence Number will be required. Request\r
+       it now in order to fail out if necessary. */\r
+       ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber( *ipLOCAL_IP_ADDRESS_POINTER,\r
+                                                                                                                                 pxSocket->usLocalPort,\r
+                                                                                                                                 pxTCPPacket->xIPHeader.ulSourceIPAddress,\r
+                                                                                                                                 pxTCPPacket->xTCPHeader.usSourcePort );\r
 \r
        /* A pure SYN (without ACK) has come in, create a new socket to answer\r
        it. */\r
-    if( 0 != ulInitialSequenceNumber )\r
-    {\r
-        if( pxSocket->u.xTCP.bits.bReuseSocket != pdFALSE_UNSIGNED )\r
-        {\r
-            /* The flag bReuseSocket indicates that the same instance of the\r
-            listening socket should be used for the connection. */\r
-            pxReturn = pxSocket;\r
-            pxSocket->u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED;\r
-            pxSocket->u.xTCP.pxPeerSocket = pxSocket;\r
-        }\r
-        else\r
-        {\r
-            /* The socket does not have the bReuseSocket flag set meaning create a\r
-            new socket when a connection comes in. */\r
-            pxReturn = NULL;\r
-\r
-            if( pxSocket->u.xTCP.usChildCount >= pxSocket->u.xTCP.usBacklog )\r
-            {\r
-                FreeRTOS_printf( ( "Check: Socket %u already has %u / %u child%s\n",\r
-                    pxSocket->usLocalPort,\r
-                    pxSocket->u.xTCP.usChildCount,\r
-                    pxSocket->u.xTCP.usBacklog,\r
-                    pxSocket->u.xTCP.usChildCount == 1 ? "" : "ren" ) );\r
-                prvTCPSendReset( pxNetworkBuffer );\r
-            }\r
-            else\r
-            {\r
-                FreeRTOS_Socket_t *pxNewSocket = ( FreeRTOS_Socket_t * )\r
-                    FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );\r
-\r
-                if( ( pxNewSocket == NULL ) || ( pxNewSocket == FREERTOS_INVALID_SOCKET ) )\r
-                {\r
-                    FreeRTOS_debug_printf( ( "TCP: Listen: new socket failed\n" ) );\r
-                    prvTCPSendReset( pxNetworkBuffer );\r
-                }\r
-                else if( prvTCPSocketCopy( pxNewSocket, pxSocket ) != pdFALSE )\r
-                {\r
-                    /* The socket will be connected immediately, no time for the\r
-                    owner to setsockopt's, therefore copy properties of the server\r
-                    socket to the new socket.  Only the binding might fail (due to\r
-                    lack of resources). */\r
-                    pxReturn = pxNewSocket;\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    if( 0 != ulInitialSequenceNumber && pxReturn != NULL )\r
+       if( 0 != ulInitialSequenceNumber )\r
+       {\r
+               if( pxSocket->u.xTCP.bits.bReuseSocket != pdFALSE_UNSIGNED )\r
+               {\r
+                       /* The flag bReuseSocket indicates that the same instance of the\r
+                       listening socket should be used for the connection. */\r
+                       pxReturn = pxSocket;\r
+                       pxSocket->u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED;\r
+                       pxSocket->u.xTCP.pxPeerSocket = pxSocket;\r
+               }\r
+               else\r
+               {\r
+                       /* The socket does not have the bReuseSocket flag set meaning create a\r
+                       new socket when a connection comes in. */\r
+                       pxReturn = NULL;\r
+\r
+                       if( pxSocket->u.xTCP.usChildCount >= pxSocket->u.xTCP.usBacklog )\r
+                       {\r
+                               FreeRTOS_printf( ( "Check: Socket %u already has %u / %u child%s\n",\r
+                                       pxSocket->usLocalPort,\r
+                                       pxSocket->u.xTCP.usChildCount,\r
+                                       pxSocket->u.xTCP.usBacklog,\r
+                                       pxSocket->u.xTCP.usChildCount == 1 ? "" : "ren" ) );\r
+                               prvTCPSendReset( pxNetworkBuffer );\r
+                       }\r
+                       else\r
+                       {\r
+                               FreeRTOS_Socket_t *pxNewSocket = ( FreeRTOS_Socket_t * )\r
+                                       FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );\r
+\r
+                               if( ( pxNewSocket == NULL ) || ( pxNewSocket == FREERTOS_INVALID_SOCKET ) )\r
+                               {\r
+                                       FreeRTOS_debug_printf( ( "TCP: Listen: new socket failed\n" ) );\r
+                                       prvTCPSendReset( pxNetworkBuffer );\r
+                               }\r
+                               else if( prvTCPSocketCopy( pxNewSocket, pxSocket ) != pdFALSE )\r
+                               {\r
+                                       /* The socket will be connected immediately, no time for the\r
+                                       owner to setsockopt's, therefore copy properties of the server\r
+                                       socket to the new socket.  Only the binding might fail (due to\r
+                                       lack of resources). */\r
+                                       pxReturn = pxNewSocket;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       if( ( 0 != ulInitialSequenceNumber ) && ( pxReturn != NULL ) )\r
        {\r
                pxReturn->u.xTCP.usRemotePort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usSourcePort );\r
                pxReturn->u.xTCP.ulRemoteIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulSourceIPAddress );\r
@@ -3310,5 +3304,6 @@ BaseType_t xResult = pdFALSE;
 \r
 /* Provide access to private members for testing. */\r
 #ifdef AMAZON_FREERTOS_ENABLE_UNIT_TESTS\r
-    #include "aws_freertos_tcp_test_access_tcp_define.h"\r
+       #include "aws_freertos_tcp_test_access_tcp_define.h"\r
 #endif\r
+\r
index 94a8e17f84ccda5e4d6f627d7331d8f6ee39e473..532b89b91a57506ced14e62fcdd9b5abe511851e 100644 (file)
@@ -244,7 +244,7 @@ FreeRTOS_Socket_t *pxSocket;
 UDPPacket_t *pxUDPPacket = (UDPPacket_t *) pxNetworkBuffer->pucEthernetBuffer;\r
 \r
        /* Caller must check for minimum packet size. */\r
-    pxSocket = pxUDPSocketLookup( usPort );\r
+       pxSocket = pxUDPSocketLookup( usPort );\r
 \r
        if( pxSocket )\r
        {\r
index dd8ae07f404e9447b13c70711c039ccd79811bf4..4b3a741151746a752a06000a39861b30a59906d4 100644 (file)
@@ -389,9 +389,9 @@ from the FreeRTOSIPConfig.h configuration header file. */
 \r
 #if( ipconfigUSE_DNS_CACHE != 0 )\r
        #ifndef ipconfigDNS_CACHE_NAME_LENGTH\r
-        /* Per https://tools.ietf.org/html/rfc1035, 253 is the maximum string length\r
-        of a DNS name. The following default accounts for a null terminator. */\r
-        #define ipconfigDNS_CACHE_NAME_LENGTH   254\r
+               /* Per https://tools.ietf.org/html/rfc1035, 253 is the maximum string length\r
+               of a DNS name. The following default accounts for a null terminator. */\r
+               #define ipconfigDNS_CACHE_NAME_LENGTH   254\r
        #endif\r
 \r
        #ifndef ipconfigDNS_CACHE_ENTRIES\r
@@ -535,7 +535,7 @@ connections, hang protection can help reduce the impact of SYN floods. */
 \r
 /* Non-activity timeout is expressed in seconds. */\r
 #ifndef ipconfigTCP_HANG_PROTECTION_TIME\r
-    #define ipconfigTCP_HANG_PROTECTION_TIME 30\r
+       #define ipconfigTCP_HANG_PROTECTION_TIME 30\r
 #endif\r
 \r
 #ifndef ipconfigTCP_IP_SANITY\r
index 74bb71ebc08f18c438195c56f320e4a07bd5f3f5..92b7902972de6c0c758c515edc12fca993e21dc2 100644 (file)
@@ -80,9 +80,9 @@ typedef struct xTCP_WINSIZE
  */\r
 /* Keep this as a multiple of 4 */\r
 #if( ipconfigUSE_TCP_WIN == 1 )\r
-    #define ipSIZE_TCP_OPTIONS 16u\r
+       #define ipSIZE_TCP_OPTIONS      16u\r
 #else\r
-    #define ipSIZE_TCP_OPTIONS   12u\r
+       #define ipSIZE_TCP_OPTIONS   12u\r
 #endif\r
 \r
 /*\r