From 3cc5d1c024972ab59a32c323aeb9a417c5e8101f Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Fri, 6 Oct 2023 15:40:42 +0530 Subject: [PATCH] Update sockets header to include ntop/pton IPv4/v6 API declarations (#1031) * update sockets header to include ntop / pton IPv4/v6 API declarations * Uncrustify: triggered by comment --------- Co-authored-by: GitHub Action --- source/include/FreeRTOS_IPv4_Sockets.h | 9 -------- source/include/FreeRTOS_Sockets.h | 30 +++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/source/include/FreeRTOS_IPv4_Sockets.h b/source/include/FreeRTOS_IPv4_Sockets.h index 60b28f317..731f801fd 100644 --- a/source/include/FreeRTOS_IPv4_Sockets.h +++ b/source/include/FreeRTOS_IPv4_Sockets.h @@ -38,15 +38,6 @@ extern "C" { #endif - -/* Translate from 192.168.1.1 to a 32-bit number. */ - BaseType_t FreeRTOS_inet_pton4( const char * pcSource, - void * pvDestination ); - - const char * FreeRTOS_inet_ntop4( const void * pvSource, - char * pcDestination, - socklen_t uxSize ); - /** * @brief Called by prvSendUDPPacket(), this function will UDP packet * fields and IPv4 address for the packet to be send. diff --git a/source/include/FreeRTOS_Sockets.h b/source/include/FreeRTOS_Sockets.h index b0c2be4ea..d5c811f49 100644 --- a/source/include/FreeRTOS_Sockets.h +++ b/source/include/FreeRTOS_Sockets.h @@ -499,9 +499,6 @@ char * pcDestination, socklen_t uxSize ); - BaseType_t FreeRTOS_inet_pton6( const char * pcSource, - void * pvDestination ); - /** @brief This function converts a human readable string, representing an 48-bit MAC address, * into a 6-byte address. Valid inputs are e.g. "62:48:5:83:A0:b2" and "0-12-34-fe-dc-ba". */ BaseType_t FreeRTOS_EUI48_pton( const char * pcSource, @@ -565,6 +562,33 @@ #endif /* ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) */ + + #if ipconfigUSE_IPv4 + /* Translate from dot-decimal notation (example 192.168.1.1) to a 32-bit number. */ + BaseType_t FreeRTOS_inet_pton4( const char * pcSource, + void * pvDestination ); + +/* Translate 32-bit IPv4 address representation dot-decimal notation. */ + const char * FreeRTOS_inet_ntop4( const void * pvSource, + char * pcDestination, + socklen_t uxSize ); + #endif + + #if ipconfigUSE_IPv6 + /* Translate hexadecimal IPv6 address to 16 bytes binary format */ + BaseType_t FreeRTOS_inet_pton6( const char * pcSource, + void * pvDestination ); + +/* + * Convert a string like 'fe80::8d11:cd9b:8b66:4a80' + * to a 16-byte IPv6 address + */ + const char * FreeRTOS_inet_ntop6( const void * pvSource, + char * pcDestination, + socklen_t uxSize ); + + #endif + #ifdef __cplusplus } /* extern "C" */ #endif