aboutsummaryrefslogtreecommitdiffstats
path: root/sharkd_daemon.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-01-25 20:27:13 -0500
committerMichael Mann <mmann78@netscape.net>2017-01-26 04:08:59 +0000
commit19028ebab4f3c097c8e87d3b532b80a5c1369eae (patch)
tree62fe87dd1db3ded74f27b64be94b37af6170f3b9 /sharkd_daemon.c
parenteeab554cf2e1d893f144081a762cc52782271e2e (diff)
Fix sharkd compiling on Windows
Change-Id: I8c614189159f1263d9452d495cee34d1a2c1bfcb Reviewed-on: https://code.wireshark.org/review/19790 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'sharkd_daemon.c')
-rw-r--r--sharkd_daemon.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/sharkd_daemon.c b/sharkd_daemon.c
index 1f7981b..408c6db 100644
--- a/sharkd_daemon.c
+++ b/sharkd_daemon.c
@@ -30,13 +30,40 @@
#include <stddef.h>
#include <stdlib.h>
#include <signal.h>
+
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
-#include <sys/un.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
+#endif
+
+#ifndef _WIN32
+#include <sys/un.h>
#include <netinet/tcp.h>
+#endif
+
+/*
+#if defined(_WIN32)
+ #ifdef HAVE_WINDOWS_H
+ #include <windows.h>
+ #endif
+
+ #include <ws2tcpip.h>
+
+ #ifdef HAVE_WINSOCK2_H
+ #include <winsock2.h>
+ #endif
+#endif
+*/
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
+#endif
#include <wsutil/strtoi.h>
@@ -49,6 +76,7 @@ socket_init(char *path)
{
int fd = -1;
+#ifndef _WIN32
if (!strncmp(path, "unix:", 5))
{
struct sockaddr_un s_un;
@@ -79,8 +107,9 @@ socket_init(char *path)
}
}
+#endif
#ifdef SHARKD_TCP_SUPPORT
- else if (!strncmp(path, "tcp:", 4))
+ if (!strncmp(path, "tcp:", 4))
{
struct sockaddr_in s_in;
int one = 1;
@@ -115,24 +144,28 @@ socket_init(char *path)
return -1;
}
}
-#endif
else
{
+#endif
return -1;
+#ifdef SHARKD_TCP_SUPPORT
}
+#endif
+#ifndef _WIN32
if (listen(fd, SOMAXCONN))
{
close(fd);
return -1;
}
-
+#endif
return fd;
}
int
sharkd_init(int argc, char **argv)
{
+#ifndef _WIN32
int fd;
pid_t pid;
@@ -168,12 +201,14 @@ sharkd_init(int argc, char **argv)
}
_server_fd = fd;
+#endif
return 0;
}
int
sharkd_loop(void)
{
+#ifndef _WIN32
while (1)
{
int fd;
@@ -205,7 +240,7 @@ sharkd_loop(void)
close(fd);
}
-
+#endif
return 0;
}