Skip to content

Commit f459461

Browse files
committed
UniRec output: Introduce ODID translate function (converter)
1 parent d62beff commit f459461

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

extra_plugins/output/unirec/src/translator.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,32 @@ translate_internal_lbf(translator_t *trans)
839839
return 0;
840840
}
841841

842+
/**
843+
* \brief Convert (fill) ODID field
844+
*
845+
* \note This function uses a message context configured by the user. It's independent on the
846+
* content of an IPFIX record.
847+
* \param[in] trans Internal translator structure
848+
* \return On success returns 0. Otherwise returns non-zero value!
849+
*/
850+
static int
851+
translate_internal_odid(translator_t *trans)
852+
{
853+
if (!trans->msg_context.hdr) {
854+
return 1; // Message header is not available!
855+
}
856+
857+
// Get the ODID value
858+
uint32_t odid = ntohl(trans->msg_context.hdr->odid);
859+
860+
ur_field_type_t ur_id = trans->extra_conv.odid.field_id;
861+
void *field_ptr = ur_get_ptr_by_id(trans->record.ur_tmplt, trans->record.data, ur_id);
862+
863+
*((uint32_t *) field_ptr) = odid;
864+
865+
return 0;
866+
}
867+
842868
/**
843869
* \brief Get size of UniRec numeric data types
844870
* \param type UniRec data types

0 commit comments

Comments
 (0)