Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class RSVP_LabelReq(Packet):
name = "Label Req"
overload_fields = {RSVP_Object: {"Class": 0x13}}
fields_desc = [ShortField("reserve", 1),
ShortField("L3PID", 1)]
def default_payload_class(self, payload):
return RSVP_Object
class RSVP_SessionAttrb(Packet):
name = "Session_Attribute"
overload_fields = {RSVP_Object: {"Class": 0xCF}}
fields_desc = [ByteField("Setup_priority", 1),
ByteField("Hold_priority", 1),
ByteField("flags", 1),
FieldLenField("Name_length", None, length_of="Name"),
StrLenField("Name", "", length_from=lambda pkt:pkt.Name_length), # noqa: E501
]
def default_payload_class(self, payload):
return RSVP_Object
bind_layers(IP, RSVP, {"proto": 46})
bind_layers(RSVP, RSVP_Object)
SignedIntField("request_id", -1),
ByteField("retcode", 0x0a),
ByteField("sender_id", 0),
ByteField("action_type", 0),
IntField("req_info", 0),
SignedIntField("tid", -1),
SignedShortField("uid", -1),
ByteField("mode", 0xff),
SignedIntField("wp_id", -1),
SignedIntField("wp_ca_blk", -1),
SignedIntField("appc_ca_blk", -1),
LenField("length", None, fmt="
IntField("timereceived", 0),
IntField("timetosend", 0),
IntField("timereachable", 0),
IntField("sent", 0),
IntField("unused1", 0),
IntField("processed", 0),
IntField("unused2", 0),
IntField("badauth", 0),
IntField("bogusorg", 0),
IntField("oldpkt", 0),
IntField("unused3", 0),
IntField("unused4", 0),
IntField("seldisp", 0),
IntField("selbroken", 0),
IntField("unused5", 0),
ByteField("candidate", 0),
ByteField("unused6", 0),
ByteField("unused7", 0),
ByteField("unused8", 0),
IntField("v6_flag", 0),
IntField("unused9", 0),
IP6Field("dstaddr6", "::"),
IP6Field("srcaddr6", "::"),
]
class NTPInfoLoop(Packet):
"""
Loop filter variables.
"""
name = "info_loop"
IntField("compliance", 0),
IntField("watchdog_timer", 0)
]
class NTPInfoSys(Packet):
"""
System info. Mostly the sys.* variables, plus a few unique to
the implementation.
"""
name = "info_sys"
fields_desc = [
IPField("peer", "0.0.0.0"),
ByteField("peer_mode", 0),
ByteField("leap", 0),
ByteField("stratum", 0),
ByteField("precision", 0),
FixedPointField("rootdelay", 0, size=32, frac_bits=16),
FixedPointField("rootdispersion", 0, size=32, frac_bits=16),
IPField("refid", 0),
TimeStampField("reftime", 0),
IntField("poll", 0),
FlagsField("flags", 0, 8, _sys_info_flags),
ByteField("unused1", 0),
ByteField("unused2", 0),
ByteField("unused3", 0),
FixedPointField("bdelay", 0, size=32, frac_bits=16),
FixedPointField("frequency", 0, size=32, frac_bits=16),
TimeStampField("authdelay", 0),
FixedPointField("stability", 0, size=32, frac_bits=16),
IntField("v6_flag", 0),
def mysummary(self):
if isinstance(self.underlayer, Ether):
return self.underlayer.sprintf("802.1q %Ether.src% > %Ether.dst% (%Dot1Q.type%) vlan %Dot1Q.vlan%") # noqa: E501
else:
return self.sprintf("802.1q (%Dot1Q.type%) vlan %Dot1Q.vlan%")
conf.neighbor.register_l3(Ether, Dot1Q, l2_register_l3)
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 ARP(Packet):
name = "ARP"
fields_desc = [
ConditionalField(XBitField("spare", 0x000, 3),
lambda pkt: pkt.length > 3),
ConditionalField(XBitField("mean_troughput", 0x00000, 5),
lambda pkt: pkt.length > 3),
ConditionalField(XBitField("traffic_class", 0x000, 3),
lambda pkt: pkt.length > 4),
ConditionalField(XBitField("delivery_order", 0x00, 2),
lambda pkt: pkt.length > 4),
ConditionalField(XBitField("delivery_of_err_sdu", 0x000, 3),
lambda pkt: pkt.length > 4),
ConditionalField(ByteField("max_sdu_size", None),
lambda pkt: pkt.length > 5),
ConditionalField(ByteField("max_bitrate_up", None),
lambda pkt: pkt.length > 6),
ConditionalField(ByteField("max_bitrate_down", None),
lambda pkt: pkt.length > 7),
ConditionalField(XBitField("redidual_ber", 0x0000, 4),
lambda pkt: pkt.length > 8),
ConditionalField(XBitField("sdu_err_ratio", 0x0000, 4),
lambda pkt: pkt.length > 8),
ConditionalField(XBitField("transfer_delay", 0x00000, 6),
lambda pkt: pkt.length > 9),
ConditionalField(XBitField("traffic_handling_prio",
0x000,
2),
lambda pkt: pkt.length > 9),
ConditionalField(ByteField("guaranteed_bit_rate_up", None),
ShortField("PartialAID", 0),
lambda pkt: pkt.present and pkt.present.VHT),
# timestamp
ConditionalField(
_RadiotapReversePadField(
LELongField("timestamp", 0)
),
lambda pkt: pkt.present and pkt.present.timestamp),
ConditionalField(
LEShortField("ts_accuracy", 0),
lambda pkt: pkt.present and pkt.present.timestamp),
ConditionalField(
ByteField("ts_position", 0),
lambda pkt: pkt.present and pkt.present.timestamp),
ConditionalField(
ByteField("ts_flags", 0),
lambda pkt: pkt.present and pkt.present.timestamp),
# HE - XXX not complete
ConditionalField(
_RadiotapReversePadField(
ShortField("he_data1", 0)
),
lambda pkt: pkt.present and pkt.present.HE),
ConditionalField(
ShortField("he_data2", 0),
lambda pkt: pkt.present and pkt.present.HE),
ConditionalField(
ShortField("he_data3", 0),
lambda pkt: pkt.present and pkt.present.HE),
ConditionalField(
ShortField("he_data4", 0),
lambda pkt: pkt.present and pkt.present.HE),
class SAPMS(Packet):
"""SAP Message Server packet
This packet is used for the Message Server protocol.
"""
name = "SAP Message Server"
fields_desc = [
StrFixedLenField("eyecatcher", "**MESSAGE**\x00", 12),
ByteField("version", 0x04),
ByteEnumKeysField("errorno", 0x00, ms_errorno_values),
StrFixedLenField("toname", "-" + " " * 39, 40),
FlagsField("msgtype", 0, 8, ["DIA", "UPD", "ENQ", "BTC", "SPO", "UP2", "ATP", "ICM"]),
ByteField("reserved", 0x00),
ByteEnumKeysField("domain", 0x00, ms_domain_values),
ByteField("reserved", 0x00),
StrFixedLenField("key", "\x00" * 8, 8),
ByteEnumKeysField("flag", 0x01, ms_flag_values),
ByteEnumKeysField("iflag", 0x01, ms_iflag_values),
StrFixedLenField("fromname", "-" + " " * 39, 40),
ConditionalField(ShortField("diag_port", 3200), lambda pkt:pkt.iflag == 0x08 and pkt.flag == 0x02), # for MS_REQUEST+MS_LOGIN_2 it's the diag port
ConditionalField(ShortField("padd", 0x0000), lambda pkt:pkt.iflag != 0x08 or pkt.flag != 0x02),
# OpCode fields
ConditionalField(ByteEnumKeysField("opcode", 0x01, ms_opcode_values), lambda pkt:pkt.iflag in [0x00, 0x01, 0x02, 0x07]), # extending all those fields with MS_SEND_TYPE and MS_SEND_TYPE_ONCE packets
ConditionalField(ByteEnumKeysField("opcode_error", 0x00, ms_opcode_error_values), lambda pkt:pkt.iflag in [0x00, 0x01, 0x02, 0x7]),
ConditionalField(ByteField("opcode_version", 0x01), lambda pkt:pkt.iflag in [0x00, 0x01, 0x02, 0x07]),
ConditionalField(ByteField("opcode_charset", 0x03), lambda pkt:pkt.iflag in [0x00, 0x01, 0x02, 0x07]),
ConditionalField(StrField("opcode_value", ""), lambda pkt:pkt.iflag in [0x00, 0x01] and pkt.opcode not in [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x11, 0x1c, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2f, 0x43, 0x44, 0x45, 0x46, 0x47, 0x4a]),
ConditionalField(StrField("opcode_trailer", ""), lambda pkt:pkt.iflag in [0x00, 0x01] and pkt.opcode not in [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x11, 0x1c, 0x1e, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2f, 0x43, 0x44, 0x45, 0x46, 0x47, 0x4a]),
# Dispatcher info
BitField("flag_TERM_VKEY", 0, 1), # 10
BitField("flag_TERM_SEP", 0, 1), # 8
BitField("flag_TERM_MEN", 0, 1), # 4
BitField("flag_TERM_SEL", 0, 1), # 2
BitField("flag_TERM_??1", 0, 1), # 1
ByteField("virtual_key", 0),
ByteField("return_code_1", 0),
ByteField("return_code_2", 0),
ByteField("return_code_3", 0),
ByteField("return_code_4", 0),
ByteField("return_code_5", 0),
ByteField("return_code_6", 0),
ByteField("function_code_1", 0),
ByteField("function_code_2", 0),
ByteField("function_code_3", 0),
ByteField("function_code_4", 0),
ByteField("function_code_5", 0),
ByteField("function_code_6", 0),
StrNullField("text", ""),
StrNullField("accelerator", ""),
StrNullField("info", ""),
]
# Diag Menu Entries Container
class SAPDiagMenuEntries(Packet):
name = "SAP Diag Menu Entries"
fields_desc = [
PacketListField("entries", None, SAPDiagMenuEntry)
]
bind_diagitem(SAPDiagMenuEntries, "APPL", 0x0b, 0x01)
def __init__(self, name, default):
Field.__init__(self, name, default, "!I")
def addfield(self, pkt, s, val):
return s + struct.pack(self.fmt, self.i2m(pkt, val))[1:4]
def getfield(self, pkt, s):
return s[3:], self.m2i(pkt, struct.unpack(self.fmt, b"\x00" + s[:3])[0]) # noqa: E501
class X3BytesField(ThreeBytesField, XByteField):
def i2repr(self, pkt, x):
return XByteField.i2repr(self, pkt, x)
class LEThreeBytesField(ByteField):
def __init__(self, name, default):
Field.__init__(self, name, default, "