|
492 | 492 | } |
493 | 493 | #endif /* if ( ipconfigDNS_USE_CALLBACKS == 0 ) */ |
494 | 494 |
|
495 | | - #if ( ipconfigINCLUDE_FULL_INET_ADDR == 1 ) |
496 | | - |
497 | 495 | /** |
498 | 496 | * @brief See if pcHostName contains a valid IPv4 or IPv6 IP-address. |
499 | 497 | * @param[in] pcHostName: The name to be looked up |
|
502 | 500 | * be stored. |
503 | 501 | * @return Either 0 or an IP=address. |
504 | 502 | */ |
505 | | - static uint32_t prvPrepare_ReadIPAddress( const char * pcHostName, |
506 | | - BaseType_t xFamily, |
507 | | - struct freertos_addrinfo ** ppxAddressInfo ) |
508 | | - { |
509 | | - uint32_t ulIPAddress = 0U; |
| 503 | + static uint32_t prvPrepare_ReadIPAddress( const char * pcHostName, |
| 504 | + BaseType_t xFamily, |
| 505 | + struct freertos_addrinfo ** ppxAddressInfo ) |
| 506 | + { |
| 507 | + uint32_t ulIPAddress = 0U; |
510 | 508 |
|
511 | | - ( void ) xFamily; |
| 509 | + ( void ) xFamily; |
512 | 510 |
|
513 | | - /* Check if the hostname given is actually an IP-address. */ |
514 | | - #if ( ipconfigUSE_IPv6 != 0 ) |
515 | | - if( xFamily == FREERTOS_AF_INET6 ) |
516 | | - { |
517 | | - IPv6_Address_t xAddress_IPv6; |
518 | | - BaseType_t xResult; |
| 511 | + /* Check if the hostname given is actually an IP-address. */ |
| 512 | + #if ( ipconfigUSE_IPv6 != 0 ) |
| 513 | + if( xFamily == FREERTOS_AF_INET6 ) |
| 514 | + { |
| 515 | + IPv6_Address_t xAddress_IPv6; |
| 516 | + BaseType_t xResult; |
519 | 517 |
|
520 | | - /* ulIPAddress does not represent an IPv4 address here. It becomes non-zero when the look-up succeeds. */ |
521 | | - xResult = FreeRTOS_inet_pton6( pcHostName, xAddress_IPv6.ucBytes ); |
| 518 | + /* ulIPAddress does not represent an IPv4 address here. It becomes non-zero when the look-up succeeds. */ |
| 519 | + xResult = FreeRTOS_inet_pton6( pcHostName, xAddress_IPv6.ucBytes ); |
522 | 520 |
|
523 | | - if( xResult == 1 ) |
524 | | - { |
525 | | - /* This function returns either a valid IPv4 address, or |
526 | | - * in case of an IPv6 lookup, it will return a non-zero */ |
527 | | - ulIPAddress = 1U; |
| 521 | + if( xResult == 1 ) |
| 522 | + { |
| 523 | + /* This function returns either a valid IPv4 address, or |
| 524 | + * in case of an IPv6 lookup, it will return a non-zero */ |
| 525 | + ulIPAddress = 1U; |
528 | 526 |
|
529 | | - if( ppxAddressInfo != NULL ) |
530 | | - { |
531 | | - *( ppxAddressInfo ) = pxNew_AddrInfo( pcHostName, FREERTOS_AF_INET6, xAddress_IPv6.ucBytes ); |
532 | | - } |
| 527 | + if( ppxAddressInfo != NULL ) |
| 528 | + { |
| 529 | + *( ppxAddressInfo ) = pxNew_AddrInfo( pcHostName, FREERTOS_AF_INET6, xAddress_IPv6.ucBytes ); |
533 | 530 | } |
534 | 531 | } |
535 | | - else |
536 | | - #endif /* ipconfigUSE_IPv6 */ |
537 | | - { |
538 | | - ulIPAddress = FreeRTOS_inet_addr( pcHostName ); |
| 532 | + } |
| 533 | + else |
| 534 | + #endif /* ipconfigUSE_IPv6 */ |
| 535 | + { |
| 536 | + ulIPAddress = FreeRTOS_inet_addr( pcHostName ); |
539 | 537 |
|
540 | | - if( ( ulIPAddress != 0U ) && ( ppxAddressInfo != NULL ) ) |
541 | | - { |
542 | | - const uint8_t * ucBytes = ( uint8_t * ) &( ulIPAddress ); |
| 538 | + if( ( ulIPAddress != 0U ) && ( ppxAddressInfo != NULL ) ) |
| 539 | + { |
| 540 | + const uint8_t * ucBytes = ( uint8_t * ) &( ulIPAddress ); |
543 | 541 |
|
544 | | - *( ppxAddressInfo ) = pxNew_AddrInfo( pcHostName, FREERTOS_AF_INET4, ucBytes ); |
545 | | - } |
| 542 | + *( ppxAddressInfo ) = pxNew_AddrInfo( pcHostName, FREERTOS_AF_INET4, ucBytes ); |
546 | 543 | } |
547 | | - |
548 | | - return ulIPAddress; |
549 | 544 | } |
550 | | - #endif /* ( ipconfigINCLUDE_FULL_INET_ADDR == 1 ) */ |
| 545 | + |
| 546 | + return ulIPAddress; |
| 547 | + } |
551 | 548 | /*-----------------------------------------------------------*/ |
552 | 549 |
|
553 | 550 | #if ( ipconfigDNS_USE_CALLBACKS == 1 ) |
|
622 | 619 | { |
623 | 620 | /* If the supplied hostname is an IP address, put it in ppxAddressInfo |
624 | 621 | * and return. */ |
625 | | - #if ( ipconfigINCLUDE_FULL_INET_ADDR == 1 ) |
626 | | - { |
627 | | - ulIPAddress = prvPrepare_ReadIPAddress( pcHostName, xFamily, ppxAddressInfo ); |
628 | | - } |
629 | | - #endif /* ipconfigINCLUDE_FULL_INET_ADDR == 1 */ |
| 622 | + ulIPAddress = prvPrepare_ReadIPAddress( pcHostName, xFamily, ppxAddressInfo ); |
630 | 623 |
|
631 | 624 | /* If a DNS cache is used then check the cache before issuing another DNS |
632 | 625 | * request. */ |
|
0 commit comments