diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2016-02-10 09:11:12 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2016-02-19 15:55:09 +0000 |
commit | 8bee8bad813446bbf75428a8cdd756fe6063ca6f (patch) | |
tree | d6a335bcf1bf745c36fcefefab3356f6c1705a05 /wsutil/inet_ntop.c | |
parent | 5fec8fa74619a69e3faeca01fd483157d39f7b13 (diff) | |
download | wireshark-8bee8bad813446bbf75428a8cdd756fe6063ca6f.tar.gz |
Add inet_pton/inet_ntop interface to libwsutil
Change-Id: Ifc344ed33f2f7ca09a6912a5adb49dc35f07c81f
Reviewed-on: https://code.wireshark.org/review/13881
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'wsutil/inet_ntop.c')
-rw-r--r-- | wsutil/inet_ntop.c | 59 |
1 files changed, 12 insertions, 47 deletions
diff --git a/wsutil/inet_ntop.c b/wsutil/inet_ntop.c index c4e080a255..cbb9c227dd 100644 --- a/wsutil/inet_ntop.c +++ b/wsutil/inet_ntop.c @@ -15,48 +15,21 @@ * SOFTWARE. */ - #include "config.h" -#ifdef HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif - -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> /* needed to define AF_ values on UNIX */ -#endif +#include "inet_addr-int.h" -#ifdef HAVE_WINSOCK2_H -#include <winsock2.h> /* 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 <string.h> +#include <errno.h> -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif +#include <glib.h> -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif +#include <wsutil/ws_diag_control.h> -#ifdef HAVE_ARPA_NAMESER_H -#include <arpa/nameser.h> +#ifndef __P +#define __P(args) args #endif -#include <errno.h> -#include <stdio.h> -#include <string.h> - -#include "inet_v6defs.h" - -#include <glib.h> - #ifndef NS_INADDRSZ #define NS_INADDRSZ 4 #endif @@ -67,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. @@ -84,11 +59,7 @@ static const char *inet_ntop6 __P((const u_char *src, char *dst, size_t size)); * Paul Vixie, 1996. */ const char * -inet_ntop(af, src, dst, size) - int af; - const void *src; - char *dst; - size_t size; +inet_ntop(int af, const void *src, char *dst, size_t size) { switch (af) { case AF_INET: @@ -114,10 +85,7 @@ inet_ntop(af, src, dst, size) * Paul Vixie, 1996. */ static const char * -inet_ntop4(src, dst, size) - const u_char *src; - char *dst; - size_t size; +inet_ntop4(const u_char *src, char *dst, size_t size) { static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; @@ -140,10 +108,7 @@ inet_ntop4(src, dst, size) * Paul Vixie, 1996. */ static const char * -inet_ntop6(src, dst, size) - const u_char *src; - char *dst; - size_t size; +inet_ntop6(const u_char *src, char *dst, size_t size) { /* * Note that int32_t and int16_t need only be "at least" large enough |