Skip to content

Commit 0ed9597

Browse files
committed
UniRec output: Use ipx_msg_ctx struct as message context in translator instead of message header
1 parent abcdeed commit 0ed9597

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

extra_plugins/output/unirec/src/translator.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ struct translator_s {
137137
} progress; /**< Auxiliary conversion variables */
138138

139139
struct {
140-
/** IPFIX Message header */
141-
const struct fds_ipfix_msg_hdr *hdr;
140+
/** IPFIX Message context */
141+
const struct ipx_msg_ctx *ctx;
142142
} msg_context; /**< IPFIX context of the record to translate */
143143

144144
struct {
@@ -808,12 +808,12 @@ translate_internal_dbf(translator_t *trans, const struct translator_rec *rec,
808808
static int
809809
translate_internal_lbf(translator_t *trans)
810810
{
811-
if (!trans->msg_context.hdr) {
812-
return 1; // Message header is not available!
811+
if (!trans->msg_context.ctx) {
812+
return 1; // Message context is not available!
813813
}
814814

815815
// Get the ODID value
816-
uint32_t odid = ntohl(trans->msg_context.hdr->odid);
816+
uint32_t odid = trans->msg_context.ctx->odid;
817817

818818
// Store the value is 'link bit field'
819819
ur_field_type_t ur_id = trans->extra_conv.lbf.field_id;
@@ -850,12 +850,12 @@ translate_internal_lbf(translator_t *trans)
850850
static int
851851
translate_internal_odid(translator_t *trans)
852852
{
853-
if (!trans->msg_context.hdr) {
854-
return 1; // Message header is not available!
853+
if (!trans->msg_context.ctx) {
854+
return 1; // Message context is not available!
855855
}
856856

857857
// Get the ODID value
858-
uint32_t odid = ntohl(trans->msg_context.hdr->odid);
858+
uint32_t odid = trans->msg_context.ctx->odid;
859859

860860
ur_field_type_t ur_id = trans->extra_conv.odid.field_id;
861861
void *field_ptr = ur_get_ptr_by_id(trans->record.ur_tmplt, trans->record.data, ur_id);
@@ -1707,9 +1707,9 @@ translator_destroy(translator_t *trans)
17071707
}
17081708

17091709
void
1710-
translator_set_context(translator_t *trans, const struct fds_ipfix_msg_hdr *hdr)
1710+
translator_set_context(translator_t *trans, const struct ipx_msg_ctx *ctx)
17111711
{
1712-
trans->msg_context.hdr = hdr;
1712+
trans->msg_context.ctx = ctx;
17131713
}
17141714

17151715
const void *

extra_plugins/output/unirec/src/translator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ translator_destroy(translator_t *trans);
7878
* This function MUST be called before processing each IPFIX Message to set proper record
7979
* parameters. The message header is required for determine ODID or other parameters.
8080
* \param[in] trans Translator instance
81-
* \param[in] hdr IPFIX message header
81+
* \param[in] ctx IPFIX message context
8282
*/
8383
void
84-
translator_set_context(translator_t *trans, const struct fds_ipfix_msg_hdr *hdr);
84+
translator_set_context(translator_t *trans, const struct ipx_msg_ctx *ctx);
8585

8686
/**
8787
* \brief Convert a IPFIX record to an UniRec message

extra_plugins/output/unirec/src/unirecplugin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ ipx_plugin_process(ipx_ctx_t *ctx, void *cfg, ipx_msg_t *msg)
344344
const void *msg_data = NULL;
345345

346346
ipx_msg_ipfix_t *ipfix = ipx_msg_base2ipfix(msg);
347-
const uint8_t *ipfix_raw_msg = ipx_msg_ipfix_get_packet(ipfix);
348-
translator_set_context(conf->trans, (const struct fds_ipfix_msg_hdr *) ipfix_raw_msg);
347+
const struct ipx_msg_ctx *ipfix_msg_ctx = ipx_msg_ipfix_get_ctx(ipfix);
348+
translator_set_context(conf->trans, ipfix_msg_ctx);
349349

350350
const uint32_t rec_cnt = ipx_msg_ipfix_get_drec_cnt(ipfix);
351351
for (uint32_t i = 0; i < rec_cnt; i++) {

0 commit comments

Comments
 (0)