/**
* libcollectdclient - src/libcollectdclient/client.c
- * Copyright (C) 2008-2012 Florian octo Forster
+ * Copyright (C) 2008-2014 Florian octo Forster
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "collectd/lcc_features.h"
+#if WIN32
+
+#include <winsock2.h>
+#include <wspiapi.h>
+#include <windows.h>
+#include <io.h>
+#include <stdio.h>
+#include <math.h>
+#include <assert.h>
+
+#else
+
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <math.h>
#include <netdb.h>
+#endif
+
#include "collectd/client.h"
/* NI_MAXHOST has been obsoleted by RFC 3493 which is a reason for SunOS 5.11
return (status);
} /* }}} int lcc_sendreceive */
+#if !WIN32
static int lcc_open_unixsocket (lcc_connection_t *c, const char *path) /* {{{ */
{
struct sockaddr_un sa;
return (0);
} /* }}} int lcc_open_unixsocket */
+#endif /* !WIN32 */
static int lcc_open_netsocket (lcc_connection_t *c, /* {{{ */
const char *addr_orig)
assert (c->fh == NULL);
assert (addr != NULL);
+#if !WIN32
if (strncmp ("unix:", addr, strlen ("unix:")) == 0)
status = lcc_open_unixsocket (c, addr + strlen ("unix:"));
else if (addr[0] == '/')
status = lcc_open_unixsocket (c, addr);
else
+#endif
status = lcc_open_netsocket (c, addr);
return (status);
/**
* 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,
/**
* collectd - src/libcollectdclient/network_buffer.c
- * Copyright (C) 2010-2012 Florian octo Forster
+ * Copyright (C) 2010-2014 Florian octo Forster
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* Florian octo Forster <octo at collectd.org>
**/
-#include "config.h"
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if WIN32
+
+#include <windows.h>
+#include <math.h>
+#include <assert.h>
+
+#else
#include <stdlib.h>
#include <string.h>
GCRY_THREAD_OPTION_PTHREAD_IMPL;
#endif
+#endif /* !WIN32 */
+
#include "collectd/network_buffer.h"
#define TYPE_HOST 0x0000
#define PART_SIGNATURE_SHA256_SIZE 36
#define PART_ENCRYPTION_AES256_SIZE 42
+#ifndef ENOTSUP
+# define ENOTSUP -1
+#endif
+
#define ADD_GENERIC(nb,srcptr,size) do { \
assert ((size) <= (nb)->free); \
memcpy ((nb)->ptr, (srcptr), (size)); \
return (0);
} /* }}} int nb_add_value_list */
+/* TODO: Add encryption for Windows */
#if HAVE_LIBGCRYPT
static int nb_add_signature (lcc_network_buffer_t *nb) /* {{{ */
{