diff options
Diffstat (limited to 'lib/inet_ntop.c')
-rw-r--r-- | lib/inet_ntop.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c index 64f90a1fd..6b5cbe5c1 100644 --- a/lib/inet_ntop.c +++ b/lib/inet_ntop.c @@ -38,12 +38,25 @@ /* Specification. */ #include <arpa/inet.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> +#if HAVE_DECL_INET_NTOP -#define NS_IN6ADDRSZ 16 -#define NS_INT16SZ 2 +# undef inet_ntop + +const char * +rpl_inet_ntop (int af, const void *restrict src, + char *restrict dst, socklen_t cnt) +{ + return inet_ntop (af, src, dst, cnt); +} + +#else + +# include <stdio.h> +# include <string.h> +# include <errno.h> + +# define NS_IN6ADDRSZ 16 +# define NS_INT16SZ 2 /* * WARNING: Don't even consider trying to compile this on a system where @@ -52,9 +65,9 @@ typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1]; static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size); -#if HAVE_IPV6 +# if HAVE_IPV6 static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t size); -#endif +# endif /* char * @@ -71,15 +84,15 @@ inet_ntop (int af, const void *restrict src, { switch (af) { -#if HAVE_IPV4 +# if HAVE_IPV4 case AF_INET: return (inet_ntop4 (src, dst, cnt)); -#endif +# endif -#if HAVE_IPV6 +# if HAVE_IPV6 case AF_INET6: return (inet_ntop6 (src, dst, cnt)); -#endif +# endif default: errno = EAFNOSUPPORT; @@ -118,7 +131,7 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size) return strcpy (dst, tmp); } -#if HAVE_IPV6 +# if HAVE_IPV6 /* const char * * inet_ntop6(src, dst, size) @@ -231,4 +244,6 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size) return strcpy (dst, tmp); } +# endif + #endif |