Skip to content

Bidirectional flow #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions netflow/ipfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def __init__(self, data, template: List[Union[TemplateField, TemplateFieldEnterp
pack = struct.unpack(unpacker, data[0:offset])

# Iterate through template again, but taking the unpacked values this time
for index, ((field_datatype, field_type_id), value) in enumerate(zip(discovered_fields, pack)):
for index, ((field_datatype, field_type_id), value, field) in enumerate(zip(discovered_fields, pack, template)):
if type(value) is bytes:
# Check if value is raw bytes, so no conversion happened in struct.unpack
if field_datatype in ["string"]:
Expand All @@ -782,7 +782,8 @@ def __init__(self, data, template: List[Union[TemplateField, TemplateFieldEnterp
value = int.from_bytes(value, "big")
# If not bytes, struct.unpack already did necessary conversions (int, float...),
# value can be used as-is.
self.fields.add((field_type_id, value))
self.fields.add((field_type_id, value, True if type(field) is TemplateFieldEnterprise and
field.enterprise_number == 29305 else False))

self._length = offset
self.__dict__.update(self.data)
Expand All @@ -793,7 +794,7 @@ def get_length(self):
@property
def data(self):
return {
IPFIXFieldTypes.by_id(key)[1]: value for (key, value) in self.fields
IPFIXFieldTypes.by_id(key)[1] + ("_" if biflow else ""): value for (key, value, biflow) in self.fields
}

def __repr__(self):
Expand Down