Skip to content

Commit

Permalink
fix ip diffconfig test
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Feb 4, 2024
1 parent ba0d494 commit d39b828
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 31 deletions.
6 changes: 4 additions & 2 deletions test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_DNS_Cache_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,10 @@ void test_processDNS_CACHE_exceed_host_entry_limit( void )
pxIP[ i ].xIPAddress.ulIP_IPv4 = pulIP_arr[ i ];
pxIP[ i ].xIs_IPv6 = 0;
memcpy( template, "helloXXXXXX", strlen( template ) );
char * name = mktemp( template );
memcpy( hosts, name, ipconfigDNS_CACHE_ENTRIES );
if( mkstemp( template ) != -1 )
{
memcpy( hosts, template, ipconfigDNS_CACHE_ENTRIES );
}
xTaskGetTickCount_ExpectAndReturn( 3000 );
FreeRTOS_inet_ntop_ExpectAnyArgsAndReturn( NULL );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ static void vSetIPTaskHandle( TaskHandle_t xTaskHandleToSet )
const uint8_t ucDNSServerAddress[ ipIP_ADDRESS_LENGTH_BYTES ];
const uint8_t ucMACAddress[ ipMAC_ADDRESS_LENGTH_BYTES ];
NetworkEndPoint_t xFirstEndPoint = { 0 }, * pxFirstEndPoint = &xFirstEndPoint;
NetworkInterface_t * pxNetworkInterface;
NetworkInterface_t xNetworkInterface;
NetworkInterface_t * pxNetworkInterface = &xNetworkInterface;

pxFillInterfaceDescriptor_IgnoreAndReturn( pxNetworkInterface );
FreeRTOS_FillEndPoint_Ignore();
Expand Down Expand Up @@ -195,7 +196,8 @@ void test_FreeRTOS_IPInit_HappyPath( void )
QueueHandle_t ulPointerToQueue = ( QueueHandle_t ) 0x1234ABCD;
TaskHandle_t xTaskHandleToSet = ( TaskHandle_t ) 0xCDBA9087;
NetworkEndPoint_t xFirstEndPoint = { 0 };
NetworkInterface_t * pxNetworkInterface;
NetworkInterface_t xNetworkInterface;
NetworkInterface_t * pxNetworkInterface = &xNetworkInterface;

/* Set the local IP to something other than 0. */
*ipLOCAL_IP_ADDRESS_POINTER = 0xABCD;
Expand Down Expand Up @@ -248,7 +250,8 @@ void test_FreeRTOS_IPInit_QueueCreationFails( void )
BaseType_t xReturn;
QueueHandle_t pxPointerToQueue = NULL;
NetworkEndPoint_t xFirstEndPoint = { 0 };
NetworkInterface_t * pxNetworkInterface;
NetworkInterface_t xNetworkInterface;
NetworkInterface_t * pxNetworkInterface = &xNetworkInterface;

/* Set the local IP to something other than 0. */
*ipLOCAL_IP_ADDRESS_POINTER = 0xABCD;
Expand Down Expand Up @@ -289,7 +292,8 @@ void test_FreeRTOS_IPInit_BufferCreationFails( void )
BaseType_t xReturn;
QueueHandle_t pxPointerToQueue = ( QueueHandle_t ) 0x1234ABCD;
NetworkEndPoint_t xFirstEndPoint = { 0 };
NetworkInterface_t * pxNetworkInterface;
NetworkInterface_t xNetworkInterface;
NetworkInterface_t * pxNetworkInterface = &xNetworkInterface;

/* Set the local IP to something other than 0. */
*ipLOCAL_IP_ADDRESS_POINTER = 0xABCD;
Expand Down Expand Up @@ -338,7 +342,8 @@ void test_FreeRTOS_IPInit_TaskCreationFails( void )
BaseType_t xReturn;
QueueHandle_t pxPointerToQueue = ( QueueHandle_t ) 0x1234ABCD;
NetworkEndPoint_t xFirstEndPoint = { 0 };
NetworkInterface_t * pxNetworkInterface;
NetworkInterface_t xNetworkInterface;
NetworkInterface_t * pxNetworkInterface = &xNetworkInterface;

/* Set the local IP to something other than 0. */
*ipLOCAL_IP_ADDRESS_POINTER = 0xABCD;
Expand Down
6 changes: 3 additions & 3 deletions tools/tcp_utilities/http_client_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@
#if ( ipconfigUSE_IPv4 != 0 )
pxEndPoint = FreeRTOS_FindGateWay( ipTYPE_IPv4 );

if( ( pxEndPoint != NULL ) && ( pxEndPoint->ipv4_settings.ulGatewayAddress != 0U ) )
if( ( pxEndPoint != NULL ) && ( pxEndPoint->u.ipv4_settings.ulGatewayAddress != 0U ) )
{
xARPWaitResolution( pxEndPoint->ipv4_settings.ulGatewayAddress, pdMS_TO_TICKS( 1000U ) );
xARPWaitResolution( pxEndPoint->u.ipv4_settings.ulGatewayAddress, pdMS_TO_TICKS( 1000U ) );
}
#endif /* ( ipconfigUSE_IPv4 != 0 ) */

Expand Down Expand Up @@ -400,7 +400,7 @@

if( pxEndPoint != NULL )
{
xBindAddress.sin_address.ulIP_IPv4 = pxEndPoint->ipv4_settings.ulIPAddress;
xBindAddress.sin_address.ulIP_IPv4 = pxEndPoint->u.ipv4_settings.ulIPAddress;
xBindAddress.sin_family = FREERTOS_AF_INET;
}
}
Expand Down
42 changes: 21 additions & 21 deletions tools/tcp_utilities/plus_tcp_demo_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static const char * pcARPReturnType( eARPLookupResult_t eResult )
pxEndpoint != NULL;
pxEndpoint = FreeRTOS_NextEndPoint( NULL, pxEndpoint ) )
{
if( memcmp( pxEndpoint->ipv6_settings.xGatewayAddress.ucBytes, pxAddress->ucBytes, ipSIZE_OF_IPv6_ADDRESS ) == 0 )
if( memcmp( pxEndpoint->u.ipv6_settings.xGatewayAddress.ucBytes, pxAddress->ucBytes, ipSIZE_OF_IPv6_ADDRESS ) == 0 )
{
break;
}
Expand Down Expand Up @@ -895,12 +895,12 @@ size_t uxGetOptions( CommandOptions_t * pxOptions,
#if ( ipconfigUSE_IPv6 != 0 )
if( pxEndPoint->bits.bIPv6 )
{
FreeRTOS_printf( ( "IPv6: %pip on '%s'\n", pxEndPoint->ipv6_settings.xIPAddress.ucBytes, pxEndPoint->pxNetworkInterface->pcName ) );
FreeRTOS_printf( ( "IPv6: %pip on '%s'\n", pxEndPoint->u.ipv6_settings.xIPAddress.ucBytes, pxEndPoint->pxNetworkInterface->pcName ) );
}
else
#endif
{
FreeRTOS_printf( ( "IPv4: %xip on '%s'\n", ( unsigned ) FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulIPAddress ), pxEndPoint->pxNetworkInterface->pcName ) );
FreeRTOS_printf( ( "IPv4: %xip on '%s'\n", ( unsigned ) FreeRTOS_ntohl( pxEndPoint->u.ipv4_settings.ulIPAddress ), pxEndPoint->pxNetworkInterface->pcName ) );
}
}
}
Expand Down Expand Up @@ -940,17 +940,17 @@ static void handle_help( char * pcBuffer )
#if ( ipconfigUSE_IPv6 != 0 )
if( pxEndPoint->bits.bIPv6 )
{
if( memcmp( pxEndPoint->ipv6_settings.xGatewayAddress.ucBytes, FreeRTOS_in6addr_any.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 )
if( memcmp( pxEndPoint->u.ipv6_settings.xGatewayAddress.ucBytes, FreeRTOS_in6addr_any.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 )
{
FreeRTOS_printf( ( "IPv6: %pip on '%s'\n", pxEndPoint->ipv6_settings.xGatewayAddress.ucBytes, pxEndPoint->pxNetworkInterface->pcName ) );
FreeRTOS_printf( ( "IPv6: %pip on '%s'\n", pxEndPoint->u.ipv6_settings.xGatewayAddress.ucBytes, pxEndPoint->pxNetworkInterface->pcName ) );
}
}
else
#endif
{
if( pxEndPoint->ipv4_settings.ulGatewayAddress != 0U )
if( pxEndPoint->u.ipv4_settings.ulGatewayAddress != 0U )
{
FreeRTOS_printf( ( "IPv4: %xip on '%s'\n", ( unsigned ) FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulGatewayAddress ), pxEndPoint->pxNetworkInterface->pcName ) );
FreeRTOS_printf( ( "IPv4: %xip on '%s'\n", ( unsigned ) FreeRTOS_ntohl( pxEndPoint->u.ipv4_settings.ulGatewayAddress ), pxEndPoint->pxNetworkInterface->pcName ) );
}
}
}
Expand Down Expand Up @@ -1590,46 +1590,46 @@ static void vDNSEvent( const char * pcName,
IPv6_Address_t xPrefix;

/* Extract the prefix from the IP-address */
FreeRTOS_CreateIPv6Address( &( xPrefix ), &( pxEndPoint->ipv6_settings.xIPAddress ), pxEndPoint->ipv6_settings.uxPrefixLength, pdFALSE );
FreeRTOS_CreateIPv6Address( &( xPrefix ), &( pxEndPoint->u.ipv6_settings.xIPAddress ), pxEndPoint->u.ipv6_settings.uxPrefixLength, pdFALSE );

FreeRTOS_printf( ( "IP-address : %pip\n", pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );
FreeRTOS_printf( ( "IP-address : %pip\n", pxEndPoint->u.ipv6_settings.xIPAddress.ucBytes ) );

if( memcmp( pxEndPoint->ipv6_defaults.xIPAddress.ucBytes, pxEndPoint->ipv6_settings.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 )
if( memcmp( pxEndPoint->u.ipv6_defaults.xIPAddress.ucBytes, pxEndPoint->u.ipv6_settings.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 )
{
FreeRTOS_printf( ( "Default IP : %pip\n", pxEndPoint->ipv6_defaults.xIPAddress.ucBytes ) );
FreeRTOS_printf( ( "Default IP : %pip\n", pxEndPoint->u.ipv6_defaults.xIPAddress.ucBytes ) );
}

FreeRTOS_printf( ( "End-point : up = %s method %s\n", ( pxEndPoint->bits.bEndPointUp != 0 ) ? "yes" : "no", pcMethodName ) );
FreeRTOS_printf( ( "Prefix : %pip/%d\n", xPrefix.ucBytes, ( int ) pxEndPoint->ipv6_settings.uxPrefixLength ) );
FreeRTOS_printf( ( "GW : %pip\n", pxEndPoint->ipv6_settings.xGatewayAddress.ucBytes ) );
FreeRTOS_printf( ( "Prefix : %pip/%d\n", xPrefix.ucBytes, ( int ) pxEndPoint->u.ipv6_settings.uxPrefixLength ) );
FreeRTOS_printf( ( "GW : %pip\n", pxEndPoint->u.ipv6_settings.xGatewayAddress.ucBytes ) );

for( uxDNSIndex = 0U; uxDNSIndex < ipconfigENDPOINT_DNS_ADDRESS_COUNT; uxDNSIndex++ )
{
FreeRTOS_printf( ( "DNS-%u : %pip\n", uxDNSIndex, pxEndPoint->ipv6_settings.xDNSServerAddresses[ uxDNSIndex ].ucBytes ) );
FreeRTOS_printf( ( "DNS-%u : %pip\n", uxDNSIndex, pxEndPoint->u.ipv6_settings.xDNSServerAddresses[ uxDNSIndex ].ucBytes ) );
}
}
else
#endif /* ( ipconfigUSE_IPv6 != 0 ) */
{
FreeRTOS_printf( ( "IP-address : %lxip\n",
FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulIPAddress ) ) );
FreeRTOS_ntohl( pxEndPoint->u.ipv4_settings.ulIPAddress ) ) );

if( pxEndPoint->ipv4_settings.ulIPAddress != pxEndPoint->ipv4_defaults.ulIPAddress )
if( pxEndPoint->u.ipv4_settings.ulIPAddress != pxEndPoint->u.ipv4_defaults.ulIPAddress )
{
FreeRTOS_printf( ( "Default IP : %lxip\n", FreeRTOS_ntohl( pxEndPoint->ipv4_defaults.ulIPAddress ) ) );
FreeRTOS_printf( ( "Default IP : %lxip\n", FreeRTOS_ntohl( pxEndPoint->u.ipv4_defaults.ulIPAddress ) ) );
}

FreeRTOS_printf( ( "End-point : up = %s method %s\n", pxEndPoint->bits.bEndPointUp ? "yes" : "no", pcMethodName ) );

FreeRTOS_printf( ( "Net mask : %lxip\n", FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulNetMask ) ) );
FreeRTOS_printf( ( "GW : %lxip\n", FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulGatewayAddress ) ) );
FreeRTOS_printf( ( "Net mask : %lxip\n", FreeRTOS_ntohl( pxEndPoint->u.ipv4_settings.ulNetMask ) ) );
FreeRTOS_printf( ( "GW : %lxip\n", FreeRTOS_ntohl( pxEndPoint->u.ipv4_settings.ulGatewayAddress ) ) );

for( uxDNSIndex = 0U; uxDNSIndex < ipconfigENDPOINT_DNS_ADDRESS_COUNT; uxDNSIndex++ )
{
FreeRTOS_printf( ( "DNS-%u : %xip\n", uxDNSIndex, ( unsigned ) FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulDNSServerAddresses[ uxDNSIndex ] ) ) );
FreeRTOS_printf( ( "DNS-%u : %xip\n", uxDNSIndex, ( unsigned ) FreeRTOS_ntohl( pxEndPoint->u.ipv4_settings.ulDNSServerAddresses[ uxDNSIndex ] ) ) );
}

FreeRTOS_printf( ( "Broadcast : %lxip\n", FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulBroadcastAddress ) ) );
FreeRTOS_printf( ( "Broadcast : %lxip\n", FreeRTOS_ntohl( pxEndPoint->u.ipv4_settings.ulBroadcastAddress ) ) );
}

FreeRTOS_printf( ( "MAC address: %02x-%02x-%02x-%02x-%02x-%02x\n",
Expand Down

0 comments on commit d39b828

Please sign in to comment.