Skip to content

Commit 61e7942

Browse files
committed
UniRec output: Enable EXPORTER_IP field in translator
1 parent a5e6c69 commit 61e7942

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
@@ -1568,6 +1568,34 @@ translator_table_fill_internal(translator_t *trans, const struct map_rec *map_re
15681568
return IPX_ERR_NOTFOUND; // Do NOT add the record!
15691569
}
15701570

1571+
/* Internal "exporter_ip field" function
1572+
* Implemented as a special converter that must be enabled in the translator because
1573+
* IPFIX Message session is not defined in IPFIX record
1574+
*/
1575+
if (src == MAP_SRC_INTERNAL_EXPORTER_IP) {
1576+
if (trans->extra_conv.exporter_ip.en) {
1577+
// The function is already enabled!
1578+
IPX_CTX_ERROR(trans->ctx, "Internal 'exporter_ip field' function can be mapped only "
1579+
"to one UniRec field!", '\0');
1580+
return IPX_ERR_DENIED;
1581+
}
1582+
1583+
if (ur_type != UR_TYPE_IP) {
1584+
IPX_CTX_ERROR(trans->ctx, "Internal 'exporter_ip field' function supports only UniRec "
1585+
"ipaddress type but UniRec field '%s' is '%s'!", map_rec->unirec.name,
1586+
map_rec->unirec.type_str);
1587+
return IPX_ERR_DENIED;
1588+
}
1589+
1590+
// Enable the internal converter
1591+
trans->extra_conv.exporter_ip.en = true;
1592+
trans->extra_conv.exporter_ip.req_idx = field_idx;
1593+
trans->extra_conv.exporter_ip.field_id = ur_id;
1594+
IPX_CTX_DEBUG(trans->ctx, "Added conversion from internal 'exporter_ip field' to UniRec '%s'",
1595+
map_rec->unirec.name);
1596+
return IPX_ERR_NOTFOUND; // Do NOT add the record!
1597+
}
1598+
15711599
IPX_CTX_ERROR(trans->ctx, "Unimplemented internal mapping function!", '\0');
15721600
return IPX_ERR_DENIED;
15731601
}
@@ -1728,6 +1756,19 @@ translator_call_internals(translator_t *trans)
17281756
}
17291757
}
17301758

1759+
if (trans->extra_conv.exporter_ip.en) {
1760+
// Call internal 'exporter_ip field' converter
1761+
int field_idx = trans->extra_conv.exporter_ip.req_idx;
1762+
if (translate_internal_exporter_ip(trans) == 0) {
1763+
// Success
1764+
trans->progress.req_fields[field_idx] = 0; // Filled!
1765+
converted_fields++;
1766+
} else {
1767+
IPX_CTX_WARNING(trans->ctx, "Internal function 'exporter_ip field' failed to fill "
1768+
"UniRec field '%s'", trans->progress.req_names[field_idx]);
1769+
}
1770+
}
1771+
17311772
return converted_fields;
17321773
}
17331774

0 commit comments

Comments
 (0)