From 8bee8bad813446bbf75428a8cdd756fe6063ca6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Wed, 10 Feb 2016 09:11:12 +0000 Subject: Add inet_pton/inet_ntop interface to libwsutil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifc344ed33f2f7ca09a6912a5adb49dc35f07c81f Reviewed-on: https://code.wireshark.org/review/13881 Petri-Dish: João Valverde Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde --- wsutil/inet_pton.c | 52 ++++++++++++---------------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) (limited to 'wsutil/inet_pton.c') diff --git a/wsutil/inet_pton.c b/wsutil/inet_pton.c index 28c295abb0..78b14fd3d6 100644 --- a/wsutil/inet_pton.c +++ b/wsutil/inet_pton.c @@ -17,42 +17,19 @@ #include "config.h" -#ifdef HAVE_SYS_PARAM_H -#include -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#ifdef HAVE_SYS_SOCKET_H -#include /* needed to define AF_ values on UNIX */ -#endif +#include "inet_addr-int.h" -#ifdef HAVE_WINSOCK2_H -#include /* needed to define AF_ values on Windows */ -#if _MSC_VER < 1600 /* errno.h defines EAFNOSUPPORT in Windows VC10 (and presumably eventually in VC11 ...) */ -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#endif -#endif +#include +#include -#ifdef HAVE_NETINET_IN_H -#include -#endif +#include -#ifdef HAVE_ARPA_INET_H -#include -#endif +#include -#ifdef HAVE_ARPA_NAMESER_H -#include +#ifndef __P +#define __P(args) args #endif -#include -#include - -#include "inet_v6defs.h" - #ifndef NS_INADDRSZ #define NS_INADDRSZ 4 #endif @@ -63,6 +40,8 @@ #define NS_INT16SZ 2 #endif +DIAG_OFF(c++-compat) + /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. @@ -87,10 +66,7 @@ static int inet_pton6 __P((const char *src, u_char *dst)); * Paul Vixie, 1996. */ int -inet_pton(af, src, dst) - int af; - const char *src; - void *dst; +inet_pton(int af, const char *src, void *dst) { switch (af) { #ifdef AF_INET @@ -120,9 +96,7 @@ inet_pton(af, src, dst) * Paul Vixie, 1996. */ static int -inet_pton4(src, dst) - const char *src; - u_char *dst; +inet_pton4(const char *src, u_char *dst) { static const char digits[] = "0123456789"; int saw_digit, octets, ch; @@ -175,9 +149,7 @@ inet_pton4(src, dst) * Paul Vixie, 1996. */ static int -inet_pton6(src, dst) - const char *src; - u_char *dst; +inet_pton6(const char *src, u_char *dst) { static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; -- cgit v1.2.1