How to use the netflow.v9.V9DataFlowSet function in netflow

To help you get started, we’ve selected a few netflow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitkeks / python-netflow-v9-softflowd / netflow / v9.py View on Github external
offset += tfs.length
            else:
                try:
                    dfs = V9DataFlowSet(data[offset:], self._templates)
                    self._flows += dfs.flows
                    offset += dfs.length
                except V9TemplateNotRecognized:
                    # Could not be parsed, continue to check for templates
                    length = struct.unpack("!H", data[offset + 2:offset + 4])[0]
                    skipped_flowsets_offsets.append(offset)
                    offset += length

        if skipped_flowsets_offsets and self._new_templates:
            # Process flowsets in the data slice which occured before the template sets
            for offset in skipped_flowsets_offsets:
                dfs = V9DataFlowSet(data[offset:], self._templates)
                self._flows += dfs.flows
        elif skipped_flowsets_offsets:
            raise V9TemplateNotRecognized
github bitkeks / python-netflow-v9-softflowd / netflow / v9.py View on Github external
if flowset_id == 0:  # TemplateFlowSet always have id 0
                tfs = V9TemplateFlowSet(data[offset:])

                # Check for any new/changed templates
                if not self._new_templates:
                    for id_, template in tfs.templates.items():
                        if id_ not in self._templates or self._templates[id_] != template:
                            self._new_templates = True
                            break

                # Update the templates with the provided templates, even if they are the same
                self._templates.update(tfs.templates)
                offset += tfs.length
            else:
                try:
                    dfs = V9DataFlowSet(data[offset:], self._templates)
                    self._flows += dfs.flows
                    offset += dfs.length
                except V9TemplateNotRecognized:
                    # Could not be parsed, continue to check for templates
                    length = struct.unpack("!H", data[offset + 2:offset + 4])[0]
                    skipped_flowsets_offsets.append(offset)
                    offset += length

        if skipped_flowsets_offsets and self._new_templates:
            # Process flowsets in the data slice which occured before the template sets
            for offset in skipped_flowsets_offsets:
                dfs = V9DataFlowSet(data[offset:], self._templates)
                self._flows += dfs.flows
        elif skipped_flowsets_offsets:
            raise V9TemplateNotRecognized