Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lambda pkt: pkt.reportType in [0x07, 0x08]),
]
@staticmethod
def get_log(pkt):
return pkt.sprintf("%UDS.service%"), repr(pkt)
bind_layers(UDS, UDS_RDTCI, service=0x19)
class UDS_RDTCIPR(Packet):
name = 'ReadDTCInformationPositiveResponse'
fields_desc = [
ByteEnumField('reportType', 0, UDS_RDTCI.reportTypes),
ConditionalField(XByteField('DTCStatusAvailabilityMask', 0),
lambda pkt: pkt.reportType in [0x01, 0x07, 0x11,
0x12, 0x02, 0x0A,
0x0B, 0x0C, 0x0D,
0x0E, 0x0F, 0x13,
0x15]),
ConditionalField(ByteEnumField('DTCFormatIdentifier', 0,
{0: 'ISO15031-6DTCFormat',
1: 'UDS-1DTCFormat',
2: 'SAEJ1939-73DTCFormat',
3: 'ISO11992-4DTCFormat'}),
lambda pkt: pkt.reportType in [0x01, 0x07,
0x11, 0x12]),
ConditionalField(ShortField('DTCCount', 0),
lambda pkt: pkt.reportType in [0x01, 0x07,
0x11, 0x12]),
ConditionalField(StrField('DTCAndStatusRecord', 0),
class ModbusPDU06WriteSingleRegisterResponse(Packet):
name = "Write Single Register Response"
fields_desc = [XByteField("funcCode", 0x06),
XShortField("registerAddr", 0x0000),
XShortField("registerValue", 0x0000)]
class ModbusPDU06WriteSingleRegisterError(Packet):
name = "Write Single Register Exception"
fields_desc = [XByteField("funcCode", 0x86),
ByteEnumField("exceptCode", 1, _modbus_exceptions)]
class ModbusPDU07ReadExceptionStatusRequest(Packet):
name = "Read Exception Status"
fields_desc = [XByteField("funcCode", 0x07)]
def extract_padding(self, s):
return b"", None
class ModbusPDU07ReadExceptionStatusResponse(Packet):
name = "Read Exception Status Response"
fields_desc = [XByteField("funcCode", 0x07),
XByteField("startAddr", 0x00)]
class ModbusPDU07ReadExceptionStatusError(Packet):
name = "Read Exception Status Exception"
fields_desc = [XByteField("funcCode", 0x87),
ByteEnumField("exceptCode", 1, _modbus_exceptions)]
lambda pkt:(0x1A5 >= pkt.__offset and 0x1A6 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("PCIClassCodeSubClass", 0x00),
lambda pkt:(0x1A6 >= pkt.__offset and 0x1A7 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("PCIRevisionID", 0x00),
lambda pkt:(0x1A7 >= pkt.__offset and 0x1A8 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XShortField("PCISubsystemID", 0x0000),
lambda pkt:(0x1A8 >= pkt.__offset and 0x1AA <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XShortField("PCISybsystemVendorID", 0x0000),
lambda pkt:(0x1AA >= pkt.__offset and 0x1AC <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(StrFixedLenField("reserved_8",
b"\x00" * 64,
64),
lambda pkt:(0x1AC >= pkt.__offset and 0x1EC <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("OverrideIGMPDefaults", 0x00),
lambda pkt:(0x1EC >= pkt.__offset and 0x1ED <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("ConfigFlags", 0x00),
lambda pkt:(0x1ED >= pkt.__offset and 0x1EE <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("NumCpToSend_PLFrames", 0x00),
lambda pkt:(0x1EE >= pkt.__offset and 0x1EF <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(StrFixedLenField("reserved_9",
b"\x00" * 29,
29),
lambda pkt:(0x1EF >= pkt.__offset and 0x20C <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("UniCastPriority", 0x00),
lambda pkt:(0x20C >= pkt.__offset and 0x20D <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("McastPriority", 0x00),
lambda pkt:(0x20D >= pkt.__offset and 0x20E <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("IGMPPriority", 0x00),
lambda pkt:(0x20E >= pkt.__offset and 0x20F <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("AVStreamPriority", 0x00),
lambda pkt:(0x20F >= pkt.__offset and 0x210 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(LEIntField("PriorityTTL_0", 0),
lambda pkt:(0x1FB2 >= pkt.__offset and 0x1FB6 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("GoodSoundCountThreshold", 0),
lambda pkt:(0x1FB6 >= pkt.__offset and 0x1FB7 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("SoundCountThreshold_GoodSoundCountPass", 0), # noqa: E501
lambda pkt:(0x1FB7 >= pkt.__offset and 0x1FB8 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("SoundCountThreshold_GoodSoundCountFail", 0), # noqa: E501
lambda pkt:(0x1FB8 >= pkt.__offset and 0x1FB9 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XShortField("reserved_21", 0),
lambda pkt:(0x1FB9 >= pkt.__offset and 0x1FBB <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("ExclusiveTxPbs_percentage", 0),
lambda pkt:(0x1FBB >= pkt.__offset and 0x1FBC <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("ExclusiveRxPbs_percentage", 0),
lambda pkt:(0x1FBC >= pkt.__offset and 0x1FBD <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("OptimizationBackwardCompatible", 0),
lambda pkt:(0x1FBD >= pkt.__offset and 0x1FBE <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("reserved_21", 0),
lambda pkt:(0x1FBE >= pkt.__offset and 0x1FBF <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("MaxPbsPerSymbol", 0),
lambda pkt:(0x1FBF >= pkt.__offset and 0x1FC0 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("MaxModulation", 0),
lambda pkt:(0x1FC0 >= pkt.__offset and 0x1FC1 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("ContinuousRx", 0),
lambda pkt:(0x1FC1 >= pkt.__offset and 0x1FC2 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(StrFixedLenField("reserved_22",
b"\x00" * 6,
6),
lambda pkt:(0x1FC2 >= pkt.__offset and 0x1FC8 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("PBControlStatus", 0),
lambda pkt:(0x1FC8 >= pkt.__offset and 0x1FC9 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("STAMembershipMaskEnabled", 0),
lambda pkt:(0x1FC9 >= pkt.__offset and 0x1FCA <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("ExitDefaultEnabled", 0),
class ONUObject(Packet):
""" Object Context: ONU Object """
name = "Object Context: ONU Object"
fields_desc = [ByteEnumField("branch", 0xD6, OamBranchEnum),
ShortEnumField("leaf", 0x0009, ObjectContextEnum),
XByteField("length", 6),
MACField("mac", "54:42:e2:22:11:00")
]
class GpioObject(Packet):
""" Object Context: GPIO Object """
name = "Object Context: GPIO Object"
fields_desc = [ByteEnumField("branch", 0xD6, OamBranchEnum),
ShortEnumField("leaf", 0x000B, ObjectContextEnum),
XByteField("length", 1),
XByteField("condition", 1)
]
####
#### 0x09 - BRANCH ATTRIBUTES
####
class PhyAdminControl(Packet):
""" Variable Descriptor: Phy Admin Control """
name = "Phy Admin Control"
fields_desc = [ByteEnumField("branch", 0x09, OamBranchEnum),
XShortField("leaf", 0x0005),
]
class PhyAdminControlEnableSet(Packet):
""" Variable Descriptor: Phy Admin Control Enable """
name = "Phy Admin Control Enable"
fields_desc = [ByteEnumField("branch", 0x09, OamBranchEnum),
lambda pkt:(0x114 >= pkt.__offset and 0x115 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("NumOfPeerNodes", 0x00),
lambda pkt:(0x115 >= pkt.__offset and 0x116 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(PacketListField("PeerNodes", "", PeerNode, length_from=lambda x: 56), # noqa: E501
lambda pkt:(0x116 >= pkt.__offset and 0x11C <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(StrFixedLenField("reserved_5",
b"\x00" * 62,
62),
lambda pkt:(0x146 >= pkt.__offset and 0x14e <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("OverideModeDefaults", 0x00),
lambda pkt:(0x18C >= pkt.__offset and 0x18D <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("DisableFlowControl", 0x00),
lambda pkt:(0x18D >= pkt.__offset and 0x18E <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("AdvertisementCapabilities", 0x00),
lambda pkt:(0x18E >= pkt.__offset and 0x18F <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("OverrideMeteringDefaults", 0x00),
lambda pkt:(0x18F >= pkt.__offset and 0x190 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(LEIntField("MaxFramesPerSec", 0),
lambda pkt:(0x190 >= pkt.__offset and 0x194 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("DisableAutoNegotiation", 0x00),
lambda pkt:(0x194 >= pkt.__offset and 0x195 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("EnetSpeedSetting", 0x00),
lambda pkt:(0x195 >= pkt.__offset and 0x196 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("EnetDuplexSetting", 0x00),
lambda pkt:(0x196 >= pkt.__offset and 0x197 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("DisableTxFlowControl", 0x00),
lambda pkt:(0x197 >= pkt.__offset and 0x198 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("DisableRxFlowControl", 0x00),
lambda pkt:(0x198 >= pkt.__offset and 0x199 <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("PhyAddressSelection", 0x00),
lambda pkt:(0x199 >= pkt.__offset and 0x19A <= pkt.__offset + pkt.__length)), # noqa: E501
ConditionalField(XByteField("PhyAddressSelection_Data", 0x00),
XByteField("length", 0x0a),
XByteField("num_queue_sets", 4),
XByteField("values", 1),
XShortField("threshold0", 0x800),
XShortField("threshold1", 0x1000),
XShortField("threshold2", 0x1800),
XShortField("threshold3", 0x2000),
]
class UnicastLogicalLinkReportThresholdsSet(Packet):
""" Variable Descriptor: Report Thresholds Unicast Logical Link Set"""
name = "Report Thresholds Unicast Logical Link Set"
fields_desc = [ByteEnumField("branch", 0xD7, OamBranchEnum),
XShortField("leaf", 0x000b),
XByteField("length", 0x0a),
XByteField("num_queue_sets", 4),
XByteField("values", 1),
XShortField("threshold0", 0x2800),
XShortField("threshold1", 0x5000),
XShortField("threshold2", 0x7800),
XShortField("threshold3", 0xa000),
]
class LogicalLinkForwarding(Packet):
""" Variable Descriptor: Logical Link Forwarding """
name = "Logical Link Forwarding"
fields_desc = [ByteEnumField("branch", 0xD7, OamBranchEnum),
XShortField("leaf", 0x000c),
]
class OamFrameRate(Packet):
""" Variable Descriptor: OAM Frame Rate """
XByteField("LLID2-numq", 1),
XByteField("l2Q0-size", 32),
XByteField("LLID3-numq", 1),
XByteField("l3Q0-size", 32),
XByteField("LLID4-numq", 1),
XByteField("l4Q0-size", 32),
XByteField("LLID5-numq", 1),
XByteField("l5Q0-size", 32),
XByteField("LLID6-numq", 1),
XByteField("l6Q0-size", 32),
XByteField("LLID7-numq", 1),
XByteField("l7Q0-size", 32),
XByteField("LLID8-numq", 1),
XByteField("l8Q0-size", 32),
XByteField("LLID9-numq", 1),
XByteField("l9Q0-size", 32),
XByteField("LLID10-numq", 1),
XByteField("l10Q0-size", 32),
XByteField("LLID11-numq", 1),
XByteField("l11Q0-size", 32),
XByteField("LLID12-numq", 1),
XByteField("l12Q0-size", 32),
XByteField("LLID13-numq", 1),
XByteField("l13Q0-size", 32),
XByteField("LLID14-numq", 1),
XByteField("l14Q0-size", 32),
XByteField("LLID15-numq", 1),
XByteField("l15Q0-size", 16),
XByteField("numPort", DFLT_NUM_UNI_PORTS),
XByteField("Port0-numq", DFLT_NUM_PORT_QUEUES),
XByteField("p0Q0-size", DFLT_LLID_QUEUE_SIZE),
]
bind_layers(CRO, ACTION_SERVICE, cmd=0x21)
# ##### DTOs ######
class DEFAULT_DTO(Packet):
fields_desc = [
StrFixedLenField('load', b'\xff' * 5, length=5),
]
class GET_CCP_VERSION_DTO(Packet):
fields_desc = [
XByteField('main_protocol_version', 0),
XByteField('release_version', 0),
StrFixedLenField('ccp_reserved', b'\x00' * 3, length=3)
]
class EXCHANGE_ID_DTO(Packet):
fields_desc = [
ByteField('slave_device_ID_length', 0),
ByteField('data_type_qualifier', 0),
ByteField('resource_availability_mask', 0),
ByteField('resource_protection_mask', 0),
StrFixedLenField('ccp_reserved', b'\xff' * 1, length=1),
]
class GET_SEED_DTO(Packet):
"""
from scapy.fields import ByteEnumField, ByteField, IPField, LongField, \
ShortField, XByteField
from scapy.packet import Packet, bind_layers, bind_bottom_up
from scapy.layers.inet import IP, UDP
class MobileIP(Packet):
name = "Mobile IP (RFC3344)"
fields_desc = [ByteEnumField("type", 1, {1: "RRQ", 3: "RRP"})]
class MobileIPRRQ(Packet):
name = "Mobile IP Registration Request (RFC3344)"
fields_desc = [XByteField("flags", 0),
ShortField("lifetime", 180),
IPField("homeaddr", "0.0.0.0"),
IPField("haaddr", "0.0.0.0"),
IPField("coaddr", "0.0.0.0"),
LongField("id", 0), ]
class MobileIPRRP(Packet):
name = "Mobile IP Registration Reply (RFC3344)"
fields_desc = [ByteField("code", 0),
ShortField("lifetime", 180),
IPField("homeaddr", "0.0.0.0"),
IPField("haaddr", "0.0.0.0"),
LongField("id", 0), ]