UM C API  6.16.1
Source code for lbmmonfmtpb.c
/*
All of the documentation and software included in this and any
other Informatica Inc. Ultra Messaging Releases
Copyright (C) Informatica Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted only as covered by the terms of a
valid software license agreement with Informatica Inc.
(C) Copyright 2004,2023 Informatica Inc. All Rights Reserved.
THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF
NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE
UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE
LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR
INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE
TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF
THE LIKELIHOOD OF SUCH DAMAGES.
*/
#ifdef __VOS__
#define _POSIX_C_SOURCE 200112L
#include <sys/time.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <time.h>
#include <limits.h>
#include <errno.h>
#include <ctype.h>
#ifdef _WIN32
#define strcasecmp stricmp
#define snprintf _snprintf
#else
#endif
#if defined(__TANDEM)
#include <strings.h>
#endif
#include <lbm/lbmmon.h>
#include "lbmmon_int.h"
#include "lbmcommon.h"
#include "mullog.h"
#include <lbm/lbmaux.h>
#include "lbmconf.h"
#include "lbmmon_store_filter_options.h"
/* Generated structures have unnamed unions which C99 complains about but are valid in C11 */
LBM_GNU_PRAGMA(GCC diagnostic ignored "-Wpedantic")
#include "gen/ums_mon_filters.pb-c.h"
LBM_GNU_PRAGMA_RESET()
static const lbmmon_format_func_t LBMMON_FORMAT_PB =
{
lbmmon_format_pb_init,
lbmmon_format_pb_apply_format_options,
lbmmon_rcv_format_pb_serialize,
lbmmon_src_format_pb_serialize,
lbmmon_rcv_format_pb_deserialize,
lbmmon_src_format_pb_deserialize,
lbmmon_format_pb_finish,
lbmmon_format_pb_errmsg,
lbmmon_evq_format_pb_serialize,
lbmmon_evq_format_pb_deserialize,
lbmmon_ctx_format_pb_serialize,
lbmmon_ctx_format_pb_deserialize,
lbmmon_rcv_topic_format_pb_serialize,
lbmmon_rcv_topic_format_pb_deserialize,
lbmmon_wildcard_rcv_format_pb_serialize,
lbmmon_wildcard_rcv_format_pb_deserialize,
lbmmon_store_format_pb_serialize,
lbmmon_store_format_pb_deserialize,
lbmmon_store_format_pb_filter_options,
lbmmon_store_free_unpacked,
lbmmon_gateway_format_pb_serialize,
lbmmon_gateway_format_pb_deserialize,
lbmmon_gateway_free_unpacked
};
typedef struct
{
int mPassthrough;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__TCP mRcvTcpFilter;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__LBTRM mRcvLbtrmFilter;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__LBTRU mRcvLbtruFilter;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__LBTIPC mRcvLbtipcFilter;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__LBTSMX mRcvLbtsmxFilter;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__TCP mSrcTcpFilter;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__LBTRM mSrcLbtrmFilter;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__LBTRU mSrcLbtruFilter;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__LBTIPC mSrcLbtipcFilter;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__LBTSMX mSrcLbtsmxFilter;
Lbmmon_Filter__UMSMonMsg__Stats__EventQueue mEventQueueFilter;
Lbmmon_Filter__UMSMonMsg__Stats__Context mContextFilter;
Lbmmon_FilterMessage ** filters;
} lbmmon_format_pb_t;
#define LBMMON_NUM_FILTER_MSGS 12
static char ErrorString[LBM_CONFIG_MAX_LINE_LEN];
static void lbmmon_format_pb_report_allocation_error(size_t Size)
{
snprintf(ErrorString, sizeof(ErrorString), "Unable to allocate %u bytes", (unsigned)Size);
}
const lbmmon_format_func_t * lbmmon_format_pb_module(void)
{
return (&LBMMON_FORMAT_PB);
}
int typeFor(char * type_name)
{
int type = 0;
if (strcasecmp(type_name, "LBMMON_FORMAT_FILTER_OFF") == 0) {
} else if (strcasecmp(type_name, "LBMMON_FORMAT_FILTER_ON") == 0) {
} else if (strcasecmp(type_name, "LBMMON_FORMAT_FILTER_EQ") == 0) {
} else if (strcasecmp(type_name, "LBMMON_FORMAT_FILTER_NE") == 0) {
} else if (strcasecmp(type_name, "LBMMON_FORMAT_FILTER_LT") == 0) {
} else if (strcasecmp(type_name, "LBMMON_FORMAT_FILTER_GT") == 0) {
} else {
return (-1);
}
return type;
}
/* Return 1 if filter applied, -1 if error, 0 otherwise. */
int lbmmon_apply_filter(char * message, const ProtobufCMessageDescriptor *descriptor, char *key, char *value)
{
size_t message_len;
char name[LBMMON_MAX_LEN];
char *last;
int i;
char * typeString = NULL;
char * valueString = NULL;
int type = 0;
if (descriptor == NULL) {
snprintf(ErrorString, sizeof(ErrorString), "[lbmmon_apply_filter] Descriptor was NULL.\n");
return (-1);
}
message_len = strlen(descriptor->name);
if (strncasecmp(descriptor->name, key, message_len) == 0) {
strncpy(name, &key[message_len + 1], LBMMON_MAX_LEN);
MUL_DEBUG(LBM_DEBUG_LBMMON, ("[lbmmon_apply_filter] Key[%s] Value[%s] \n", name, value));
for (i = 0; i < descriptor->n_fields; i++) {
if (strcasecmp(name, descriptor->fields[i].name) == 0) {
typeString = mul_strtok_r(value, "(", &last);
if (typeString == NULL) {
snprintf(ErrorString, sizeof(ErrorString), "[lbmmon_apply_filter] Invalid option for %s given Value[%s]\n", key, value);
return (-1);
}
type = typeFor(typeString);
if (type == -1) {
snprintf(ErrorString, sizeof(ErrorString), "[lbmmon_apply_filter] Invalid option for %s given Value[%s]\n", key, value);
return (-1);
}
valueString = mul_strtok_r(0, ")", &last);
if ((type >= LBMMON_FORMAT_FILTER_EQ) && (valueString == NULL)) {
snprintf(ErrorString, sizeof(ErrorString), "[lbmmon_apply_filter] Value %s must be in the form %s(number);\n", typeString, typeString);
return (-1);
}
switch (descriptor->fields[i].type)
{
case PROTOBUF_C_TYPE_UINT64:
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_SINT64:
case PROTOBUF_C_TYPE_SFIXED64:
case PROTOBUF_C_TYPE_FIXED64:
{
lbmmon_filter_uint64_t * filter = ((lbmmon_filter_uint64_t *)(message + descriptor->fields[i].offset));
filter->type = type;
if (valueString != NULL) {
if ((lbm_conf_parse_uint64(&filter->value, valueString) != LBM_OK)) {
snprintf(ErrorString, sizeof(ErrorString), "[lbmmon_apply_filter] Value %s must be a 64-bit number in the form %s(number);\n", valueString, typeString);
return (-1);
}
} else {
filter->value = 0;
}
MUL_DEBUG(LBM_DEBUG_LBMMON, ("[lbmmon_apply_filter] filter.type[%d] filter.value[%lu] \n", filter->type, filter->value));
return (1);
}
case PROTOBUF_C_TYPE_UINT32:
case PROTOBUF_C_TYPE_INT32:
case PROTOBUF_C_TYPE_SINT32:
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
case PROTOBUF_C_TYPE_STRING:
{
/* Not currently used so any code here would be untestable */
}
case PROTOBUF_C_TYPE_BYTES:
case PROTOBUF_C_TYPE_FLOAT:
case PROTOBUF_C_TYPE_DOUBLE:
case PROTOBUF_C_TYPE_BOOL:
case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_MESSAGE:
{
/* Unsupported Field Types */
}
}
snprintf(ErrorString, sizeof(ErrorString), "[lbmmon_apply_filter] Invalid Key %s Value %s\n", key, value);
return (-1);
}
}
/* Intentionally don't complain about field names we don't recognize
* as they could be from the future */
}
return (0);
}
/* This function can apply format options at startup or dynamically from a received command message */
int lbmmon_format_pb_apply_format_options(void * FormatClientData, const void * FormatOptions)
{
lbmmon_format_pb_t * data = FormatClientData;
const char * ptr = (const char *)FormatOptions;
char key[LBMMON_MAX_LEN];
char value[LBMMON_MAX_LEN];
while ((ptr = lbmmon_next_key_value_pair(ptr, key, sizeof(key), value, sizeof(value))) != NULL)
{
if (strcasecmp(key, "passthrough") == 0)
{
if (strcasecmp(value, "off") == 0) {
data->mPassthrough = LBMMON_FORMAT_PASSTHROUGH_OFF;
} else if (strcasecmp(value, "on") == 0) {
data->mPassthrough = LBMMON_FORMAT_PASSTHROUGH_ON;
} else if (strcasecmp(value, "convert") == 0) {
/* No need to convert so just set to passthrough */
data->mPassthrough = LBMMON_FORMAT_PASSTHROUGH_ON;
} else {
strncpy(ErrorString, "Value must be \"off\", \"on\" or \"convert\" for monitor format option \"passthrough\".", sizeof(ErrorString));
return (-1);
}
} else {
int i = 0;
int rc;
for (i = 0; i < LBMMON_NUM_FILTER_MSGS; i++) {
rc = lbmmon_apply_filter((char *)(data->filters[i]), data->filters[i]->base.descriptor, key, value);
if (rc == 1) {
/* Found message and applied filter. Move on to next one */
break;
}
if (rc == -1) {
/* Found message but there was a problem applying the filter. Error message set in lbmmon_apply_filter*/
return (-1);
}
/* Otherwise, keep looping through all messages. */
}
}
}
/* Intentionally don't complain about key/value pairs we don't recognize
* as they could be for the store or from the future */
return (0);
}
int lbmmon_format_pb_init(void * * FormatClientData, const void * FormatOptions)
{
lbmmon_format_pb_t * data;
char format_options_file[LBMMON_MAX_LEN];
char * FormatOptionsBuffer = NULL;
char key[LBMMON_MAX_LEN];
char value[LBMMON_MAX_LEN];
const char * ptr = (const char *)FormatOptions;
memset(ErrorString, 0, sizeof(ErrorString));
*FormatClientData = NULL;
data = malloc(sizeof(lbmmon_format_pb_t));
if (data == NULL)
{
lbmmon_format_pb_report_allocation_error(sizeof(lbmmon_format_pb_t));
return (-1);
}
data->filters = malloc(sizeof(Lbmmon_FilterMessage *) * LBMMON_NUM_FILTER_MSGS);
if (data->filters == NULL)
{
lbmmon_format_pb_report_allocation_error(sizeof(sizeof(Lbmmon_FilterMessage *) * LBMMON_NUM_FILTER_MSGS));
return (-1);
}
data->mPassthrough = LBMMON_FORMAT_PASSTHROUGH_OFF;
lbmmon_filter__umsmon_msg__stats__receiver_transport__tcp__init(&(data->mRcvTcpFilter));
lbmmon_filter__umsmon_msg__stats__receiver_transport__lbtrm__init(&(data->mRcvLbtrmFilter));
lbmmon_filter__umsmon_msg__stats__receiver_transport__lbtru__init(&(data->mRcvLbtruFilter));
lbmmon_filter__umsmon_msg__stats__receiver_transport__lbtipc__init(&(data->mRcvLbtipcFilter));
lbmmon_filter__umsmon_msg__stats__receiver_transport__lbtsmx__init(&(data->mRcvLbtsmxFilter));
lbmmon_filter__umsmon_msg__stats__source_transport__tcp__init(&(data->mSrcTcpFilter));
lbmmon_filter__umsmon_msg__stats__source_transport__lbtrm__init(&(data->mSrcLbtrmFilter));
lbmmon_filter__umsmon_msg__stats__source_transport__lbtru__init(&(data->mSrcLbtruFilter));
lbmmon_filter__umsmon_msg__stats__source_transport__lbtipc__init(&(data->mSrcLbtipcFilter));
lbmmon_filter__umsmon_msg__stats__source_transport__lbtsmx__init(&(data->mSrcLbtsmxFilter));
lbmmon_filter__umsmon_msg__stats__event_queue__init(&(data->mEventQueueFilter));
lbmmon_filter__umsmon_msg__stats__context__init(&(data->mContextFilter));
data->filters[0] = (Lbmmon_FilterMessage *)&(data->mRcvTcpFilter);
data->filters[1] = (Lbmmon_FilterMessage *)&(data->mRcvLbtrmFilter);
data->filters[2] = (Lbmmon_FilterMessage *)&(data->mRcvLbtruFilter);
data->filters[3] = (Lbmmon_FilterMessage *)&(data->mRcvLbtipcFilter);
data->filters[4] = (Lbmmon_FilterMessage *)&(data->mRcvLbtsmxFilter);
data->filters[5] = (Lbmmon_FilterMessage *)&(data->mSrcTcpFilter);
data->filters[6] = (Lbmmon_FilterMessage *)&(data->mSrcLbtrmFilter);
data->filters[7] = (Lbmmon_FilterMessage *)&(data->mSrcLbtruFilter);
data->filters[8] = (Lbmmon_FilterMessage *)&(data->mSrcLbtipcFilter);
data->filters[9] = (Lbmmon_FilterMessage *)&(data->mSrcLbtsmxFilter);
data->filters[10] = (Lbmmon_FilterMessage *)&(data->mEventQueueFilter);
data->filters[11] = (Lbmmon_FilterMessage *)&(data->mContextFilter);
/* Process format options */
memset(format_options_file, 0, sizeof(format_options_file));
while ((ptr = lbmmon_next_key_value_pair(ptr, key, sizeof(key), value, sizeof(value))) != NULL)
{
if (strcasecmp(key, "filters") == 0)
{
strncpy(format_options_file, value, sizeof(format_options_file));
if (lbmaux_lbmmon_format_options_from_file(&FormatOptionsBuffer, format_options_file, ErrorString) != 0) {
free(data->filters);
free(data);
return -1;
}
if (lbmmon_format_pb_apply_format_options(data, (const char *)FormatOptionsBuffer) != 0) {
free(FormatOptionsBuffer);
free(data->filters);
free(data);
return -1;
}
free(FormatOptionsBuffer);
}
}
if (lbmmon_format_pb_apply_format_options(data, (const char *)FormatOptions) != 0) {
free(data->filters);
free(data);
return -1;
}
*FormatClientData = (void *)data;
return (0);
}
int lbmmon_format_pb_default_filter_options(void * FormatClientData, char * Destination, size_t Size)
{
lbmmon_format_pb_t * data = FormatClientData;
const ProtobufCMessageDescriptor *descriptor;
int i, j = 0;
char work[LBMMON_MAX_LEN];
char lbmmon_filter_options_prologue[] =
"# LBM filter option settings\n"
"# LBMMON_FORMAT_FILTER_OFF - include field in message(default)\n"
"# LBMMON_FORMAT_FILTER_ON - exclude field from message\n"
"# LBMMON_FORMAT_FILTER_EQ(numeric value) - exclude field from message when field == value\n"
"# LBMMON_FORMAT_FILTER_NE(numeric value) - exclude field from message field != value\n"
"# LBMMON_FORMAT_FILTER_LT(numeric value) - exclude field from message field < value\n"
"# LBMMON_FORMAT_FILTER_GT(numeric value) - exclude field from message field > value\n"
"#\n"
"# LBM default filter options\n"
;
if ((data == NULL) || (data->filters == NULL)) {
return (-1);
}
strncpy(Destination, lbmmon_filter_options_prologue, Size);
for (i = 0; i < LBMMON_NUM_FILTER_MSGS; i++) {
if (data->filters[i] == NULL) {
return (-1);
}
descriptor = data->filters[i]->base.descriptor;
for (j = 0; j < descriptor->n_fields; j++) {
snprintf(work, sizeof(work), "%s.%s=LBMMON_FORMAT_FILTER_OFF;\n", descriptor->name, descriptor->fields[j].name);
if ((strlen(Destination) + strlen(work) + 1) > Size) {
snprintf(ErrorString, sizeof(ErrorString), "[lbmmon_format_pb_default_filter_options] Destination buffer too small. Buffer is %lu but need %lu.\n",
Size, strlen(Destination) + strlen(work));
return (-1);
}
strncat(Destination, work, Size - strlen(Destination) - 1);
}
}
return 0;
}
/* lbmmon_store_free_msg_filter_option_strings - free message filter strings */
void lbmmon_store_free_msg_filter_option_strings(Lbmmon__UMPMonMsg *store_msg) {
ProtobufCMessageDescriptor *base_descriptor = (ProtobufCMessageDescriptor *)store_msg->base.descriptor;
int i;
for (i = 0; i < base_descriptor->n_fields; ++i) {
if (base_descriptor->fields[i].type == PROTOBUF_C_TYPE_STRING) {
unsigned int *opt = (unsigned int *)(store_msg->base.unknown_fields);
if (opt[base_descriptor->fields[i].id - 1] == LBMMON_FORMAT_SELECT_MATCH_REGX) {
char *regex_t_ptr;
char *p = (char *)(store_msg); /* the stored value is actually a regex_t pointer */
p += base_descriptor->fields[i].offset;
regex_t_ptr = *(char **)p;
#if defined(LBM_HAS_REGEX_H)
regfree((regex_t *)regex_t_ptr);
#endif
free(regex_t_ptr);
}
else {
if (opt[base_descriptor->fields[i].id - 1] == LBMMON_FORMAT_SELECT_MATCH) {
char *p = (char *)(store_msg);
p += base_descriptor->fields[i].offset;
if (*(char **)p != NULL) {
free(*(char **)p);
}
}
}
}
}
} /* lbmmon_store_free_msg_filter_option_strings */
/* lbmmon_store_init_filter_options - initialize the set of messages to hold filter options settings for the designated store */
void lbmmon_store_init_filter_options(store_filter_t *store_filter_options) {
STORE_FILTER_OPTIONS_INIT(store_filter_options, configs, configs, Lbmmon__UMPMonMsg__Configs);
STORE_FILTER_OPTIONS_INIT(store_filter_options, pattern_config, configs__pattern_config, Lbmmon__UMPMonMsg__Configs__PatternConfig);
STORE_FILTER_OPTIONS_INIT(store_filter_options, topic_config, configs__topic_config, Lbmmon__UMPMonMsg__Configs__TopicConfig);
STORE_FILTER_OPTIONS_INIT(store_filter_options, repo_config, configs__topic_config__repo_config, Lbmmon__UMPMonMsg__Configs__TopicConfig__RepoConfig);
STORE_FILTER_OPTIONS_INIT(store_filter_options, rcv_config, configs__topic_config__repo_config__rcv_config, Lbmmon__UMPMonMsg__Configs__TopicConfig__RepoConfig__RcvConfig);
STORE_FILTER_OPTIONS_INIT(store_filter_options, stats, stats, Lbmmon__UMPMonMsg__Stats);
STORE_FILTER_OPTIONS_INIT(store_filter_options, smart_heap_stat, stats__smart_heap_stat, Lbmmon__UMPMonMsg__Stats__SmartHeapStat);
STORE_FILTER_OPTIONS_INIT(store_filter_options, src_repo_stat, stats__src_repo_stat, Lbmmon__UMPMonMsg__Stats__SrcRepoStat);
STORE_FILTER_OPTIONS_INIT(store_filter_options, src_disk_stat, stats__src_repo_stat__src_disk_stat, Lbmmon__UMPMonMsg__Stats__SrcRepoStat__SrcDiskStat);
STORE_FILTER_OPTIONS_INIT(store_filter_options, rcv_stat, stats__src_repo_stat__rcv_stat, Lbmmon__UMPMonMsg__Stats__SrcRepoStat__RcvStat);
} /* lbmmon_store_init_filter_options */
/* lbmmon_store_free_filter_options - free the set of messages that hold filter options settings for the designated store */
void lbmmon_store_free_filter_options(store_filter_t *store_filter_options) {
STORE_FREE_FILTER_OPTIONS(store_filter_options, configs);
STORE_FREE_FILTER_OPTIONS(store_filter_options, pattern_config);
STORE_FREE_FILTER_OPTIONS(store_filter_options, topic_config);
STORE_FREE_FILTER_OPTIONS(store_filter_options, repo_config);
STORE_FREE_FILTER_OPTIONS(store_filter_options, rcv_config);
STORE_FREE_FILTER_OPTIONS(store_filter_options, stats);
STORE_FREE_FILTER_OPTIONS(store_filter_options, smart_heap_stat);
STORE_FREE_FILTER_OPTIONS(store_filter_options, src_repo_stat);
STORE_FREE_FILTER_OPTIONS(store_filter_options, src_disk_stat);
STORE_FREE_FILTER_OPTIONS(store_filter_options, rcv_stat);
} /* lbmmon_store_free_filter_options */
/* lbmmon_list_field_names - list field names with the qualifier prefix */
int lbmmon_list_field_names(ProtobufCMessageDescriptor *msg_descriptor, char * default_filter_options_buffer, size_t default_filter_options_buffer_size) {
int field_idx;
char field_name_default[LBMMON_MAX_LEN];
for (field_idx = 0; field_idx < msg_descriptor->n_fields; ++field_idx) {
if (msg_descriptor->fields[field_idx].type != PROTOBUF_C_TYPE_MESSAGE) { /* skips "lbmmon." prefix leader */
snprintf(field_name_default, sizeof(field_name_default), "%s.%s=LBMMON_FORMAT_FILTER_OFF;\n", &msg_descriptor->name[7], msg_descriptor->fields[field_idx].name);
if ((strlen(default_filter_options_buffer) + strlen(field_name_default) + 1) > default_filter_options_buffer_size) {
snprintf(ErrorString, sizeof(ErrorString), "[lbmmon_list_field_names] Destination buffer too small. Buffer is %lu but need %lu.\n",
default_filter_options_buffer_size, strlen(default_filter_options_buffer) + strlen(field_name_default));
return (-1);
}
strncat(default_filter_options_buffer, field_name_default, default_filter_options_buffer_size);
}
else
if (lbmmon_list_field_names((ProtobufCMessageDescriptor *)msg_descriptor->fields[field_idx].descriptor, default_filter_options_buffer, default_filter_options_buffer_size) == -1) {
return (-1);
}
}
return 0;
}
int lbmmon_format_pb_default_store_filter_options(char * Destination, size_t Size)
{
char lbmmon_store_filter_options_prologue[] =
"\n"
"# Store filter option settings\n"
"# LBMMON_FORMAT_FILTER_OFF - include field in message(default)\n"
"# LBMMON_FORMAT_FILTER_ON - exclude field from message\n"
"# LBMMON_FORMAT_FILTER_EQ(numeric value) - exclude field from message when field == value\n"
"# LBMMON_FORMAT_FILTER_NE(numeric value) - exclude field from message field != value\n"
"# LBMMON_FORMAT_FILTER_LT(numeric value) - exclude field from message field < value\n"
"# LBMMON_FORMAT_FILTER_GT(numeric value) - exclude field from message field > value\n"
"# LBMMON_FORMAT_SELECT_EQ(numeric value) - send message when field == value\n"
"# LBMMON_FORMAT_SELECT_NE(numeric value) - send message when field != value\n"
"# LBMMON_FORMAT_SELECT_LT(numeric value) - send message when field < value\n"
"# LBMMON_FORMAT_SELECT_GT(numeric value) - send message when field > value\n"
"# LBMMON_FORMAT_SELECT_MATCH(string) - send message with an exact string match\n"
"# LBMMON_FORMAT_SELECT_MATCH_REGX(regx string) - send message with a regular expression string match\n"
"#\n"
"# Store default filter options\n"
;
store_filter_t *store_filter_options;
LBM_MALLOC(store_filter_options, sizeof(store_filter_t));
memset(store_filter_options, 0, sizeof(store_filter_t));
lbmmon_store_init_filter_options(store_filter_options);
if ((strlen(Destination) + strlen(lbmmon_store_filter_options_prologue) + 1) > Size) {
snprintf(ErrorString, sizeof(ErrorString), "[lbmmon_format_pb_default_store_filter_options] Destination buffer too small. Buffer is %lu but need %lu.\n",
Size, strlen(Destination) + strlen(lbmmon_store_filter_options_prologue));
return (-1);
}
strcat(Destination, lbmmon_store_filter_options_prologue);
if (lbmmon_list_field_names((ProtobufCMessageDescriptor *)store_filter_options->configs->base.descriptor, Destination, Size - 1) != 0) {
return -1;
}
if (lbmmon_list_field_names((ProtobufCMessageDescriptor *)store_filter_options->stats->base.descriptor, Destination, Size - 1) != 0) {
return -1;
}
lbmmon_store_free_filter_options(store_filter_options);
free(store_filter_options);
return 0;
}
char * lbmmon_store_format_pb_filter_options(const char * FormatOptions)
{
char key[LBMMON_MAX_LEN];
char value[LBMMON_MAX_LEN];
const char * ptr = (const char *)FormatOptions;
char * store_filters = NULL;
int store_filter_size = 0;
const ProtobufCMessageDescriptor *store_descriptor = &lbmmon__umpmon_msg__descriptor;
while ((ptr = lbmmon_next_key_value_pair(ptr, key, sizeof(key), value, sizeof(value))) != NULL)
{
if (strcasecmp(key, "filters") == 0)
{
char format_options_file[LBMMON_MAX_LEN];
char * FormatOptionsBuffer;
char * tmp_buf;
strncpy(format_options_file, value, sizeof(format_options_file));
if (lbmaux_lbmmon_format_options_from_file(&FormatOptionsBuffer, format_options_file, ErrorString) != 0) {
if (store_filters != NULL) {
free(store_filters);
}
return NULL;
}
tmp_buf = lbmmon_store_format_pb_filter_options((const char *)FormatOptionsBuffer);
if (tmp_buf != NULL) {
if (store_filters == NULL) {
store_filter_size = strlen(tmp_buf + 1) * 2;
store_filters = malloc(store_filter_size);
if (store_filters == NULL)
{
lbmmon_format_pb_report_allocation_error(store_filter_size);
return NULL;
}
strncpy(store_filters, tmp_buf, store_filter_size);
} else {
if ((strlen(tmp_buf) + strlen(store_filters)) > store_filter_size) {
char * new_buf;
store_filter_size = (strlen(tmp_buf) + strlen(store_filters)) * 2;
new_buf = malloc(store_filter_size);
if (new_buf == NULL)
{
lbmmon_format_pb_report_allocation_error(store_filter_size);
return NULL;
}
strncpy(new_buf, store_filters, store_filter_size);
free(store_filters);
store_filters = new_buf;
}
strncat(store_filters, tmp_buf, sizeof(store_filter_size) - strlen(store_filters) - 1);
}
free(tmp_buf);
}
free(FormatOptionsBuffer);
}
else if (strncasecmp(key, store_descriptor->short_name, strlen(store_descriptor->short_name)) == 0){
if (store_filters == NULL) {
store_filter_size = 1000 * LBM_CONFIG_MAX_LINE_LEN;
store_filters = malloc(store_filter_size);
if (store_filters == NULL)
{
lbmmon_format_pb_report_allocation_error(store_filter_size);
return NULL;
}
memset(store_filters, 0, store_filter_size);
}
if (strlen(store_filters) + LBM_CONFIG_MAX_LINE_LEN >= store_filter_size)
{
char * new_buf;
store_filter_size *= 2;
new_buf = malloc(store_filter_size);
if (new_buf == NULL)
{
lbmmon_format_pb_report_allocation_error(store_filter_size);
return NULL;
}
strncpy(new_buf, store_filters, store_filter_size);
free(store_filters);
store_filters = new_buf;
}
snprintf(store_filters + strlen(store_filters), store_filter_size, "%s=%s;", key, value);
}
}
return store_filters;
}
void lbmmon_attributes_format_pb_serialize(Lbmmon__UMMonAttributes *AttributeBlock, const lbmmon_packet_attributes_t * Attributes)
{
struct in_addr addr;
addr.s_addr = Attributes->mAddress;
AttributeBlock->sender_ipv4_address = inet_ntoa(addr);
AttributeBlock->timestamp = time(NULL);
if ((Attributes->mFlags & PACKET_ATTRIBUTES_FLAG_APPSOURCE_ID) != 0) {
AttributeBlock->application_id = (char *)&Attributes->mApplicationSourceID;
}
/* Move in the object (context) ID. It's a pointer, but we treat it as an integer. */
AttributeBlock->object_id = (uint64_t)Attributes->mObjectID;
AttributeBlock->process_id = Attributes->mProcessID;
AttributeBlock->domain_id = Attributes->mDomainID;
if ((Attributes->mFlags & PACKET_ATTRIBUTES_FLAG_CTXINST) != 0) {
AttributeBlock->context_instance.data = (lbm_uint8_t *)Attributes->mContextInstance;
AttributeBlock->context_instance.len = LBM_CONTEXT_INSTANCE_BLOCK_SZ;
}
}
int lbmmon_rcv_format_pb_serialize(char * Destination, size_t * Size, unsigned short * ModuleID,
const lbmmon_packet_attributes_t * Attributes, const lbm_rcv_transport_stats_t * Statistics, void * FormatClientData)
{
lbmmon_format_pb_t * fmt = (lbmmon_format_pb_t *)FormatClientData;
Lbmmon__UMSMonMsg lbmmon_msg = LBMMON__UMSMON_MSG__INIT;
Lbmmon__UMSMonMsg__Stats lbmmon_msg_stats = LBMMON__UMSMON_MSG__STATS__INIT;
Lbmmon__UMSMonMsg__Stats__ReceiverTransport msg = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__INIT;
Lbmmon__UMMonAttributes attributes = LBMMON__UMMON_ATTRIBUTES__INIT;
Lbmmon__UMSMonMsg__Stats__ReceiverTransport__TCP tcp = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TCP__INIT;
Lbmmon__UMSMonMsg__Stats__ReceiverTransport__LBTRM lbtrm = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__LBTRM__INIT;
Lbmmon__UMSMonMsg__Stats__ReceiverTransport__LBTRU lbtru = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__LBTRU__INIT;
Lbmmon__UMSMonMsg__Stats__ReceiverTransport__LBTIPC lbtipc = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__LBTIPC__INIT;
Lbmmon__UMSMonMsg__Stats__ReceiverTransport__LBTSMX lbtsmx = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__LBTSMX__INIT;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__TCP filter_tcp = fmt->mRcvTcpFilter;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__LBTRM filter_lbtrm = fmt->mRcvLbtrmFilter;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__LBTRU filter_lbtru = fmt->mRcvLbtruFilter;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__LBTIPC filter_lbtipc = fmt->mRcvLbtipcFilter;
Lbmmon_Filter__UMSMonMsg__Stats__ReceiverTransport__LBTSMX filter_lbtsmx = fmt->mRcvLbtsmxFilter;
if ((Destination == NULL) || (Size == NULL) || (*Size == 0) || (Statistics == NULL))
{
return (-1);
}
*ModuleID = MAKE_MODULE_VERSION(LBMMON_FORMAT_PB_MODULE_ID, LBMMON_FORMAT_PB_VERSION_CURRENT);
lbmmon_attributes_format_pb_serialize(&attributes, Attributes);
lbmmon_msg.attributes = &attributes;
lbmmon_msg.stats = &lbmmon_msg_stats;
lbmmon_msg_stats.n_receiver_transports = 1;
lbmmon_msg_stats.receiver_transports = &msg_ptr;
msg.source_string = (char *)Statistics->source;
msg.source_flag = Attributes->mSourceFlag;
switch (Statistics->type)
{
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_TCP;
LBMMON_UINT64_SET(filter_tcp, tcp, Statistics->transport.tcp, bytes_rcved);
LBMMON_UINT64_SET(filter_tcp, tcp, Statistics->transport.tcp, lbm_msgs_rcved);
LBMMON_UINT64_SET(filter_tcp, tcp, Statistics->transport.tcp, lbm_msgs_no_topic_rcved);
LBMMON_UINT64_SET(filter_tcp, tcp, Statistics->transport.tcp, lbm_reqs_rcved);
msg.tcp = &tcp;
break;
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTRM;
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, msgs_rcved);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, bytes_rcved);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, nak_pckts_sent);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, naks_sent);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, lost);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, ncfs_ignored);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, ncfs_shed);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, ncfs_rx_delay);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, ncfs_unknown);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, nak_stm_min);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, nak_stm_mean);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, nak_stm_max);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, nak_tx_min);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, nak_tx_mean);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, nak_tx_max);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, duplicate_data);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, unrecovered_txw);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, unrecovered_tmo);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, lbm_msgs_rcved);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, lbm_msgs_no_topic_rcved);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, lbm_reqs_rcved);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, dgrams_dropped_size);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, dgrams_dropped_type);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, dgrams_dropped_version);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, dgrams_dropped_hdr);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, dgrams_dropped_other);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, out_of_order);
msg.lbtrm = &lbtrm;
break;
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTRU;
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, msgs_rcved);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, bytes_rcved);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, nak_pckts_sent);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, naks_sent);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, lost);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, ncfs_ignored);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, ncfs_shed);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, ncfs_rx_delay);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, ncfs_unknown);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, nak_stm_min);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, nak_stm_mean);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, nak_stm_max);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, nak_tx_min);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, nak_tx_mean);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, nak_tx_max);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, duplicate_data);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, unrecovered_txw);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, unrecovered_tmo);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, lbm_msgs_rcved);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, lbm_msgs_no_topic_rcved);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, lbm_reqs_rcved);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, dgrams_dropped_size);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, dgrams_dropped_type);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, dgrams_dropped_version);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, dgrams_dropped_hdr);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, dgrams_dropped_other);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, dgrams_dropped_sid);
msg.lbtru = &lbtru;
break;
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTIPC;
LBMMON_UINT64_SET(filter_lbtipc, lbtipc, Statistics->transport.lbtipc, msgs_rcved);
LBMMON_UINT64_SET(filter_lbtipc, lbtipc, Statistics->transport.lbtipc, bytes_rcved);
LBMMON_UINT64_SET(filter_lbtipc, lbtipc, Statistics->transport.lbtipc, lbm_msgs_rcved);
LBMMON_UINT64_SET(filter_lbtipc, lbtipc, Statistics->transport.lbtipc, lbm_msgs_no_topic_rcved);
LBMMON_UINT64_SET(filter_lbtipc, lbtipc, Statistics->transport.lbtipc, lbm_reqs_rcved);
msg.lbtipc = &lbtipc;
break;
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTSMX;
LBMMON_UINT64_SET(filter_lbtsmx, lbtsmx, Statistics->transport.lbtsmx, msgs_rcved);
LBMMON_UINT64_SET(filter_lbtsmx, lbtsmx, Statistics->transport.lbtsmx, bytes_rcved);
LBMMON_UINT64_SET(filter_lbtsmx, lbtsmx, Statistics->transport.lbtsmx, lbm_msgs_rcved);
LBMMON_UINT64_SET(filter_lbtsmx, lbtsmx, Statistics->transport.lbtsmx, lbm_msgs_no_topic_rcved);
msg.lbtsmx = &lbtsmx;
break;
default:
strncpy(ErrorString, "Unknown LBM transport type", sizeof(ErrorString));
return (-1);
}
*Size = lbmmon__umsmon_msg__get_packed_size(&lbmmon_msg);
lbmmon__umsmon_msg__pack(&lbmmon_msg, (lbm_uint8_t *)Destination);
return (0);
}
int lbmmon_src_format_pb_serialize(char * Destination, size_t * Size, unsigned short * ModuleID,
const lbmmon_packet_attributes_t * Attributes, const lbm_src_transport_stats_t * Statistics, void * FormatClientData)
{
lbmmon_format_pb_t * fmt = (lbmmon_format_pb_t *)FormatClientData;
Lbmmon__UMSMonMsg lbmmon_msg = LBMMON__UMSMON_MSG__INIT;
Lbmmon__UMSMonMsg__Stats lbmmon_msg_stats = LBMMON__UMSMON_MSG__STATS__INIT;
Lbmmon__UMSMonMsg__Stats__SourceTransport msg = LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__INIT;
Lbmmon__UMMonAttributes attributes = LBMMON__UMMON_ATTRIBUTES__INIT;
Lbmmon__UMSMonMsg__Stats__SourceTransport__TCP tcp = LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__TCP__INIT;
Lbmmon__UMSMonMsg__Stats__SourceTransport__LBTRM lbtrm = LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__LBTRM__INIT;
Lbmmon__UMSMonMsg__Stats__SourceTransport__LBTRU lbtru = LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__LBTRU__INIT;
Lbmmon__UMSMonMsg__Stats__SourceTransport__LBTIPC lbtipc = LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__LBTIPC__INIT;
Lbmmon__UMSMonMsg__Stats__SourceTransport__LBTSMX lbtsmx = LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__LBTSMX__INIT;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__TCP filter_tcp = fmt->mSrcTcpFilter;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__LBTRM filter_lbtrm = fmt->mSrcLbtrmFilter;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__LBTRU filter_lbtru = fmt->mSrcLbtruFilter;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__LBTIPC filter_lbtipc = fmt->mSrcLbtipcFilter;
Lbmmon_Filter__UMSMonMsg__Stats__SourceTransport__LBTSMX filter_lbtsmx = fmt->mSrcLbtsmxFilter;
if ((Destination == NULL) || (Size == NULL) || (*Size == 0) || (Statistics == NULL))
{
return (-1);
}
*ModuleID = MAKE_MODULE_VERSION(LBMMON_FORMAT_PB_MODULE_ID,LBMMON_FORMAT_PB_VERSION_CURRENT);
lbmmon_attributes_format_pb_serialize(&attributes, Attributes);
lbmmon_msg.attributes = &attributes;
lbmmon_msg.stats = &lbmmon_msg_stats;
lbmmon_msg_stats.n_source_transports = 1;
lbmmon_msg_stats.source_transports = &msg_ptr;
msg.source_string = (char *)Statistics->source;
msg.source_flag = Attributes->mSourceFlag;
switch (Statistics->type)
{
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__TRANSPORT_TYPE_TCP;
LBMMON_UINT64_SET(filter_tcp, tcp, Statistics->transport.tcp, num_clients);
LBMMON_UINT64_SET(filter_tcp, tcp, Statistics->transport.tcp, bytes_buffered);
msg.tcp = &tcp;
break;
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__TRANSPORT_TYPE_LBTRM;
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, msgs_sent);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, bytes_sent);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, txw_msgs);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, txw_bytes);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, nak_pckts_rcved);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, naks_rcved);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, naks_ignored);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, naks_shed);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, naks_rx_delay_ignored);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, rxs_sent);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, rctlr_data_msgs);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, rctlr_rx_msgs);
LBMMON_UINT64_SET(filter_lbtrm, lbtrm, Statistics->transport.lbtrm, rx_bytes_sent);
msg.lbtrm = &lbtrm;
break;
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__TRANSPORT_TYPE_LBTRU;
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, msgs_sent);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, bytes_sent);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, nak_pckts_rcved);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, naks_rcved);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, naks_ignored);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, naks_shed);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, naks_rx_delay_ignored);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, rxs_sent);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, num_clients);
LBMMON_UINT64_SET(filter_lbtru, lbtru, Statistics->transport.lbtru, rx_bytes_sent);
msg.lbtru = &lbtru;
break;
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTIPC;
LBMMON_UINT64_SET(filter_lbtipc, lbtipc, Statistics->transport.lbtipc, num_clients);
LBMMON_UINT64_SET(filter_lbtipc, lbtipc, Statistics->transport.lbtipc, msgs_sent);
LBMMON_UINT64_SET(filter_lbtipc, lbtipc, Statistics->transport.lbtipc, bytes_sent);
msg.lbtipc = &lbtipc;
break;
msg.transport_type_case = LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTSMX;
LBMMON_UINT64_SET(filter_lbtsmx, lbtsmx, Statistics->transport.lbtsmx, num_clients);
LBMMON_UINT64_SET(filter_lbtsmx, lbtsmx, Statistics->transport.lbtsmx, msgs_sent);
LBMMON_UINT64_SET(filter_lbtsmx, lbtsmx, Statistics->transport.lbtsmx, bytes_sent);
msg.lbtsmx = &lbtsmx;
break;
default:
strncpy(ErrorString, "Unknown LBM transport type", sizeof(ErrorString));
return (-1);
}
*Size = lbmmon__umsmon_msg__get_packed_size(&lbmmon_msg);
lbmmon__umsmon_msg__pack(&lbmmon_msg, (lbm_uint8_t *)Destination);
return (0);
}
int lbmmon_evq_format_pb_serialize(char * Destination, size_t * Size, unsigned short * ModuleID,
const lbmmon_packet_attributes_t * Attributes, const lbm_event_queue_stats_t * Statistics, void * FormatClientData)
{
lbmmon_format_pb_t * fmt = (lbmmon_format_pb_t *)FormatClientData;
Lbmmon__UMSMonMsg lbmmon_msg = LBMMON__UMSMON_MSG__INIT;
Lbmmon__UMSMonMsg__Stats lbmmon_msg_stats = LBMMON__UMSMON_MSG__STATS__INIT;
Lbmmon__UMSMonMsg__Stats__EventQueue msg = LBMMON__UMSMON_MSG__STATS__EVENT_QUEUE__INIT;
Lbmmon_Filter__UMSMonMsg__Stats__EventQueue filter_msg = fmt->mEventQueueFilter;
Lbmmon__UMMonAttributes attributes = LBMMON__UMMON_ATTRIBUTES__INIT;
if ((Destination == NULL) || (Size == NULL) || (*Size == 0) || (Statistics == NULL))
{
return (-1);
}
*ModuleID = MAKE_MODULE_VERSION(LBMMON_FORMAT_PB_MODULE_ID,LBMMON_FORMAT_PB_VERSION_CURRENT);
lbmmon_attributes_format_pb_serialize(&attributes, Attributes);
lbmmon_msg.attributes = &attributes;
lbmmon_msg.stats = &lbmmon_msg_stats;
lbmmon_msg_stats.n_event_queues = 1;
lbmmon_msg_stats.event_queues = &msg_ptr;
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), data_msgs);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), data_msgs_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), data_msgs_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), data_msgs_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), data_msgs_svc_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), resp_msgs);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), resp_msgs_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), resp_msgs_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), resp_msgs_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), resp_msgs_svc_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), topicless_im_msgs);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), topicless_im_msgs_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), topicless_im_msgs_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), topicless_im_msgs_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), topicless_im_msgs_svc_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), wrcv_msgs);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), wrcv_msgs_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), wrcv_msgs_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), wrcv_msgs_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), wrcv_msgs_svc_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), io_events);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), io_events_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), io_events_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), io_events_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), io_events_svc_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), timer_events);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), timer_events_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), timer_events_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), timer_events_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), timer_events_svc_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), source_events);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), source_events_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), source_events_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), source_events_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), source_events_svc_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), unblock_events);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), unblock_events_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), cancel_events);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), cancel_events_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), cancel_events_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), cancel_events_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), cancel_events_svc_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), context_source_events);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), context_source_events_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), context_source_events_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), context_source_events_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), context_source_events_svc_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), events);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), events_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), age_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), age_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), age_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), callback_events);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), callback_events_tot);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), callback_events_svc_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), callback_events_svc_mean);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), callback_events_svc_max);
*Size = lbmmon__umsmon_msg__get_packed_size(&lbmmon_msg);
lbmmon__umsmon_msg__pack(&lbmmon_msg, (lbm_uint8_t *)Destination);
return (0);
}
int lbmmon_ctx_format_pb_serialize(char * Destination, size_t * Size, unsigned short * ModuleID,
const lbmmon_packet_attributes_t * Attributes, const lbm_context_stats_t * Statistics, void * FormatClientData)
{
lbmmon_format_pb_t * fmt = (lbmmon_format_pb_t *)FormatClientData;
Lbmmon__UMSMonMsg lbmmon_msg = LBMMON__UMSMON_MSG__INIT;
Lbmmon__UMSMonMsg__Stats lbmmon_msg_stats = LBMMON__UMSMON_MSG__STATS__INIT;
Lbmmon__UMSMonMsg__Stats__Context msg = LBMMON__UMSMON_MSG__STATS__CONTEXT__INIT;
Lbmmon_Filter__UMSMonMsg__Stats__Context filter_msg = fmt->mContextFilter;
Lbmmon__UMMonAttributes attributes = LBMMON__UMMON_ATTRIBUTES__INIT;
if ((Destination == NULL) || (Size == NULL) || (*Size == 0) || (Statistics == NULL))
{
return (-1);
}
*ModuleID = MAKE_MODULE_VERSION(LBMMON_FORMAT_PB_MODULE_ID, LBMMON_FORMAT_PB_VERSION_CURRENT);
lbmmon_attributes_format_pb_serialize(&attributes, Attributes);
lbmmon_msg.attributes = &attributes;
lbmmon_msg.stats = &lbmmon_msg_stats;
lbmmon_msg_stats.context = &msg;
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_dgrams_sent);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_bytes_sent);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_dgrams_rcved);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_bytes_rcved);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_dgrams_dropped_ver);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_dgrams_dropped_type);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_dgrams_dropped_malformed);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_dgrams_send_failed);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_src_topics);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_rcv_topics);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), tr_rcv_unresolved_topics);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), lbtrm_unknown_msgs_rcved);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), lbtru_unknown_msgs_rcved);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), send_blocked);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), send_would_block);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), resp_blocked);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), resp_would_block);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), uim_dup_msgs_rcved);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), uim_msgs_no_stream_rcved);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), fragments_lost);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), fragments_unrecoverably_lost);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), rcv_cb_svc_time_min);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), rcv_cb_svc_time_max);
LBMMON_UINT64_SET(filter_msg, msg, (*Statistics), rcv_cb_svc_time_mean);
*Size = lbmmon__umsmon_msg__get_packed_size(&lbmmon_msg);
lbmmon__umsmon_msg__pack(&lbmmon_msg, (lbm_uint8_t *)Destination);
return (0);
}
int lbmmon_rcv_topic_format_pb_serialize(char * Destination, size_t * Size, unsigned short * ModuleID,
const lbmmon_packet_attributes_t * Attributes, const char * Topic, lbm_ulong_t SourceCount,
const lbm_rcv_topic_stats_t * Sources, void * FormatClientData)
{
Lbmmon__UMSMonMsg lbmmon_msg = LBMMON__UMSMON_MSG__INIT;
Lbmmon__UMSMonMsg__Events lbmmon_msg_events = LBMMON__UMSMON_MSG__EVENTS__INIT;
Lbmmon__UMSMonMsg__Events__ReceiverTopic msg = LBMMON__UMSMON_MSG__EVENTS__RECEIVER_TOPIC__INIT;
Lbmmon__UMMonAttributes attributes = LBMMON__UMMON_ATTRIBUTES__INIT;
char **otid_strings = NULL;
int idx;
size_t packed_size;
if ((Destination == NULL) || (Size == NULL) || (*Size == 0))
{
return (-1);
}
*ModuleID = MAKE_MODULE_VERSION(LBMMON_FORMAT_PB_MODULE_ID,LBMMON_FORMAT_PB_VERSION_CURRENT);
lbmmon_attributes_format_pb_serialize(&attributes, Attributes);
lbmmon_msg.attributes = &attributes;
lbmmon_msg.events = &lbmmon_msg_events;
lbmmon_msg_events.n_receiver_topics = 1;
lbmmon_msg_events.receiver_topics = &msg_ptr;
msg.topic = (char *)Topic;
if (SourceCount > 0)
{
sources = malloc(sizeof(Lbmmon__UMSMonMsg__Events__ReceiverTopic__Source *) * SourceCount);
if (sources == NULL)
{
lbmmon_format_pb_report_allocation_error(sizeof(Lbmmon__UMSMonMsg__Events__ReceiverTopic__Source *) * SourceCount);
return (-1);
}
otid_strings = malloc(sizeof(char *) * SourceCount);
if (otid_strings == NULL)
{
lbmmon_format_pb_report_allocation_error(sizeof(char *) * SourceCount);
free(sources);
return (-1);
}
for (idx = 0; idx < SourceCount; ++idx)
{
sources[idx] = malloc(sizeof(Lbmmon__UMSMonMsg__Events__ReceiverTopic__Source));
if (sources[idx] == NULL)
{
lbmmon_format_pb_report_allocation_error(sizeof(Lbmmon__UMSMonMsg__Events__ReceiverTopic__Source));
free(otid_strings);
free(sources);
return (-1);
}
lbmmon__umsmon_msg__events__receiver_topic__source__init(sources[idx]);
sources[idx]->source_string = (char *)Sources[idx].source;
otid_strings[idx] = malloc((LBM_OTID_BLOCK_SZ * 2) + 1);
if (otid_strings[idx] == NULL)
{
lbmmon_format_pb_report_allocation_error(LBM_OTID_BLOCK_SZ);
free(sources);
free(otid_strings);
return (-1);
}
strcpy(otid_strings[idx], (char *)mul_hexdump((const char *)Sources[idx].otid, LBM_OTID_BLOCK_SZ));
sources[idx]->otid = otid_strings[idx];
sources[idx]->topic_idx = Sources[idx].topic_idx;
sources[idx]->source_state = Sources[idx].flags;
sources[idx]->timestamp_sec = Sources[idx].timestamp_sec;
sources[idx]->timestamp_usec = Sources[idx].timestamp_usec;
}
msg.n_sources = SourceCount;
msg.sources = sources;
}
packed_size = lbmmon__umsmon_msg__get_packed_size(&lbmmon_msg);
if (packed_size > *Size) {
snprintf(ErrorString, sizeof(ErrorString), "[LBMMON] Unable to send monitoring message that is larger than the maximum allowed size of %lu (size=%lu).\n",
*Size, packed_size);
return (-1);
}
*Size = packed_size;
lbmmon__umsmon_msg__pack(&lbmmon_msg, (lbm_uint8_t *)Destination);
for (idx = 0; idx < SourceCount; ++idx)
{
free(sources[idx]);
free(otid_strings[idx]);
}
free(sources);
free(otid_strings);
return (0);
}
int lbmmon_wildcard_rcv_format_pb_serialize(char * Destination, size_t * Size, unsigned short * ModuleID,
const lbmmon_packet_attributes_t * Attributes, const lbm_wildcard_rcv_stats_t * Statistics, void * FormatClientData)
{
Lbmmon__UMSMonMsg lbmmon_msg = LBMMON__UMSMON_MSG__INIT;
Lbmmon__UMSMonMsg__Events lbmmon_msg_events = LBMMON__UMSMON_MSG__EVENTS__INIT;
Lbmmon__UMSMonMsg__Events__WildcardReceiver msg = LBMMON__UMSMON_MSG__EVENTS__WILDCARD_RECEIVER__INIT;
Lbmmon__UMMonAttributes attributes = LBMMON__UMMON_ATTRIBUTES__INIT;
size_t packed_size;
if ((Destination == NULL) || (Size == NULL) || (*Size == 0) || (Statistics == NULL))
{
return (-1);
}
*ModuleID = MAKE_MODULE_VERSION(LBMMON_FORMAT_PB_MODULE_ID,LBMMON_FORMAT_PB_VERSION_CURRENT);
lbmmon_attributes_format_pb_serialize(&attributes, Attributes);
lbmmon_msg.attributes = &attributes;
lbmmon_msg.events = &lbmmon_msg_events;
lbmmon_msg_events.n_wildcard_receivers = 1;
lbmmon_msg_events.wildcard_receivers = &msg_ptr;
msg.pattern = (char *)Statistics->pattern;
msg.type = Statistics->type;
packed_size = lbmmon__umsmon_msg__get_packed_size(&lbmmon_msg);
if (packed_size > *Size) {
snprintf(ErrorString, sizeof(ErrorString), "[LBMMON] Unable to send monitoring message that is larger than the maximum allowed size of %lu (size=%lu).\n",
*Size, packed_size);
return (-1);
}
*Size = packed_size;
lbmmon__umsmon_msg__pack(&lbmmon_msg, (lbm_uint8_t *)Destination);
return (0);
}
int lbmmon_store_format_pb_serialize(char * Destination, size_t * Size, unsigned short * ModuleID,
const lbmmon_packet_attributes_t * Attributes, Lbmmon__UMPMonMsg * StoreMsg, int Action, void * FormatClientData)
{
Lbmmon__UMMonAttributes attributes = LBMMON__UMMON_ATTRIBUTES__INIT;
size_t packed_size;
if ((Size == NULL) || (StoreMsg == NULL) || (((Destination == NULL) || (*Size == 0)) && (Action == LBMMON_SERIALIZE_PACK_MESSAGE)))
{
return (-1);
}
*ModuleID = MAKE_MODULE_VERSION(LBMMON_FORMAT_PB_MODULE_ID,LBMMON_FORMAT_PB_VERSION_CURRENT);
lbmmon_attributes_format_pb_serialize(&attributes, Attributes);
StoreMsg->attributes = &attributes;
packed_size = lbmmon__umpmon_msg__get_packed_size(StoreMsg);
*Size = packed_size;
return (0);
}
if (packed_size > *Size) {
snprintf(ErrorString, sizeof(ErrorString), "[LBMMON] Unable to send monitoring message for store \"%s\" that is larger than the maximum allowed size of %lu (size=%lu).\n",
attributes.application_id, *Size, packed_size);
return (-1);
}
*Size = packed_size;
lbmmon__umpmon_msg__pack(StoreMsg, (lbm_uint8_t *)Destination);
return (0);
}
int lbmmon_gateway_format_pb_serialize(char * Destination, size_t * Size, unsigned short * ModuleID,
const lbmmon_packet_attributes_t * Attributes, Lbmmon__DROMonMsg * GatewayMsg, void * FormatClientData)
{
Lbmmon__UMMonAttributes attributes = LBMMON__UMMON_ATTRIBUTES__INIT;
size_t packed_size;
if ((Destination == NULL) || (Size == NULL) || (*Size == 0) || (GatewayMsg == NULL))
{
return (-1);
}
*ModuleID = MAKE_MODULE_VERSION(LBMMON_FORMAT_PB_MODULE_ID, LBMMON_FORMAT_PB_VERSION_CURRENT);
lbmmon_attributes_format_pb_serialize(&attributes, Attributes);
GatewayMsg->attributes = &attributes;
packed_size = lbmmon__dromon_msg__get_packed_size(GatewayMsg);
if (packed_size > *Size) {
snprintf(ErrorString, sizeof(ErrorString), "[LBMMON] Unable to send monitoring message that is larger than the maximum allowed size of %lu (size=%lu).\n",
*Size, packed_size);
return (-1);
}
*Size = packed_size;
lbmmon__dromon_msg__pack(GatewayMsg, (lbm_uint8_t *)Destination);
return (0);
}
void lbmmon_attributes_format_pb_deserialize(lbmmon_packet_attributes_t * Attributes, Lbmmon__UMMonAttributes *attributes)
{
struct in_addr addr;
mul_inet_aton(attributes->sender_ipv4_address, &addr);
Attributes->mAddress = addr.s_addr;
Attributes->mTimestamp = attributes->timestamp;
strncpy(Attributes->mApplicationSourceID, attributes->application_id, sizeof(Attributes->mApplicationSourceID));
Attributes->mObjectID = attributes->object_id;
Attributes->mProcessID = attributes->process_id;
if (attributes->context_instance.len > 0){
memcpy(Attributes->mContextInstance, attributes->context_instance.data, LBM_CONTEXT_INSTANCE_BLOCK_SZ);
}
Attributes->mDomainID = attributes->domain_id;
}
int lbmmon_rcv_format_pb_deserialize(lbmmon_packet_attributes_t * Attributes, lbm_rcv_transport_stats_t * Statistics,
const char * Source, size_t Length, unsigned short ModuleID, void * FormatClientData)
{
unsigned char modid;
lbmmon_format_pb_t * format_options;
Lbmmon__UMSMonMsg *lbmmon_msg = NULL;
if ((Statistics == NULL) || (Source == NULL) || (*Source == '\0') || (Length == 0) || (FormatClientData == NULL))
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
modid = MODULE_ID(ModuleID);
{
snprintf(ErrorString, sizeof(ErrorString), "Invalid module ID %u", (unsigned)modid);
}
format_options = (lbmmon_format_pb_t *)FormatClientData;
if (format_options->mPassthrough == LBMMON_FORMAT_PASSTHROUGH_ON)
{
}
lbmmon_msg = lbmmon__umsmon_msg__unpack(NULL, Length, (lbm_uint8_t *)Source);
if ((lbmmon_msg == NULL) || (lbmmon_msg->attributes == NULL) || (lbmmon_msg->stats == NULL) ||
(lbmmon_msg->stats->receiver_transports == NULL) || (lbmmon_msg->stats->n_receiver_transports != 1))
{
snprintf(ErrorString, sizeof(ErrorString), "Error unpacking incoming receiver transport stats message\n");
}
lbmmon_attributes_format_pb_deserialize(Attributes, lbmmon_msg->attributes);
msg = *(lbmmon_msg->stats->receiver_transports);
Attributes->mSourceFlag = msg->source_flag;
strncpy(Statistics->source, msg->source_string, sizeof(Statistics->source));
switch (msg->transport_type_case)
{
case LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_TCP:
memset((void *)&(Statistics->transport.tcp), 0, sizeof(lbm_rcv_transport_stats_tcp_t));
tcp = msg->tcp;
Statistics->transport.tcp.bytes_rcved = tcp->bytes_rcved;
Statistics->transport.tcp.lbm_msgs_rcved = tcp->lbm_msgs_rcved;
Statistics->transport.tcp.lbm_msgs_no_topic_rcved = tcp->lbm_msgs_no_topic_rcved;
Statistics->transport.tcp.lbm_reqs_rcved = tcp->lbm_reqs_rcved;
break;
case LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTRM:
memset((void *)&(Statistics->transport.lbtrm), 0, sizeof(lbm_rcv_transport_stats_lbtrm_t));
lbtrm = msg->lbtrm;
Statistics->transport.lbtrm.msgs_rcved = lbtrm->msgs_rcved;
Statistics->transport.lbtrm.bytes_rcved = lbtrm->bytes_rcved;
Statistics->transport.lbtrm.nak_pckts_sent = lbtrm->nak_pckts_sent;
Statistics->transport.lbtrm.naks_sent = lbtrm->naks_sent;
Statistics->transport.lbtrm.lost = lbtrm->lost;
Statistics->transport.lbtrm.ncfs_ignored = lbtrm->ncfs_ignored;
Statistics->transport.lbtrm.ncfs_shed = lbtrm->ncfs_shed;
Statistics->transport.lbtrm.ncfs_rx_delay = lbtrm->ncfs_rx_delay;
Statistics->transport.lbtrm.ncfs_unknown = lbtrm->ncfs_unknown;
Statistics->transport.lbtrm.nak_stm_min = lbtrm->nak_stm_min;
Statistics->transport.lbtrm.nak_stm_mean = lbtrm->nak_stm_mean;
Statistics->transport.lbtrm.nak_stm_max = lbtrm->nak_stm_max;
Statistics->transport.lbtrm.nak_tx_min = lbtrm->nak_tx_min;
Statistics->transport.lbtrm.nak_tx_mean = lbtrm->nak_tx_mean;
Statistics->transport.lbtrm.nak_tx_max = lbtrm->nak_tx_max;
Statistics->transport.lbtrm.duplicate_data = lbtrm->duplicate_data;
Statistics->transport.lbtrm.unrecovered_txw = lbtrm->unrecovered_txw;
Statistics->transport.lbtrm.unrecovered_tmo = lbtrm->unrecovered_tmo;
Statistics->transport.lbtrm.lbm_msgs_rcved = lbtrm->lbm_msgs_rcved;
Statistics->transport.lbtrm.lbm_msgs_no_topic_rcved = lbtrm->lbm_msgs_no_topic_rcved;
Statistics->transport.lbtrm.lbm_reqs_rcved = lbtrm->lbm_reqs_rcved;
Statistics->transport.lbtrm.dgrams_dropped_size = lbtrm->dgrams_dropped_size;
Statistics->transport.lbtrm.dgrams_dropped_type = lbtrm->dgrams_dropped_type;
Statistics->transport.lbtrm.dgrams_dropped_version = lbtrm->dgrams_dropped_version;
Statistics->transport.lbtrm.dgrams_dropped_hdr = lbtrm->dgrams_dropped_hdr;
Statistics->transport.lbtrm.dgrams_dropped_other = lbtrm->dgrams_dropped_other;
Statistics->transport.lbtrm.out_of_order = lbtrm->out_of_order;
break;
case LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTRU:
memset((void *)&(Statistics->transport.lbtru), 0, sizeof(lbm_rcv_transport_stats_lbtru_t));
lbtru = msg->lbtru;
Statistics->transport.lbtru.msgs_rcved = lbtru->msgs_rcved;
Statistics->transport.lbtru.bytes_rcved = lbtru->bytes_rcved;
Statistics->transport.lbtru.nak_pckts_sent = lbtru->nak_pckts_sent;
Statistics->transport.lbtru.naks_sent = lbtru->naks_sent;
Statistics->transport.lbtru.lost = lbtru->lost;
Statistics->transport.lbtru.ncfs_ignored = lbtru->ncfs_ignored;
Statistics->transport.lbtru.ncfs_shed = lbtru->ncfs_shed;
Statistics->transport.lbtru.ncfs_rx_delay = lbtru->ncfs_rx_delay;
Statistics->transport.lbtru.ncfs_unknown = lbtru->ncfs_unknown;
Statistics->transport.lbtru.nak_stm_min = lbtru->nak_stm_min;
Statistics->transport.lbtru.nak_stm_mean = lbtru->nak_stm_mean;
Statistics->transport.lbtru.nak_stm_max = lbtru->nak_stm_max;
Statistics->transport.lbtru.nak_tx_min = lbtru->nak_tx_min;
Statistics->transport.lbtru.nak_tx_mean = lbtru->nak_tx_mean;
Statistics->transport.lbtru.nak_tx_max = lbtru->nak_tx_max;
Statistics->transport.lbtru.duplicate_data = lbtru->duplicate_data;
Statistics->transport.lbtru.unrecovered_txw = lbtru->unrecovered_txw;
Statistics->transport.lbtru.unrecovered_tmo = lbtru->unrecovered_tmo;
Statistics->transport.lbtru.lbm_msgs_rcved = lbtru->lbm_msgs_rcved;
Statistics->transport.lbtru.lbm_msgs_no_topic_rcved = lbtru->lbm_msgs_no_topic_rcved;
Statistics->transport.lbtru.lbm_reqs_rcved = lbtru->lbm_reqs_rcved;
Statistics->transport.lbtru.dgrams_dropped_size = lbtru->dgrams_dropped_size;
Statistics->transport.lbtru.dgrams_dropped_type = lbtru->dgrams_dropped_type;
Statistics->transport.lbtru.dgrams_dropped_version = lbtru->dgrams_dropped_version;
Statistics->transport.lbtru.dgrams_dropped_hdr = lbtru->dgrams_dropped_hdr;
Statistics->transport.lbtru.dgrams_dropped_other = lbtru->dgrams_dropped_other;
Statistics->transport.lbtru.dgrams_dropped_sid = lbtru->dgrams_dropped_sid;
break;
case LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTIPC:
memset((void *)&(Statistics->transport.lbtipc), 0, sizeof(lbm_rcv_transport_stats_lbtipc_t));
lbtipc = msg->lbtipc;
Statistics->transport.lbtipc.msgs_rcved = lbtipc->msgs_rcved;
Statistics->transport.lbtipc.bytes_rcved = lbtipc->bytes_rcved;
Statistics->transport.lbtipc.lbm_msgs_rcved = lbtipc->lbm_msgs_rcved;
Statistics->transport.lbtipc.lbm_msgs_no_topic_rcved = lbtipc->lbm_msgs_no_topic_rcved;
Statistics->transport.lbtipc.lbm_reqs_rcved = lbtipc->lbm_reqs_rcved;
break;
case LBMMON__UMSMON_MSG__STATS__RECEIVER_TRANSPORT__TRANSPORT_TYPE_LBTSMX:
memset((void *)&(Statistics->transport.lbtsmx), 0, sizeof(lbm_rcv_transport_stats_lbtsmx_t));
lbtsmx = msg->lbtsmx;
Statistics->transport.lbtsmx.msgs_rcved = lbtsmx->msgs_rcved;
Statistics->transport.lbtsmx.bytes_rcved = lbtsmx->bytes_rcved;
Statistics->transport.lbtsmx.lbm_msgs_rcved = lbtsmx->lbm_msgs_rcved;
Statistics->transport.lbtsmx.lbm_msgs_no_topic_rcved = lbtsmx->lbm_msgs_no_topic_rcved;
break;
default:
strncpy(ErrorString, "Invalid LBM transport type", sizeof(ErrorString));
}
lbmmon__umsmon_msg__free_unpacked(lbmmon_msg, NULL);
}
int lbmmon_src_format_pb_deserialize(lbmmon_packet_attributes_t * Attributes, lbm_src_transport_stats_t * Statistics,
const char * Source, size_t Length, unsigned short ModuleID, void * FormatClientData)
{
unsigned char modid;
lbmmon_format_pb_t * format_options;
Lbmmon__UMSMonMsg *lbmmon_msg = NULL;
if ((Statistics == NULL) || (Source == NULL) || (*Source == '\0') || (Length == 0) || (FormatClientData == NULL))
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
modid = MODULE_ID(ModuleID);
{
snprintf(ErrorString, sizeof(ErrorString), "Invalid module ID %u", (unsigned)modid);
}
format_options = (lbmmon_format_pb_t *)FormatClientData;
if (format_options->mPassthrough == LBMMON_FORMAT_PASSTHROUGH_ON)
{
}
lbmmon_msg = lbmmon__umsmon_msg__unpack(NULL, Length, (lbm_uint8_t *)Source);
if ((lbmmon_msg == NULL) || (lbmmon_msg->attributes == NULL) || (lbmmon_msg->stats == NULL) ||
(lbmmon_msg->stats->source_transports == NULL) || (lbmmon_msg->stats->n_source_transports != 1))
{
snprintf(ErrorString, sizeof(ErrorString), "Error unpacking incoming source transport stats message\n");
}
lbmmon_attributes_format_pb_deserialize(Attributes, lbmmon_msg->attributes);
msg = *(lbmmon_msg->stats->source_transports);
Attributes->mSourceFlag = msg->source_flag;
strncpy(Statistics->source, msg->source_string, sizeof(Statistics->source));
MUL_DEBUG(LBM_DEBUG_LBMMON, ("lbmmon_src_format_pb_deserialize (%s) (%d) (%d)\n", Statistics->source, msg->transport_type_case, Length));
switch (msg->transport_type_case)
{
case LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__TRANSPORT_TYPE_TCP:
memset((void *)&(Statistics->transport.tcp), 0, sizeof(lbm_src_transport_stats_tcp_t));
tcp = msg->tcp;
Statistics->transport.tcp.num_clients = tcp->num_clients;
Statistics->transport.tcp.bytes_buffered = tcp->bytes_buffered;
break;
case LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__TRANSPORT_TYPE_LBTRM:
memset((void *)&(Statistics->transport.lbtrm), 0, sizeof(lbm_src_transport_stats_lbtrm_t));
lbtrm = msg->lbtrm;
Statistics->transport.lbtrm.msgs_sent = msg->lbtrm->msgs_sent;
Statistics->transport.lbtrm.bytes_sent = lbtrm->bytes_sent;
Statistics->transport.lbtrm.txw_msgs = lbtrm->txw_msgs;
Statistics->transport.lbtrm.txw_bytes = lbtrm->txw_bytes;
Statistics->transport.lbtrm.nak_pckts_rcved = lbtrm->nak_pckts_rcved;
Statistics->transport.lbtrm.naks_rcved = lbtrm->naks_rcved;
Statistics->transport.lbtrm.naks_ignored = lbtrm->naks_ignored;
Statistics->transport.lbtrm.naks_shed = lbtrm->naks_shed;
Statistics->transport.lbtrm.naks_rx_delay_ignored = lbtrm->naks_rx_delay_ignored;
Statistics->transport.lbtrm.rxs_sent = lbtrm->rxs_sent;
Statistics->transport.lbtrm.rctlr_data_msgs = lbtrm->rctlr_data_msgs;
Statistics->transport.lbtrm.rctlr_rx_msgs = lbtrm->rctlr_rx_msgs;
Statistics->transport.lbtrm.rx_bytes_sent = lbtrm->rx_bytes_sent;
break;
case LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__TRANSPORT_TYPE_LBTRU:
memset((void *)&(Statistics->transport.lbtru), 0, sizeof(lbm_src_transport_stats_lbtru_t));
lbtru = msg->lbtru;
Statistics->transport.lbtru.msgs_sent = lbtru->msgs_sent;
Statistics->transport.lbtru.bytes_sent = lbtru->bytes_sent;
Statistics->transport.lbtru.nak_pckts_rcved = lbtru->nak_pckts_rcved;
Statistics->transport.lbtru.naks_rcved = lbtru->naks_rcved;
Statistics->transport.lbtru.naks_ignored = lbtru->naks_ignored;
Statistics->transport.lbtru.naks_shed = lbtru->naks_shed;
Statistics->transport.lbtru.naks_rx_delay_ignored = lbtru->naks_rx_delay_ignored;
Statistics->transport.lbtru.rxs_sent = lbtru->rxs_sent;
Statistics->transport.lbtru.num_clients = lbtru->num_clients;
Statistics->transport.lbtru.rx_bytes_sent = lbtru->rx_bytes_sent;
break;
case LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__TRANSPORT_TYPE_LBTIPC:
memset((void *)&(Statistics->transport.lbtipc), 0, sizeof(lbm_src_transport_stats_lbtipc_t));
lbtipc = msg->lbtipc;
Statistics->transport.lbtipc.num_clients = lbtipc->num_clients;
Statistics->transport.lbtipc.msgs_sent = lbtipc->msgs_sent;
Statistics->transport.lbtipc.bytes_sent = lbtipc->bytes_sent;
break;
case LBMMON__UMSMON_MSG__STATS__SOURCE_TRANSPORT__TRANSPORT_TYPE_LBTSMX:
memset((void *)&(Statistics->transport.lbtsmx), 0, sizeof(lbm_src_transport_stats_lbtsmx_t));
lbtsmx = msg->lbtsmx;
Statistics->transport.lbtsmx.num_clients = lbtsmx->num_clients;
Statistics->transport.lbtsmx.msgs_sent = lbtsmx->msgs_sent;
Statistics->transport.lbtsmx.bytes_sent = lbtsmx->bytes_sent;
break;
default:
strncpy(ErrorString, "Invalid LBM transport type", sizeof(ErrorString));
}
lbmmon__umsmon_msg__free_unpacked(lbmmon_msg, NULL);
}
int lbmmon_evq_format_pb_deserialize(lbmmon_packet_attributes_t * Attributes, lbm_event_queue_stats_t * Statistics,
const char * Source, size_t Length, unsigned short ModuleID, void * FormatClientData)
{
unsigned char modid;
lbmmon_format_pb_t * format_options;
Lbmmon__UMSMonMsg *lbmmon_msg = NULL;
if ((Statistics == NULL) || (Source == NULL) || (*Source == '\0') || (Length == 0) || (FormatClientData == NULL))
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
modid = MODULE_ID(ModuleID);
{
snprintf(ErrorString, sizeof(ErrorString), "Invalid module ID %u", (unsigned)modid);
}
format_options = (lbmmon_format_pb_t *)FormatClientData;
if (format_options->mPassthrough == LBMMON_FORMAT_PASSTHROUGH_ON)
{
}
lbmmon_msg = lbmmon__umsmon_msg__unpack(NULL, Length, (lbm_uint8_t *)Source);
if ((lbmmon_msg == NULL) || (lbmmon_msg->attributes == NULL) || (lbmmon_msg->stats == NULL) ||
(lbmmon_msg->stats->event_queues == NULL) || (lbmmon_msg->stats->n_event_queues != 1))
{
snprintf(ErrorString, sizeof(ErrorString), "Error unpacking incoming event queue stats message\n");
}
lbmmon_attributes_format_pb_deserialize(Attributes, lbmmon_msg->attributes);
msg = *(lbmmon_msg->stats->event_queues);
memset((void *)Statistics, 0, sizeof(lbm_event_queue_t));
Statistics->data_msgs = msg->data_msgs;
Statistics->data_msgs_tot = msg->data_msgs_tot;
Statistics->data_msgs_svc_min = msg->data_msgs_svc_min;
Statistics->data_msgs_svc_mean = msg->data_msgs_svc_mean;
Statistics->data_msgs_svc_max = msg->data_msgs_svc_max;
Statistics->resp_msgs = msg->resp_msgs;
Statistics->resp_msgs_tot = msg->resp_msgs_tot;
Statistics->resp_msgs_svc_min = msg->resp_msgs_svc_min;
Statistics->resp_msgs_svc_mean = msg->resp_msgs_svc_mean;
Statistics->resp_msgs_svc_max = msg->resp_msgs_svc_max;
Statistics->topicless_im_msgs = msg->topicless_im_msgs;
Statistics->topicless_im_msgs_tot = msg->topicless_im_msgs_tot;
Statistics->topicless_im_msgs_svc_min = msg->topicless_im_msgs_svc_min;
Statistics->topicless_im_msgs_svc_mean = msg->topicless_im_msgs_svc_mean;
Statistics->topicless_im_msgs_svc_max = msg->topicless_im_msgs_svc_max;
Statistics->wrcv_msgs = msg->wrcv_msgs;
Statistics->wrcv_msgs_tot = msg->wrcv_msgs_tot;
Statistics->wrcv_msgs_svc_min = msg->wrcv_msgs_svc_min;
Statistics->wrcv_msgs_svc_mean = msg->wrcv_msgs_svc_mean;
Statistics->wrcv_msgs_svc_max = msg->wrcv_msgs_svc_max;
Statistics->io_events = msg->io_events;
Statistics->io_events_tot = msg->io_events_tot;
Statistics->io_events_svc_min = msg->io_events_svc_min;
Statistics->io_events_svc_mean = msg->io_events_svc_mean;
Statistics->io_events_svc_max = msg->io_events_svc_max;
Statistics->timer_events = msg->timer_events;
Statistics->timer_events_tot = msg->timer_events_tot;
Statistics->timer_events_svc_min = msg->timer_events_svc_min;
Statistics->timer_events_svc_mean = msg->timer_events_svc_mean;
Statistics->timer_events_svc_max = msg->timer_events_svc_max;
Statistics->source_events = msg->source_events;
Statistics->source_events_tot = msg->source_events_tot;
Statistics->source_events_svc_min = msg->source_events_svc_min;
Statistics->source_events_svc_mean = msg->source_events_svc_mean;
Statistics->source_events_svc_max = msg->source_events_svc_max;
Statistics->unblock_events = msg->unblock_events;
Statistics->unblock_events_tot = msg->unblock_events_tot;
Statistics->cancel_events = msg->cancel_events;
Statistics->cancel_events_tot = msg->cancel_events_tot;
Statistics->cancel_events_svc_min = msg->cancel_events_svc_min;
Statistics->cancel_events_svc_mean = msg->cancel_events_svc_mean;
Statistics->cancel_events_svc_max = msg->cancel_events_svc_max;
Statistics->context_source_events = msg->context_source_events;
Statistics->context_source_events_tot = msg->context_source_events_tot;
Statistics->context_source_events_svc_min = msg->context_source_events_svc_min;
Statistics->context_source_events_svc_mean = msg->context_source_events_svc_mean;
Statistics->context_source_events_svc_max = msg->context_source_events_svc_max;
Statistics->events = msg->events;
Statistics->events_tot = msg->events_tot;
Statistics->age_min = msg->age_min;
Statistics->age_mean = msg->age_mean;
Statistics->age_max = msg->age_max;
Statistics->callback_events = msg->callback_events;
Statistics->callback_events_tot = msg->callback_events_tot;
Statistics->callback_events_svc_min = msg->callback_events_svc_min;
Statistics->callback_events_svc_mean = msg->callback_events_svc_mean;
Statistics->callback_events_svc_max = msg->callback_events_svc_max;
lbmmon__umsmon_msg__free_unpacked(lbmmon_msg, NULL);
}
int lbmmon_ctx_format_pb_deserialize(lbmmon_packet_attributes_t * Attributes, lbm_context_stats_t * Statistics,
const char * Source, size_t Length, unsigned short ModuleID, void * FormatClientData)
{
unsigned char modid;
lbmmon_format_pb_t * format_options;
Lbmmon__UMSMonMsg *lbmmon_msg = NULL;
if ((Statistics == NULL) || (Source == NULL) || (*Source == '\0') || (Length == 0) || (FormatClientData == NULL))
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
modid = MODULE_ID(ModuleID);
{
snprintf(ErrorString, sizeof(ErrorString), "Invalid module ID %u", (unsigned)modid);
}
format_options = (lbmmon_format_pb_t *)FormatClientData;
if (format_options->mPassthrough == LBMMON_FORMAT_PASSTHROUGH_ON)
{
}
lbmmon_msg = lbmmon__umsmon_msg__unpack(NULL, Length, (lbm_uint8_t *)Source);
if ((lbmmon_msg == NULL) || (lbmmon_msg->attributes == NULL) || (lbmmon_msg->stats == NULL) ||
(lbmmon_msg->stats->context == NULL))
{
snprintf(ErrorString, sizeof(ErrorString), "Error unpacking incoming context stats message\n");
}
lbmmon_attributes_format_pb_deserialize(Attributes, lbmmon_msg->attributes);
msg = lbmmon_msg->stats->context;
memset((void *)Statistics, 0, sizeof(lbm_context_stats_t));
Statistics->tr_dgrams_sent = msg->tr_dgrams_sent;
Statistics->tr_bytes_sent = msg->tr_bytes_sent;
Statistics->tr_dgrams_rcved = msg->tr_dgrams_rcved;
Statistics->tr_bytes_rcved = msg->tr_bytes_rcved;
Statistics->tr_dgrams_dropped_ver = msg->tr_dgrams_dropped_ver;
Statistics->tr_dgrams_dropped_type = msg->tr_dgrams_dropped_type;
Statistics->tr_dgrams_dropped_malformed = msg->tr_dgrams_dropped_malformed;
Statistics->tr_dgrams_send_failed = msg->tr_dgrams_send_failed;
Statistics->tr_src_topics = msg->tr_src_topics;
Statistics->tr_rcv_topics = msg->tr_rcv_topics;
Statistics->tr_rcv_unresolved_topics = msg->tr_rcv_unresolved_topics;
Statistics->lbtrm_unknown_msgs_rcved = msg->lbtrm_unknown_msgs_rcved;
Statistics->lbtru_unknown_msgs_rcved = msg->lbtru_unknown_msgs_rcved;
Statistics->send_blocked = msg->send_blocked;
Statistics->send_would_block = msg->send_would_block;
Statistics->resp_blocked = msg->resp_blocked;
Statistics->resp_would_block = msg->resp_would_block;
Statistics->uim_dup_msgs_rcved = msg->uim_dup_msgs_rcved;
Statistics->uim_msgs_no_stream_rcved = msg->uim_msgs_no_stream_rcved;
Statistics->fragments_lost = msg->fragments_lost;
Statistics->fragments_unrecoverably_lost = msg->fragments_unrecoverably_lost;
Statistics->rcv_cb_svc_time_min = msg->rcv_cb_svc_time_min;
Statistics->rcv_cb_svc_time_max = msg->rcv_cb_svc_time_max;
Statistics->rcv_cb_svc_time_mean = msg->rcv_cb_svc_time_mean;
lbmmon__umsmon_msg__free_unpacked(lbmmon_msg, NULL);
}
int lbmmon_rcv_topic_format_pb_deserialize(lbmmon_packet_attributes_t * Attributes, size_t * Count,
lbm_rcv_topic_stats_t * Statistics, const char * Source,
size_t Length, unsigned short ModuleID, void * FormatClientData)
{
unsigned char modid;
lbmmon_format_pb_t * format_options;
Lbmmon__UMSMonMsg *lbmmon_msg = NULL;
size_t idx;
char topic[LBM_MSG_MAX_TOPIC_LEN + 1];
size_t src_count;
if ((Count == NULL) || (*Count == 0) || (Statistics == NULL) || (Source == NULL) ||
(*Source == '\0') || (Length == 0) || (FormatClientData == NULL))
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
modid = MODULE_ID(ModuleID);
{
snprintf(ErrorString, sizeof(ErrorString), "Invalid module ID %u", (unsigned)modid);
}
format_options = (lbmmon_format_pb_t *)FormatClientData;
if (format_options->mPassthrough == LBMMON_FORMAT_PASSTHROUGH_ON)
{
}
lbmmon_msg = lbmmon__umsmon_msg__unpack(NULL, Length, (lbm_uint8_t *)Source);
if ((lbmmon_msg == NULL) || (lbmmon_msg->attributes == NULL) || (lbmmon_msg->events == NULL) ||
(lbmmon_msg->events->receiver_topics == NULL) || (lbmmon_msg->events->n_receiver_topics != 1))
{
snprintf(ErrorString, sizeof(ErrorString), "Error unpacking incoming receiver topic stats message\n");
}
lbmmon_attributes_format_pb_deserialize(Attributes, lbmmon_msg->attributes);
msg = *(lbmmon_msg->events->receiver_topics);
strncpy(topic, msg->topic, sizeof(topic));
src_count = msg->n_sources;
if (*Count < src_count)
{
/* Not enough entries. */
*Count = src_count;
}
if (src_count == 0)
{
memset((void *)&(Statistics[0]), 0, sizeof(lbm_rcv_topic_stats_t));
strncpy(Statistics[0].topic, topic, sizeof(Statistics[idx].topic));
src_count = 1;
} else {
for (idx = 0; idx < src_count; ++idx)
{
size_t count;
char * pos;
memset((void *)&(Statistics[idx]), 0, sizeof(lbm_rcv_topic_stats_t));
strncpy(Statistics[idx].topic, topic, sizeof(Statistics[idx].topic));
Statistics[idx].flags = msg->sources[idx]->source_state;
strncpy(Statistics[idx].source, msg->sources[idx]->source_string, sizeof(Statistics[idx].source));
pos = msg->sources[idx]->otid;
for (count = 0; count < LBM_OTID_BLOCK_SZ; count++) {
sscanf(pos, "%2hhx", &Statistics[idx].otid[count]);
pos += 2;
}
Statistics[idx].topic_idx = msg->sources[idx]->topic_idx;
Statistics[idx].timestamp_sec = msg->sources[idx]->timestamp_sec;
Statistics[idx].timestamp_usec = msg->sources[idx]->timestamp_usec;
}
}
lbmmon__umsmon_msg__free_unpacked(lbmmon_msg, NULL);
*Count = src_count;
}
int lbmmon_wildcard_rcv_format_pb_deserialize(lbmmon_packet_attributes_t * Attributes, lbm_wildcard_rcv_stats_t * Statistics,
const char * Source, size_t Length, unsigned short ModuleID, void * FormatClientData)
{
unsigned char modid;
lbmmon_format_pb_t * format_options;
Lbmmon__UMSMonMsg *lbmmon_msg = NULL;
if ((Statistics == NULL) || (Source == NULL) || (*Source == '\0') || (Length == 0) || (FormatClientData == NULL))
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
modid = MODULE_ID(ModuleID);
{
snprintf(ErrorString, sizeof(ErrorString), "Invalid module ID %u", (unsigned)modid);
}
format_options = (lbmmon_format_pb_t *)FormatClientData;
if (format_options->mPassthrough == LBMMON_FORMAT_PASSTHROUGH_ON)
{
}
lbmmon_msg = lbmmon__umsmon_msg__unpack(NULL, Length, (lbm_uint8_t *)Source);
if ((lbmmon_msg == NULL) || (lbmmon_msg->attributes == NULL) || (lbmmon_msg->events == NULL) ||
(lbmmon_msg->events->wildcard_receivers == NULL) || (lbmmon_msg->events->n_wildcard_receivers != 1))
{
snprintf(ErrorString, sizeof(ErrorString), "Error unpacking incoming wildcard stats message\n");
}
lbmmon_attributes_format_pb_deserialize(Attributes, lbmmon_msg->attributes);
msg = *(lbmmon_msg->events->wildcard_receivers);
memset((void *)Statistics, 0, sizeof(lbm_wildcard_rcv_stats_t));
strncpy(Statistics->pattern, msg->pattern, sizeof(Statistics->pattern));
Statistics->type = (lbm_uint8_t)msg->type;
lbmmon__umsmon_msg__free_unpacked(lbmmon_msg, NULL);
}
int lbmmon_store_format_pb_deserialize(lbmmon_packet_attributes_t * Attributes, Lbmmon__UMPMonMsg ** StoreMsg,
const char * Source, size_t Length, unsigned short ModuleID, void * FormatClientData)
{
Lbmmon__UMPMonMsg *msg = NULL;
unsigned char modid;
lbmmon_format_pb_t * format_options;
if ((StoreMsg == NULL) || (Source == NULL) || (*Source == '\0') || (Length == 0) || (FormatClientData == NULL))
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
modid = MODULE_ID(ModuleID);
{
strncpy(ErrorString, "Invalid module ID", sizeof(ErrorString));
}
format_options = (lbmmon_format_pb_t *)FormatClientData;
if (format_options->mPassthrough == LBMMON_FORMAT_PASSTHROUGH_ON)
{
}
msg = lbmmon__umpmon_msg__unpack(NULL, Length, (lbm_uint8_t *)Source);
if (msg == NULL)
{
snprintf(ErrorString, sizeof(ErrorString), "Error unpacking incoming UME store lbmmon message\n");
}
lbmmon_attributes_format_pb_deserialize(Attributes, msg->attributes);
*StoreMsg = msg;
}
int lbmmon_store_free_unpacked(Lbmmon__UMPMonMsg * StoreMsg)
{
if (StoreMsg == NULL)
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
lbmmon__umpmon_msg__free_unpacked(StoreMsg, NULL);
}
int lbmmon_gateway_format_pb_deserialize(lbmmon_packet_attributes_t * Attributes, Lbmmon__DROMonMsg ** GatewayMsg,
const char * Source, size_t Length, unsigned short ModuleID, void * FormatClientData)
{
Lbmmon__DROMonMsg *msg = NULL;
unsigned char modid;
lbmmon_format_pb_t * format_options;
if ((GatewayMsg == NULL) || (Source == NULL) || (*Source == '\0') || (Length == 0) || (FormatClientData == NULL))
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
modid = MODULE_ID(ModuleID);
{
strncpy(ErrorString, "Invalid module ID", sizeof(ErrorString));
}
format_options = (lbmmon_format_pb_t *)FormatClientData;
if (format_options->mPassthrough == LBMMON_FORMAT_PASSTHROUGH_ON)
{
}
msg = lbmmon__dromon_msg__unpack(NULL, Length, (lbm_uint8_t *)Source);
if (msg == NULL)
{
snprintf(ErrorString, sizeof(ErrorString), "Error unpacking incoming UME gateway lbmmon message\n");
}
lbmmon_attributes_format_pb_deserialize(Attributes, msg->attributes);
*GatewayMsg = msg;
}
int lbmmon_gateway_free_unpacked(Lbmmon__DROMonMsg * GatewayMsg)
{
if (GatewayMsg == NULL)
{
strncpy(ErrorString, "Invalid parameter", sizeof(ErrorString));
}
lbmmon__dromon_msg__free_unpacked(GatewayMsg, NULL);
}
int lbmmon_format_pb_finish(void * FormatClientData)
{
if (FormatClientData != NULL)
{
lbmmon_format_pb_t * data = (lbmmon_format_pb_t *)FormatClientData;
free(data->filters);
free(data);
}
return (0);
}
const char * lbmmon_format_pb_errmsg(void)
{
return (ErrorString);
}