Ejemplo n.º 1
0
    def __init__(self, unpacker: Unpacker):
        self.counter_format = None
        self.counter = None

        self.counter_format = unpacker.unpack_uint()
        counter_data = unpacker.unpack_opaque()
        unpacker_counter_data = Unpacker(counter_data)

        if self.counter_format == SFlowCounterRecord.COUNTER_DATA_GENERIC_INTERFACE:
            self.counter = GenericInterfaceCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_ETHERNET_INTERFACE:
            self.counter = EthernetInterfaceCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_TOKEN_RING:
            pass
            self.counter = TokenRingCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_VG_INTERFACE:
            pass
            self.counter = VgInterfaceCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_VLAN:
            self.counter = VlanCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_PROCESSOR:
            self.counter = ProcessorCounters(unpacker_counter_data)
        else:
            logging.debug('read_flow_record:Unimplemented data_format (%d)' %
                          self.flow_format)
Ejemplo n.º 2
0
    def __init__(self, unpacker: Unpacker):
        self.sequence_number = None
        self.source_id = None
        self.counters = []

        sample_data = unpacker.unpack_opaque()
        unpacker_sample_data = Unpacker(sample_data)
        self._parse_raw_sflow_counter_sample(unpacker_sample_data)
Ejemplo n.º 3
0
    def __init__(self, unpacker: Unpacker):
        # struct struct counters_sample_expanded
        self.sequence_number = None
        self.source_id = {}
        self.counters = []

        sample_data = unpacker.unpack_opaque()
        unpacker_sample_data = Unpacker(sample_data)
        self._parse_raw_expanded_sflow_counter_sample(unpacker_sample_data)
Ejemplo n.º 4
0
    def unpack(self, u: xdrlib.Unpacker):
        self.response_from_agent = u.unpack_bool()
        self.agent_id = u.unpack_opaque()

        n = u.unpack_uint()
        self.controllers = []
        for i in range(n):
            c = AccessibleController()
            c.trayId = u.unpack_uint()
            c.slot = u.unpack_uint()
            c.wwn = u.unpack_opaque()
            c.token = u.unpack_fopaque(12)
            c.controller_refs = []

            m = u.unpack_uint()
            for j in range(m):
                c.controller_refs.append(u.unpack_fopaque(12))

            self.controllers.append(c)
Ejemplo n.º 5
0
    def __init__(self, unpacker: Unpacker):
        self.sequence_number = None
        self.source_id = None
        self.sampling_rate = None
        self.sample_pool = None
        self.drops = None
        self.input_if = None
        self.output_if = None
        self.flows = []

        sample_data = unpacker.unpack_opaque()
        unpacker_sample_data = Unpacker(sample_data)
        self._parse_raw_sflow_flow_sample(unpacker_sample_data)
Ejemplo n.º 6
0
    def unpack(self, u: xdrlib.Unpacker):
        self.needs_attention = u.unpack_bool()
        self.fixing = u.unpack_bool()
        self.wwn = u.unpack_opaque()
        self.management_class_name = u.unpack_string()
        self.storage_array_label = u.unpack_string().decode('utf-16be')
        self.boot_time = struct.unpack('>Q', u.unpack_fopaque(8))[0]
        self.fw_version = u.unpack_fopaque(4)
        self.app_version = u.unpack_fopaque(4)
        self.boot_version = u.unpack_fopaque(4)
        self.nvsram_version = u.unpack_string()
        self.fw_prefix = u.unpack_string()
        self.chassis_serial_number = u.unpack_string()
        self.event_configuration_data_version = u.unpack_string()

        self.array_attributes = []
        nb = u.unpack_uint()
        for i in range(nb):
            self.array_attributes.append(u.unpack_uint())
        self.res4 = []
        nb = u.unpack_uint()
        for i in range(nb):
            self.res4.append(u.unpack_uint())
        self.res5 = []
        nb = u.unpack_uint()
        for i in range(nb):
            self.res5.append(u.unpack_uint())
        self.res6 = []
        nb = u.unpack_uint()
        for i in range(nb):
            self.res6.append(u.unpack_uint())
        self.res7 = u.unpack_opaque()

        last = u.unpack_int()
        if last > 0:
            this.reserved1 = u.get_opaque()
            u.set_position(u.get_position() + last)
Ejemplo n.º 7
0
    def __init__(self, unpacker: Unpacker):
        self.flow_format = None
        self.flow = None

        self.flow_format = unpacker.unpack_uint()
        flow_data = unpacker.unpack_opaque()
        unpacker_flow_data = Unpacker(flow_data)

        if self.flow_format == SFlowFlowRecord.FLOW_DATA_RAW_HEADER:
            self.flow = FlowDataRawHeader(unpacker_flow_data)
        elif self.flow_format == SFlowFlowRecord.FLOW_DATA_ETHERNET_HEADER:
            self.flow = FlowDataEthernetHeader(unpacker_flow_data)
        elif self.flow_format == SFlowFlowRecord.FLOW_DATA_IPV4_HEADER:
            self.flow = FlowDataIPv4Header(unpacker_flow_data)
        elif self.flow_format == SFlowFlowRecord.FLOW_DATA_EXT_SWITCH:
            self.flow = FlowDataExtSwitch(unpacker_flow_data)
        else:
            logging.debug('read_flow_record:Unimplemented data_format (%d)' % self.flow_format)
Ejemplo n.º 8
0
    def __init__(self, unpacker: Unpacker):
        self.type = None
        self.sample = None

        self.type = unpacker.unpack_uint()

        if self.type == SFlowSample.SAMPLE_DATA_FLOW_SAMPLE:
            self.sample = SFlowFlowSample(unpacker)

        elif self.type == SFlowSample.SAMPLE_DATA_COUNTER_SAMPLE:
            self.sample = SFlowCounterSample(unpacker)

        elif self.type == SFlowSample.SAMPLE_DATA_EXPANDED_FLOW_SAMPLE:
            self.sample = SFlowExpandedFlowSample(unpacker)

        elif self.type == SFlowSample.SAMPLE_DATA_EXPANDED_COUNTER_SAMPLE:
            self.sample = SFlowExpandedCounterSample(unpacker)

        else:
            logging.debug("Unknown data format: {}".format(type))
            logging.debug(unpacker.unpack_opaque())
Ejemplo n.º 9
0
    def __init__(self, unpacker: Unpacker):
        self.counter_format = None
        self.counter = None

        self.counter_format = unpacker.unpack_uint()
        counter_data = unpacker.unpack_opaque()
        unpacker_counter_data = Unpacker(counter_data)

        if self.counter_format == SFlowCounterRecord.COUNTER_DATA_GENERIC_INTERFACE:
            self.counter = GenericInterfaceCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_ETHERNET_INTERFACE:
            self.counter = EthernetInterfaceCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_TOKEN_RING:
            pass
            self.counter = TokenRingCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_VG_INTERFACE:
            pass
            self.counter = VgInterfaceCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_VLAN:
            self.counter = VlanCounters(unpacker_counter_data)
        elif self.counter_format == SFlowCounterRecord.COUNTER_DATA_PROCESSOR:
            self.counter = ProcessorCounters(unpacker_counter_data)
        else:
            logging.debug('read_flow_record:Unimplemented data_format (%d)' % self.flow_format)