summaryrefslogtreecommitdiff
path: root/wsutil/inet_pton.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2016-02-10 09:11:12 +0000
committerJoão Valverde <j@v6e.pt>2016-02-19 15:55:09 +0000
commit8bee8bad813446bbf75428a8cdd756fe6063ca6f (patch)
treed6a335bcf1bf745c36fcefefab3356f6c1705a05 /wsutil/inet_pton.c
parent5fec8fa74619a69e3faeca01fd483157d39f7b13 (diff)
downloadwireshark-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_pton.c')
-rw-r--r--wsutil/inet_pton.c52
1 files changed, 12 insertions, 40 deletions
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 <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 <string.h>
-#include <errno.h>
-
-#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";