mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-24 07:21:57 -04:00
Fix mixed tabs and spaces in the latest TCP patches.
This commit is contained in:
parent
e2750cd388
commit
97a686b2e1
|
@ -359,19 +359,19 @@ BaseType_t xGivingUp = pdFALSE;
|
||||||
|
|
||||||
if( xDHCPData.xDHCPTxPeriod <= ipconfigMAXIMUM_DISCOVER_TX_PERIOD )
|
if( xDHCPData.xDHCPTxPeriod <= ipconfigMAXIMUM_DISCOVER_TX_PERIOD )
|
||||||
{
|
{
|
||||||
xDHCPData.ulTransactionId = ipconfigRAND32( );
|
xDHCPData.ulTransactionId = ipconfigRAND32( );
|
||||||
|
|
||||||
if( 0 != xDHCPData.ulTransactionId )
|
if( 0 != xDHCPData.ulTransactionId )
|
||||||
{
|
{
|
||||||
xDHCPData.xDHCPTxTime = xTaskGetTickCount( );
|
xDHCPData.xDHCPTxTime = xTaskGetTickCount( );
|
||||||
xDHCPData.xUseBroadcast = !xDHCPData.xUseBroadcast;
|
xDHCPData.xUseBroadcast = !xDHCPData.xUseBroadcast;
|
||||||
prvSendDHCPDiscover( );
|
prvSendDHCPDiscover( );
|
||||||
FreeRTOS_debug_printf( ( "vDHCPProcess: timeout %lu ticks\n", xDHCPData.xDHCPTxPeriod ) );
|
FreeRTOS_debug_printf( ( "vDHCPProcess: timeout %lu ticks\n", xDHCPData.xDHCPTxPeriod ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FreeRTOS_debug_printf( ( "vDHCPProcess: failed to generate a random Transaction ID\n" ) );
|
FreeRTOS_debug_printf( ( "vDHCPProcess: failed to generate a random Transaction ID\n" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -592,23 +592,23 @@ TickType_t xTimeoutTime = ( TickType_t ) 0;
|
||||||
static void prvInitialiseDHCP( void )
|
static void prvInitialiseDHCP( void )
|
||||||
{
|
{
|
||||||
/* Initialise the parameters that will be set by the DHCP process. Per
|
/* Initialise the parameters that will be set by the DHCP process. Per
|
||||||
https://www.ietf.org/rfc/rfc2131.txt, Transaction ID should be a random
|
https://www.ietf.org/rfc/rfc2131.txt, Transaction ID should be a random
|
||||||
value chosen by the client. */
|
value chosen by the client. */
|
||||||
xDHCPData.ulTransactionId = ipconfigRAND32();
|
xDHCPData.ulTransactionId = ipconfigRAND32();
|
||||||
|
|
||||||
/* Check for random number generator API failure. */
|
/* Check for random number generator API failure. */
|
||||||
if( 0 != xDHCPData.ulTransactionId )
|
if( 0 != xDHCPData.ulTransactionId )
|
||||||
{
|
{
|
||||||
xDHCPData.xUseBroadcast = 0;
|
xDHCPData.xUseBroadcast = 0;
|
||||||
xDHCPData.ulOfferedIPAddress = 0UL;
|
xDHCPData.ulOfferedIPAddress = 0UL;
|
||||||
xDHCPData.ulDHCPServerAddress = 0UL;
|
xDHCPData.ulDHCPServerAddress = 0UL;
|
||||||
xDHCPData.xDHCPTxPeriod = dhcpINITIAL_DHCP_TX_PERIOD;
|
xDHCPData.xDHCPTxPeriod = dhcpINITIAL_DHCP_TX_PERIOD;
|
||||||
|
|
||||||
/* Create the DHCP socket if it has not already been created. */
|
/* Create the DHCP socket if it has not already been created. */
|
||||||
prvCreateDHCPSocket();
|
prvCreateDHCPSocket();
|
||||||
FreeRTOS_debug_printf( ( "prvInitialiseDHCP: start after %lu ticks\n", dhcpINITIAL_TIMER_PERIOD ) );
|
FreeRTOS_debug_printf( ( "prvInitialiseDHCP: start after %lu ticks\n", dhcpINITIAL_TIMER_PERIOD ) );
|
||||||
vIPReloadDHCPTimer( dhcpINITIAL_TIMER_PERIOD );
|
vIPReloadDHCPTimer( dhcpINITIAL_TIMER_PERIOD );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -633,13 +633,13 @@ const uint32_t ulMandatoryOptions = 2ul; /* DHCP server address, and the correct
|
||||||
|
|
||||||
/* Sanity check. */
|
/* Sanity check. */
|
||||||
if( ( lBytes >= sizeof( DHCPMessage_t ) ) &&
|
if( ( lBytes >= sizeof( DHCPMessage_t ) ) &&
|
||||||
( pxDHCPMessage->ulDHCPCookie == ( uint32_t ) dhcpCOOKIE ) &&
|
( pxDHCPMessage->ulDHCPCookie == ( uint32_t ) dhcpCOOKIE ) &&
|
||||||
( pxDHCPMessage->ucOpcode == ( uint8_t ) dhcpREPLY_OPCODE ) &&
|
( pxDHCPMessage->ucOpcode == ( uint8_t ) dhcpREPLY_OPCODE ) &&
|
||||||
( pxDHCPMessage->ulTransactionID == FreeRTOS_htonl( xDHCPData.ulTransactionId ) ) )
|
( pxDHCPMessage->ulTransactionID == FreeRTOS_htonl( xDHCPData.ulTransactionId ) ) )
|
||||||
{
|
{
|
||||||
if( memcmp( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress ),
|
if( memcmp( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress ),
|
||||||
( void * ) ipLOCAL_MAC_ADDRESS,
|
( void * ) ipLOCAL_MAC_ADDRESS,
|
||||||
sizeof( MACAddress_t ) ) == 0 )
|
sizeof( MACAddress_t ) ) == 0 )
|
||||||
{
|
{
|
||||||
/* None of the essential options have been processed yet. */
|
/* None of the essential options have been processed yet. */
|
||||||
ulProcessed = 0ul;
|
ulProcessed = 0ul;
|
||||||
|
@ -665,36 +665,36 @@ const uint32_t ulMandatoryOptions = 2ul; /* DHCP server address, and the correct
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop if the response is malformed. */
|
/* Stop if the response is malformed. */
|
||||||
if( pucByte < pucLastByte - 1 )
|
if( pucByte < pucLastByte - 1 )
|
||||||
{
|
{
|
||||||
ucLength = pucByte[ 1 ];
|
ucLength = pucByte[ 1 ];
|
||||||
pucByte += 2;
|
pucByte += 2;
|
||||||
|
|
||||||
if( pucByte >= pucLastByte - ucLength )
|
if( pucByte >= pucLastByte - ucLength )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* In most cases, a 4-byte network-endian parameter follows,
|
/* In most cases, a 4-byte network-endian parameter follows,
|
||||||
just get it once here and use later. */
|
just get it once here and use later. */
|
||||||
if( ucLength >= sizeof( ulParameter ) )
|
if( ucLength >= sizeof( ulParameter ) )
|
||||||
{
|
{
|
||||||
memcpy( ( void * ) &( ulParameter ),
|
memcpy( ( void * ) &( ulParameter ),
|
||||||
( void * ) pucByte,
|
( void * ) pucByte,
|
||||||
( size_t ) sizeof( ulParameter ) );
|
( size_t ) sizeof( ulParameter ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ulParameter = 0;
|
ulParameter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Option-specific handling. */
|
/* Option-specific handling. */
|
||||||
switch( ucOptionCode )
|
switch( ucOptionCode )
|
||||||
{
|
{
|
||||||
case dhcpMESSAGE_TYPE_OPTION_CODE :
|
case dhcpMESSAGE_TYPE_OPTION_CODE :
|
||||||
|
|
|
@ -98,7 +98,7 @@ the query will be responded to with these flags: */
|
||||||
|
|
||||||
/* Flag DNS parsing errors in situations where an IPv4 address is the return
|
/* Flag DNS parsing errors in situations where an IPv4 address is the return
|
||||||
type. */
|
type. */
|
||||||
#define dnsPARSE_ERROR 0UL
|
#define dnsPARSE_ERROR 0UL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a socket and bind it to the standard DNS port number. Return the
|
* Create a socket and bind it to the standard DNS port number. Return the
|
||||||
|
@ -146,7 +146,7 @@ static uint32_t prvGetHostByName( const char *pcHostName, TickType_t xIdentifier
|
||||||
{
|
{
|
||||||
uint32_t ulIPAddress; /* The IP address of an ARP cache entry. */
|
uint32_t ulIPAddress; /* The IP address of an ARP cache entry. */
|
||||||
char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ]; /* The name of the host */
|
char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ]; /* The name of the host */
|
||||||
uint32_t ulTTL; /* Time-to-Live (in seconds) from the DNS server. */
|
uint32_t ulTTL; /* Time-to-Live (in seconds) from the DNS server. */
|
||||||
uint32_t ulTimeWhenAddedInSeconds;
|
uint32_t ulTimeWhenAddedInSeconds;
|
||||||
} DNSCacheRow_t;
|
} DNSCacheRow_t;
|
||||||
|
|
||||||
|
@ -189,10 +189,10 @@ typedef struct xDNSTail DNSTail_t;
|
||||||
#include "pack_struct_start.h"
|
#include "pack_struct_start.h"
|
||||||
struct xDNSAnswerRecord
|
struct xDNSAnswerRecord
|
||||||
{
|
{
|
||||||
uint16_t usType;
|
uint16_t usType;
|
||||||
uint16_t usClass;
|
uint16_t usClass;
|
||||||
uint32_t ulTTL;
|
uint32_t ulTTL;
|
||||||
uint16_t usDataLength;
|
uint16_t usDataLength;
|
||||||
}
|
}
|
||||||
#include "pack_struct_end.h"
|
#include "pack_struct_end.h"
|
||||||
typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
||||||
|
@ -416,67 +416,67 @@ uint32_t ulIPAddress = 0UL;
|
||||||
TickType_t xReadTimeOut_ms = ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME;
|
TickType_t xReadTimeOut_ms = ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME;
|
||||||
TickType_t xIdentifier = 0;
|
TickType_t xIdentifier = 0;
|
||||||
|
|
||||||
/* If the supplied hostname is IP address, convert it to uint32_t
|
/* If the supplied hostname is IP address, convert it to uint32_t
|
||||||
and return. */
|
and return. */
|
||||||
#if( ipconfigINCLUDE_FULL_INET_ADDR == 1 )
|
#if( ipconfigINCLUDE_FULL_INET_ADDR == 1 )
|
||||||
{
|
{
|
||||||
ulIPAddress = FreeRTOS_inet_addr( pcHostName );
|
ulIPAddress = FreeRTOS_inet_addr( pcHostName );
|
||||||
}
|
}
|
||||||
#endif /* ipconfigINCLUDE_FULL_INET_ADDR == 1 */
|
#endif /* ipconfigINCLUDE_FULL_INET_ADDR == 1 */
|
||||||
|
|
||||||
/* If a DNS cache is used then check the cache before issuing another DNS
|
/* If a DNS cache is used then check the cache before issuing another DNS
|
||||||
request. */
|
request. */
|
||||||
#if( ipconfigUSE_DNS_CACHE == 1 )
|
#if( ipconfigUSE_DNS_CACHE == 1 )
|
||||||
{
|
{
|
||||||
if( ulIPAddress == 0UL )
|
if( ulIPAddress == 0UL )
|
||||||
{
|
{
|
||||||
ulIPAddress = FreeRTOS_dnslookup( pcHostName );
|
ulIPAddress = FreeRTOS_dnslookup( pcHostName );
|
||||||
if( ulIPAddress != 0 )
|
if( ulIPAddress != 0 )
|
||||||
{
|
{
|
||||||
FreeRTOS_debug_printf( ( "FreeRTOS_gethostbyname: found '%s' in cache: %lxip\n", pcHostName, ulIPAddress ) );
|
FreeRTOS_debug_printf( ( "FreeRTOS_gethostbyname: found '%s' in cache: %lxip\n", pcHostName, ulIPAddress ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* prvGetHostByName will be called to start a DNS lookup */
|
/* prvGetHostByName will be called to start a DNS lookup */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* ipconfigUSE_DNS_CACHE == 1 */
|
#endif /* ipconfigUSE_DNS_CACHE == 1 */
|
||||||
|
|
||||||
/* Generate a unique identifier. */
|
/* Generate a unique identifier. */
|
||||||
if( 0 == ulIPAddress )
|
if( 0 == ulIPAddress )
|
||||||
{
|
{
|
||||||
xIdentifier = ( TickType_t )ipconfigRAND32( );
|
xIdentifier = ( TickType_t )ipconfigRAND32( );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if( ipconfigDNS_USE_CALLBACKS != 0 )
|
#if( ipconfigDNS_USE_CALLBACKS != 0 )
|
||||||
{
|
{
|
||||||
if( pCallback != NULL )
|
if( pCallback != NULL )
|
||||||
{
|
{
|
||||||
if( ulIPAddress == 0UL )
|
if( ulIPAddress == 0UL )
|
||||||
{
|
{
|
||||||
/* The user has provided a callback function, so do not block on recvfrom() */
|
/* The user has provided a callback function, so do not block on recvfrom() */
|
||||||
if( 0 != xIdentifier )
|
if( 0 != xIdentifier )
|
||||||
{
|
{
|
||||||
xReadTimeOut_ms = 0;
|
xReadTimeOut_ms = 0;
|
||||||
vDNSSetCallBack( pcHostName, pvSearchID, pCallback, xTimeout, ( TickType_t )xIdentifier );
|
vDNSSetCallBack( pcHostName, pvSearchID, pCallback, xTimeout, ( TickType_t )xIdentifier );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The IP address is known, do the call-back now. */
|
/* The IP address is known, do the call-back now. */
|
||||||
pCallback( pcHostName, pvSearchID, ulIPAddress );
|
pCallback( pcHostName, pvSearchID, ulIPAddress );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( ulIPAddress == 0UL && 0 != xIdentifier )
|
if( ( ulIPAddress == 0UL ) && ( 0 != xIdentifier ) )
|
||||||
{
|
{
|
||||||
ulIPAddress = prvGetHostByName( pcHostName, xIdentifier, xReadTimeOut_ms );
|
ulIPAddress = prvGetHostByName( pcHostName, xIdentifier, xReadTimeOut_ms );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ulIPAddress;
|
return ulIPAddress;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -675,71 +675,71 @@ static const DNSMessage_t xDefaultPartDNSHeader =
|
||||||
static uint8_t *prvReadNameField( uint8_t *pucByte, size_t xSourceLen, char *pcName, size_t xDestLen )
|
static uint8_t *prvReadNameField( uint8_t *pucByte, size_t xSourceLen, char *pcName, size_t xDestLen )
|
||||||
{
|
{
|
||||||
size_t xNameLen = 0;
|
size_t xNameLen = 0;
|
||||||
BaseType_t xCount;
|
BaseType_t xCount;
|
||||||
|
|
||||||
if( 0 == xSourceLen )
|
if( 0 == xSourceLen )
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine if the name is the fully coded name, or an offset to the name
|
/* Determine if the name is the fully coded name, or an offset to the name
|
||||||
elsewhere in the message. */
|
elsewhere in the message. */
|
||||||
if( ( *pucByte & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET )
|
if( ( *pucByte & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET )
|
||||||
{
|
{
|
||||||
/* Jump over the two byte offset. */
|
/* Jump over the two byte offset. */
|
||||||
if( xSourceLen > sizeof( uint16_t ) )
|
if( xSourceLen > sizeof( uint16_t ) )
|
||||||
{
|
{
|
||||||
pucByte += sizeof( uint16_t );
|
pucByte += sizeof( uint16_t );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pucByte = NULL;
|
pucByte = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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++ ] = '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process the first/next sub-string. */
|
|
||||||
for( xCount = *(pucByte++), xSourceLen--;
|
|
||||||
xCount-- && xSourceLen > 1;
|
|
||||||
pucByte++, xSourceLen-- )
|
|
||||||
{
|
{
|
||||||
if( xNameLen < xDestLen - 1 )
|
pcName[ xNameLen++ ] = '.';
|
||||||
{
|
}
|
||||||
pcName[ xNameLen++ ] = *( ( char * )pucByte );
|
|
||||||
}
|
/* Process the first/next sub-string. */
|
||||||
else
|
for( xCount = *(pucByte++), xSourceLen--;
|
||||||
{
|
xCount-- && xSourceLen > 1;
|
||||||
/* DNS name is too big for the provided buffer. */
|
pucByte++, xSourceLen-- )
|
||||||
pucByte = NULL;
|
{
|
||||||
break;
|
if( xNameLen < xDestLen - 1 )
|
||||||
}
|
{
|
||||||
|
pcName[ xNameLen++ ] = *( ( char * )pucByte );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* DNS name is too big for the provided buffer. */
|
||||||
|
pucByte = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Confirm that a fully formed name was found. */
|
/* Confirm that a fully formed name was found. */
|
||||||
if( NULL != pucByte )
|
if( NULL != pucByte )
|
||||||
{
|
{
|
||||||
if( 0x00 == *pucByte )
|
if( 0x00 == *pucByte )
|
||||||
{
|
{
|
||||||
pucByte++;
|
pucByte++;
|
||||||
xSourceLen--;
|
xSourceLen--;
|
||||||
pcName[ xNameLen++ ] = '\0';
|
pcName[ xNameLen++ ] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pucByte = NULL;
|
pucByte = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pucByte;
|
return pucByte;
|
||||||
|
@ -749,58 +749,58 @@ static const DNSMessage_t xDefaultPartDNSHeader =
|
||||||
|
|
||||||
static uint8_t *prvSkipNameField( uint8_t *pucByte, size_t xSourceLen )
|
static uint8_t *prvSkipNameField( uint8_t *pucByte, size_t xSourceLen )
|
||||||
{
|
{
|
||||||
size_t xChunkLength;
|
size_t xChunkLength;
|
||||||
|
|
||||||
if( 0 == xSourceLen )
|
if( 0 == xSourceLen )
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine if the name is the fully coded name, or an offset to the name
|
/* Determine if the name is the fully coded name, or an offset to the name
|
||||||
elsewhere in the message. */
|
elsewhere in the message. */
|
||||||
if( ( *pucByte & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET )
|
if( ( *pucByte & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET )
|
||||||
{
|
{
|
||||||
/* Jump over the two byte offset. */
|
/* Jump over the two byte offset. */
|
||||||
if( xSourceLen > sizeof( uint16_t ) )
|
if( xSourceLen > sizeof( uint16_t ) )
|
||||||
{
|
{
|
||||||
pucByte += sizeof( uint16_t );
|
pucByte += sizeof( uint16_t );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pucByte = NULL;
|
pucByte = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
||||||
if( xSourceLen > xChunkLength )
|
if( xSourceLen > xChunkLength )
|
||||||
{
|
{
|
||||||
xSourceLen -= xChunkLength;
|
xSourceLen -= xChunkLength;
|
||||||
pucByte += xChunkLength;
|
pucByte += xChunkLength;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pucByte = NULL;
|
pucByte = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Confirm that a fully formed name was found. */
|
/* Confirm that a fully formed name was found. */
|
||||||
if( NULL != pucByte )
|
if( NULL != pucByte )
|
||||||
{
|
{
|
||||||
if( 0x00 == *pucByte )
|
if( 0x00 == *pucByte )
|
||||||
{
|
{
|
||||||
pucByte++;
|
pucByte++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pucByte = NULL;
|
pucByte = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pucByte;
|
return pucByte;
|
||||||
|
@ -822,12 +822,12 @@ DNSMessage_t *pxDNSMessageHeader;
|
||||||
pucUDPPayloadBuffer = pxNetworkBuffer->pucEthernetBuffer + sizeof( UDPPacket_t );
|
pucUDPPayloadBuffer = pxNetworkBuffer->pucEthernetBuffer + sizeof( UDPPacket_t );
|
||||||
pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer;
|
pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer;
|
||||||
|
|
||||||
if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t ) )
|
if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t ) )
|
||||||
{
|
{
|
||||||
prvParseDNSReply( pucUDPPayloadBuffer,
|
prvParseDNSReply( pucUDPPayloadBuffer,
|
||||||
xPlayloadBufferLength,
|
xPlayloadBufferLength,
|
||||||
( uint32_t )pxDNSMessageHeader->usIdentifier );
|
( uint32_t )pxDNSMessageHeader->usIdentifier );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The packet was not consumed. */
|
/* The packet was not consumed. */
|
||||||
return pdFAIL;
|
return pdFAIL;
|
||||||
|
@ -841,12 +841,12 @@ DNSMessage_t *pxDNSMessageHeader;
|
||||||
UDPPacket_t *pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer;
|
UDPPacket_t *pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer;
|
||||||
uint8_t *pucUDPPayloadBuffer = pxNetworkBuffer->pucEthernetBuffer + sizeof( UDPPacket_t );
|
uint8_t *pucUDPPayloadBuffer = pxNetworkBuffer->pucEthernetBuffer + sizeof( UDPPacket_t );
|
||||||
|
|
||||||
if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t) )
|
if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t) )
|
||||||
{
|
{
|
||||||
prvTreatNBNS( pucUDPPayloadBuffer,
|
prvTreatNBNS( pucUDPPayloadBuffer,
|
||||||
pxNetworkBuffer->xDataLength - sizeof( UDPPacket_t ),
|
pxNetworkBuffer->xDataLength - sizeof( UDPPacket_t ),
|
||||||
pxUDPPacket->xIPHeader.ulSourceIPAddress );
|
pxUDPPacket->xIPHeader.ulSourceIPAddress );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The packet was not consumed. */
|
/* The packet was not consumed. */
|
||||||
return pdFAIL;
|
return pdFAIL;
|
||||||
|
@ -873,24 +873,24 @@ uint16_t x, usDataLength, usQuestions;
|
||||||
char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ] = "";
|
char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ] = "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Ensure that the buffer is of at least minimal DNS message length. */
|
/* Ensure that the buffer is of at least minimal DNS message length. */
|
||||||
if( xBufferLength < sizeof( DNSMessage_t ) )
|
if( xBufferLength < sizeof( DNSMessage_t ) )
|
||||||
{
|
{
|
||||||
return dnsPARSE_ERROR;
|
return dnsPARSE_ERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xSourceBytesRemaining = xBufferLength;
|
xSourceBytesRemaining = xBufferLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the DNS message header. */
|
/* Parse the DNS message header. */
|
||||||
pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer;
|
pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer;
|
||||||
|
|
||||||
if( pxDNSMessageHeader->usIdentifier == ( uint16_t ) xIdentifier )
|
if( pxDNSMessageHeader->usIdentifier == ( uint16_t ) xIdentifier )
|
||||||
{
|
{
|
||||||
/* Start at the first byte after the header. */
|
/* Start at the first byte after the header. */
|
||||||
pucByte = pucUDPPayloadBuffer + sizeof( DNSMessage_t );
|
pucByte = pucUDPPayloadBuffer + sizeof( DNSMessage_t );
|
||||||
xSourceBytesRemaining -= sizeof( DNSMessage_t );
|
xSourceBytesRemaining -= sizeof( DNSMessage_t );
|
||||||
|
|
||||||
/* Skip any question records. */
|
/* Skip any question records. */
|
||||||
usQuestions = FreeRTOS_ntohs( pxDNSMessageHeader->usQuestions );
|
usQuestions = FreeRTOS_ntohs( pxDNSMessageHeader->usQuestions );
|
||||||
|
@ -909,58 +909,58 @@ uint16_t x, usDataLength, usQuestions;
|
||||||
if( x == 0 )
|
if( x == 0 )
|
||||||
{
|
{
|
||||||
pucByte = prvReadNameField( pucByte,
|
pucByte = prvReadNameField( pucByte,
|
||||||
xSourceBytesRemaining,
|
xSourceBytesRemaining,
|
||||||
pcName,
|
pcName,
|
||||||
sizeof( pcName ) );
|
sizeof( pcName ) );
|
||||||
|
|
||||||
/* Check for a malformed response. */
|
/* Check for a malformed response. */
|
||||||
if( NULL == pucByte )
|
if( NULL == pucByte )
|
||||||
{
|
{
|
||||||
return dnsPARSE_ERROR;
|
return dnsPARSE_ERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xSourceBytesRemaining = ( pucUDPPayloadBuffer + xBufferLength ) - pucByte;
|
xSourceBytesRemaining = ( pucUDPPayloadBuffer + xBufferLength ) - pucByte;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* ipconfigUSE_DNS_CACHE */
|
#endif /* ipconfigUSE_DNS_CACHE */
|
||||||
{
|
{
|
||||||
/* Skip the variable length pcName field. */
|
/* Skip the variable length pcName field. */
|
||||||
pucByte = prvSkipNameField( pucByte,
|
pucByte = prvSkipNameField( pucByte,
|
||||||
xSourceBytesRemaining );
|
xSourceBytesRemaining );
|
||||||
|
|
||||||
/* Check for a malformed response. */
|
/* Check for a malformed response. */
|
||||||
if( NULL == pucByte )
|
if( NULL == pucByte )
|
||||||
{
|
{
|
||||||
return dnsPARSE_ERROR;
|
return dnsPARSE_ERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte;
|
xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the remaining buffer size. */
|
/* Check the remaining buffer size. */
|
||||||
if( xSourceBytesRemaining >= sizeof( uint32_t ) )
|
if( xSourceBytesRemaining >= sizeof( uint32_t ) )
|
||||||
{
|
{
|
||||||
#if( ipconfigUSE_LLMNR == 1 )
|
#if( ipconfigUSE_LLMNR == 1 )
|
||||||
{
|
{
|
||||||
/* usChar2u16 returns value in host endianness */
|
/* usChar2u16 returns value in host endianness */
|
||||||
usType = usChar2u16( pucByte );
|
usType = usChar2u16( pucByte );
|
||||||
usClass = usChar2u16( pucByte + 2 );
|
usClass = usChar2u16( pucByte + 2 );
|
||||||
}
|
}
|
||||||
#endif /* ipconfigUSE_LLMNR */
|
#endif /* ipconfigUSE_LLMNR */
|
||||||
|
|
||||||
/* Skip the type and class fields. */
|
/* Skip the type and class fields. */
|
||||||
pucByte += sizeof( uint32_t );
|
pucByte += sizeof( uint32_t );
|
||||||
xSourceBytesRemaining -= sizeof( uint32_t );
|
xSourceBytesRemaining -= sizeof( uint32_t );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Malformed response. */
|
/* Malformed response. */
|
||||||
return dnsPARSE_ERROR;
|
return dnsPARSE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search through the answer records. */
|
/* Search through the answer records. */
|
||||||
|
@ -971,33 +971,33 @@ uint16_t x, usDataLength, usQuestions;
|
||||||
for( x = 0; x < pxDNSMessageHeader->usAnswers; x++ )
|
for( x = 0; x < pxDNSMessageHeader->usAnswers; x++ )
|
||||||
{
|
{
|
||||||
pucByte = prvSkipNameField( pucByte,
|
pucByte = prvSkipNameField( pucByte,
|
||||||
xSourceBytesRemaining );
|
xSourceBytesRemaining );
|
||||||
|
|
||||||
/* Check for a malformed response. */
|
/* Check for a malformed response. */
|
||||||
if( NULL == pucByte )
|
if( NULL == pucByte )
|
||||||
{
|
{
|
||||||
return dnsPARSE_ERROR;
|
return dnsPARSE_ERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte;
|
xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is there enough data for an IPv4 A record answer and, if so,
|
/* Is there enough data for an IPv4 A record answer and, if so,
|
||||||
is this an A record? */
|
is this an A record? */
|
||||||
if( xSourceBytesRemaining >= sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) &&
|
if( xSourceBytesRemaining >= sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) &&
|
||||||
usChar2u16( pucByte ) == dnsTYPE_A_HOST )
|
usChar2u16( pucByte ) == dnsTYPE_A_HOST )
|
||||||
{
|
{
|
||||||
/* This is the required record type and is of sufficient size. */
|
/* This is the required record type and is of sufficient size. */
|
||||||
pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte;
|
pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte;
|
||||||
|
|
||||||
/* Sanity check the data length of an IPv4 answer. */
|
/* Sanity check the data length of an IPv4 answer. */
|
||||||
if( FreeRTOS_ntohs( pxDNSAnswerRecord->usDataLength ) == sizeof( uint32_t ) )
|
if( FreeRTOS_ntohs( pxDNSAnswerRecord->usDataLength ) == sizeof( uint32_t ) )
|
||||||
{
|
{
|
||||||
/* Copy the IP address out of the record. */
|
/* Copy the IP address out of the record. */
|
||||||
memcpy( &ulIPAddress,
|
memcpy( &ulIPAddress,
|
||||||
pucByte + sizeof( DNSAnswerRecord_t ),
|
pucByte + sizeof( DNSAnswerRecord_t ),
|
||||||
sizeof( uint32_t ) );
|
sizeof( uint32_t ) );
|
||||||
|
|
||||||
#if( ipconfigUSE_DNS_CACHE == 1 )
|
#if( ipconfigUSE_DNS_CACHE == 1 )
|
||||||
{
|
{
|
||||||
|
@ -1012,32 +1012,32 @@ uint16_t x, usDataLength, usQuestions;
|
||||||
#endif /* ipconfigDNS_USE_CALLBACKS != 0 */
|
#endif /* ipconfigDNS_USE_CALLBACKS != 0 */
|
||||||
}
|
}
|
||||||
|
|
||||||
pucByte += sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t );
|
pucByte += sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t );
|
||||||
xSourceBytesRemaining -= ( sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) );
|
xSourceBytesRemaining -= ( sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( xSourceBytesRemaining >= sizeof( DNSAnswerRecord_t ) )
|
else if( xSourceBytesRemaining >= sizeof( DNSAnswerRecord_t ) )
|
||||||
{
|
{
|
||||||
/* It's not an A record, so skip it. Get the header location
|
/* It's not an A record, so skip it. Get the header location
|
||||||
and then jump over the header. */
|
and then jump over the header. */
|
||||||
pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte;
|
pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte;
|
||||||
pucByte += sizeof( DNSAnswerRecord_t );
|
pucByte += sizeof( DNSAnswerRecord_t );
|
||||||
xSourceBytesRemaining -= sizeof( DNSAnswerRecord_t );
|
xSourceBytesRemaining -= sizeof( DNSAnswerRecord_t );
|
||||||
|
|
||||||
/* Determine the length of the answer data from the header. */
|
/* Determine the length of the answer data from the header. */
|
||||||
usDataLength = FreeRTOS_ntohs( pxDNSAnswerRecord->usDataLength );
|
usDataLength = FreeRTOS_ntohs( pxDNSAnswerRecord->usDataLength );
|
||||||
|
|
||||||
/* Jump over the answer. */
|
/* Jump over the answer. */
|
||||||
if( xSourceBytesRemaining >= usDataLength )
|
if( xSourceBytesRemaining >= usDataLength )
|
||||||
{
|
{
|
||||||
pucByte += usDataLength;
|
pucByte += usDataLength;
|
||||||
xSourceBytesRemaining -= usDataLength;
|
xSourceBytesRemaining -= usDataLength;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Malformed response. */
|
/* Malformed response. */
|
||||||
return dnsPARSE_ERROR;
|
return dnsPARSE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -1130,13 +1129,13 @@ uint16_t x, usDataLength, usQuestions;
|
||||||
uint8_t ucByte;
|
uint8_t ucByte;
|
||||||
uint8_t ucNBNSName[ 17 ];
|
uint8_t ucNBNSName[ 17 ];
|
||||||
|
|
||||||
/* Check for minimum buffer size. */
|
/* Check for minimum buffer size. */
|
||||||
if( xBufferLength < sizeof( NBNSRequest_t ) )
|
if( xBufferLength < sizeof( NBNSRequest_t ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the request flags in host endianness. */
|
/* Read the request flags in host endianness. */
|
||||||
usFlags = usChar2u16( pucUDPPayloadBuffer + offsetof( NBNSRequest_t, usFlags ) );
|
usFlags = usChar2u16( pucUDPPayloadBuffer + offsetof( NBNSRequest_t, usFlags ) );
|
||||||
|
|
||||||
if( ( usFlags & dnsNBNS_FLAGS_OPCODE_MASK ) == dnsNBNS_FLAGS_OPCODE_QUERY )
|
if( ( usFlags & dnsNBNS_FLAGS_OPCODE_MASK ) == dnsNBNS_FLAGS_OPCODE_QUERY )
|
||||||
|
@ -1303,22 +1302,22 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
|
||||||
pxIPHeader = &pxUDPPacket->xIPHeader;
|
pxIPHeader = &pxUDPPacket->xIPHeader;
|
||||||
pxUDPHeader = &pxUDPPacket->xUDPHeader;
|
pxUDPHeader = &pxUDPPacket->xUDPHeader;
|
||||||
/* HT: started using defines like 'ipSIZE_OF_xxx' */
|
/* HT: started using defines like 'ipSIZE_OF_xxx' */
|
||||||
pxIPHeader->usLength = FreeRTOS_htons( lNetLength + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_UDP_HEADER );
|
pxIPHeader->usLength = FreeRTOS_htons( lNetLength + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_UDP_HEADER );
|
||||||
/* HT:endian: should not be translated, copying from packet to packet */
|
/* HT:endian: should not be translated, copying from packet to packet */
|
||||||
pxIPHeader->ulDestinationIPAddress = pxIPHeader->ulSourceIPAddress;
|
pxIPHeader->ulDestinationIPAddress = pxIPHeader->ulSourceIPAddress;
|
||||||
pxIPHeader->ulSourceIPAddress = *ipLOCAL_IP_ADDRESS_POINTER;
|
pxIPHeader->ulSourceIPAddress = *ipLOCAL_IP_ADDRESS_POINTER;
|
||||||
pxIPHeader->ucTimeToLive = ipconfigUDP_TIME_TO_LIVE;
|
pxIPHeader->ucTimeToLive = ipconfigUDP_TIME_TO_LIVE;
|
||||||
pxIPHeader->usIdentification = FreeRTOS_htons( usPacketIdentifier );
|
pxIPHeader->usIdentification = FreeRTOS_htons( usPacketIdentifier );
|
||||||
usPacketIdentifier++;
|
usPacketIdentifier++;
|
||||||
pxUDPHeader->usLength = FreeRTOS_htons( lNetLength + ipSIZE_OF_UDP_HEADER );
|
pxUDPHeader->usLength = FreeRTOS_htons( lNetLength + ipSIZE_OF_UDP_HEADER );
|
||||||
vFlip_16( pxUDPPacket->xUDPHeader.usSourcePort, pxUDPPacket->xUDPHeader.usDestinationPort );
|
vFlip_16( pxUDPPacket->xUDPHeader.usSourcePort, pxUDPPacket->xUDPHeader.usDestinationPort );
|
||||||
|
|
||||||
#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 )
|
#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 )
|
||||||
{
|
{
|
||||||
/* calculate the IP header checksum */
|
/* calculate the IP header checksum */
|
||||||
pxIPHeader->usHeaderChecksum = 0x00;
|
pxIPHeader->usHeaderChecksum = 0x00;
|
||||||
pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER );
|
pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER );
|
||||||
pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );
|
pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );
|
||||||
|
|
||||||
/* calculate the UDP checksum for outgoing package */
|
/* calculate the UDP checksum for outgoing package */
|
||||||
usGenerateProtocolChecksum( ( uint8_t* ) pxUDPPacket, lNetLength, pdTRUE );
|
usGenerateProtocolChecksum( ( uint8_t* ) pxUDPPacket, lNetLength, pdTRUE );
|
||||||
|
@ -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. */
|
||||||
|
@ -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? */
|
/* Is this function called for a lookup or to add/update an IP address? */
|
||||||
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;
|
else
|
||||||
}
|
{
|
||||||
else
|
/* Age out the old cached record. */
|
||||||
{
|
xDNSCache[ x ].pcName[ 0 ] = 0;
|
||||||
/* Age out the old cached record. */
|
}
|
||||||
xDNSCache[ x ].pcName[ 0 ] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xDNSCache[ x ].ulIPAddress = *pulIP;
|
xDNSCache[ x ].ulIPAddress = *pulIP;
|
||||||
xDNSCache[ x ].ulTTL = ulTTL;
|
xDNSCache[ x ].ulTTL = ulTTL;
|
||||||
xDNSCache[ x ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds;
|
xDNSCache[ x ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
xFound = pdTRUE;
|
xFound = pdTRUE;
|
||||||
|
@ -1392,20 +1388,20 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Add or update the item. */
|
/* Add or update the item. */
|
||||||
if( strlen( pcName ) < ipconfigDNS_CACHE_NAME_LENGTH )
|
if( strlen( pcName ) < ipconfigDNS_CACHE_NAME_LENGTH )
|
||||||
{
|
{
|
||||||
strcpy( xDNSCache[ xFreeEntry ].pcName, pcName );
|
strcpy( xDNSCache[ xFreeEntry ].pcName, pcName );
|
||||||
|
|
||||||
xDNSCache[ xFreeEntry ].ulIPAddress = *pulIP;
|
xDNSCache[ xFreeEntry ].ulIPAddress = *pulIP;
|
||||||
xDNSCache[ xFreeEntry ].ulTTL = ulTTL;
|
xDNSCache[ xFreeEntry ].ulTTL = ulTTL;
|
||||||
xDNSCache[ xFreeEntry ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds;
|
xDNSCache[ xFreeEntry ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds;
|
||||||
|
|
||||||
xFreeEntry++;
|
xFreeEntry++;
|
||||||
if( xFreeEntry == ipconfigDNS_CACHE_ENTRIES )
|
if( xFreeEntry == ipconfigDNS_CACHE_ENTRIES )
|
||||||
{
|
{
|
||||||
xFreeEntry = 0;
|
xFreeEntry = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1423,5 +1419,6 @@ TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
|
||||||
|
|
||||||
/* Provide access to private members for testing. */
|
/* Provide access to private members for testing. */
|
||||||
#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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,9 +804,8 @@ 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 ] );
|
||||||
|
@ -831,11 +831,11 @@ NetworkBufferDescriptor_t * pxNewBuffer;
|
||||||
|
|
||||||
if( pxNewBuffer != NULL )
|
if( pxNewBuffer != NULL )
|
||||||
{
|
{
|
||||||
/* Set the actual packet size in case a bigger buffer than requested
|
/* Set the actual packet size in case a bigger buffer than requested
|
||||||
was returned. */
|
was returned. */
|
||||||
pxNewBuffer->xDataLength = xNewLength;
|
pxNewBuffer->xDataLength = xNewLength;
|
||||||
|
|
||||||
/* Copy the original packet information. */
|
/* Copy the original packet information. */
|
||||||
pxNewBuffer->ulIPAddress = pxNetworkBuffer->ulIPAddress;
|
pxNewBuffer->ulIPAddress = pxNetworkBuffer->ulIPAddress;
|
||||||
pxNewBuffer->usPort = pxNetworkBuffer->usPort;
|
pxNewBuffer->usPort = pxNetworkBuffer->usPort;
|
||||||
pxNewBuffer->usBoundPort = pxNetworkBuffer->usBoundPort;
|
pxNewBuffer->usBoundPort = pxNetworkBuffer->usBoundPort;
|
||||||
|
@ -995,13 +995,13 @@ BaseType_t xReturn = pdFALSE;
|
||||||
memcpy( ( void * ) ipLOCAL_MAC_ADDRESS, ( void * ) ucMACAddress, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES );
|
memcpy( ( void * ) ipLOCAL_MAC_ADDRESS, ( void * ) ucMACAddress, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES );
|
||||||
|
|
||||||
/* Prepare the sockets interface. */
|
/* Prepare the sockets interface. */
|
||||||
xReturn = vNetworkSocketsInit();
|
xReturn = vNetworkSocketsInit();
|
||||||
|
|
||||||
if( pdTRUE == xReturn )
|
if( pdTRUE == xReturn )
|
||||||
{
|
{
|
||||||
/* Create the task that processes Ethernet and stack events. */
|
/* Create the task that processes Ethernet and stack events. */
|
||||||
xReturn = xTaskCreate( prvIPTask, "IP-task", ( uint16_t )ipconfigIP_TASK_STACK_SIZE_WORDS, NULL, ( UBaseType_t )ipconfigIP_TASK_PRIORITY, &xIPTaskHandle );
|
xReturn = xTaskCreate( prvIPTask, "IP-task", ( uint16_t )ipconfigIP_TASK_STACK_SIZE_WORDS, NULL, ( UBaseType_t )ipconfigIP_TASK_PRIORITY, &xIPTaskHandle );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1350,47 +1350,47 @@ eFrameProcessingResult_t eReturned = eReleaseBuffer;
|
||||||
configASSERT( pxNetworkBuffer );
|
configASSERT( pxNetworkBuffer );
|
||||||
|
|
||||||
/* Interpret the Ethernet frame. */
|
/* Interpret the Ethernet frame. */
|
||||||
if( pxNetworkBuffer->xDataLength >= sizeof( EthernetHeader_t ) )
|
if( pxNetworkBuffer->xDataLength >= sizeof( EthernetHeader_t ) )
|
||||||
{
|
{
|
||||||
eReturned = ipCONSIDER_FRAME_FOR_PROCESSING( pxNetworkBuffer->pucEthernetBuffer );
|
eReturned = ipCONSIDER_FRAME_FOR_PROCESSING( pxNetworkBuffer->pucEthernetBuffer );
|
||||||
pxEthernetHeader = ( EthernetHeader_t * )( pxNetworkBuffer->pucEthernetBuffer );
|
pxEthernetHeader = ( EthernetHeader_t * )( pxNetworkBuffer->pucEthernetBuffer );
|
||||||
|
|
||||||
if( eReturned == eProcessBuffer )
|
if( eReturned == eProcessBuffer )
|
||||||
{
|
{
|
||||||
/* Interpret the received Ethernet packet. */
|
/* Interpret the received Ethernet packet. */
|
||||||
switch( pxEthernetHeader->usFrameType )
|
switch( pxEthernetHeader->usFrameType )
|
||||||
{
|
{
|
||||||
case ipARP_FRAME_TYPE:
|
case ipARP_FRAME_TYPE:
|
||||||
/* The Ethernet frame contains an ARP packet. */
|
/* The Ethernet frame contains an ARP packet. */
|
||||||
if( pxNetworkBuffer->xDataLength >= sizeof( ARPPacket_t ) )
|
if( pxNetworkBuffer->xDataLength >= sizeof( ARPPacket_t ) )
|
||||||
{
|
{
|
||||||
eReturned = eARPProcessPacket( ( ARPPacket_t * )pxNetworkBuffer->pucEthernetBuffer );
|
eReturned = eARPProcessPacket( ( ARPPacket_t * )pxNetworkBuffer->pucEthernetBuffer );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eReturned = eReleaseBuffer;
|
eReturned = eReleaseBuffer;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ipIPv4_FRAME_TYPE:
|
case ipIPv4_FRAME_TYPE:
|
||||||
/* The Ethernet frame contains an IP packet. */
|
/* The Ethernet frame contains an IP packet. */
|
||||||
if( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) )
|
if( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) )
|
||||||
{
|
{
|
||||||
eReturned = prvProcessIPPacket( ( IPPacket_t * )pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer );
|
eReturned = prvProcessIPPacket( ( IPPacket_t * )pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eReturned = eReleaseBuffer;
|
eReturned = eReleaseBuffer;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* No other packet types are handled. Nothing to do. */
|
/* No other packet types are handled. Nothing to do. */
|
||||||
eReturned = eReleaseBuffer;
|
eReturned = eReleaseBuffer;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform any actions that resulted from processing the Ethernet frame. */
|
/* Perform any actions that resulted from processing the Ethernet frame. */
|
||||||
switch( eReturned )
|
switch( eReturned )
|
||||||
|
@ -1513,14 +1513,14 @@ IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader );
|
||||||
UBaseType_t uxHeaderLength = ( UBaseType_t ) ( ( pxIPHeader->ucVersionHeaderLength & 0x0Fu ) << 2 );
|
UBaseType_t uxHeaderLength = ( UBaseType_t ) ( ( pxIPHeader->ucVersionHeaderLength & 0x0Fu ) << 2 );
|
||||||
uint8_t ucProtocol;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
ucProtocol = pxIPPacket->xIPHeader.ucProtocol;
|
ucProtocol = pxIPPacket->xIPHeader.ucProtocol;
|
||||||
/* Check if the IP headers are acceptable and if it has our destination. */
|
/* Check if the IP headers are acceptable and if it has our destination. */
|
||||||
|
@ -1544,10 +1544,9 @@ uint8_t ucProtocol;
|
||||||
memmove( pucTarget, pucSource, xMoveLen );
|
memmove( pucTarget, pucSource, xMoveLen );
|
||||||
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. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the IP and MAC addresses to the ARP table if they are not
|
/* Add the IP and MAC addresses to the ARP table if they are not
|
||||||
|
@ -1573,18 +1572,18 @@ uint8_t ucProtocol;
|
||||||
be able to validate what it receives. */
|
be able to validate what it receives. */
|
||||||
#if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 )
|
#if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 )
|
||||||
{
|
{
|
||||||
if( pxNetworkBuffer->xDataLength >= sizeof( ICMPPacket_t ) )
|
if( pxNetworkBuffer->xDataLength >= sizeof( ICMPPacket_t ) )
|
||||||
{
|
{
|
||||||
ICMPPacket_t *pxICMPPacket = ( ICMPPacket_t * )( pxNetworkBuffer->pucEthernetBuffer );
|
ICMPPacket_t *pxICMPPacket = ( ICMPPacket_t * )( pxNetworkBuffer->pucEthernetBuffer );
|
||||||
if( pxIPHeader->ulDestinationIPAddress == *ipLOCAL_IP_ADDRESS_POINTER )
|
if( pxIPHeader->ulDestinationIPAddress == *ipLOCAL_IP_ADDRESS_POINTER )
|
||||||
{
|
{
|
||||||
eReturn = prvProcessICMPPacket( pxICMPPacket );
|
eReturn = prvProcessICMPPacket( pxICMPPacket );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eReturn = eReleaseBuffer;
|
eReturn = eReleaseBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) */
|
#endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) */
|
||||||
break;
|
break;
|
||||||
|
@ -1594,47 +1593,46 @@ uint8_t ucProtocol;
|
||||||
/* The IP packet contained a UDP frame. */
|
/* The IP packet contained a UDP frame. */
|
||||||
UDPPacket_t *pxUDPPacket = ( UDPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer );
|
UDPPacket_t *pxUDPPacket = ( UDPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer );
|
||||||
|
|
||||||
/* Only proceed if the payload length indicated in the header
|
/* Only proceed if the payload length indicated in the header
|
||||||
appears to be valid. */
|
appears to be valid. */
|
||||||
if ( pxNetworkBuffer->xDataLength >= sizeof( UDPPacket_t ) )
|
if ( pxNetworkBuffer->xDataLength >= sizeof( UDPPacket_t ) )
|
||||||
{
|
{
|
||||||
/* Ensure that downstream UDP packet handling has the lesser
|
/* Ensure that downstream UDP packet handling has the lesser
|
||||||
* of: the actual network buffer Ethernet frame length, or
|
* of: the actual network buffer Ethernet frame length, or
|
||||||
* the sender's UDP packet header payload length, minus the
|
* the sender's UDP packet header payload length, minus the
|
||||||
* size of the UDP header.
|
* size of the UDP header.
|
||||||
*
|
*
|
||||||
* The size of the UDP packet structure in this implementation
|
* The size of the UDP packet structure in this implementation
|
||||||
* includes the size of the Ethernet header, the size of
|
* includes the size of the Ethernet header, the size of
|
||||||
* the IP header, and the size of the UDP header.
|
* the IP header, and the size of the UDP header.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pxNetworkBuffer->xDataLength -= sizeof( UDPPacket_t );
|
pxNetworkBuffer->xDataLength -= sizeof( UDPPacket_t );
|
||||||
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. */
|
||||||
pxNetworkBuffer->usPort = pxUDPPacket->xUDPHeader.usSourcePort;
|
pxNetworkBuffer->usPort = pxUDPPacket->xUDPHeader.usSourcePort;
|
||||||
pxNetworkBuffer->ulIPAddress = pxUDPPacket->xIPHeader.ulSourceIPAddress;
|
pxNetworkBuffer->ulIPAddress = pxUDPPacket->xIPHeader.ulSourceIPAddress;
|
||||||
|
|
||||||
/* ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM:
|
/* ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM:
|
||||||
* In some cases, the upper-layer checksum has been calculated
|
* In some cases, the upper-layer checksum has been calculated
|
||||||
* by the NIC driver.
|
* by the NIC driver.
|
||||||
*
|
*
|
||||||
* Pass the packet payload to the UDP sockets implementation. */
|
* Pass the packet payload to the UDP sockets implementation. */
|
||||||
if( xProcessReceivedUDPPacket( pxNetworkBuffer,
|
if( xProcessReceivedUDPPacket( pxNetworkBuffer,
|
||||||
pxUDPPacket->xUDPHeader.usDestinationPort ) == pdPASS )
|
pxUDPPacket->xUDPHeader.usDestinationPort ) == pdPASS )
|
||||||
{
|
{
|
||||||
eReturn = eFrameConsumed;
|
eReturn = eFrameConsumed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eReturn = eReleaseBuffer;
|
eReturn = eReleaseBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1803,47 +1801,46 @@ uint8_t ucProtocol;
|
||||||
const char *pcType;
|
const char *pcType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check for minimum packet size. */
|
/* Check for minimum packet size. */
|
||||||
if( uxBufferLength < sizeof( IPPacket_t ) )
|
if( uxBufferLength < sizeof( IPPacket_t ) )
|
||||||
{
|
{
|
||||||
return ipINVALID_LENGTH;
|
return ipINVALID_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the packet length. */
|
/* Parse the packet length. */
|
||||||
pxIPPacket = ( const IPPacket_t * ) pucEthernetBuffer;
|
pxIPPacket = ( const IPPacket_t * ) pucEthernetBuffer;
|
||||||
|
|
||||||
/* 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 )
|
||||||
{
|
{
|
||||||
return ipINVALID_LENGTH;
|
return ipINVALID_LENGTH;
|
||||||
}
|
}
|
||||||
if( uxBufferLength < FreeRTOS_ntohs( pxIPPacket->xIPHeader.usLength ) )
|
if( uxBufferLength < FreeRTOS_ntohs( pxIPPacket->xIPHeader.usLength ) )
|
||||||
{
|
{
|
||||||
return ipINVALID_LENGTH;
|
return ipINVALID_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Identify the next protocol. */
|
/* Identify the next protocol. */
|
||||||
ucProtocol = pxIPPacket->xIPHeader.ucProtocol;
|
ucProtocol = pxIPPacket->xIPHeader.ucProtocol;
|
||||||
|
|
||||||
/* N.B., if this IP packet header includes Options, then the following
|
/* N.B., if this IP packet header includes Options, then the following
|
||||||
assignment results in a pointer into the protocol packet with the Ethernet
|
assignment results in a pointer into the protocol packet with the Ethernet
|
||||||
and IP headers incorrectly aligned. However, either way, the "third"
|
and IP headers incorrectly aligned. However, either way, the "third"
|
||||||
protocol (Layer 3 or 4) header will be aligned, which is the convenience
|
protocol (Layer 3 or 4) header will be aligned, which is the convenience
|
||||||
of this calculation. */
|
of this calculation. */
|
||||||
pxProtPack = ( ProtocolPacket_t * ) ( pucEthernetBuffer + ( uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ) );
|
pxProtPack = ( ProtocolPacket_t * ) ( pucEthernetBuffer + ( uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ) );
|
||||||
|
|
||||||
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
pusChecksum = ( uint16_t * ) ( &( pxProtPack->xUDPPacket.xUDPHeader.usChecksum ) );
|
pusChecksum = ( uint16_t * ) ( &( pxProtPack->xUDPPacket.xUDPHeader.usChecksum ) );
|
||||||
#if( ipconfigHAS_DEBUG_PRINTF != 0 )
|
#if( ipconfigHAS_DEBUG_PRINTF != 0 )
|
||||||
|
@ -1854,12 +1851,12 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
pusChecksum = ( uint16_t * ) ( &( pxProtPack->xTCPPacket.xTCPHeader.usChecksum ) );
|
pusChecksum = ( uint16_t * ) ( &( pxProtPack->xTCPPacket.xTCPHeader.usChecksum ) );
|
||||||
#if( ipconfigHAS_DEBUG_PRINTF != 0 )
|
#if( ipconfigHAS_DEBUG_PRINTF != 0 )
|
||||||
{
|
{
|
||||||
pcType = "TCP";
|
pcType = "TCP";
|
||||||
|
@ -1869,12 +1866,12 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
pusChecksum = ( uint16_t * ) ( &( pxProtPack->xICMPPacket.xICMPHeader.usChecksum ) );
|
pusChecksum = ( uint16_t * ) ( &( pxProtPack->xICMPPacket.xICMPHeader.usChecksum ) );
|
||||||
#if( ipconfigHAS_DEBUG_PRINTF != 0 )
|
#if( ipconfigHAS_DEBUG_PRINTF != 0 )
|
||||||
{
|
{
|
||||||
if( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP )
|
if( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP )
|
||||||
|
@ -1894,8 +1891,8 @@ uint8_t ucProtocol;
|
||||||
return ipUNHANDLED_PROTOCOL;
|
return ipUNHANDLED_PROTOCOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The protocol and checksum field have been identified. Check the direction
|
/* The protocol and checksum field have been identified. Check the direction
|
||||||
of the packet. */
|
of the packet. */
|
||||||
if( xOutgoingPacket != pdFALSE )
|
if( xOutgoingPacket != pdFALSE )
|
||||||
{
|
{
|
||||||
/* This is an outgoing packet. Before calculating the checksum, set it
|
/* This is an outgoing packet. Before calculating the checksum, set it
|
||||||
|
@ -2021,12 +2018,12 @@ uint8_t ucProtocol;
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* ulSum: This argument provides a value to initialize the progressive summation
|
* ulSum: This argument provides a value to initialize the progressive summation
|
||||||
* of the header's values to. It is often 0, but protocols like TCP or UDP
|
* of the header's values to. It is often 0, but protocols like TCP or UDP
|
||||||
* can have pseudo-header fields which need to be included in the checksum.
|
* can have pseudo-header fields which need to be included in the checksum.
|
||||||
* pucNextData: This argument contains the address of the first byte which this
|
* pucNextData: This argument contains the address of the first byte which this
|
||||||
* method should process. The method's memory iterator is initialized to this value.
|
* method should process. The method's memory iterator is initialized to this value.
|
||||||
* uxDataLengthBytes: This argument contains the number of bytes that this method
|
* uxDataLengthBytes: This argument contains the number of bytes that this method
|
||||||
* should process.
|
* should process.
|
||||||
*/
|
*/
|
||||||
uint16_t usGenerateChecksum( uint32_t ulSum, const uint8_t * pucNextData, size_t uxDataLengthBytes )
|
uint16_t usGenerateChecksum( uint32_t ulSum, const uint8_t * pucNextData, size_t uxDataLengthBytes )
|
||||||
{
|
{
|
||||||
|
@ -2226,8 +2223,8 @@ uint32_t FreeRTOS_GetNetmask( void )
|
||||||
|
|
||||||
void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ipMAC_ADDRESS_LENGTH_BYTES] )
|
void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ipMAC_ADDRESS_LENGTH_BYTES] )
|
||||||
{
|
{
|
||||||
/* Copy the MAC address at the start of the default packet header fragment. */
|
/* Copy the MAC address at the start of the default packet header fragment. */
|
||||||
memcpy( ( void * )ipLOCAL_MAC_ADDRESS, ( void * )ucMACAddress, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );
|
memcpy( ( void * )ipLOCAL_MAC_ADDRESS, ( void * )ucMACAddress, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ port number. */
|
||||||
|
|
||||||
/* Test if a socket it bound which means it is either included in
|
/* Test if a socket it bound which means it is either included in
|
||||||
xBoundUDPSocketsList or xBoundTCPSocketsList */
|
xBoundUDPSocketsList or xBoundTCPSocketsList */
|
||||||
#define socketSOCKET_IS_BOUND( pxSocket ) ( listLIST_ITEM_CONTAINER( & ( pxSocket )->xBoundSocketListItem ) != NULL )
|
#define socketSOCKET_IS_BOUND( pxSocket ) ( listLIST_ITEM_CONTAINER( & ( pxSocket )->xBoundSocketListItem ) != NULL )
|
||||||
|
|
||||||
/* If FreeRTOS_sendto() is called on a socket that is not bound to a port
|
/* If FreeRTOS_sendto() is called on a socket that is not bound to a port
|
||||||
number then, depending on the FreeRTOSIPConfig.h settings, it might be that a
|
number then, depending on the FreeRTOSIPConfig.h settings, it might be that a
|
||||||
|
@ -190,15 +190,15 @@ BaseType_t xReturn = pdTRUE;
|
||||||
|
|
||||||
BaseType_t vNetworkSocketsInit( void )
|
BaseType_t vNetworkSocketsInit( void )
|
||||||
{
|
{
|
||||||
vListInitialise( &xBoundUDPSocketsList );
|
vListInitialise( &xBoundUDPSocketsList );
|
||||||
|
|
||||||
#if( ipconfigUSE_TCP == 1 )
|
#if( ipconfigUSE_TCP == 1 )
|
||||||
{
|
{
|
||||||
vListInitialise( &xBoundTCPSocketsList );
|
vListInitialise( &xBoundTCPSocketsList );
|
||||||
}
|
}
|
||||||
#endif /* ipconfigUSE_TCP == 1 */
|
#endif /* ipconfigUSE_TCP == 1 */
|
||||||
|
|
||||||
return pdTRUE;
|
return pdTRUE;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ FreeRTOS_Socket_t *pxSocket;
|
||||||
if( xType != FREERTOS_SOCK_DGRAM )
|
if( xType != FREERTOS_SOCK_DGRAM )
|
||||||
{
|
{
|
||||||
xReturn = pdFAIL;
|
xReturn = pdFAIL;
|
||||||
configASSERT( xReturn );
|
configASSERT( xReturn );
|
||||||
}
|
}
|
||||||
/* In case a UDP socket is created, do not allocate space for TCP data. */
|
/* In case a UDP socket is created, do not allocate space for TCP data. */
|
||||||
*pxSocketSize = ( sizeof( *pxSocket ) - sizeof( pxSocket->u ) ) + sizeof( pxSocket->u.xUDP );
|
*pxSocketSize = ( sizeof( *pxSocket ) - sizeof( pxSocket->u ) ) + sizeof( pxSocket->u.xUDP );
|
||||||
|
@ -243,7 +243,7 @@ FreeRTOS_Socket_t *pxSocket;
|
||||||
if( xType != FREERTOS_SOCK_STREAM )
|
if( xType != FREERTOS_SOCK_STREAM )
|
||||||
{
|
{
|
||||||
xReturn = pdFAIL;
|
xReturn = pdFAIL;
|
||||||
configASSERT( xReturn );
|
configASSERT( xReturn );
|
||||||
}
|
}
|
||||||
|
|
||||||
*pxSocketSize = ( sizeof( *pxSocket ) - sizeof( pxSocket->u ) ) + sizeof( pxSocket->u.xTCP );
|
*pxSocketSize = ( sizeof( *pxSocket ) - sizeof( pxSocket->u ) ) + sizeof( pxSocket->u.xTCP );
|
||||||
|
@ -252,7 +252,7 @@ FreeRTOS_Socket_t *pxSocket;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xReturn = pdFAIL;
|
xReturn = pdFAIL;
|
||||||
configASSERT( xReturn );
|
configASSERT( xReturn );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* In case configASSERT() is not used */
|
/* In case configASSERT() is not used */
|
||||||
|
@ -317,9 +317,9 @@ Socket_t xReturn;
|
||||||
listSET_LIST_ITEM_OWNER( &( pxSocket->xBoundSocketListItem ), ( void * ) pxSocket );
|
listSET_LIST_ITEM_OWNER( &( pxSocket->xBoundSocketListItem ), ( void * ) pxSocket );
|
||||||
|
|
||||||
pxSocket->xReceiveBlockTime = ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME;
|
pxSocket->xReceiveBlockTime = ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME;
|
||||||
pxSocket->xSendBlockTime = ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME;
|
pxSocket->xSendBlockTime = ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME;
|
||||||
pxSocket->ucSocketOptions = ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT;
|
pxSocket->ucSocketOptions = ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT;
|
||||||
pxSocket->ucProtocol = ( uint8_t ) xProtocol; /* protocol: UDP or TCP */
|
pxSocket->ucProtocol = ( uint8_t ) xProtocol; /* protocol: UDP or TCP */
|
||||||
|
|
||||||
#if( ipconfigUSE_TCP == 1 )
|
#if( ipconfigUSE_TCP == 1 )
|
||||||
{
|
{
|
||||||
|
@ -327,7 +327,7 @@ Socket_t xReturn;
|
||||||
{
|
{
|
||||||
/* StreamSize is expressed in number of bytes */
|
/* StreamSize is expressed in number of bytes */
|
||||||
/* Round up buffer sizes to nearest multiple of MSS */
|
/* Round up buffer sizes to nearest multiple of MSS */
|
||||||
pxSocket->u.xTCP.usInitMSS = pxSocket->u.xTCP.usCurMSS = ipconfigTCP_MSS;
|
pxSocket->u.xTCP.usInitMSS = pxSocket->u.xTCP.usCurMSS = ipconfigTCP_MSS;
|
||||||
pxSocket->u.xTCP.uxRxStreamSize = ( size_t ) ipconfigTCP_RX_BUFFER_LENGTH;
|
pxSocket->u.xTCP.uxRxStreamSize = ( size_t ) ipconfigTCP_RX_BUFFER_LENGTH;
|
||||||
pxSocket->u.xTCP.uxTxStreamSize = ( size_t ) FreeRTOS_round_up( ipconfigTCP_TX_BUFFER_LENGTH, ipconfigTCP_MSS );
|
pxSocket->u.xTCP.uxTxStreamSize = ( size_t ) FreeRTOS_round_up( ipconfigTCP_TX_BUFFER_LENGTH, ipconfigTCP_MSS );
|
||||||
/* Use half of the buffer size of the TCP windows */
|
/* Use half of the buffer size of the TCP windows */
|
||||||
|
@ -1010,10 +1010,10 @@ List_t *pxSocketList;
|
||||||
if( pxAddress->sin_port == 0u )
|
if( pxAddress->sin_port == 0u )
|
||||||
{
|
{
|
||||||
pxAddress->sin_port = prvGetPrivatePortNumber( ( BaseType_t )pxSocket->ucProtocol );
|
pxAddress->sin_port = prvGetPrivatePortNumber( ( BaseType_t )pxSocket->ucProtocol );
|
||||||
if( 0 == pxAddress->sin_port )
|
if( 0 == pxAddress->sin_port )
|
||||||
{
|
{
|
||||||
return -pdFREERTOS_ERRNO_EADDRNOTAVAIL;
|
return -pdFREERTOS_ERRNO_EADDRNOTAVAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If vSocketBind() is called from the API FreeRTOS_bind() it has been
|
/* If vSocketBind() is called from the API FreeRTOS_bind() it has been
|
||||||
|
@ -1611,7 +1611,7 @@ FreeRTOS_Socket_t *pxSocket;
|
||||||
static uint16_t prvGetPrivatePortNumber( BaseType_t xProtocol )
|
static uint16_t prvGetPrivatePortNumber( BaseType_t xProtocol )
|
||||||
{
|
{
|
||||||
const uint16_t usEphemeralPortCount =
|
const uint16_t usEphemeralPortCount =
|
||||||
socketAUTO_PORT_ALLOCATION_MAX_NUMBER - socketAUTO_PORT_ALLOCATION_START_NUMBER + 1;
|
socketAUTO_PORT_ALLOCATION_MAX_NUMBER - socketAUTO_PORT_ALLOCATION_START_NUMBER + 1;
|
||||||
uint16_t usIterations = usEphemeralPortCount;
|
uint16_t usIterations = usEphemeralPortCount;
|
||||||
uint32_t ulRandomSeed = 0;
|
uint32_t ulRandomSeed = 0;
|
||||||
uint16_t usResult = 0;
|
uint16_t usResult = 0;
|
||||||
|
@ -1632,51 +1632,51 @@ const List_t *pxList;
|
||||||
/* Avoid compiler warnings if ipconfigUSE_TCP is not defined. */
|
/* Avoid compiler warnings if ipconfigUSE_TCP is not defined. */
|
||||||
( void ) xProtocol;
|
( void ) xProtocol;
|
||||||
|
|
||||||
/* Find the next available port using the random seed as a starting
|
/* Find the next available port using the random seed as a starting
|
||||||
point. */
|
point. */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Generate a random seed. */
|
/* Generate a random seed. */
|
||||||
ulRandomSeed = ipconfigRAND32( );
|
ulRandomSeed = ipconfigRAND32( );
|
||||||
|
|
||||||
/* Only proceed if the random number generator succeeded. */
|
/* Only proceed if the random number generator succeeded. */
|
||||||
if( 0 == ulRandomSeed )
|
if( 0 == ulRandomSeed )
|
||||||
{
|
{
|
||||||
if( pdFALSE == xGotZeroOnce )
|
if( pdFALSE == xGotZeroOnce )
|
||||||
{
|
{
|
||||||
xGotZeroOnce = pdTRUE;
|
xGotZeroOnce = pdTRUE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Map the random to a candidate port. */
|
/* Map the random to a candidate port. */
|
||||||
usResult =
|
usResult =
|
||||||
socketAUTO_PORT_ALLOCATION_START_NUMBER +
|
socketAUTO_PORT_ALLOCATION_START_NUMBER +
|
||||||
( ( ( uint16_t )ulRandomSeed ) % usEphemeralPortCount );
|
( ( ( uint16_t )ulRandomSeed ) % usEphemeralPortCount );
|
||||||
|
|
||||||
/* Check if there's already an open socket with the same protocol
|
/* Check if there's already an open socket with the same protocol
|
||||||
and port. */
|
and port. */
|
||||||
if( NULL == pxListFindListItemWithValue(
|
if( NULL == pxListFindListItemWithValue(
|
||||||
pxList,
|
pxList,
|
||||||
( TickType_t )FreeRTOS_htons( usResult ) ) )
|
( TickType_t )FreeRTOS_htons( usResult ) ) )
|
||||||
{
|
{
|
||||||
usResult = FreeRTOS_htons( usResult );
|
usResult = FreeRTOS_htons( usResult );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usResult = 0;
|
usResult = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
usIterations--;
|
usIterations--;
|
||||||
}
|
}
|
||||||
while( usIterations > 0 );
|
while( usIterations > 0 );
|
||||||
|
|
||||||
return usResult;
|
return usResult;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -3339,7 +3339,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FreeRTOS_printf( ( "Prot Port IP-Remote : Port R/T Status Alive tmout Child\n" ) );
|
FreeRTOS_printf( ( "Prot Port IP-Remote : Port R/T Status Alive tmout Child\n" ) );
|
||||||
for( pxIterator = ( ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList );
|
for( pxIterator = ( ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList );
|
||||||
pxIterator != ( ListItem_t * ) listGET_END_MARKER( &xBoundTCPSocketsList );
|
pxIterator != ( ListItem_t * ) listGET_END_MARKER( &xBoundTCPSocketsList );
|
||||||
pxIterator = ( ListItem_t * ) listGET_NEXT( pxIterator ) )
|
pxIterator = ( ListItem_t * ) listGET_NEXT( pxIterator ) )
|
||||||
|
|
|
@ -352,11 +352,10 @@ 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 );
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -854,8 +853,8 @@ NetworkBufferDescriptor_t xTempBuffer;
|
||||||
vFlip_32( pxTCPPacket->xTCPHeader.ulSequenceNumber, pxTCPPacket->xTCPHeader.ulAckNr );
|
vFlip_32( pxTCPPacket->xTCPHeader.ulSequenceNumber, pxTCPPacket->xTCPHeader.ulAckNr );
|
||||||
}
|
}
|
||||||
|
|
||||||
pxIPHeader->ucTimeToLive = ( uint8_t ) ipconfigTCP_TIME_TO_LIVE;
|
pxIPHeader->ucTimeToLive = ( uint8_t ) ipconfigTCP_TIME_TO_LIVE;
|
||||||
pxIPHeader->usLength = FreeRTOS_htons( ulLen );
|
pxIPHeader->usLength = FreeRTOS_htons( ulLen );
|
||||||
if( ( pxSocket == NULL ) || ( *ipLOCAL_IP_ADDRESS_POINTER == 0ul ) )
|
if( ( pxSocket == NULL ) || ( *ipLOCAL_IP_ADDRESS_POINTER == 0ul ) )
|
||||||
{
|
{
|
||||||
/* When pxSocket is NULL, this function is called by prvTCPSendReset()
|
/* When pxSocket is NULL, this function is called by prvTCPSendReset()
|
||||||
|
@ -1023,21 +1022,20 @@ uint32_t ulInitialSequenceNumber = 0;
|
||||||
xReturn = pdFALSE;
|
xReturn = pdFALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 );
|
|
||||||
|
|
||||||
/* Check for a random number generation error. */
|
/* Check for a random number generation error. */
|
||||||
if( 0 == ulInitialSequenceNumber )
|
if( 0 == ulInitialSequenceNumber )
|
||||||
{
|
{
|
||||||
xReturn = pdFALSE;
|
xReturn = pdFALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( xReturn != pdFALSE )
|
if( xReturn != pdFALSE )
|
||||||
{
|
{
|
||||||
|
@ -1152,17 +1150,17 @@ UBaseType_t uxNewMSS;
|
||||||
pucLast = pucPtr + (((pxTCPHeader->ucTCPOffset >> 4) - 5) << 2);
|
pucLast = pucPtr + (((pxTCPHeader->ucTCPOffset >> 4) - 5) << 2);
|
||||||
pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow;
|
pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow;
|
||||||
|
|
||||||
/* Validate options size calculation. */
|
/* Validate options size calculation. */
|
||||||
if( pucLast > ( pxNetworkBuffer->pucEthernetBuffer + pxNetworkBuffer->xDataLength ) )
|
if( pucLast > ( pxNetworkBuffer->pucEthernetBuffer + pxNetworkBuffer->xDataLength ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The comparison with pucLast is only necessary in case the option data are
|
/* The comparison with pucLast is only necessary in case the option data are
|
||||||
corrupted, we don't like to run into invalid memory and crash. */
|
corrupted, we don't like to run into invalid memory and crash. */
|
||||||
while( pucPtr < pucLast )
|
while( pucPtr < pucLast )
|
||||||
{
|
{
|
||||||
UBaseType_t xRemainingOptionsBytes = pucLast - pucPtr;
|
UBaseType_t xRemainingOptionsBytes = pucLast - pucPtr;
|
||||||
|
|
||||||
if( pucPtr[ 0 ] == TCP_OPT_END )
|
if( pucPtr[ 0 ] == TCP_OPT_END )
|
||||||
{
|
{
|
||||||
|
@ -1171,26 +1169,25 @@ UBaseType_t uxNewMSS;
|
||||||
}
|
}
|
||||||
if( pucPtr[ 0 ] == TCP_OPT_NOOP)
|
if( pucPtr[ 0 ] == TCP_OPT_NOOP)
|
||||||
{
|
{
|
||||||
/* NOP option, inserted to make the length a multiple of 4. */
|
/* NOP option, inserted to make the length a multiple of 4. */
|
||||||
pucPtr++;
|
pucPtr++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Any other well-formed option must be at least two bytes: the option
|
/* Any other well-formed option must be at least two bytes: the option
|
||||||
type byte followed by a length byte. */
|
type byte followed by a length byte. */
|
||||||
if( xRemainingOptionsBytes < 2 )
|
if( xRemainingOptionsBytes < 2 )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if( ipconfigUSE_TCP_WIN != 0 )
|
#if( ipconfigUSE_TCP_WIN != 0 )
|
||||||
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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pxSocket->u.xTCP.ucPeerWinScaleFactor = pucPtr[ 2 ];
|
pxSocket->u.xTCP.ucPeerWinScaleFactor = pucPtr[ 2 ];
|
||||||
pxSocket->u.xTCP.bits.bWinScaling = pdTRUE_UNSIGNED;
|
pxSocket->u.xTCP.bits.bWinScaling = pdTRUE_UNSIGNED;
|
||||||
|
@ -1199,25 +1196,24 @@ UBaseType_t uxNewMSS;
|
||||||
#endif /* ipconfigUSE_TCP_WIN */
|
#endif /* ipconfigUSE_TCP_WIN */
|
||||||
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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* An MSS option with the correct option length. FreeRTOS_htons()
|
/* An MSS option with the correct option length. FreeRTOS_htons()
|
||||||
is not needed here because usChar2u16() already returns a host
|
is not needed here because usChar2u16() already returns a host
|
||||||
endian number. */
|
endian number. */
|
||||||
uxNewMSS = usChar2u16( pucPtr + 2 );
|
uxNewMSS = usChar2u16( pucPtr + 2 );
|
||||||
|
|
||||||
if( pxSocket->u.xTCP.usInitMSS != uxNewMSS )
|
if( pxSocket->u.xTCP.usInitMSS != uxNewMSS )
|
||||||
{
|
{
|
||||||
/* Perform a basic check on the the new MSS. */
|
/* Perform a basic check on the the new MSS. */
|
||||||
if( uxNewMSS == 0 )
|
if( uxNewMSS == 0 )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeRTOS_debug_printf( ( "MSS change %u -> %lu\n", pxSocket->u.xTCP.usInitMSS, uxNewMSS ) );
|
FreeRTOS_debug_printf( ( "MSS change %u -> %lu\n", pxSocket->u.xTCP.usInitMSS, uxNewMSS ) );
|
||||||
}
|
}
|
||||||
|
@ -1253,10 +1249,10 @@ 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. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1394,7 +1390,7 @@ UBaseType_t uxOptionsLength;
|
||||||
pxTCPHeader->ucOptdata[ uxOptionsLength + 3 ] = 2; /* 2: length of this option. */
|
pxTCPHeader->ucOptdata[ uxOptionsLength + 3 ] = 2; /* 2: length of this option. */
|
||||||
uxOptionsLength += 4u;
|
uxOptionsLength += 4u;
|
||||||
|
|
||||||
return uxOptionsLength; /* bytes, not words. */
|
return uxOptionsLength; /* bytes, not words. */
|
||||||
}
|
}
|
||||||
#endif /* ipconfigUSE_TCP_WIN == 0 */
|
#endif /* ipconfigUSE_TCP_WIN == 0 */
|
||||||
}
|
}
|
||||||
|
@ -1639,8 +1635,8 @@ BaseType_t xResize;
|
||||||
|
|
||||||
if( pxReturn != NULL )
|
if( pxReturn != NULL )
|
||||||
{
|
{
|
||||||
/* Set the actual packet size, in case the returned buffer is larger. */
|
/* Set the actual packet size, in case the returned buffer is larger. */
|
||||||
pxReturn->xDataLength = lNeeded;
|
pxReturn->xDataLength = lNeeded;
|
||||||
|
|
||||||
/* Copy the existing data to the new created buffer. */
|
/* Copy the existing data to the new created buffer. */
|
||||||
if( pxNetworkBuffer )
|
if( pxNetworkBuffer )
|
||||||
|
@ -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
|
The size of the TCP header is given in a multiple of 4-byte words (single
|
||||||
byte, needs no ntoh() translation). A shift-right 2: is the same as
|
byte, needs no ntoh() translation). A shift-right 2: is the same as
|
||||||
(offset >> 4) * 4. */
|
(offset >> 4) * 4. */
|
||||||
lTCPHeaderLength = ( BaseType_t ) ( ( pxTCPHeader->ucTCPOffset & VALID_BITS_IN_TCP_OFFSET_BYTE ) >> 2 );
|
lTCPHeaderLength = ( BaseType_t ) ( ( pxTCPHeader->ucTCPOffset & VALID_BITS_IN_TCP_OFFSET_BYTE ) >> 2 );
|
||||||
|
|
||||||
/* Let pucRecvData point to the first byte received. */
|
/* Let pucRecvData point to the first byte received. */
|
||||||
*ppucRecvData = pxNetworkBuffer->pucEthernetBuffer + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + lTCPHeaderLength;
|
*ppucRecvData = pxNetworkBuffer->pucEthernetBuffer + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + lTCPHeaderLength;
|
||||||
|
@ -2436,7 +2432,7 @@ int32_t lDistance, lSendResult;
|
||||||
{
|
{
|
||||||
/* xTCPWindowTxDone returns true when all Tx queues are empty. */
|
/* xTCPWindowTxDone returns true when all Tx queues are empty. */
|
||||||
bRxComplete = xTCPWindowRxEmpty( pxTCPWindow );
|
bRxComplete = xTCPWindowRxEmpty( pxTCPWindow );
|
||||||
bTxDone = xTCPWindowTxDone( pxTCPWindow );
|
bTxDone = xTCPWindowTxDone( pxTCPWindow );
|
||||||
|
|
||||||
if( ( bRxComplete == 0 ) || ( bTxDone == 0 ) )
|
if( ( bRxComplete == 0 ) || ( bTxDone == 0 ) )
|
||||||
{
|
{
|
||||||
|
@ -2905,24 +2901,23 @@ uint32_t ulRemoteIP;
|
||||||
uint16_t xRemotePort;
|
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 );
|
xLocalPort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usDestinationPort );
|
||||||
xLocalPort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usDestinationPort );
|
ulRemoteIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulSourceIPAddress );
|
||||||
ulRemoteIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulSourceIPAddress );
|
xRemotePort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usSourcePort );
|
||||||
xRemotePort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usSourcePort );
|
|
||||||
|
|
||||||
/* Find the destination socket, and if not found: return a socket listing to
|
/* Find the destination socket, and if not found: return a socket listing to
|
||||||
the destination PORT. */
|
the destination PORT. */
|
||||||
pxSocket = ( FreeRTOS_Socket_t * )pxTCPSocketLookup( ulLocalIP, xLocalPort, ulRemoteIP, xRemotePort );
|
pxSocket = ( FreeRTOS_Socket_t * )pxTCPSocketLookup( ulLocalIP, xLocalPort, ulRemoteIP, xRemotePort );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return pdFAIL;
|
return pdFAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( pxSocket == NULL ) || ( prvTCPSocketIsActive( ( UBaseType_t ) pxSocket->u.xTCP.ucTCPState ) == pdFALSE ) )
|
if( ( pxSocket == NULL ) || ( prvTCPSocketIsActive( ( UBaseType_t ) pxSocket->u.xTCP.ucTCPState ) == pdFALSE ) )
|
||||||
{
|
{
|
||||||
|
@ -3086,64 +3081,63 @@ TCPPacket_t * pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuff
|
||||||
FreeRTOS_Socket_t *pxReturn = NULL;
|
FreeRTOS_Socket_t *pxReturn = NULL;
|
||||||
uint32_t ulInitialSequenceNumber;
|
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 );
|
|
||||||
|
|
||||||
/* A pure SYN (without ACK) has come in, create a new socket to answer
|
/* A pure SYN (without ACK) has come in, create a new socket to answer
|
||||||
it. */
|
it. */
|
||||||
if( 0 != ulInitialSequenceNumber )
|
if( 0 != ulInitialSequenceNumber )
|
||||||
{
|
{
|
||||||
if( pxSocket->u.xTCP.bits.bReuseSocket != pdFALSE_UNSIGNED )
|
if( pxSocket->u.xTCP.bits.bReuseSocket != pdFALSE_UNSIGNED )
|
||||||
{
|
{
|
||||||
/* The flag bReuseSocket indicates that the same instance of the
|
/* The flag bReuseSocket indicates that the same instance of the
|
||||||
listening socket should be used for the connection. */
|
listening socket should be used for the connection. */
|
||||||
pxReturn = pxSocket;
|
pxReturn = pxSocket;
|
||||||
pxSocket->u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED;
|
pxSocket->u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED;
|
||||||
pxSocket->u.xTCP.pxPeerSocket = pxSocket;
|
pxSocket->u.xTCP.pxPeerSocket = pxSocket;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The socket does not have the bReuseSocket flag set meaning create a
|
/* The socket does not have the bReuseSocket flag set meaning create a
|
||||||
new socket when a connection comes in. */
|
new socket when a connection comes in. */
|
||||||
pxReturn = NULL;
|
pxReturn = NULL;
|
||||||
|
|
||||||
if( pxSocket->u.xTCP.usChildCount >= pxSocket->u.xTCP.usBacklog )
|
if( pxSocket->u.xTCP.usChildCount >= pxSocket->u.xTCP.usBacklog )
|
||||||
{
|
{
|
||||||
FreeRTOS_printf( ( "Check: Socket %u already has %u / %u child%s\n",
|
FreeRTOS_printf( ( "Check: Socket %u already has %u / %u child%s\n",
|
||||||
pxSocket->usLocalPort,
|
pxSocket->usLocalPort,
|
||||||
pxSocket->u.xTCP.usChildCount,
|
pxSocket->u.xTCP.usChildCount,
|
||||||
pxSocket->u.xTCP.usBacklog,
|
pxSocket->u.xTCP.usBacklog,
|
||||||
pxSocket->u.xTCP.usChildCount == 1 ? "" : "ren" ) );
|
pxSocket->u.xTCP.usChildCount == 1 ? "" : "ren" ) );
|
||||||
prvTCPSendReset( pxNetworkBuffer );
|
prvTCPSendReset( pxNetworkBuffer );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FreeRTOS_Socket_t *pxNewSocket = ( FreeRTOS_Socket_t * )
|
FreeRTOS_Socket_t *pxNewSocket = ( FreeRTOS_Socket_t * )
|
||||||
FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
|
FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
|
||||||
|
|
||||||
if( ( pxNewSocket == NULL ) || ( pxNewSocket == FREERTOS_INVALID_SOCKET ) )
|
if( ( pxNewSocket == NULL ) || ( pxNewSocket == FREERTOS_INVALID_SOCKET ) )
|
||||||
{
|
{
|
||||||
FreeRTOS_debug_printf( ( "TCP: Listen: new socket failed\n" ) );
|
FreeRTOS_debug_printf( ( "TCP: Listen: new socket failed\n" ) );
|
||||||
prvTCPSendReset( pxNetworkBuffer );
|
prvTCPSendReset( pxNetworkBuffer );
|
||||||
}
|
}
|
||||||
else if( prvTCPSocketCopy( pxNewSocket, pxSocket ) != pdFALSE )
|
else if( prvTCPSocketCopy( pxNewSocket, pxSocket ) != pdFALSE )
|
||||||
{
|
{
|
||||||
/* The socket will be connected immediately, no time for the
|
/* The socket will be connected immediately, no time for the
|
||||||
owner to setsockopt's, therefore copy properties of the server
|
owner to setsockopt's, therefore copy properties of the server
|
||||||
socket to the new socket. Only the binding might fail (due to
|
socket to the new socket. Only the binding might fail (due to
|
||||||
lack of resources). */
|
lack of resources). */
|
||||||
pxReturn = pxNewSocket;
|
pxReturn = pxNewSocket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 );
|
||||||
|
@ -3310,5 +3304,6 @@ BaseType_t xResult = pdFALSE;
|
||||||
|
|
||||||
/* Provide access to private members for testing. */
|
/* Provide access to private members for testing. */
|
||||||
#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
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ FreeRTOS_Socket_t *pxSocket;
|
||||||
UDPPacket_t *pxUDPPacket = (UDPPacket_t *) pxNetworkBuffer->pucEthernetBuffer;
|
UDPPacket_t *pxUDPPacket = (UDPPacket_t *) pxNetworkBuffer->pucEthernetBuffer;
|
||||||
|
|
||||||
/* Caller must check for minimum packet size. */
|
/* Caller must check for minimum packet size. */
|
||||||
pxSocket = pxUDPSocketLookup( usPort );
|
pxSocket = pxUDPSocketLookup( usPort );
|
||||||
|
|
||||||
if( pxSocket )
|
if( pxSocket )
|
||||||
{
|
{
|
||||||
|
|
|
@ -389,9 +389,9 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
||||||
|
|
||||||
#if( ipconfigUSE_DNS_CACHE != 0 )
|
#if( ipconfigUSE_DNS_CACHE != 0 )
|
||||||
#ifndef ipconfigDNS_CACHE_NAME_LENGTH
|
#ifndef ipconfigDNS_CACHE_NAME_LENGTH
|
||||||
/* Per https://tools.ietf.org/html/rfc1035, 253 is the maximum string length
|
/* Per https://tools.ietf.org/html/rfc1035, 253 is the maximum string length
|
||||||
of a DNS name. The following default accounts for a null terminator. */
|
of a DNS name. The following default accounts for a null terminator. */
|
||||||
#define ipconfigDNS_CACHE_NAME_LENGTH 254
|
#define ipconfigDNS_CACHE_NAME_LENGTH 254
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ipconfigDNS_CACHE_ENTRIES
|
#ifndef ipconfigDNS_CACHE_ENTRIES
|
||||||
|
@ -535,7 +535,7 @@ connections, hang protection can help reduce the impact of SYN floods. */
|
||||||
|
|
||||||
/* Non-activity timeout is expressed in seconds. */
|
/* Non-activity timeout is expressed in seconds. */
|
||||||
#ifndef ipconfigTCP_HANG_PROTECTION_TIME
|
#ifndef ipconfigTCP_HANG_PROTECTION_TIME
|
||||||
#define ipconfigTCP_HANG_PROTECTION_TIME 30
|
#define ipconfigTCP_HANG_PROTECTION_TIME 30
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ipconfigTCP_IP_SANITY
|
#ifndef ipconfigTCP_IP_SANITY
|
||||||
|
|
|
@ -80,9 +80,9 @@ typedef struct xTCP_WINSIZE
|
||||||
*/
|
*/
|
||||||
/* Keep this as a multiple of 4 */
|
/* Keep this as a multiple of 4 */
|
||||||
#if( ipconfigUSE_TCP_WIN == 1 )
|
#if( ipconfigUSE_TCP_WIN == 1 )
|
||||||
#define ipSIZE_TCP_OPTIONS 16u
|
#define ipSIZE_TCP_OPTIONS 16u
|
||||||
#else
|
#else
|
||||||
#define ipSIZE_TCP_OPTIONS 12u
|
#define ipSIZE_TCP_OPTIONS 12u
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue