class LACP(Packet): name = "LACP" deprecated_fields = { "actor_port_numer": ("actor_port_number", "2.4.4"), "partner_port_numer": ("partner_port_number", "2.4.4"), "colletctor_reserved": ("collector_reserved", "2.4.4"), } fields_desc = [ ByteField("version", 1), ByteField("actor_type", 1), ByteField("actor_length", 20), ShortField("actor_system_priority", 0), MACField("actor_system", None), ShortField("actor_key", 0), ShortField("actor_port_priority", 0), ShortField("actor_port_number", 0), ByteField("actor_state", 0), XStrFixedLenField("actor_reserved", "", 3), ByteField("partner_type", 2), ByteField("partner_length", 20), ShortField("partner_system_priority", 0), MACField("partner_system", None), ShortField("partner_key", 0), ShortField("partner_port_priority", 0), ShortField("partner_port_number", 0), ByteField("partner_state", 0), XStrFixedLenField("partner_reserved", "", 3), ByteField("collector_type", 3), ByteField("collector_length", 16), ShortField("collector_max_delay", 0), XStrFixedLenField("collector_reserved", "", 12), ByteField("terminator_type", 0), ByteField("terminator_length", 0), XStrFixedLenField("reserved", "", 50), ]
class BeaconMetricsQuery(IEEE1905_TLV): name = "Beacon Metrics Query TLV" fields_desc = [ XByteField("type", 0x99), XShortField("len", None), MACField("assoc_sta_mac", None), XByteField("op_class", None), XByteField("chnl_num", None), MACField("bssid", None), XByteField("detail", None), FieldLenField("ssid_len", None, fmt='B', length_of="ssid"), StrLenField("ssid", None, length_from=lambda p: p.ssid_len), ConditionalField(XByteField("chnl_report_cnt", 0), lambda p: p.chnl_num != 255), ConditionalField( FieldLenField("chnl_report_cnt", None, fmt='B', count_of="chnl_report_list"), lambda p: p.chnl_num == 255), ConditionalField( PacketListField("chnl_report_list", None, BeaconMetricsQuery_ChnlReport, count_from=lambda p: p.chnl_report_cnt), lambda p: p.chnl_num == 255), FieldLenField("elt_cnt", None, fmt='B', count_of="elt_list"), FieldListField("elt_list", None, XByteField("elt_id", None), count_from=lambda p: p.elt_cnt) ]
class StrgPolicy(IEEE1905_TLV): name = "Steering Policy TLV" fields_desc = [ XByteField("type", 0x89), XShortField("len", None), FieldLenField("strg_disallowed_cnt", None, fmt='B', count_of="strg_disallowed_list"), FieldListField("strg_disallowed_list", None, MACField("sta_mac", None), count_from=lambda p: p.strg_disallowed_cnt), FieldLenField("btm_strg_disallowed_cnt", None, fmt='B', count_of="btm_strg_disallowed_list"), FieldListField("btm_strg_disallowed_list", None, MACField("sta_mac", None), count_from=lambda p: p.btm_strg_disallowed_cnt), FieldLenField("policy_cnt", None, fmt='B', count_of="policy_list"), PacketListField("policy_list", None, StrgPolicy_Policy, count_from=lambda p: p.policy_cnt) ]
class StrgRequest(IEEE1905_TLV): name = "Steering Request TLV" fields_desc = [ XByteField("type", 0x9B), XShortField("len", None), MACField("bssid", None), BitField("request_flag", 0, 1), BitField("btm_disassoc_imminent_flag", 0, 1), BitField("btm_abriged_flag", 0, 1), BitField("reserved", 0, 5), XShortField("strg_op_window", 0), XShortField("btm_disassoc_timer", 0), FieldLenField("sta_cnt", None, fmt='B', count_of="sta_list"), FieldListField("sta_list", None, MACField("mac", None), count_from=lambda p: p.sta_cnt), FieldLenField("target_bssid_cnt", None, fmt='B', count_of="target_bssid_list"), PacketListField("target_bssid_list", None, StrgRequest_TargetBSSID, count_from=lambda p: p.target_bssid_cnt) ]
class VQPEntry(Packet): name = "VQPEntry" fields_desc = [ IntEnumField( "datatype", 0, { 3073: "clientIPAddress", 3074: "portName", 3075: "VLANName", 3076: "Domain", 3077: "ethernetPacket", 3078: "ReqMACAddress", 3079: "unknown", 3080: "ResMACAddress" }), FieldLenField("len", None), ConditionalField(IPField("datatom", "0.0.0.0"), lambda p: p.datatype == 3073), ConditionalField(MACField("data", "00:00:00:00:00:00"), lambda p: p.datatype == 3078), ConditionalField(MACField("data", "00:00:00:00:00:00"), lambda p: p.datatype == 3080), ConditionalField( StrLenField("data", None, length_from=lambda p: p.len), lambda p: p.datatype not in [3073, 3078, 3080]), ] def post_build(self, p, pay): if self.len is None: tmp_len = len(p.data) p = p[:2] + struct.pack("!H", tmp_len) + p[4:] return p
class Ether(Packet): name = "Ethernet" # TRex Change - Avoid lookup by putting fixed fields. fields_desc = [ MACField("dst", "00:00:00:01:00:00"), MACField("src", "00:00:00:02:00:00"), XShortEnumField("type", 0x9000, ETHER_TYPES) ] __slots__ = ["_defrag_pos"] def hashret(self): return struct.pack("H", self.type) + self.payload.hashret() def answers(self, other): if isinstance(other, Ether): if self.type == other.type: return self.payload.answers(other.payload) return 0 def mysummary(self): return self.sprintf("%src% > %dst% (%type%)") @classmethod def dispatch_hook(cls, _pkt=None, *args, **kargs): if _pkt and len(_pkt) >= 14: if struct.unpack("!H", _pkt[12:14])[0] <= 1500: return Dot3 return cls
class LLTDRecveeDesc(Packet): name = "LLTD - Recvee Desc" fields_desc = [ ShortEnumField("type", 0, {0: "Probe", 1: "ARP or ICMPv6"}), MACField("real_src", ETHER_ANY), MACField("ether_src", ETHER_ANY), MACField("ether_dst", ETHER_ANY), ]
class LLTDEmiteeDesc(Packet): name = "LLTD - Emitee Desc" fields_desc = [ ByteEnumField("type", 0, {0: "Train", 1: "Probe"}), ByteField("pause", 0), MACField("src", None), MACField("dst", ETHER_ANY), ]
class ClientInfo(IEEE1905_TLV): name = "Client Info TLV" fields_desc = [ XByteField("type", 0x90), XShortField("len", None), MACField("bssid", None), MACField("sta_mac", None) ]
class LLTDHello(Packet): name = "LLTD - Hello" show_summary = False fields_desc = [ ShortField("gen_number", 0), MACField("current_mapper_address", ETHER_ANY), MACField("apparent_mapper_address", ETHER_ANY), ]
class BhStrgResponse(IEEE1905_TLV): name = "Backhaul Steering Response TLV" fields_desc = [ XByteField("type", 0x9F), XShortField("len", None), MACField("bh_sta_mac", None), MACField("target_bssid", None), XByteField("status", 0x00) ]
class PushBtnJoinNotif(IEEE1905_TLV): name = "Push Button Join Notification TLV" fields_desc = [ XByteField("type", 0x13), XShortField("len", None), MACField("al_mac", None), XShortField("msg_id", None), MACField("mac", None), MACField("new_mac", None) ]
class BhStrgRequest(IEEE1905_TLV): name = "Backhaul Steering Request TLV" fields_desc = [ XByteField("type", 0x9E), XShortField("len", None), MACField("bh_sta_mac", None), MACField("target_bssid", None), XByteField("op_class", 0), XByteField("chnl_num", 0) ]
class StrgBTMReport(IEEE1905_TLV): name = "Steering BTM Report TLV" fields_desc = [ XByteField("type", 0x9C), XShortField("len", None), MACField("bssid", None), MACField("sta_mac", None), XByteField("btm_status", None), StrLenField("target_bssid", None, length_from=lambda p: p.len - 13), ]
class ClientAssocEvent(IEEE1905_TLV): name = "Client Association Event TLV" fields_desc = [ XByteField("type", 0x92), XShortField("len", None), MACField("mac", None), MACField("bssid", None), BitField("assoc_flag", None, 1), BitField("reserved", None, 7) ]
class SLAC_varfield(Packet): name = "SLAC_varfield" fields_desc = [ StrFixedLenField("EVID", b"\x00" * 17, 17), MACField("EVMAC", "00:00:00:00:00:00"), StrFixedLenField("EVSEID", b"\x00" * 17, 17), MACField("EVSEMAC", "00:00:00:00:00:00"), StrFixedLenField("RunID", b"\x00" * 8, 8), StrFixedLenField("RSVD", b"\x00" * 8, 8) ]
class CM_SLAC_PARM_CNF(Packet): name = "CM_SLAC_PARM_CNF" fields_desc = [ MACField("MSoundTargetMAC", "00:00:00:00:00:00"), ByteField("NumberMSounds", 0x0), ByteField("TimeOut", 0x0), ByteField("ResponseType", 0x0), MACField("ForwardingSTA", "00:00:00:00:00:00"), ByteField("ApplicationType", 0x0), ByteField("SecurityType", 0x0), StrFixedLenField("RunID", b"\x00" * 8, 8) ]
class RxLinkMetric(IEEE1905_TLV): name = "Receiver Link Metric TLV" fields_desc = [ XByteField("type", 0x0A), XShortField("len", None), MACField("local_al_mac", None), MACField("neigh_al_mac", None), FieldLenField("metric_cnt", None, fmt='B', count_of="metric_list"), PacketListField("metric_list", None, RxLinkMetric_Entry, count_from=lambda p: p.metric_cnt) ]
class SLAC_varfield_cnf(Packet): name = "SLAC_varfield" fields_desc = [ StrFixedLenField("EVID", b"\x00" * 17, 17), MACField("EVMAC", "00:00:00:00:00:00"), StrFixedLenField("EVSEID", b"\x00" * 17, 17), MACField("EVSEMAC", "00:00:00:00:00:00"), StrFixedLenField("RunID", b"\x00" * 8, 8), StrFixedLenField("RSVD", b"\x00" * 8, 8), StrFixedLenField("NetworkID", b"\x00" * 7, 7), ByteField("Reserved", 0x0), StrFixedLenField("NMK", b"\x00" * 16, 16) ]
class RxLinkMetric_Entry(Packet): name = "Entry" fields_desc = [ MACField("local_al_mac", None), MACField("neigh_al_mac", None), XShortField("media_type", None), XIntField("packet_errors", None), XIntField("rx_packets", None), XByteField("rssi", None) ] def extract_padding(self, s): return "", s
class ClientAssocCtrlRequest(IEEE1905_TLV): name = "Client Association Control Request TLV" fields_desc = [ XByteField("type", 0x9D), XShortField("len", None), MACField("bssid", None), XByteField("assoc_ctrl", 0x00), XShortField("validity_period", 0), FieldLenField("sta_cnt", None, fmt='B', count_of="sta_list"), FieldListField("sta_list", None, MACField("mac", None), count_from=lambda p: p.sta_cnt) ]
class FlowTableEntryMatchSetLyr24(Packet): fields_desc = [ MACField('smac', '00:00:00:00:00:00'), ShortField('ethertype', 0), MACField('dmac', '00:00:00:00:00:00'), BitField('first_prio', 0, 3), BitField('first_cfi', 0, 1), BitField('first_vid', 0, 12), ByteField('ip_protocol', 0), BitField('ip_dscp', 0, 6), BitField('ip_ecn', 0, 2), BitField('cvlan_tag', 0, 1), BitField('svlan_tag', 0, 1), BitField('frag', 0, 1), BitField('ip_version', 0, 4), BitField('tcp_flags', 0, 9), ShortField('tcp_sport', 0), ShortField('tcp_dport', 0), BitField('reserved1', 0, 16), BitField('ipv4_ihl', 0, 4), BitField('l3_ok', 0, 1), BitField('l4_ok', 0, 1), BitField('ipv4_checksum_ok', 0, 1), BitField('l4_checksum_ok', 0, 1), ByteField('ip_ttl_hoplimit', 0), ShortField('udp_sport', 0), ShortField('udp_dport', 0), # Ipv4 and IPv6 fields are edited manually: # Added lambda conditioning # Field names must be different ConditionalField( BitField('src_ip_mask', 0, 128), lambda pkt: pkt.ip_version != 4 and pkt.ip_version != 6), ConditionalField(BitField('reserved', 0, 96), lambda pkt: pkt.ip_version == 4), ConditionalField(IPField("src_ip4", "0.0.0.0"), lambda pkt: pkt.ip_version == 4), ConditionalField(IP6Field("src_ip6", "::"), lambda pkt: pkt.ip_version == 6), ConditionalField( BitField('dst_ip_mask', 0, 128), lambda pkt: pkt.ip_version != 4 and pkt.ip_version != 6), ConditionalField(BitField('reserved', 0, 96), lambda pkt: pkt.ip_version == 4), ConditionalField(IPField("dst_ip4", "0.0.0.0"), lambda pkt: pkt.ip_version == 4), ConditionalField(IP6Field("dst_ip6", "::"), lambda pkt: pkt.ip_version == 6), ]
class Non1905NeighDevList(IEEE1905_TLV): name = "Non-1905 Neighbor Device List TLV" fields_desc = [ XByteField("type", 0x06), XShortField("len", None), MACField("local_mac", None), FieldLenField("non1905_neigh_cnt", None, fmt='B', count_of="non1905_neigh_list"), FieldListField("non1905_neigh_list", None, MACField("mac", None), count_from=lambda p: p.non1905_neigh_cnt) ]
class Dot3(Packet): name = "802.3" fields_desc = [ DestMACField("dst"), MACField("src", ETHER_ANY), LenField("len", None, "H") ] def extract_padding(self, s): tmp_len = self.len return s[:tmp_len], s[tmp_len:] def answers(self, other): if isinstance(other, Dot3): return self.payload.answers(other.payload) return 0 def mysummary(self): return "802.3 %s > %s" % (self.src, self.dst) @classmethod def dispatch_hook(cls, _pkt=None, *args, **kargs): if _pkt and len(_pkt) >= 14: if struct.unpack("!H", _pkt[12:14])[0] > 1500: return Ether return cls
class L2NeighDevice_NeighEntry(Packet): name = "Neighbor Entry" fields_desc = [ MACField("neigh_mac", None), FieldLenField("behind_mac_cnt", None, fmt='B', count_of="behind_mac_list"), FieldListField("behind_mac_list", None, MACField("mac", None), count_from=lambda p: p.behind_mac_cnt) ] def extract_padding(self, s): return "", s
class MacBridgePortConfigurationData(EntityClass): class_id = 47 attributes = [ ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), ECA(ShortField("bridge_id_pointer", None), {AA.R, AA.W, AA.SBC}), ECA(ByteField("port_num", None), {AA.R, AA.W, AA.SBC}), ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC}, range_check=lambda x: 1 <= x <= 12), ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}), ECA(ShortField("port_priority", None), {AA.R, AA.W, AA.SBC}), ECA(ShortField("port_path_cost", None), {AA.R, AA.W, AA.SBC}), ECA(ByteField("port_spanning_tree_in", None), {AA.R, AA.W, AA.SBC}), ECA(ByteField("encapsulation_methods", None), {AA.R, AA.W, AA.SBC}, optional=True, deprecated=True), ECA(ByteField("lan_fcs_ind", None), {AA.R, AA.W, AA.SBC}, optional=True, deprecated=True), ECA(MACField("port_mac_address", None), {AA.R}, optional=True), ECA(ShortField("outbound_td_pointer", None), {AA.R, AA.W}, optional=True), ECA(ShortField("inbound_td_pointer", None), {AA.R, AA.W}, optional=True), # TODO: ECA(ByteField("mac_learning_depth", 0), {AA.R, AA.W, AA.SBC}, optional=True), ] mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} notifications = {OP.AlarmNotification}
class STAMACAddrType(IEEE1905_TLV): name = "STA MAC Address Type TLV" fields_desc = [ XByteField("type", 0x95), XShortField("len", None), MACField("mac", None) ]
class APRadioId(IEEE1905_TLV): name = "AP Radio Identifier TLV" fields_desc = [ XByteField("type", 0x82), XShortField("len", None), MACField("radio_id", None) ]
class STP(Packet): name = "Spanning Tree Protocol" fields_desc = [ShortField("proto", 0), ByteField("version", 0), ByteField("bpdutype", 0), ByteField("bpduflags", 0), ShortField("rootid", 0), MACField("rootmac", ETHER_ANY), IntField("pathcost", 0), ShortField("bridgeid", 0), MACField("bridgemac", ETHER_ANY), ShortField("portid", 0), BCDFloatField("age", 1), BCDFloatField("maxage", 20), BCDFloatField("hellotime", 2), BCDFloatField("fwddelay", 15)]
class Dot11EltMeasReport(Packet): name = "IEEE 802.11 Measurement Report Element" fields_desc = [ XByteField("id", 39), XByteField("len", None), XByteField("op_class", None), XByteField("chnl_num", None), XLongField("meas_start_time", None), XShortField("meas_duration", None), XByteField("reported_frame_info", None), XByteField("rcpi", None), XByteField("rsni", None), MACField("bssid", None), XByteField("ant_id", None), XIntField("parent_tsf", None), PacketListField("sub_elt_list", [], Dot11SubElt, length_from=lambda p: p.len - 26) ] def post_build(self, p, pay): if self.len is None: l = len(p) - 2 p = p[:1] + struct.pack("!B", l) + p[2:] return p + pay def extract_padding(self, s): return "", s