/**
* collectd - src/libcollectdclient/network.c
- * Copyright (C) 2005-2013 Florian Forster
+ * Copyright (C) 2005-2014 Florian Forster
* Copyright (C) 2010 Max Henkel
*
* Permission is hereby granted, free of charge, to any person obtaining a
* Max Henkel <henkel at gmx.at>
**/
+#if WIN32
+
+#include <winsock2.h>
+#include <wspiapi.h>
+#include <windows.h>
+#include <io.h>
+#include <assert.h>
+
+#else
+
#include "collectd.h"
#include <stdlib.h>
# include <net/if.h>
#endif
+#endif /* !WIN32 */
+
#include "collectd/network.h"
#include "collectd/network_buffer.h"
optname = IP_TTL;
setsockopt (srv->fd, IPPROTO_IP, optname,
- &srv->ttl,
+ (void *) &srv->ttl,
sizeof (srv->ttl));
}
else if (ai_ptr->ai_family == AF_INET6)
optname = IPV6_UNICAST_HOPS;
setsockopt (srv->fd, IPPROTO_IPV6, optname,
- &srv->ttl,
+ (void *) &srv->ttl,
sizeof (srv->ttl));
}
return (0);
} /* }}} int lcc_server_set_ttl */
-int lcc_server_set_interface (lcc_server_t *srv, char const *interface) /* {{{ */
+#if WIN32
+int lcc_server_set_interface (lcc_server_t *srv, char const *ifname) /* {{{ */
+{
+ return (-1);
+} /* }}} int lcc_server_set_interface */
+#else
+int lcc_server_set_interface (lcc_server_t *srv, char const *ifname) /* {{{ */
{
int if_index;
int status;
- if ((srv == NULL) || (interface == NULL))
+ if ((srv == NULL) || (ifname == NULL))
return (EINVAL);
- if_index = if_nametoindex (interface);
+ if_index = if_nametoindex (ifname);
if (if_index == 0)
return (ENOENT);
#endif
status = setsockopt (srv->fd, IPPROTO_IP, IP_MULTICAST_IF,
- &mreq, sizeof (mreq));
+ (void *) &mreq, sizeof (mreq));
if (status != 0)
return (status);
if (IN6_IS_ADDR_MULTICAST (&addr->sin6_addr))
{
status = setsockopt (srv->fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
- &if_index, sizeof (if_index));
+ (void *) &if_index, sizeof (if_index));
if (status != 0)
return (status);
/* else: Not a multicast interface. */
#if defined(SO_BINDTODEVICE)
status = setsockopt (srv->fd, SOL_SOCKET, SO_BINDTODEVICE,
- interface, strlen (interface) + 1);
+ ifname, strlen (ifname) + 1);
if (status != 0)
return (-1);
#endif
return (0);
} /* }}} int lcc_server_set_interface */
+#endif /* !WIN32 */
int lcc_server_set_security_level (lcc_server_t *srv, /* {{{ */
lcc_security_level_t level,