Skip to content

Commit 507749e

Browse files
committed
unirec: integrate configuration by @jaroslavh, fixed ifctype
Configuration file -> trapIfcType element can contain TCP/UNIXSOCKET/TLS/BLACKHOLE/FILE, it is afterwards converted into t/u/T/f.
1 parent e568ce2 commit 507749e

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

extra_plugins/output/unirec/configuration.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ enum params_xml_nodes {
7878
/** Definition of the \<params\> node */
7979
static const struct fds_xml_args args_params[] = {
8080
FDS_OPTS_ROOT("params"),
81-
FDS_OPTS_ELEM(NODE_TRAP_IFC_TYPE, "trapIfcType", FDS_OPTS_T_INT, 0),
81+
FDS_OPTS_ELEM(NODE_TRAP_IFC_TYPE, "trapIfcType", FDS_OPTS_T_STRING, 0),
8282
FDS_OPTS_ELEM(NODE_TRAP_IFC_SOCKET, "trapIfcSocket", FDS_OPTS_T_STRING, 0),
8383
FDS_OPTS_ELEM(NODE_TRAP_IFC_TIMEOUT, "trapIfcTimeout", FDS_OPTS_T_STRING, 0),
8484
FDS_OPTS_ELEM(NODE_TRAP_IFC_FLUSH_TIMEOUT, "trapIfcFlushTimeout", FDS_OPTS_T_STRING, 0),
@@ -129,8 +129,20 @@ configuration_parse_root(ipx_ctx_t *ctx, fds_xml_ctx_t *root, struct conf_params
129129
while(fds_xml_next(root, &content) != FDS_EOC) {
130130
switch (content->id) {
131131
case NODE_TRAP_IFC_TYPE:
132-
assert(content->type == FDS_OPTS_T_INT);
133-
cnf->trap_ifc_type = content->val_int;
132+
assert(content->type == FDS_OPTS_T_STRING);
133+
if (strcmp(content->ptr_string, "UNIXSOCKET") == 0) {
134+
cnf->trap_ifc_type = 'u';
135+
} else if (strcmp(content->ptr_string, "TCP") == 0) {
136+
cnf->trap_ifc_type = 't';
137+
} else if (strcmp(content->ptr_string, "TLS") == 0) {
138+
cnf->trap_ifc_type = 'T';
139+
} else if (strcmp(content->ptr_string, "FILE") == 0) {
140+
cnf->trap_ifc_type = 'f';
141+
} else if (strcmp(content->ptr_string, "BLACKHOLE") == 0) {
142+
cnf->trap_ifc_type = 'b';
143+
} else {
144+
IPX_CTX_ERROR(ctx, "Unsupported trapIfcType.");
145+
}
134146
break;
135147
case NODE_TRAP_IFC_SOCKET:
136148
assert(content->type == FDS_OPTS_T_STRING);

extra_plugins/output/unirec/unirecplugin.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,11 @@ int
9999
ipx_plugin_init(ipx_ctx_t *ctx, const char *params) {
100100
IPX_CTX_INFO(ctx, "UniRec plugin initialization.");
101101
// Process XML configuration
102-
//struct conf_params *parsed_params = configuration_parse(ctx, params);
103-
//if (!parsed_params) {
104-
// IPX_CTX_ERROR(ctx, "Failed to parse the plugin configuration.", '\0');
105-
// return IPX_ERR_DENIED;
106-
//}
107-
/* TODO delete: */
108-
struct conf_params *parsed_params = calloc(1, sizeof(*parsed_params));
109-
parsed_params->trap_ifc_type = 'u';
110-
parsed_params->trap_ifc_socket = strdup("ipfix-ur");
111-
parsed_params->unirec_format = strdup("SRC_IP,DST_IP,?SRC_PORT,?DST_PORT,?TCP_FLAGS");
102+
struct conf_params *parsed_params = configuration_parse(ctx, params);
103+
if (!parsed_params) {
104+
IPX_CTX_ERROR(ctx, "Failed to parse the plugin configuration.", '\0');
105+
return IPX_ERR_DENIED;
106+
}
112107

113108
if (pthread_mutex_lock(&urp_mutex) == -1) {
114109
return IPX_ERR_DENIED;

0 commit comments

Comments
 (0)