Skip to content

Commit 5bf737b

Browse files
committed
UniRec output: Enable ODID field in translator
1 parent f459461 commit 5bf737b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

extra_plugins/output/unirec/src/translator.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,34 @@ translator_table_fill_internal(translator_t *trans, const struct map_rec *map_re
14831483
return IPX_OK;
14841484
}
14851485

1486+
/* Internal "ODID field" function
1487+
* Implemented as a special converter that must be enabled in the translator because
1488+
* ODID is not defined in the IPFIX record but in the IPFIX Message header
1489+
*/
1490+
if (src == MAP_SRC_INTERNAL_ODID) {
1491+
if (trans->extra_conv.odid.en) {
1492+
// The function is already enabled!
1493+
IPX_CTX_ERROR(trans->ctx, "Internal 'odid field' function can be mapped only "
1494+
"to one UniRec field!", '\0');
1495+
return IPX_ERR_DENIED;
1496+
}
1497+
1498+
if (ur_type != UR_TYPE_UINT32) {
1499+
IPX_CTX_ERROR(trans->ctx, "Internal 'odid field' function supports only UniRec "
1500+
"uint32 type but UniRec field '%s' is '%s'!", map_rec->unirec.name,
1501+
map_rec->unirec.type_str);
1502+
return IPX_ERR_DENIED;
1503+
}
1504+
1505+
// Enable the internal converter
1506+
trans->extra_conv.odid.en = true;
1507+
trans->extra_conv.odid.req_idx = field_idx;
1508+
trans->extra_conv.odid.field_id = ur_id;
1509+
IPX_CTX_DEBUG(trans->ctx, "Added conversion from internal 'odid field' to UniRec '%s'",
1510+
map_rec->unirec.name);
1511+
return IPX_ERR_NOTFOUND; // Do NOT add the record!
1512+
}
1513+
14861514
IPX_CTX_ERROR(trans->ctx, "Unimplemented internal mapping function!", '\0');
14871515
return IPX_ERR_DENIED;
14881516
}
@@ -1630,6 +1658,19 @@ translator_call_internals(translator_t *trans)
16301658
}
16311659
}
16321660

1661+
if (trans->extra_conv.odid.en) {
1662+
// Call internal 'odid field' converter
1663+
int field_idx = trans->extra_conv.odid.req_idx;
1664+
if (translate_internal_odid(trans) == 0) {
1665+
// Success
1666+
trans->progress.req_fields[field_idx] = 0; // Filled!
1667+
converted_fields++;
1668+
} else {
1669+
IPX_CTX_WARNING(trans->ctx, "Internal function 'odid field' failed to fill "
1670+
"UniRec field '%s'", trans->progress.req_names[field_idx]);
1671+
}
1672+
}
1673+
16331674
return converted_fields;
16341675
}
16351676

0 commit comments

Comments
 (0)