- else if (pkg_type == TYPE_VALUES)
- {
- status = parse_part_values (&buffer, &buffer_size,
- &vl.values, &vl.values_len);
- if (status != 0)
- break;
-
- network_dispatch_values (&vl, username);
-
- sfree (vl.values);
- }
- else if (pkg_type == TYPE_TIME)
- {
- uint64_t tmp = 0;
- status = parse_part_number (&buffer, &buffer_size,
- &tmp);
- if (status == 0)
- {
- vl.time = TIME_T_TO_CDTIME_T (tmp);
- n.time = TIME_T_TO_CDTIME_T (tmp);
- }
- }
- else if (pkg_type == TYPE_TIME_HR)
- {
- uint64_t tmp = 0;
- status = parse_part_number (&buffer, &buffer_size,
- &tmp);
- if (status == 0)
- {
- vl.time = (cdtime_t) tmp;
- n.time = (cdtime_t) tmp;
- }
- }
- else if (pkg_type == TYPE_INTERVAL)
- {
- uint64_t tmp = 0;
- status = parse_part_number (&buffer, &buffer_size,
- &tmp);
- if (status == 0)
- vl.interval = TIME_T_TO_CDTIME_T (tmp);
- }
- else if (pkg_type == TYPE_INTERVAL_HR)
- {
- uint64_t tmp = 0;
- status = parse_part_number (&buffer, &buffer_size,
- &tmp);
- if (status == 0)
- vl.interval = (cdtime_t) tmp;
- }
- else if (pkg_type == TYPE_HOST)
- {
- status = parse_part_string (&buffer, &buffer_size,
- vl.host, sizeof (vl.host));
- if (status == 0)
- sstrncpy (n.host, vl.host, sizeof (n.host));
- }
- else if (pkg_type == TYPE_PLUGIN)
- {
- status = parse_part_string (&buffer, &buffer_size,
- vl.plugin, sizeof (vl.plugin));
- if (status == 0)
- sstrncpy (n.plugin, vl.plugin,
- sizeof (n.plugin));
- }
- else if (pkg_type == TYPE_PLUGIN_INSTANCE)
- {
- status = parse_part_string (&buffer, &buffer_size,
- vl.plugin_instance,
- sizeof (vl.plugin_instance));
- if (status == 0)
- sstrncpy (n.plugin_instance,
- vl.plugin_instance,
- sizeof (n.plugin_instance));
- }
- else if (pkg_type == TYPE_TYPE)
- {
- status = parse_part_string (&buffer, &buffer_size,
- vl.type, sizeof (vl.type));
- if (status == 0)
- sstrncpy (n.type, vl.type, sizeof (n.type));
- }
- else if (pkg_type == TYPE_TYPE_INSTANCE)
- {
- status = parse_part_string (&buffer, &buffer_size,
- vl.type_instance,
- sizeof (vl.type_instance));
- if (status == 0)
- sstrncpy (n.type_instance, vl.type_instance,
- sizeof (n.type_instance));
- }
- else if (pkg_type == TYPE_MESSAGE)
- {
- status = parse_part_string (&buffer, &buffer_size,
- n.message, sizeof (n.message));
-
- if (status != 0)
- {
- /* do nothing */
- }
- else if ((n.severity != NOTIF_FAILURE)
- && (n.severity != NOTIF_WARNING)
- && (n.severity != NOTIF_OKAY))
- {
- INFO ("network plugin: "
- "Ignoring notification with "
- "unknown severity %i.",
- n.severity);
- }
- else if (n.time == 0)
- {
- INFO ("network plugin: "
- "Ignoring notification with "
- "time == 0.");
- }
- else if (strlen (n.message) == 0)
- {
- INFO ("network plugin: "
- "Ignoring notification with "
- "an empty message.");
- }
- else
- {
- network_dispatch_notification (&n);
- }
- }
- else if (pkg_type == TYPE_SEVERITY)
- {
- uint64_t tmp = 0;
- status = parse_part_number (&buffer, &buffer_size,
- &tmp);
- if (status == 0)
- n.severity = (int) tmp;
- }
- else
- {
- DEBUG ("network plugin: parse_packet: Unknown part"
- " type: 0x%04hx", pkg_type);
- buffer = ((char *) buffer) + pkg_length;
- buffer_size -= (size_t) pkg_length;
- }
- } /* while (buffer_size > sizeof (part_header_t)) */
-
- if (status == 0 && buffer_size > 0)
- WARNING ("network plugin: parse_packet: Received truncated "
- "packet, try increasing `MaxPacketSize'");
-
- return (status);
+ else if (pkg_type == TYPE_VALUES) {
+ status =
+ parse_part_values(&buffer, &buffer_size, &vl.values, &vl.values_len);
+ if (status != 0)
+ break;
+
+ network_dispatch_values(&vl, username);
+
+ sfree(vl.values);
+ } else if (pkg_type == TYPE_TIME) {
+ uint64_t tmp = 0;
+ status = parse_part_number(&buffer, &buffer_size, &tmp);
+ if (status == 0) {
+ vl.time = TIME_T_TO_CDTIME_T(tmp);
+ n.time = TIME_T_TO_CDTIME_T(tmp);
+ }
+ } else if (pkg_type == TYPE_TIME_HR) {
+ uint64_t tmp = 0;
+ status = parse_part_number(&buffer, &buffer_size, &tmp);
+ if (status == 0) {
+ vl.time = (cdtime_t)tmp;
+ n.time = (cdtime_t)tmp;
+ }
+ } else if (pkg_type == TYPE_INTERVAL) {
+ uint64_t tmp = 0;
+ status = parse_part_number(&buffer, &buffer_size, &tmp);
+ if (status == 0)
+ vl.interval = TIME_T_TO_CDTIME_T(tmp);
+ } else if (pkg_type == TYPE_INTERVAL_HR) {
+ uint64_t tmp = 0;
+ status = parse_part_number(&buffer, &buffer_size, &tmp);
+ if (status == 0)
+ vl.interval = (cdtime_t)tmp;
+ } else if (pkg_type == TYPE_HOST) {
+ status =
+ parse_part_string(&buffer, &buffer_size, vl.host, sizeof(vl.host));
+ if (status == 0)
+ sstrncpy(n.host, vl.host, sizeof(n.host));
+ } else if (pkg_type == TYPE_PLUGIN) {
+ status = parse_part_string(&buffer, &buffer_size, vl.plugin,
+ sizeof(vl.plugin));
+ if (status == 0)
+ sstrncpy(n.plugin, vl.plugin, sizeof(n.plugin));
+ } else if (pkg_type == TYPE_PLUGIN_INSTANCE) {
+ status = parse_part_string(&buffer, &buffer_size, vl.plugin_instance,
+ sizeof(vl.plugin_instance));
+ if (status == 0)
+ sstrncpy(n.plugin_instance, vl.plugin_instance,
+ sizeof(n.plugin_instance));
+ } else if (pkg_type == TYPE_TYPE) {
+ status =
+ parse_part_string(&buffer, &buffer_size, vl.type, sizeof(vl.type));
+ if (status == 0)
+ sstrncpy(n.type, vl.type, sizeof(n.type));
+ } else if (pkg_type == TYPE_TYPE_INSTANCE) {
+ status = parse_part_string(&buffer, &buffer_size, vl.type_instance,
+ sizeof(vl.type_instance));
+ if (status == 0)
+ sstrncpy(n.type_instance, vl.type_instance, sizeof(n.type_instance));
+ } else if (pkg_type == TYPE_MESSAGE) {
+ status = parse_part_string(&buffer, &buffer_size, n.message,
+ sizeof(n.message));
+
+ if (status != 0) {
+ /* do nothing */
+ } else if ((n.severity != NOTIF_FAILURE) &&
+ (n.severity != NOTIF_WARNING) && (n.severity != NOTIF_OKAY)) {
+ INFO("network plugin: "
+ "Ignoring notification with "
+ "unknown severity %i.",
+ n.severity);
+ } else if (n.time == 0) {
+ INFO("network plugin: "
+ "Ignoring notification with "
+ "time == 0.");
+ } else if (strlen(n.message) == 0) {
+ INFO("network plugin: "
+ "Ignoring notification with "
+ "an empty message.");
+ } else {
+ network_dispatch_notification(&n);
+ }
+ } else if (pkg_type == TYPE_SEVERITY) {
+ uint64_t tmp = 0;
+ status = parse_part_number(&buffer, &buffer_size, &tmp);
+ if (status == 0)
+ n.severity = (int)tmp;
+ } else {
+ DEBUG("network plugin: parse_packet: Unknown part"
+ " type: 0x%04hx",
+ pkg_type);
+ buffer = ((char *)buffer) + pkg_length;
+ buffer_size -= (size_t)pkg_length;
+ }
+ } /* while (buffer_size > sizeof (part_header_t)) */
+
+ if (status == 0 && buffer_size > 0)
+ WARNING("network plugin: parse_packet: Received truncated "
+ "packet, try increasing `MaxPacketSize'");
+
+ return (status);