IPFIX: extend string field conversion to fallback to str()

Closes #42
This commit is contained in:
Dominik Pataky 2022-12-02 17:24:55 +01:00
parent 4e065644fa
commit 0afa4b37e8

View file

@ -770,7 +770,10 @@ class IPFIXDataRecord:
if type(value) is bytes:
# Check if value is raw bytes, so no conversion happened in struct.unpack
if field_datatype in ["string"]:
value = value.decode()
try:
value = value.decode()
except UnicodeDecodeError:
value = str(value)
# TODO: handle octetArray (= does not have to be unicode encoded)
elif field_datatype in ["boolean"]:
value = True if value == 1 else False # 2 = false per RFC