Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class SCTPChunkParamHearbeatInfo(_SCTPChunkParam, Packet):
fields_desc = [ShortEnumField("type", 1, sctpchunkparamtypes),
FieldLenField("len", None, length_of="data",
adjust=lambda pkt, x:x + 4),
PadField(StrLenField("data", "",
length_from=lambda pkt: pkt.len - 4),
4, padwith=b"\x00"), ]
class SCTPChunkParamIPv4Addr(_SCTPChunkParam, Packet):
fields_desc = [ShortEnumField("type", 5, sctpchunkparamtypes),
ShortField("len", 8),
IPField("addr", "127.0.0.1"), ]
class SCTPChunkParamIPv6Addr(_SCTPChunkParam, Packet):
fields_desc = [ShortEnumField("type", 6, sctpchunkparamtypes),
ShortField("len", 20),
IP6Field("addr", "::1"), ]
class SCTPChunkParamStateCookie(_SCTPChunkParam, Packet):
fields_desc = [ShortEnumField("type", 7, sctpchunkparamtypes),
FieldLenField("len", None, length_of="cookie",
adjust=lambda pkt, x:x + 4),
PadField(StrLenField("cookie", "",
length_from=lambda pkt: pkt.len - 4),
4, padwith=b"\x00"), ]
class SCTPChunkParamUnrocognizedParam(_SCTPChunkParam, Packet):
fields_desc = [ShortEnumField("type", 8, sctpchunkparamtypes),
fields_desc = []
class ResetDeviceConfirmation(Packet):
name = "ResetDeviceConfirmation"
fields_desc = [ByteEnumField("Status", 0x00, ResetDeviceCodes)]
######################################################################
# Read Configuration Block
######################################################################
ReadConfBlockCodes = {0x00: "Success"}
class ReadConfBlockRequest(Packet):
name = "ReadConfBlockRequest"
fields_desc = []
CBImgTCodes = {0x00: "Generic Image",
0x01: "Synopsis configuration",
0x02: "Denali configuration",
0x03: "Denali applet",
0x04: "Runtime firmware",
0x05: "OAS client",
0x06: "Custom image",
0x07: "Memory control applet",
0x08: "Power management applet",
0x09: "OAS client IP stack",
0x0A: "OAS client TR069",
0x0B: "SoftLoader",
class L2CAP_ConnResp(Packet):
name = "L2CAP Conn Resp"
fields_desc = [LEShortField("dcid", 0),
LEShortField("scid", 0),
LEShortEnumField("result", 0, ["success", "pend", "cr_bad_psm", "cr_sec_block", "cr_no_mem", "reserved", "cr_inval_scid", "cr_scid_in_use"]), # noqa: E501
LEShortEnumField("status", 0, ["no_info", "authen_pend", "author_pend", "reserved"]), # noqa: E501
]
def answers(self, other):
# dcid Resp == scid Req. Therefore compare SCIDs
return isinstance(other, L2CAP_ConnReq) and self.scid == other.scid
class L2CAP_CmdRej(Packet):
name = "L2CAP Command Rej"
fields_desc = [LEShortField("reason", 0),
]
class L2CAP_ConfReq(Packet):
name = "L2CAP Conf Req"
fields_desc = [LEShortField("dcid", 0),
LEShortField("flags", 0),
]
class L2CAP_ConfResp(Packet):
name = "L2CAP Conf Resp"
fields_desc = [LEShortField("scid", 0),
LEShortField("flags", 0),
class _LLAddrField(MACField):
pass
# XXX We only support Ethernet addresses at the moment. _LLAddrField
# will be modified when needed. Ask us. --arno
class DUID_LLT(Packet): # sect 9.2 RFC 3315
name = "DUID - Link-layer address plus time"
fields_desc = [ShortEnumField("type", 1, duidtypes),
XShortEnumField("hwtype", 1, duidhwtypes),
_UTCTimeField("timeval", 0), # i.e. 01 Jan 2000
_LLAddrField("lladdr", ETHER_ANY)]
class DUID_EN(Packet): # sect 9.3 RFC 3315
name = "DUID - Assigned by Vendor Based on Enterprise Number"
fields_desc = [ShortEnumField("type", 2, duidtypes),
IntEnumField("enterprisenum", 311, IANA_ENTERPRISE_NUMBERS),
StrField("id", "")]
class DUID_LL(Packet): # sect 9.4 RFC 3315
name = "DUID - Based on Link-layer Address"
fields_desc = [ShortEnumField("type", 3, duidtypes),
XShortEnumField("hwtype", 1, duidhwtypes),
_LLAddrField("lladdr", ETHER_ANY)]
class DUID_UUID(Packet): # RFC 6355
name = "DUID - Based on UUID"
fields_desc = [ShortEnumField("type", 4, duidtypes),
return Packet.guess_payload_class(self, raw_bytes)
class TLSExtPadding(PacketNoPayload):
name = "TLS Extension Padding"
fields_desc = [StrField("padding", b"\x00" * 16)]
class TLSExtPSKKeyExchangeModes(PacketNoPayload):
name = "TLS Extension PSK Key Exchange Mode"
fields_desc = [XFieldLenField("length", None, length_of="ke_modes", fmt="B"),
ReprFieldListField("ke_modes", [TLSPSKKeyExchangeMode.PSK_DHE_KE], ByteEnumField("ke_mode", None, TLS_PSK_KEY_EXCHANGE_MODE),
length_from=lambda x: x.length)]
class TLSHelloRequest(Packet):
name = "TLS Hello Request"
fields_desc = []
class TLSHelloRetryRequest(Packet):
name = "TLS Hello Retry Request"
fields_desc = [XShortEnumField("version", TLSVersion.TLS_1_3, TLS_VERSIONS),
XFieldLenField("length", None, length_of="extensions", fmt="H"),
TypedPacketListField("extensions", None, TLSExtension, length_from=lambda x:x.length, type_="TLSHelloRetryRequest")]
class TLSEncryptedExtensions(PacketNoPayload):
name = "TLS Encrypted Extensions"
fields_desc = [XFieldLenField("length", None, length_of="extensions", fmt="H"),
TypedPacketListField("extensions", None, TLSExtension, length_from=lambda x:x.length, type_="TLSEncryptedExtensions")]
def mysummary(self):
cs = conf.raw_summary
if cs:
if callable(cs):
return "Raw %s" % cs(self.load)
else:
return "Raw %r" % self.load
return Packet.mysummary(self)
bind_layers(CRO, BUILD_CHKSUM, cmd=0x0E)
class CLEAR_MEMORY(Packet):
fields_desc = [
IntField('size', 0),
StrFixedLenField('ccp_reserved', b'\xff' * 2, length=2)
]
bind_layers(CRO, CLEAR_MEMORY, cmd=0x10)
class PROGRAM(Packet):
fields_desc = [
XByteField('size', 0),
StrFixedLenField('data', b'\x00' * 0,
length_from=lambda pkt: pkt.size),
StrFixedLenField('ccp_reserved', b'\xff' * 5,
length_from=lambda pkt: 5 - pkt.size)
]
bind_layers(CRO, PROGRAM, cmd=0x18)
class PROGRAM_6(Packet):
fields_desc = [
StrFixedLenField('data', b'\x00' * 6, length=6)
]
XLEIntField("sec_framecounter", 0x00000000), # 4 octets
# Key Identifier (variable length): identifies the key that is used for cryptographic protection # noqa: E501
# Key Source : length of sec_keyid_keysource varies btwn 0, 4, and 8 bytes depending on sec_sc_keyidmode # noqa: E501
# 4 octets when sec_sc_keyidmode == 2
ConditionalField(XLEIntField("sec_keyid_keysource", 0x00000000),
lambda pkt: pkt.getfieldval("sec_sc_keyidmode") == 2),
# 8 octets when sec_sc_keyidmode == 3
ConditionalField(LELongField("sec_keyid_keysource", 0x0000000000000000), # noqa: E501
lambda pkt: pkt.getfieldval("sec_sc_keyidmode") == 3),
# Key Index (1 octet): allows unique identification of different keys with the same originator # noqa: E501
ConditionalField(XByteField("sec_keyid_keyindex", 0xFF),
lambda pkt: pkt.getfieldval("sec_sc_keyidmode") != 0),
]
class Dot15d4Data(Packet):
name = "802.15.4 Data"
fields_desc = [
XLEShortField("dest_panid", 0xFFFF),
dot15d4AddressField("dest_addr", 0xFFFF, length_of="fcf_destaddrmode"),
ConditionalField(XLEShortField("src_panid", 0x0),
lambda pkt:util_srcpanid_present(pkt)),
ConditionalField(dot15d4AddressField("src_addr", None, length_of="fcf_srcaddrmode"), # noqa: E501
lambda pkt:pkt.underlayer.getfieldval("fcf_srcaddrmode") != 0), # noqa: E501
# Security field present if fcf_security == True
ConditionalField(PacketField("aux_sec_header", Dot15d4AuxSecurityHeader(), Dot15d4AuxSecurityHeader), # noqa: E501
lambda pkt:pkt.underlayer.getfieldval("fcf_security") is True), # noqa: E501
]
def guess_payload_class(self, payload):
# TODO: See how it's done in wireshark:
# https://github.com/wireshark/wireshark/blob/93c60b3b7c801dddd11d8c7f2a0ea4b7d02d700a/epan/dissectors/packet-ieee802154.c#L2061 # noqa: E501
fields_desc = [XByteField("branch", 0xD7),
XShortField("leaf", 0x0502),
XByteField("length", 6),
XByteField("fieldcode", 0x1a),
XByteField("layerselect", 8),
XByteField("dwordoffset", 0),
XByteField("lsb", 0x18),
XByteField("width", 0x8),
XByteField("numclauses", 0),
]
####
#### 0xD9 - Port Ingress Rules
####
class ClearPortIngressRules(Packet):
""" Variable Descriptor: Clear Port Ingress Rule """
name = "Variable Descriptor: Clear Port Ingress Rule"
fields_desc = [XByteField("branch", 0xD9),
XShortField("leaf", 0x0501),
XByteField("length", 1),
XByteField("value", 0),
]
class AddPortIngressRule(Packet):
""" Variable Descriptor: Add Port Ingress Rule """
name = "Variable Descriptor: Add Port Ingress Rule"
fields_desc = [XByteField("branch", 0xD9),
XShortField("leaf", 0x0502),
XByteField("length", 0x80),
XByteField("value", 0),
]
class ModbusPDU05WriteSingleCoilError(Packet):
name = "Write Single Coil Exception"
fields_desc = [XByteField("funcCode", 0x85),
ByteEnumField("exceptCode", 1, _modbus_exceptions)]
class ModbusPDU06WriteSingleRegisterRequest(_ModbusPDUNoPayload):
name = "Write Single Register"
fields_desc = [XByteField("funcCode", 0x06),
XShortField("registerAddr", 0x0000),
XShortField("registerValue", 0x0000)]
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(_ModbusPDUNoPayload):
name = "Read Exception Status"
fields_desc = [XByteField("funcCode", 0x07)]