X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fnetwork.c;h=8acf84b1bb67434925c8e3075fe4b7a04182b5c5;hp=1e6ef14f33d4ed1fda498872ffe7f281b4514fbd;hb=97556a06e07f986d7fafc350208c05fa0b27649e;hpb=2b55b3c91907f1b95c59f2661448c336e51b61ce diff --git a/src/network.c b/src/network.c index 1e6ef14f..8acf84b1 100644 --- a/src/network.c +++ b/src/network.c @@ -27,8 +27,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #include "utils_cache.h" #include "utils_complain.h" #include "utils_fbhash.h" @@ -381,7 +381,7 @@ static bool check_send_notify_okay(const notification_t *n) /* {{{ */ LOG_ERR, &complain_forwarding, "network plugin: A notification has been received via the network " "and forwarding is enabled. Forwarding of notifications is currently " - "not supported, because there is not loop-deteciton available. " + "not supported, because there is not loop-detection available. " "Please contact the collectd mailing list if you need this " "feature."); } @@ -403,7 +403,7 @@ static int network_dispatch_values(value_list_t *vl, /* {{{ */ #if COLLECT_DEBUG char name[6 * DATA_MAX_NAME_LEN]; FORMAT_VL(name, sizeof(name), vl); - name[sizeof(name) - 1] = 0; + name[sizeof(name) - 1] = '\0'; DEBUG("network plugin: network_dispatch_values: " "NOT dispatching %s.", name); @@ -1108,7 +1108,7 @@ static int parse_part_sign_sha256(sockent_t *se, /* {{{ */ return 0; } /* }}} int parse_part_sign_sha256 */ -/* #endif HAVE_GCRYPT_H */ + /* #endif HAVE_GCRYPT_H */ #else /* if !HAVE_GCRYPT_H */ static int parse_part_sign_sha256(sockent_t *se, /* {{{ */ @@ -1263,7 +1263,7 @@ static int parse_part_encr_aes256(sockent_t *se, /* {{{ */ return 0; } /* }}} int parse_part_encr_aes256 */ -/* #endif HAVE_GCRYPT_H */ + /* #endif HAVE_GCRYPT_H */ #else /* if !HAVE_GCRYPT_H */ static int parse_part_encr_aes256(sockent_t *se, /* {{{ */ @@ -1668,7 +1668,7 @@ static int network_set_interface(const sockent_t *se, ERROR("network plugin: setsockopt (bind-if): %s", STRERRNO); return -1; } -/* #endif HAVE_IF_INDEXTONAME && SO_BINDTODEVICE */ + /* #endif HAVE_IF_INDEXTONAME && SO_BINDTODEVICE */ #else WARNING("network plugin: Cannot set the interface on a unicast " @@ -1691,7 +1691,7 @@ static int network_bind_socket_to_addr(sockent_t *se, if (se->data.client.bind_addr == NULL) return 0; - ERROR("network plugin: failed to bind client socket (ipvX) to %s: %s", pbuffer, STRERRNO); + DEBUG("network_plugin: fd %i: bind socket to address", se->data.client.fd); char pbuffer[64]; if (ai->ai_family == AF_INET) { @@ -1701,8 +1701,8 @@ static int network_bind_socket_to_addr(sockent_t *se, DEBUG("network_plugin: binding client socket to ipv4 address: %s", pbuffer); if (bind(se->data.client.fd, (struct sockaddr *)addr, sizeof(*addr)) == -1) { - ERROR("network_plugin: failed to bind client socket (ipv4): %s", - STRERRNO); + ERROR("network plugin: failed to bind client socket (ipv4) to %s: %s", + pbuffer, STRERRNO); return -1; } } else if (ai->ai_family == AF_INET6) { @@ -1712,8 +1712,8 @@ static int network_bind_socket_to_addr(sockent_t *se, DEBUG("network_plugin: binding client socket to ipv6 address: %s", pbuffer); if (bind(se->data.client.fd, (struct sockaddr *)addr, sizeof(*addr)) == -1) { - ERROR("network_plugin: failed to bind client socket (ipv6): %s", - STRERRNO); + ERROR("network plugin: failed to bind client socket (ipv6) to %s: %s", + pbuffer, STRERRNO); return -1; } } @@ -1728,10 +1728,9 @@ static int network_bind_socket(int fd, const struct addrinfo *ai, #else int loop = 0; #endif - int yes = 1; /* allow multiple sockets to use the same PORT number */ - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) { + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &(int){1}, sizeof(int)) == -1) { ERROR("network plugin: setsockopt (reuseaddr): %s", STRERRNO); return -1; } @@ -2641,7 +2640,7 @@ static int network_write(const data_set_t *ds, const value_list_t *vl, #if COLLECT_DEBUG char name[6 * DATA_MAX_NAME_LEN]; FORMAT_VL(name, sizeof(name), vl); - name[sizeof(name) - 1] = 0; + name[sizeof(name) - 1] = '\0'; DEBUG("network plugin: network_write: " "NOT sending %s.", name);