mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Allow IP address to be passed into gethostbyname().
Ensure xNetworkBuffersInitialise() doesn't use a semaphore before it has been tested against NULL.
This commit is contained in:
parent
7ddb8b342d
commit
ff74e7aa63
|
@ -404,18 +404,29 @@ TickType_t xReadTimeOut_ms = 1200U;
|
||||||
as gethostbyname() may be called from different threads */
|
as gethostbyname() may be called from different threads */
|
||||||
TickType_t xIdentifier = ( TickType_t )usIdentifier++;
|
TickType_t xIdentifier = ( TickType_t )usIdentifier++;
|
||||||
|
|
||||||
|
/* If the supplied hostname is IP address, convert it to uint32_t
|
||||||
|
and return. */
|
||||||
|
#if( ipconfigINCLUDE_FULL_INET_ADDR == 1 )
|
||||||
|
{
|
||||||
|
ulIPAddress = FreeRTOS_inet_addr( pcHostName );
|
||||||
|
}
|
||||||
|
#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 )
|
||||||
{
|
{
|
||||||
ulIPAddress = FreeRTOS_dnslookup( pcHostName );
|
if( ulIPAddress == 0UL )
|
||||||
if( ulIPAddress != 0 )
|
|
||||||
{
|
{
|
||||||
FreeRTOS_debug_printf( ( "FreeRTOS_gethostbyname: found '%s' in cache: %lxip\n", pcHostName, ulIPAddress ) );
|
ulIPAddress = FreeRTOS_dnslookup( pcHostName );
|
||||||
}
|
if( ulIPAddress != 0 )
|
||||||
else
|
{
|
||||||
{
|
FreeRTOS_debug_printf( ( "FreeRTOS_gethostbyname: found '%s' in cache: %lxip\n", pcHostName, ulIPAddress ) );
|
||||||
/* prvGetHostByName will be called to start a DNS lookup. */
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* prvGetHostByName will be called to start a DNS lookup */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* ipconfigUSE_DNS_CACHE == 1 */
|
#endif /* ipconfigUSE_DNS_CACHE == 1 */
|
||||||
|
|
|
@ -103,24 +103,25 @@ BaseType_t xReturn, x;
|
||||||
{
|
{
|
||||||
xNetworkBufferSemaphore = xSemaphoreCreateCounting( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS );
|
xNetworkBufferSemaphore = xSemaphoreCreateCounting( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS );
|
||||||
configASSERT( xNetworkBufferSemaphore );
|
configASSERT( xNetworkBufferSemaphore );
|
||||||
#if ( configQUEUE_REGISTRY_SIZE > 0 )
|
|
||||||
{
|
|
||||||
vQueueAddToRegistry( xNetworkBufferSemaphore, "NetBufSem" );
|
|
||||||
}
|
|
||||||
#endif /* configQUEUE_REGISTRY_SIZE */
|
|
||||||
|
|
||||||
/* If the trace recorder code is included name the semaphore for viewing
|
|
||||||
in FreeRTOS+Trace. */
|
|
||||||
#if( ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 )
|
|
||||||
{
|
|
||||||
extern QueueHandle_t xNetworkEventQueue;
|
|
||||||
vTraceSetQueueName( xNetworkEventQueue, "IPStackEvent" );
|
|
||||||
vTraceSetQueueName( xNetworkBufferSemaphore, "NetworkBufferCount" );
|
|
||||||
}
|
|
||||||
#endif /* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 */
|
|
||||||
|
|
||||||
if( xNetworkBufferSemaphore != NULL )
|
if( xNetworkBufferSemaphore != NULL )
|
||||||
{
|
{
|
||||||
|
#if ( configQUEUE_REGISTRY_SIZE > 0 )
|
||||||
|
{
|
||||||
|
vQueueAddToRegistry( xNetworkBufferSemaphore, "NetBufSem" );
|
||||||
|
}
|
||||||
|
#endif /* configQUEUE_REGISTRY_SIZE */
|
||||||
|
|
||||||
|
/* If the trace recorder code is included name the semaphore for viewing
|
||||||
|
in FreeRTOS+Trace. */
|
||||||
|
#if( ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 )
|
||||||
|
{
|
||||||
|
extern QueueHandle_t xNetworkEventQueue;
|
||||||
|
vTraceSetQueueName( xNetworkEventQueue, "IPStackEvent" );
|
||||||
|
vTraceSetQueueName( xNetworkBufferSemaphore, "NetworkBufferCount" );
|
||||||
|
}
|
||||||
|
#endif /* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 */
|
||||||
|
|
||||||
vListInitialise( &xFreeBuffersList );
|
vListInitialise( &xFreeBuffersList );
|
||||||
|
|
||||||
/* Initialise all the network buffers. No storage is allocated to
|
/* Initialise all the network buffers. No storage is allocated to
|
||||||
|
@ -374,7 +375,7 @@ uint8_t *pucBuffer;
|
||||||
vReleaseNetworkBuffer( pxNetworkBuffer->pucEthernetBuffer );
|
vReleaseNetworkBuffer( pxNetworkBuffer->pucEthernetBuffer );
|
||||||
pxNetworkBuffer->pucEthernetBuffer = pucBuffer;
|
pxNetworkBuffer->pucEthernetBuffer = pucBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pxNetworkBuffer;
|
return pxNetworkBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue