Skip to content

Commit 87332fe

Browse files
committed
lnfstore output: add biflow support (split into 2 single directional flows)
1 parent f65da1d commit 87332fe

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

extra_plugins/output/lnfstore/lnfstore.c

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -139,41 +139,38 @@ ipx_plugin_process(ipx_ctx_t *ctx, void *cfg, ipx_msg_t *msg)
139139
conf->window_start = new_time;
140140

141141
// Update storage files
142-
//if (conf->params->profiles.en) {
143-
// stg_profiles_new_window(conf->storage.profiles, new_time);
144-
//} else {
145-
stg_basic_new_window(conf->storage.basic, new_time);
146-
//}
142+
stg_basic_new_window(conf->storage.basic, new_time);
147143
}
148144

149145
ipx_msg_ipfix_t *ipfix = ipx_msg_base2ipfix(msg);
150146
const uint32_t rec_cnt = ipx_msg_ipfix_get_drec_cnt(ipfix);
151147
for (uint32_t i = 0; i < rec_cnt; i++) {
152148
// Get a pointer to the next record
153149
struct ipx_ipfix_record *ipfix_rec = ipx_msg_ipfix_get_drec(ipfix, i);
150+
bool biflow = (ipfix_rec->rec.tmplt->flags & FDS_TEMPLATE_BIFLOW) != 0;
154151

155-
//if (conf->params->profiles.en && !mdata->channels) {
156-
/*
157-
* Record won't be stored, it does not belong to any channel and
158-
* profiling is activated
159-
*/
160-
// continue;
161-
//}
162-
163-
// Fill record // TODO: biflow
152+
// Fill record
153+
uint16_t flags = biflow ? FDS_DREC_BIFLOW_FWD : 0; // In case of biflow, forward fields only
164154
lnf_rec_t *lnf_rec = conf->record.rec_ptr;
165-
if (translator_translate(conf->record.translator, &ipfix_rec->rec, lnf_rec) <= 0) {
155+
if (translator_translate(conf->record.translator, &ipfix_rec->rec, lnf_rec, flags) <= 0) {
156+
// Nothing to store
157+
continue;
158+
}
159+
160+
stg_basic_store(conf->storage.basic, lnf_rec);
161+
162+
// Is it biflow? Store the reverse direction
163+
if (!biflow) {
164+
continue;
165+
}
166+
167+
flags = FDS_DREC_BIFLOW_REV;
168+
if (translator_translate(conf->record.translator, &ipfix_rec->rec, lnf_rec, flags) <= 0) {
166169
// Nothing to store
167170
continue;
168171
}
169172

170-
//if (conf->params->profiles.en) {
171-
// Profile mode
172-
//stg_profiles_store(conf->storage.profiles, mdata, lnf_rec);
173-
//} else {
174-
// Basic mode
175-
stg_basic_store(conf->storage.basic, lnf_rec);
176-
//}
173+
stg_basic_store(conf->storage.basic, lnf_rec);
177174
}
178175

179176
return 0;

extra_plugins/output/lnfstore/translator.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,14 @@ translator_destroy(translator_t *trans)
495495
}
496496

497497
int
498-
translator_translate(translator_t *trans, struct fds_drec *ipfix_rec, lnf_rec_t *lnf_rec)
498+
translator_translate(translator_t *trans, struct fds_drec *ipfix_rec, lnf_rec_t *lnf_rec,
499+
uint16_t flags)
499500
{
500501
lnf_rec_clear(lnf_rec);
501502

502503
// Initialize a record iterator
503504
struct fds_drec_iter it;
504-
fds_drec_iter_init(&it, ipfix_rec, 0);
505+
fds_drec_iter_init(&it, ipfix_rec, flags);
505506

506507
// Try to convert all IPFIX fields
507508
struct translator_table_rec key;

extra_plugins/output/lnfstore/translator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ translator_destroy(translator_t *trans);
6565
* \param[in] trans Translator instance
6666
* \param[in] ipfix_rec IPFIX record (read only!)
6767
* \param[in,out] lnf_rec Filled LNF record
68+
* \param[in] flags Flags for iterator over the IPFIX record
6869
* \return Number of converted fields
6970
*/
7071
int
71-
translator_translate(translator_t *trans, struct fds_drec *ipfix_rec, lnf_rec_t *lnf_rec);
72+
translator_translate(translator_t *trans, struct fds_drec *ipfix_rec, lnf_rec_t *lnf_rec,
73+
uint16_t flags);
7274

7375
#endif //LS_TRANSLATOR_H

0 commit comments

Comments
 (0)