Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/libfds/iemgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ struct fds_iemgr_elem {

struct fds_iemgr_mapping ** mappings;
size_t mappings_cnt;
/** Exclusion flag, tells weather a fields should be excluded from export */
bool excluded;
};

/**
Expand Down
13 changes: 12 additions & 1 deletion src/converters/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,14 @@ get_converter(const struct fds_drec_field *field)
}
}

static bool match_exclude(const struct fds_drec_iter* iter)
{
if( iter->field.info->def == NULL || iter->field.info->def->excluded) {
return true;
}
return false;
}

/**
* \breaf Function for iterating through Information Elements
* \param[in] rec IPFIX Data Record to convert
Expand All @@ -1001,13 +1009,16 @@ iter_loop(const struct fds_drec *rec, struct context *buffer)
fds_drec_iter_init(&iter, (struct fds_drec *) rec, iter_flag);

while (fds_drec_iter_next(&iter) != FDS_EOC) {

// If flag of multi fields is set,
// then this field will be skiped and processed when the last occurrence is found
const fds_template_flag_t field_flags = iter.field.info->flags;
if ((field_flags & FDS_TFIELD_MULTI_IE) != 0 && (field_flags & FDS_TFIELD_LAST_IE) == 0){
continue;
}

if ( match_exclude( &iter ) ) {
continue;
}
// Separate fields
if (added != 0) {
// Add comma
Expand Down
3 changes: 2 additions & 1 deletion src/iemgr/iemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ parser_create(fds_iemgr_t* mgr)
FDS_OPTS_ELEM(ELEM_DATA_SEMAN, "dataSemantics", FDS_OPTS_T_STRING, FDS_OPTS_P_OPT),
FDS_OPTS_ELEM(ELEM_DATA_UNIT, "units", FDS_OPTS_T_STRING, FDS_OPTS_P_OPT),
FDS_OPTS_ELEM(ELEM_STATUS, "status", FDS_OPTS_T_STRING, FDS_OPTS_P_OPT),
FDS_OPTS_ELEM(ELEM_BIFLOW, "biflowId", FDS_OPTS_T_INT, FDS_OPTS_P_OPT),
FDS_OPTS_ELEM(ELEM_BIFLOW, "biflowId", FDS_OPTS_T_INT, FDS_OPTS_P_OPT),
FDS_OPTS_ELEM(ELEM_EXCLUDED, "excluded", FDS_OPTS_T_BOOL, FDS_OPTS_P_OPT),
FDS_OPTS_END
};
static const struct fds_xml_args args_biflow[] = {
Expand Down
1 change: 1 addition & 0 deletions src/iemgr/iemgr_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ enum FDS_XML_ID {
ITEM_LIST_ITEM,
ITEM_KEY,
ITEM_VALUE,
ELEM_EXCLUDED
};

/** \cond DOXYGEN_SKIP_THIS */
Expand Down
10 changes: 7 additions & 3 deletions src/iemgr/iemgr_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ element_create()
elem->aliases_cnt = 0;
elem->mappings = nullptr;
elem->mappings_cnt = 0;
elem->excluded = false;
return elem;
}

Expand All @@ -81,7 +82,7 @@ element_copy(fds_iemgr_scope_inter* scope, const fds_iemgr_elem* elem)
res->aliases = copy_flat_array(elem->aliases, elem->aliases_cnt);
res->mappings_cnt = elem->mappings_cnt;
res->mappings = copy_flat_array(elem->mappings, elem->mappings_cnt);

res->excluded = elem->excluded;
return res;
}

Expand All @@ -102,8 +103,8 @@ element_create_reverse(fds_iemgr_elem* src, uint16_t new_id)
res->aliases = nullptr;
res->mappings_cnt = 0;
res->mappings = nullptr;

src->reverse_elem = res.get();
res->excluded = src->excluded;
src->reverse_elem = res.get();
return res.release();
}

Expand Down Expand Up @@ -376,6 +377,9 @@ element_read(fds_iemgr_t* mgr, fds_xml_ctx_t* ctx, fds_iemgr_scope_inter* scope)
return false;
}
break;
case ELEM_EXCLUDED:
elem->excluded = cont->val_bool;
break;
default:
break;
}
Expand Down