class Fattr3(Packet): name = 'File Attributes' fields_desc = [ IntEnumField('type', 0, ftype3), OIntField('mode', 0), IntField('nlink', 0), IntField('uid', 0), IntField('gid', 0), LongField('size', 0), LongField('used', 0), FieldListField('rdev', [0, 0], IntField('', None), count_from=lambda x: 2), XLongField('fsid', 0), XLongField('fileid', 0), IntField('atime_s', 0), IntField('atime_ns', 0), IntField('mtime_s', 0), IntField('mtime_ns', 0), IntField('ctime_s', 0), IntField('ctime_ns', 0) ] def extract_padding(self, s): return '', s
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
class READDIR_Reply(Packet): name = 'READDIR Reply' fields_desc = [ IntEnumField('status', 0, nfsstat3), IntField('attributes_follow', 0), ConditionalField( PacketField('attributes', Fattr3(), Fattr3), lambda pkt: pkt.attributes_follow == 1 ), ConditionalField( XLongField('verifier', 0), lambda pkt: pkt.status == 0 ), ConditionalField( IntField('value_follows', 0), lambda pkt: pkt.status == 0 ), ConditionalField( PacketListField( 'files', None, File_From_Dir, next_cls_cb=lambda pkt, lst, cur, remain: File_From_Dir if pkt.value_follows == 1 and (len(lst) == 0 or cur.value_follows == 1) and len(remain) > 4 else None ), lambda pkt: pkt.status == 0), ConditionalField(IntField('eof', 0), lambda pkt: pkt.status == 0) ]
class READDIR_Call(Packet): name = 'READDIR Call' fields_desc = [ PacketField('filehandle', File_Object(), File_Object), LongField('cookie', 0), XLongField('verifier', 0), IntField('count', 0) ]
class LoWPANMesh(Packet): name = "6LoWPAN Mesh Packet" deprecated_fields = { "_v": ("v", "2.4.4"), "_f": ("f", "2.4.4"), "_sourceAddr": ("src", "2.4.4"), "_destinyAddr": ("dst", "2.4.4"), } fields_desc = [ BitField("reserved", 0x2, 2), BitEnumField("v", 0x0, 1, ["EUI-64", "Short"]), BitEnumField("f", 0x0, 1, ["EUI-64", "Short"]), BitField("hopsLeft", 0x0, 4), MultipleTypeField([(XShortField("src", 0x0), lambda pkt: pkt.v == 1)], XLongField("src", 0x0)), MultipleTypeField([(XShortField("dst", 0x0), lambda pkt: pkt.v == 1)], XLongField("dst", 0x0)) ]
class RTPSSubMessage_HEARTBEAT(EPacket): """ 0...2...........7...............15.............23...............31 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HEARTBEAT | flags | octetsToNextHeader | +---------------+---------------+---------------+---------------+ | EntityId readerEntityId | +---------------+---------------+---------------+---------------+ | EntityId writerEntityId | +---------------+---------------+---------------+---------------+ | | + SequenceNumber firstAvailableSeqNumber + | | +---------------+---------------+---------------+---------------+ | | + SequenceNumber lastSeqNumber + | | +---------------+---------------+---------------+---------------+ | Counter count | +---------------+---------------+---------------+---------------+ """ name = "RTPS HEARTBEAT (0x07)" fields_desc = [ XByteField("submessageId", 0x07), XByteField("submessageFlags", 0), EField(ShortField("octetsToNextHeader", 0)), EnumField( "reader_id", default=b"\x00\x00\x00\x00", fmt="4s", enum=_rtps_reserved_entity_ids, ), EnumField( "writer_id", default=b"\x00\x00\x00\x00", fmt="4s", enum=_rtps_reserved_entity_ids, ), XLongField("firstAvailableSeqNum", 0), XLongField("lastSeqNum", 0), EField(IntField("count", 0)), ]
class SMB2_Negociate_Protocol_Response_Header(Packet): name = "SMB2 Negociate Protocol Response Header" fields_desc = [ XLEShortField("StructureSize", 0), FlagsField("SecurityMode", 0, 16, { 0x7: "Signing Required", 0x8: "Signing Enabled", }), LEShortEnumField("Dialect", 0x0, SMB_DIALECTS), FieldLenField( "NegociateCount", 0x0, fmt="<H", count_of="NegociateContexts" ), UUIDField("ServerGUID", 0x0, uuid_fmt=UUIDField.FORMAT_LE), # Capabilities FlagsField("Capabilities", 0, 32, SMB2_CAPABILITIES), LEIntField("MaxTransactionSize", 0), LEIntField("MaxReadSize", 0), LEIntField("MaxWriteSize", 0), # TODO FIXME XLongField("SystemTime", 0), XLongField("ServerStartTime", 0), XLEShortField("SecurityBufferOffset", 0), FieldLenField( "SecurityBufferLength", 0, fmt="<H", length_of="SecurityBuffer" ), XLEIntField("NegociateContextOffset", 0), # TODO FIXME XStrLenField( "SecurityBuffer", None, length_from=lambda pkt: pkt.SecurityBufferLength ), PacketListField( "NegociateContexts", [], SMB2_Negociate_Context, count_from=lambda pkt: pkt.NegociateCount ), ]
class COMMIT_Reply(Packet): name = 'COMMIT Reply' fields_desc = [ IntEnumField('status', 0, nfsstat3), IntField('af_before', 0), ConditionalField( PacketField('attributes_before', WCC_Attr(), WCC_Attr), lambda pkt: pkt.af_before == 1), IntField('af_after', 0), ConditionalField(PacketField('attributes_after', Fattr3(), Fattr3), lambda pkt: pkt.af_after == 1), ConditionalField(XLongField('verifier', 0), lambda pkt: pkt.status == 0) ]
class OSPF_Hdr(Packet): name = "OSPF Header" fields_desc = [ ByteField("version", 2), ByteEnumField("type", 1, _OSPF_types), _NoLLSLenField("len", None, adjust=lambda x: x + 24), IPField("src", "1.1.1.1"), IPField("area", "0.0.0.0"), # default: backbone XShortField("chksum", None), ShortEnumField("authtype", 0, { 0: "Null", 1: "Simple", 2: "Crypto" }), # Null or Simple Authentication ConditionalField(XLongField("authdata", 0), lambda pkt: pkt.authtype != 2), # noqa: E501 # Crypto Authentication ConditionalField(XShortField("reserved", 0), lambda pkt: pkt.authtype == 2), # noqa: E501 ConditionalField(ByteField("keyid", 1), lambda pkt: pkt.authtype == 2), ConditionalField(ByteField("authdatalen", 0), lambda pkt: pkt.authtype == 2), # noqa: E501 ConditionalField(XIntField("seq", 0), lambda pkt: pkt.authtype == 2), # TODO: Support authdata (which is appended to the packets as if it were padding) # noqa: E501 ] def post_build(self, p, pay): # See <http://tools.ietf.org/html/rfc5613> p += pay if self.chksum is None: if self.authtype == 2: ck = 0 # Crypto, see RFC 2328, D.4.3 else: # Checksum is calculated without authentication data # Algorithm is the same as in IP() ck = checksum(p[:16] + p[24:]) p = p[:12] + struct.pack("!H", ck) + p[14:] # TODO: Handle Crypto: Add message digest (RFC 2328, D.4.3) return p def hashret(self): return struct.pack("H", self.area) + self.payload.hashret() def answers(self, other): if (isinstance(other, OSPF_Hdr) and self.area == other.area and self.type == 5): # Only acknowledgements answer other packets return self.payload.answers(other.payload) return 0
class CREATE_Call(Packet): name = 'CREATE Call' fields_desc = [ PacketField('dir', File_Object(), File_Object), PacketField('filename', Object_Name(), Object_Name), IntEnumField('create_mode', None, { 0: 'UNCHECKED', 1: 'GUARDED', 2: 'EXCLUSIVE' }), ConditionalField(PacketField('attributes', Sattr3(), Sattr3), lambda pkt: pkt.create_mode != 2), ConditionalField(XLongField('verifier', 0), lambda pkt: pkt.create_mode == 2) ]
class PortIngressRuleResultOLTBroadcastQueue(Packet): """ Variable Descriptor: Port Ingress Rule Result OLT Broadcast Queue """ name = "Variable Descriptor: Port Ingress Rule Result OLT Broadcast Queue" fields_desc = [ XByteField("branch", 0xD7), XShortField("leaf", 0x0501), ByteField("length", 15), XByteField("result", 3), XByteField("oltqueuerule", 0x13), XShortField("objecttype", 0x0001), XByteField("instance", 0), XByteField("pon", 0), XLongField("broadcast", 0xffffffffffff0000), XByteField("pad", 0), ]
class WRITE_Reply(Packet): name = 'WRITE Reply' fields_desc = [ IntEnumField('status', 0, nfsstat3), IntField('af_before', 0), ConditionalField( PacketField('attributes_before', WCC_Attr(), WCC_Attr), lambda pkt: pkt.af_before == 1), IntField('af_after', 0), ConditionalField(PacketField('attributes_after', Fattr3(), Fattr3), lambda pkt: pkt.af_after == 1), ConditionalField(IntField('count', 0), lambda pkt: pkt.status == 0), ConditionalField( IntEnumField('committed', 0, { 0: 'UNSTABLE', 1: 'STABLE' }), lambda pkt: pkt.status == 0), ConditionalField(XLongField('verifier', 0), lambda pkt: pkt.status == 0) ]
class CNPPadding(Packet): name = "CNPPadding" fields_desc = [ XLongField("reserved1", 0), XLongField("reserved2", 0), ]