Fix mixed tabs and spaces in the latest TCP patches.

pull/4/head
Richard Barry 7 years ago
parent e2750cd388
commit 97a686b2e1

@ -471,7 +471,7 @@ TickType_t xIdentifier = 0;
} }
#endif #endif
if( ulIPAddress == 0UL && 0 != xIdentifier ) if( ( ulIPAddress == 0UL ) && ( 0 != xIdentifier ) )
{ {
ulIPAddress = prvGetHostByName( pcHostName, xIdentifier, xReadTimeOut_ms ); ulIPAddress = prvGetHostByName( pcHostName, xIdentifier, xReadTimeOut_ms );
} }
@ -699,11 +699,11 @@ static const DNSMessage_t xDefaultPartDNSHeader =
else else
{ {
/* pucByte points to the full name. Walk over the string. */ /* pucByte points to the full name. Walk over the string. */
while( NULL != pucByte && *pucByte != 0x00 && xSourceLen > 1 ) while( ( NULL != pucByte ) && ( *pucByte != 0x00 ) && ( xSourceLen > 1 ) )
{ {
/* If this is not the first time through the loop, then add a /* If this is not the first time through the loop, then add a
separator in the output. */ separator in the output. */
if( xNameLen > 0 && xNameLen < xDestLen - 1 ) if( ( xNameLen > 0 ) && ( xNameLen < ( xDestLen - 1 ) ) )
{ {
pcName[ xNameLen++ ] = '.'; pcName[ xNameLen++ ] = '.';
} }
@ -773,7 +773,7 @@ static uint8_t *prvSkipNameField( uint8_t *pucByte, size_t xSourceLen )
else else
{ {
/* pucByte points to the full name. Walk over the string. */ /* pucByte points to the full name. Walk over the string. */
while( *pucByte != 0x00 && xSourceLen > 1 ) while( ( *pucByte != 0x00 ) && ( xSourceLen > 1 ) )
{ {
xChunkLength = *pucByte + 1; xChunkLength = *pucByte + 1;
@ -1055,8 +1055,7 @@ uint16_t x, usDataLength, usQuestions;
if( ( xBufferAllocFixedSize == pdFALSE ) && ( pxNetworkBuffer != NULL ) ) if( ( xBufferAllocFixedSize == pdFALSE ) && ( pxNetworkBuffer != NULL ) )
{ {
BaseType_t xDataLength = xBufferLength + sizeof( UDPHeader_t ) + BaseType_t xDataLength = xBufferLength + sizeof( UDPHeader_t ) + sizeof( EthernetHeader_t ) + sizeof( IPHeader_t );
sizeof( EthernetHeader_t ) + sizeof( IPHeader_t );
/* The field xDataLength was set to the length of the UDP payload. /* The field xDataLength was set to the length of the UDP payload.
The answer (reply) will be longer than the request, so the packet The answer (reply) will be longer than the request, so the packet
@ -1341,8 +1340,7 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
{ {
BaseType_t x; BaseType_t x;
BaseType_t xFound = pdFALSE; BaseType_t xFound = pdFALSE;
uint32_t ulCurrentTimeSeconds = uint32_t ulCurrentTimeSeconds = ( xTaskGetTickCount() / portTICK_PERIOD_MS ) / 1000;
xTaskGetTickCount( ) / portTICK_PERIOD_MS / 1000;
static BaseType_t xFreeEntry = 0; static BaseType_t xFreeEntry = 0;
/* For each entry in the DNS cache table. */ /* For each entry in the DNS cache table. */
@ -1359,9 +1357,7 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
if( xLookUp != pdFALSE ) if( xLookUp != pdFALSE )
{ {
/* Confirm that the record is still fresh. */ /* Confirm that the record is still fresh. */
if( ulCurrentTimeSeconds < if( ulCurrentTimeSeconds < ( xDNSCache[ x ].ulTimeWhenAddedInSeconds + FreeRTOS_ntohl( xDNSCache[ x ].ulTTL ) ) )
xDNSCache[ x ].ulTimeWhenAddedInSeconds +
FreeRTOS_ntohl( xDNSCache[ x ].ulTTL ) )
{ {
*pulIP = xDNSCache[ x ].ulIPAddress; *pulIP = xDNSCache[ x ].ulIPAddress;
} }
@ -1425,3 +1421,4 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
#ifdef AMAZON_FREERTOS_ENABLE_UNIT_TESTS #ifdef AMAZON_FREERTOS_ENABLE_UNIT_TESTS
#include "aws_freertos_tcp_test_access_dns_define.h" #include "aws_freertos_tcp_test_access_dns_define.h"
#endif #endif

@ -357,7 +357,8 @@ struct freertos_sockaddr xAddress;
/* Wait until there is something to do. If the following call exits /* Wait until there is something to do. If the following call exits
* due to a time out rather than a message being received, set a * due to a time out rather than a message being received, set a
* 'NoEvent' value. */ * 'NoEvent' value. */
if ( xQueueReceive( xNetworkEventQueue, ( void * ) &xReceivedEvent, xNextIPSleep ) == pdFALSE ) { if ( xQueueReceive( xNetworkEventQueue, ( void * ) &xReceivedEvent, xNextIPSleep ) == pdFALSE )
{
xReceivedEvent.eEventType = eNoEvent; xReceivedEvent.eEventType = eNoEvent;
} }
@ -804,8 +805,7 @@ void *pvReturn;
if( pxNetworkBuffer != NULL ) if( pxNetworkBuffer != NULL )
{ {
/* Set the actual packet size in case a bigger buffer was returned. */ /* Set the actual packet size in case a bigger buffer was returned. */
pxNetworkBuffer->xDataLength = pxNetworkBuffer->xDataLength = sizeof( UDPPacket_t ) + xRequestedSizeBytes;
sizeof( UDPPacket_t ) + xRequestedSizeBytes;
/* Leave space for the UPD header. */ /* Leave space for the UPD header. */
pvReturn = ( void * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ); pvReturn = ( void * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] );
@ -1516,8 +1516,8 @@ uint8_t ucProtocol;
/* Bound the calculated header length: take away the Ethernet header size, /* Bound the calculated header length: take away the Ethernet header size,
then check if the IP header is claiming to be longer than the remaining then check if the IP header is claiming to be longer than the remaining
total packet size. Also check for minimal header field length. */ total packet size. Also check for minimal header field length. */
if( uxHeaderLength > pxNetworkBuffer->xDataLength - ipSIZE_OF_ETH_HEADER || if( ( uxHeaderLength > ( pxNetworkBuffer->xDataLength - ipSIZE_OF_ETH_HEADER ) ) ||
uxHeaderLength < ipSIZE_OF_IPv4_HEADER ) ( uxHeaderLength < ipSIZE_OF_IPv4_HEADER ) )
{ {
return eReleaseBuffer; return eReleaseBuffer;
} }
@ -1545,8 +1545,7 @@ uint8_t ucProtocol;
pxNetworkBuffer->xDataLength -= optlen; pxNetworkBuffer->xDataLength -= optlen;
/* Fix-up new version/header length field in IP packet. */ /* Fix-up new version/header length field in IP packet. */
pxIPHeader->ucVersionHeaderLength = pxIPHeader->ucVersionHeaderLength = ( pxIPHeader->ucVersionHeaderLength & 0xF0 ) | /* High nibble is the version. */
( pxIPHeader->ucVersionHeaderLength & 0xF0 ) | /* High nibble is the version. */
( ( ipSIZE_OF_IPv4_HEADER >> 2 ) & 0x0F ); /* Low nibble is the header size, in bytes, divided by four. */ ( ( ipSIZE_OF_IPv4_HEADER >> 2 ) & 0x0F ); /* Low nibble is the header size, in bytes, divided by four. */
} }
@ -1612,8 +1611,7 @@ uint8_t ucProtocol;
if( ( FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t ) ) < if( ( FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t ) ) <
pxNetworkBuffer->xDataLength ) pxNetworkBuffer->xDataLength )
{ {
pxNetworkBuffer->xDataLength = FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - pxNetworkBuffer->xDataLength = FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t );
sizeof( UDPHeader_t );
} }
/* Fields in pxNetworkBuffer (usPort, ulIPAddress) are network order. */ /* Fields in pxNetworkBuffer (usPort, ulIPAddress) are network order. */
@ -1814,8 +1812,7 @@ uint8_t ucProtocol;
/* Per https://tools.ietf.org/html/rfc791, the four-bit Internet Header /* Per https://tools.ietf.org/html/rfc791, the four-bit Internet Header
Length field contains the length of the internet header in 32-bit words. */ Length field contains the length of the internet header in 32-bit words. */
uxIPHeaderLength = ( UBaseType_t ) uxIPHeaderLength = ( UBaseType_t ) ( sizeof( uint32_t ) * ( pxIPPacket->xIPHeader.ucVersionHeaderLength & 0x0Fu ) );
( sizeof( uint32_t ) * ( pxIPPacket->xIPHeader.ucVersionHeaderLength & 0x0Fu ) );
/* Check for minimum packet size. */ /* Check for minimum packet size. */
if( uxBufferLength < sizeof( IPPacket_t ) + uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ) if( uxBufferLength < sizeof( IPPacket_t ) + uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER )
@ -1840,7 +1837,7 @@ uint8_t ucProtocol;
/* Switch on the Layer 3/4 protocol. */ /* Switch on the Layer 3/4 protocol. */
if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP )
{ {
if( uxBufferLength < uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_UDP_HEADER ) if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_UDP_HEADER ) )
{ {
return ipINVALID_LENGTH; return ipINVALID_LENGTH;
} }
@ -1854,7 +1851,7 @@ uint8_t ucProtocol;
} }
else if( ucProtocol == ( uint8_t ) ipPROTOCOL_TCP ) else if( ucProtocol == ( uint8_t ) ipPROTOCOL_TCP )
{ {
if( uxBufferLength < uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_TCP_HEADER ) if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_TCP_HEADER ) )
{ {
return ipINVALID_LENGTH; return ipINVALID_LENGTH;
} }
@ -1869,7 +1866,7 @@ uint8_t ucProtocol;
else if( ( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) || else if( ( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) ||
( ucProtocol == ( uint8_t ) ipPROTOCOL_IGMP ) ) ( ucProtocol == ( uint8_t ) ipPROTOCOL_IGMP ) )
{ {
if( uxBufferLength < uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_ICMP_HEADER ) if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_ICMP_HEADER ) )
{ {
return ipINVALID_LENGTH; return ipINVALID_LENGTH;
} }

@ -352,8 +352,7 @@ static NetworkBufferDescriptor_t *prvTCPBufferResize( FreeRTOS_Socket_t *pxSocke
/* /*
* Generate a randomized TCP Initial Sequence Number per RFC. * Generate a randomized TCP Initial Sequence Number per RFC.
*/ */
extern uint32_t ulApplicationGetNextSequenceNumber( extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
uint32_t ulSourceAddress,
uint16_t usSourcePort, uint16_t usSourcePort,
uint32_t ulDestinationAddress, uint32_t ulDestinationAddress,
uint16_t usDestinationPort ); uint16_t usDestinationPort );
@ -1026,8 +1025,7 @@ uint32_t ulInitialSequenceNumber = 0;
if( xReturn != pdFALSE ) if( xReturn != pdFALSE )
{ {
/* Get a difficult-to-predict initial sequence number for this 4-tuple. */ /* Get a difficult-to-predict initial sequence number for this 4-tuple. */
ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber( ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber( *ipLOCAL_IP_ADDRESS_POINTER,
*ipLOCAL_IP_ADDRESS_POINTER,
pxSocket->usLocalPort, pxSocket->usLocalPort,
pxSocket->u.xTCP.ulRemoteIP, pxSocket->u.xTCP.ulRemoteIP,
pxSocket->u.xTCP.usRemotePort ); pxSocket->u.xTCP.usRemotePort );
@ -1186,8 +1184,7 @@ UBaseType_t uxNewMSS;
else if( pucPtr[ 0 ] == TCP_OPT_WSOPT ) else if( pucPtr[ 0 ] == TCP_OPT_WSOPT )
{ {
/* Confirm that the option fits in the remaining buffer space. */ /* Confirm that the option fits in the remaining buffer space. */
if( xRemainingOptionsBytes < TCP_OPT_WSOPT_LEN || if( ( xRemainingOptionsBytes < TCP_OPT_WSOPT_LEN ) || ( pucPtr[ 1 ] != TCP_OPT_WSOPT_LEN ) )
pucPtr[ 1 ] != TCP_OPT_WSOPT_LEN )
{ {
break; break;
} }
@ -1200,8 +1197,7 @@ UBaseType_t uxNewMSS;
else if( pucPtr[ 0 ] == TCP_OPT_MSS ) else if( pucPtr[ 0 ] == TCP_OPT_MSS )
{ {
/* Confirm that the option fits in the remaining buffer space. */ /* Confirm that the option fits in the remaining buffer space. */
if( xRemainingOptionsBytes < TCP_OPT_MSS_LEN || if( ( xRemainingOptionsBytes < TCP_OPT_MSS_LEN )|| ( pucPtr[ 1 ] != TCP_OPT_MSS_LEN ) )
pucPtr[ 1 ] != TCP_OPT_MSS_LEN )
{ {
break; break;
} }
@ -1253,7 +1249,7 @@ UBaseType_t uxNewMSS;
/* All other options have a length field, so that we easily /* All other options have a length field, so that we easily
can skip past them. */ can skip past them. */
unsigned char len = pucPtr[ 1 ]; unsigned char len = pucPtr[ 1 ];
if( len < 2 || len > xRemainingOptionsBytes ) if( ( len < 2 ) || ( len > xRemainingOptionsBytes ) )
{ {
/* If the length field is too small or too big, the options are malformed. /* If the length field is too small or too big, the options are malformed.
Don't process them further. */ Don't process them further. */
@ -2906,8 +2902,7 @@ uint16_t xRemotePort;
BaseType_t xResult = pdPASS; BaseType_t xResult = pdPASS;
/* Check for a minimum packet size. */ /* Check for a minimum packet size. */
if( pxNetworkBuffer->xDataLength >= if( pxNetworkBuffer->xDataLength >= ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) )
ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER )
{ {
ucTCPFlags = pxTCPPacket->xTCPHeader.ucTCPFlags; ucTCPFlags = pxTCPPacket->xTCPHeader.ucTCPFlags;
ulLocalIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulDestinationIPAddress ); ulLocalIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulDestinationIPAddress );
@ -3088,8 +3083,7 @@ uint32_t ulInitialSequenceNumber;
/* Assume that a new Initial Sequence Number will be required. Request /* Assume that a new Initial Sequence Number will be required. Request
it now in order to fail out if necessary. */ it now in order to fail out if necessary. */
ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber( ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber( *ipLOCAL_IP_ADDRESS_POINTER,
*ipLOCAL_IP_ADDRESS_POINTER,
pxSocket->usLocalPort, pxSocket->usLocalPort,
pxTCPPacket->xIPHeader.ulSourceIPAddress, pxTCPPacket->xIPHeader.ulSourceIPAddress,
pxTCPPacket->xTCPHeader.usSourcePort ); pxTCPPacket->xTCPHeader.usSourcePort );
@ -3143,7 +3137,7 @@ uint32_t ulInitialSequenceNumber;
} }
} }
if( 0 != ulInitialSequenceNumber && pxReturn != NULL ) if( ( 0 != ulInitialSequenceNumber ) && ( pxReturn != NULL ) )
{ {
pxReturn->u.xTCP.usRemotePort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usSourcePort ); pxReturn->u.xTCP.usRemotePort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usSourcePort );
pxReturn->u.xTCP.ulRemoteIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulSourceIPAddress ); pxReturn->u.xTCP.ulRemoteIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulSourceIPAddress );
@ -3312,3 +3306,4 @@ BaseType_t xResult = pdFALSE;
#ifdef AMAZON_FREERTOS_ENABLE_UNIT_TESTS #ifdef AMAZON_FREERTOS_ENABLE_UNIT_TESTS
#include "aws_freertos_tcp_test_access_tcp_define.h" #include "aws_freertos_tcp_test_access_tcp_define.h"
#endif #endif

Loading…
Cancel
Save