/* This is a value we already sent. Don't allow it to be received again in
* order to avoid looping. */
if ((status == 0) && (time_sent >= ((uint64_t)vl->time)))
/* This is a value we already sent. Don't allow it to be received again in
* order to avoid looping. */
if ((status == 0) && (time_sent >= ((uint64_t)vl->time)))
} /* }}} _Bool check_send_okay */
static _Bool check_notify_received(const notification_t *n) /* {{{ */
} /* }}} _Bool check_send_okay */
static _Bool check_notify_received(const notification_t *n) /* {{{ */
for (notification_meta_t *ptr = n->meta; ptr != NULL; ptr = ptr->next)
if ((strcmp("network:received", ptr->name) == 0) &&
(ptr->type == NM_TYPE_BOOLEAN))
for (notification_meta_t *ptr = n->meta; ptr != NULL; ptr = ptr->next)
if ((strcmp("network:received", ptr->name) == 0) &&
(ptr->type == NM_TYPE_BOOLEAN))
} /* }}} _Bool check_notify_received */
static _Bool check_send_notify_okay(const notification_t *n) /* {{{ */
} /* }}} _Bool check_notify_received */
static _Bool check_send_notify_okay(const notification_t *n) /* {{{ */
} /* }}} _Bool check_send_notify_okay */
static int network_dispatch_values(value_list_t *vl, /* {{{ */
} /* }}} _Bool check_send_notify_okay */
static int network_dispatch_values(value_list_t *vl, /* {{{ */
} /* }}} int network_dispatch_values */
static int network_dispatch_notification(notification_t *n) /* {{{ */
} /* }}} int network_dispatch_values */
static int network_dispatch_notification(notification_t *n) /* {{{ */
ERROR("network plugin: plugin_notification_meta_add_boolean failed.");
plugin_notification_meta_free(n->meta);
n->meta = NULL;
ERROR("network plugin: plugin_notification_meta_add_boolean failed.");
plugin_notification_meta_free(n->meta);
n->meta = NULL;
* Because you can't know in a library whether another library has
* already initialized the library */
if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P))
* Because you can't know in a library whether another library has
* already initialized the library */
if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P))
/* http://www.gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html
* To ensure thread-safety, it's important to set GCRYCTL_SET_THREAD_CBS
/* http://www.gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html
* To ensure thread-safety, it's important to set GCRYCTL_SET_THREAD_CBS
} /* }}} int network_init_gcrypt */
static gcry_cipher_hd_t network_get_aes256_cypher(sockent_t *se, /* {{{ */
} /* }}} int network_init_gcrypt */
static gcry_cipher_hd_t network_get_aes256_cypher(sockent_t *se, /* {{{ */
gcry_md_hash_buffer(GCRY_MD_SHA256, password_hash, secret, strlen(secret));
gcry_md_hash_buffer(GCRY_MD_SHA256, password_hash, secret, strlen(secret));
pkg_values_types = malloc(num_values * sizeof(*pkg_values_types));
if (pkg_values_types == NULL) {
ERROR("network plugin: write_part_values: malloc failed.");
pkg_values_types = malloc(num_values * sizeof(*pkg_values_types));
if (pkg_values_types == NULL) {
ERROR("network plugin: write_part_values: malloc failed.");
}
pkg_values = malloc(num_values * sizeof(*pkg_values));
if (pkg_values == NULL) {
free(pkg_values_types);
ERROR("network plugin: write_part_values: malloc failed.");
}
pkg_values = malloc(num_values * sizeof(*pkg_values));
if (pkg_values == NULL) {
free(pkg_values_types);
ERROR("network plugin: write_part_values: malloc failed.");
ERROR("network plugin: write_part_values: "
"Unknown data source type: %i",
ds->ds[i].type);
ERROR("network plugin: write_part_values: "
"Unknown data source type: %i",
ds->ds[i].type);
} /* int write_part_values */
static int write_part_number(char **ret_buffer, size_t *ret_buffer_len,
} /* int write_part_values */
static int write_part_number(char **ret_buffer, size_t *ret_buffer_len,
} /* int write_part_number */
static int write_part_string(char **ret_buffer, size_t *ret_buffer_len,
} /* int write_part_number */
static int write_part_string(char **ret_buffer, size_t *ret_buffer_len,
} /* int write_part_string */
static int parse_part_values(void **ret_buffer, size_t *ret_buffer_len,
} /* int write_part_string */
static int parse_part_values(void **ret_buffer, size_t *ret_buffer_len,
"Chunk of size %zu expected, "
"but buffer has only %zu bytes left.",
exp_size, buffer_len);
"Chunk of size %zu expected, "
"but buffer has only %zu bytes left.",
exp_size, buffer_len);
WARNING("network plugin: parse_part_values: "
"Length and number of values "
"in the packet don't match.");
WARNING("network plugin: parse_part_values: "
"Length and number of values "
"in the packet don't match.");
} /* int parse_part_values */
static int parse_part_number(void **ret_buffer, size_t *ret_buffer_len,
} /* int parse_part_values */
static int parse_part_number(void **ret_buffer, size_t *ret_buffer_len,
"Chunk of size %zu expected, "
"but buffer has only %zu bytes left.",
exp_size, buffer_len);
"Chunk of size %zu expected, "
"but buffer has only %zu bytes left.",
exp_size, buffer_len);
} /* int parse_part_number */
static int parse_part_string(void **ret_buffer, size_t *ret_buffer_len,
} /* int parse_part_number */
static int parse_part_string(void **ret_buffer, size_t *ret_buffer_len,
"Chunk of at least size %zu expected, "
"but buffer has only %zu bytes left.",
header_size, buffer_len);
"Chunk of at least size %zu expected, "
"but buffer has only %zu bytes left.",
header_size, buffer_len);
"Chunk of size %" PRIu16 " received, "
"but buffer has only %zu bytes left.",
pkg_length, buffer_len);
"Chunk of size %" PRIu16 " received, "
"but buffer has only %zu bytes left.",
pkg_length, buffer_len);
"which is too small to hold the received "
"%zu byte string.",
output_len, payload_size);
"which is too small to hold the received "
"%zu byte string.",
output_len, payload_size);
} /* int parse_part_string */
/* Forward declaration: parse_part_sign_sha256 and parse_part_encr_aes256 call
} /* int parse_part_string */
/* Forward declaration: parse_part_sign_sha256 and parse_part_encr_aes256 call
- if (se->data.server.userdb == NULL) {
- c_complain(
- LOG_NOTICE, &complain_no_users,
- "network plugin: Received signed network packet but can't verify it "
- "because no user DB has been configured. Will accept it.");
- return (0);
- }
-
/* Check if the buffer has enough data for this structure. */
if (buffer_len <= PART_SIGNATURE_SHA256_SIZE)
/* Check if the buffer has enough data for this structure. */
if (buffer_len <= PART_SIGNATURE_SHA256_SIZE)
/* Read type and length header */
BUFFER_READ(&pss.head.type, sizeof(pss.head.type));
/* Read type and length header */
BUFFER_READ(&pss.head.type, sizeof(pss.head.type));
if ((pss_head_length <= PART_SIGNATURE_SHA256_SIZE) ||
(pss_head_length > buffer_len)) {
ERROR("network plugin: HMAC-SHA-256 with invalid length received.");
if ((pss_head_length <= PART_SIGNATURE_SHA256_SIZE) ||
(pss_head_length > buffer_len)) {
ERROR("network plugin: HMAC-SHA-256 with invalid length received.");
+ return -1;
+ }
+
+ if (se->data.server.userdb == NULL) {
+ c_complain(
+ LOG_NOTICE, &complain_no_users,
+ "network plugin: Received signed network packet but can't verify it "
+ "because no user DB has been configured. Will accept it.");
+
+ *ret_buffer = buffer + pss_head_length;
+ *ret_buffer_len -= pss_head_length;
+
+ return 0;
username_len = pss_head_length - PART_SIGNATURE_SHA256_SIZE;
pss.username = malloc(username_len + 1);
if (pss.username == NULL)
username_len = pss_head_length - PART_SIGNATURE_SHA256_SIZE;
pss.username = malloc(username_len + 1);
if (pss.username == NULL)
BUFFER_READ(&pss.head.type, sizeof(pss.head.type));
BUFFER_READ(&pss.head.length, sizeof(pss.head.length));
part_len = ntohs(pss.head.length);
if ((part_len <= PART_SIGNATURE_SHA256_SIZE) || (part_len > buffer_size))
BUFFER_READ(&pss.head.type, sizeof(pss.head.type));
BUFFER_READ(&pss.head.length, sizeof(pss.head.length));
part_len = ntohs(pss.head.length);
if ((part_len <= PART_SIGNATURE_SHA256_SIZE) || (part_len > buffer_size))
if (warning_has_been_printed == 0) {
WARNING("network plugin: Received signed packet, but the network "
if (warning_has_been_printed == 0) {
WARNING("network plugin: Received signed packet, but the network "
if (buffer_len <= PART_ENCRYPTION_AES256_SIZE) {
NOTICE("network plugin: parse_part_encr_aes256: "
"Discarding short packet.");
if (buffer_len <= PART_ENCRYPTION_AES256_SIZE) {
NOTICE("network plugin: parse_part_encr_aes256: "
"Discarding short packet.");
if ((part_size <= PART_ENCRYPTION_AES256_SIZE) || (part_size > buffer_len)) {
NOTICE("network plugin: parse_part_encr_aes256: "
"Discarding part with invalid size.");
if ((part_size <= PART_ENCRYPTION_AES256_SIZE) || (part_size > buffer_len)) {
NOTICE("network plugin: parse_part_encr_aes256: "
"Discarding part with invalid size.");
(username_len > (part_size - (PART_ENCRYPTION_AES256_SIZE + 1)))) {
NOTICE("network plugin: parse_part_encr_aes256: "
"Discarding part with invalid username length.");
(username_len > (part_size - (PART_ENCRYPTION_AES256_SIZE + 1)))) {
NOTICE("network plugin: parse_part_encr_aes256: "
"Discarding part with invalid username length.");
}
assert(username_len > 0);
pea.username = malloc(username_len + 1);
if (pea.username == NULL)
}
assert(username_len > 0);
pea.username = malloc(username_len + 1);
if (pea.username == NULL)
BUFFER_READ(pea.username, username_len);
pea.username[username_len] = 0;
BUFFER_READ(pea.username, username_len);
pea.username[username_len] = 0;
part_size - buffer_offset,
/* in = */ NULL, /* in len = */ 0);
if (err != 0) {
part_size - buffer_offset,
/* in = */ NULL, /* in len = */ 0);
if (err != 0) {
ERROR("network plugin: gcry_cipher_decrypt returned: %s. Username: %s",
gcry_strerror(err), pea.username);
ERROR("network plugin: gcry_cipher_decrypt returned: %s. Username: %s",
gcry_strerror(err), pea.username);
if (memcmp(hash, pea.hash, sizeof(hash)) != 0) {
ERROR("network plugin: Checksum mismatch. Username: %s", pea.username);
sfree(pea.username);
if (memcmp(hash, pea.hash, sizeof(hash)) != 0) {
ERROR("network plugin: Checksum mismatch. Username: %s", pea.username);
sfree(pea.username);
}
parse_packet(se, buffer + buffer_offset, payload_len, flags | PP_ENCRYPTED,
pea.username);
}
parse_packet(se, buffer + buffer_offset, payload_len, flags | PP_ENCRYPTED,
pea.username);
/* Update return values */
*ret_buffer = buffer + part_size;
*ret_buffer_len = buffer_len - part_size;
sfree(pea.username);
/* Update return values */
*ret_buffer = buffer + part_size;
*ret_buffer_len = buffer_len - part_size;
sfree(pea.username);
if ((ph_length <= PART_ENCRYPTION_AES256_SIZE) || (ph_length > buffer_size)) {
ERROR("network plugin: AES-256 encrypted part "
"with invalid length received.");
if ((ph_length <= PART_ENCRYPTION_AES256_SIZE) || (ph_length > buffer_size)) {
ERROR("network plugin: AES-256 encrypted part "
"with invalid length received.");
WARNING("network plugin: parse_packet: Received truncated "
"packet, try increasing `MaxPacketSize'");
WARNING("network plugin: parse_packet: Received truncated "
"packet, try increasing `MaxPacketSize'");
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv4-ttl): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv4-ttl): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt(ipv6-ttl): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt(ipv6-ttl): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
} /* int network_set_ttl */
static int network_set_interface(const sockent_t *se,
} /* int network_set_ttl */
static int network_set_interface(const sockent_t *se,
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv4-multicast-if): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv4-multicast-if): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
}
} else if (ai->ai_family == AF_INET6) {
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)ai->ai_addr;
}
} else if (ai->ai_family == AF_INET6) {
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)ai->ai_addr;
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv6-multicast-if): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv6-multicast-if): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char interface_name[IFNAMSIZ];
if (if_indextoname(se->interface, interface_name) == NULL)
char interface_name[IFNAMSIZ];
if (if_indextoname(se->interface, interface_name) == NULL)
char errbuf[1024];
ERROR("network plugin: setsockopt (bind-if): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (bind-if): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
} /* }}} network_set_interface */
static int network_bind_socket(int fd, const struct addrinfo *ai,
} /* }}} network_set_interface */
static int network_bind_socket(int fd, const struct addrinfo *ai,
char errbuf[1024];
ERROR("network plugin: setsockopt (reuseaddr): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (reuseaddr): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
if (bind(fd, ai->ai_addr, ai->ai_addrlen) == -1) {
char errbuf[1024];
ERROR("bind: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
if (bind(fd, ai->ai_addr, ai->ai_addrlen) == -1) {
char errbuf[1024];
ERROR("bind: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (multicast-loop): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (multicast-loop): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
}
if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) ==
}
if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) ==
char errbuf[1024];
ERROR("network plugin: setsockopt (add-membership): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (add-membership): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv6-multicast-loop): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv6-multicast-loop): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
}
if (setsockopt(fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq,
}
if (setsockopt(fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq,
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv6-add-membership): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (ipv6-add-membership): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char interface_name[IFNAMSIZ];
if (if_indextoname(interface_idx, interface_name) == NULL)
char interface_name[IFNAMSIZ];
if (if_indextoname(interface_idx, interface_name) == NULL)
char errbuf[1024];
ERROR("network plugin: setsockopt (bind-if): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("network plugin: setsockopt (bind-if): %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
} /* int network_bind_socket */
/* Initialize a sockent structure. `type' must be either `SOCKENT_TYPE_CLIENT'
} /* int network_bind_socket */
/* Initialize a sockent structure. `type' must be either `SOCKENT_TYPE_CLIENT'
if (network_init_gcrypt() < 0) {
ERROR("network plugin: Cannot configure client socket with "
"security: Failed to initialize crypto library.");
if (network_init_gcrypt() < 0) {
ERROR("network plugin: Cannot configure client socket with "
"security: Failed to initialize crypto library.");
ERROR("network plugin: Client socket with "
"security requested, but no "
"credentials are configured.");
ERROR("network plugin: Client socket with "
"security requested, but no "
"credentials are configured.");
}
gcry_md_hash_buffer(GCRY_MD_SHA256, se->data.client.password_hash,
se->data.client.password,
}
gcry_md_hash_buffer(GCRY_MD_SHA256, se->data.client.password_hash,
se->data.client.password,
(se->data.server.auth_file == NULL)) {
ERROR("network plugin: Server socket with security requested, "
"but no \"AuthFile\" is configured.");
(se->data.server.auth_file == NULL)) {
ERROR("network plugin: Server socket with security requested, "
"but no \"AuthFile\" is configured.");
}
if (se->data.server.auth_file != NULL) {
if (network_init_gcrypt() < 0) {
ERROR("network plugin: Cannot configure server socket with security: "
"Failed to initialize crypto library.");
}
if (se->data.server.auth_file != NULL) {
if (network_init_gcrypt() < 0) {
ERROR("network plugin: Cannot configure server socket with security: "
"Failed to initialize crypto library.");
}
se->data.server.userdb = fbh_create(se->data.server.auth_file);
if (se->data.server.userdb == NULL) {
ERROR("network plugin: Reading password file \"%s\" failed.",
se->data.server.auth_file);
}
se->data.server.userdb = fbh_create(se->data.server.auth_file);
if (se->data.server.userdb == NULL) {
ERROR("network plugin: Reading password file \"%s\" failed.",
se->data.server.auth_file);
struct addrinfo ai_hints = {.ai_family = AF_UNSPEC,
.ai_flags = AI_ADDRCONFIG,
struct addrinfo ai_hints = {.ai_family = AF_UNSPEC,
.ai_flags = AI_ADDRCONFIG,
LOG_ERR, &complaint, "network plugin: getaddrinfo (%s, %s) failed: %s",
(se->node == NULL) ? "(null)" : se->node,
(se->service == NULL) ? "(null)" : se->service, gai_strerror(status));
LOG_ERR, &complaint, "network plugin: getaddrinfo (%s, %s) failed: %s",
(se->node == NULL) ? "(null)" : se->node,
(se->service == NULL) ? "(null)" : se->service, gai_strerror(status));
} else {
c_release(LOG_NOTICE, &complaint,
"network plugin: Successfully resolved \"%s\".", se->node);
} else {
c_release(LOG_NOTICE, &complaint,
"network plugin: Successfully resolved \"%s\".", se->node);
} /* }}} int sockent_client_connect */
/* Open the file descriptors for a initialized sockent structure. */
} /* }}} int sockent_client_connect */
/* Open the file descriptors for a initialized sockent structure. */
ERROR("network plugin: getaddrinfo (%s, %s) failed: %s",
(se->node == NULL) ? "(null)" : se->node,
(se->service == NULL) ? "(null)" : se->service, gai_strerror(status));
ERROR("network plugin: getaddrinfo (%s, %s) failed: %s",
(se->node == NULL) ? "(null)" : se->node,
(se->service == NULL) ? "(null)" : se->service, gai_strerror(status));
sizeof(*tmp) * (listen_sockets_num + se->data.server.fd_num));
if (tmp == NULL) {
ERROR("network plugin: realloc failed.");
sizeof(*tmp) * (listen_sockets_num + se->data.server.fd_num));
if (tmp == NULL) {
ERROR("network plugin: realloc failed.");
}
last_ptr = listen_sockets;
} else /* if (se->type == SOCKENT_TYPE_CLIENT) */
{
if (sending_sockets == NULL) {
sending_sockets = se;
}
last_ptr = listen_sockets;
} else /* if (se->type == SOCKENT_TYPE_CLIENT) */
{
if (sending_sockets == NULL) {
sending_sockets = se;
} /* }}} int sockent_add */
static void *dispatch_thread(void __attribute__((unused)) * arg) /* {{{ */
} /* }}} int sockent_add */
static void *dispatch_thread(void __attribute__((unused)) * arg) /* {{{ */
if (strcmp(vl_def->host, vl->host) != 0) {
if (write_part_string(&buffer, &buffer_size, TYPE_HOST, vl->host,
strlen(vl->host)) != 0)
if (strcmp(vl_def->host, vl->host) != 0) {
if (write_part_string(&buffer, &buffer_size, TYPE_HOST, vl->host,
strlen(vl->host)) != 0)
sstrncpy(vl_def->host, vl->host, sizeof(vl_def->host));
}
if (vl_def->time != vl->time) {
if (write_part_number(&buffer, &buffer_size, TYPE_TIME_HR,
(uint64_t)vl->time))
sstrncpy(vl_def->host, vl->host, sizeof(vl_def->host));
}
if (vl_def->time != vl->time) {
if (write_part_number(&buffer, &buffer_size, TYPE_TIME_HR,
(uint64_t)vl->time))
vl_def->time = vl->time;
}
if (vl_def->interval != vl->interval) {
if (write_part_number(&buffer, &buffer_size, TYPE_INTERVAL_HR,
(uint64_t)vl->interval))
vl_def->time = vl->time;
}
if (vl_def->interval != vl->interval) {
if (write_part_number(&buffer, &buffer_size, TYPE_INTERVAL_HR,
(uint64_t)vl->interval))
vl_def->interval = vl->interval;
}
if (strcmp(vl_def->plugin, vl->plugin) != 0) {
if (write_part_string(&buffer, &buffer_size, TYPE_PLUGIN, vl->plugin,
strlen(vl->plugin)) != 0)
vl_def->interval = vl->interval;
}
if (strcmp(vl_def->plugin, vl->plugin) != 0) {
if (write_part_string(&buffer, &buffer_size, TYPE_PLUGIN, vl->plugin,
strlen(vl->plugin)) != 0)
if (write_part_string(&buffer, &buffer_size, TYPE_PLUGIN_INSTANCE,
vl->plugin_instance,
strlen(vl->plugin_instance)) != 0)
if (write_part_string(&buffer, &buffer_size, TYPE_PLUGIN_INSTANCE,
vl->plugin_instance,
strlen(vl->plugin_instance)) != 0)
sstrncpy(vl_def->plugin_instance, vl->plugin_instance,
sizeof(vl_def->plugin_instance));
}
sstrncpy(vl_def->plugin_instance, vl->plugin_instance,
sizeof(vl_def->plugin_instance));
}
if (strcmp(vl_def->type, vl->type) != 0) {
if (write_part_string(&buffer, &buffer_size, TYPE_TYPE, vl->type,
strlen(vl->type)) != 0)
if (strcmp(vl_def->type, vl->type) != 0) {
if (write_part_string(&buffer, &buffer_size, TYPE_TYPE, vl->type,
strlen(vl->type)) != 0)
sstrncpy(vl_def->type, ds->type, sizeof(vl_def->type));
}
if (strcmp(vl_def->type_instance, vl->type_instance) != 0) {
if (write_part_string(&buffer, &buffer_size, TYPE_TYPE_INSTANCE,
vl->type_instance, strlen(vl->type_instance)) != 0)
sstrncpy(vl_def->type, ds->type, sizeof(vl_def->type));
}
if (strcmp(vl_def->type_instance, vl->type_instance) != 0) {
if (write_part_string(&buffer, &buffer_size, TYPE_TYPE_INSTANCE,
vl->type_instance, strlen(vl->type_instance)) != 0)
sstrncpy(vl_def->type_instance, vl->type_instance,
sizeof(vl_def->type_instance));
}
if (write_part_values(&buffer, &buffer_size, ds, vl) != 0)
sstrncpy(vl_def->type_instance, vl->type_instance,
sizeof(vl_def->type_instance));
}
if (write_part_values(&buffer, &buffer_size, ds, vl) != 0)
else if ((tmp > 0) && (tmp <= 255))
network_config_ttl = tmp;
else {
WARNING("network plugin: The `TimeToLive' must be between 1 and 255.");
else if ((tmp > 0) && (tmp <= 255))
network_config_ttl = tmp;
else {
WARNING("network plugin: The `TimeToLive' must be between 1 and 255.");
} /* }}} int network_config_set_ttl */
static int network_config_set_interface(const oconfig_item_t *ci, /* {{{ */
} /* }}} int network_config_set_ttl */
static int network_config_set_interface(const oconfig_item_t *ci, /* {{{ */
} /* }}} int network_config_set_interface */
static int network_config_set_buffer_size(const oconfig_item_t *ci) /* {{{ */
} /* }}} int network_config_set_interface */
static int network_config_set_buffer_size(const oconfig_item_t *ci) /* {{{ */
else if ((tmp >= 1024) && (tmp <= 65535))
network_config_packet_size = tmp;
else {
WARNING(
"network plugin: The `MaxPacketSize' must be between 1024 and 65535.");
else if ((tmp >= 1024) && (tmp <= 65535))
network_config_packet_size = tmp;
else {
WARNING(
"network plugin: The `MaxPacketSize' must be between 1024 and 65535.");
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
WARNING("network plugin: The `SecurityLevel' config option needs exactly "
"one string argument.");
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
WARNING("network plugin: The `SecurityLevel' config option needs exactly "
"one string argument.");
*retval = SECURITY_LEVEL_NONE;
else {
WARNING("network plugin: Unknown security level: %s.", str);
*retval = SECURITY_LEVEL_NONE;
else {
WARNING("network plugin: Unknown security level: %s.", str);
ERROR("network plugin: The `%s' config option needs "
"one or two string arguments.",
ci->key);
ERROR("network plugin: The `%s' config option needs "
"one or two string arguments.",
ci->key);
} /* }}} int network_config_add_listen */
static int network_config_add_server(const oconfig_item_t *ci) /* {{{ */
} /* }}} int network_config_add_listen */
static int network_config_add_server(const oconfig_item_t *ci) /* {{{ */
ERROR("network plugin: The `%s' config option needs "
"one or two string arguments.",
ci->key);
ERROR("network plugin: The `%s' config option needs "
"one or two string arguments.",
ci->key);
"requested, but no Username or Password option was given. "
"Cowardly refusing to open this socket!");
sockent_destroy(se);
"requested, but no Username or Password option was given. "
"Cowardly refusing to open this socket!");
sockent_destroy(se);
} /* }}} int network_config */
static int network_notification(const notification_t *n,
} /* }}} int network_config */
static int network_notification(const notification_t *n,
memset(buffer, 0, sizeof(buffer));
status = write_part_number(&buffer_ptr, &buffer_free, TYPE_TIME_HR,
(uint64_t)n->time);
if (status != 0)
memset(buffer, 0, sizeof(buffer));
status = write_part_number(&buffer_ptr, &buffer_free, TYPE_TIME_HR,
(uint64_t)n->time);
if (status != 0)
status = write_part_number(&buffer_ptr, &buffer_free, TYPE_SEVERITY,
(uint64_t)n->severity);
if (status != 0)
status = write_part_number(&buffer_ptr, &buffer_free, TYPE_SEVERITY,
(uint64_t)n->severity);
if (status != 0)
if (strlen(n->host) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_HOST, n->host,
strlen(n->host));
if (status != 0)
if (strlen(n->host) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_HOST, n->host,
strlen(n->host));
if (status != 0)
}
if (strlen(n->plugin) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_PLUGIN,
n->plugin, strlen(n->plugin));
if (status != 0)
}
if (strlen(n->plugin) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_PLUGIN,
n->plugin, strlen(n->plugin));
if (status != 0)
}
if (strlen(n->plugin_instance) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_PLUGIN_INSTANCE,
n->plugin_instance, strlen(n->plugin_instance));
if (status != 0)
}
if (strlen(n->plugin_instance) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_PLUGIN_INSTANCE,
n->plugin_instance, strlen(n->plugin_instance));
if (status != 0)
}
if (strlen(n->type) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_TYPE, n->type,
strlen(n->type));
if (status != 0)
}
if (strlen(n->type) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_TYPE, n->type,
strlen(n->type));
if (status != 0)
}
if (strlen(n->type_instance) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_TYPE_INSTANCE,
n->type_instance, strlen(n->type_instance));
if (status != 0)
}
if (strlen(n->type_instance) > 0) {
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_TYPE_INSTANCE,
n->type_instance, strlen(n->type_instance));
if (status != 0)
}
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_MESSAGE,
n->message, strlen(n->message));
if (status != 0)
}
status = write_part_string(&buffer_ptr, &buffer_free, TYPE_MESSAGE,
n->message, strlen(n->message));
if (status != 0)
/* Check if we were already initialized. If so, just return - there's
* nothing more to do (for now, that is). */
if (have_init)
/* Check if we were already initialized. If so, just return - there's
* nothing more to do (for now, that is). */
if (have_init)
send_buffer = malloc(network_config_packet_size);
if (send_buffer == NULL) {
ERROR("network plugin: malloc failed.");
send_buffer = malloc(network_config_packet_size);
if (send_buffer == NULL) {
ERROR("network plugin: malloc failed.");
/* If no threads need to be started, return here. */
if ((listen_sockets_num == 0) ||
((dispatch_thread_running != 0) && (receive_thread_running != 0)))
/* If no threads need to be started, return here. */
if ((listen_sockets_num == 0) ||
((dispatch_thread_running != 0) && (receive_thread_running != 0)))