Exemplo n.º 1
0
class OFPTableStats(Packet):

    def extract_padding(self, s):
        return b"", s

    name = "OFP_TABLE_STATS"
    fields_desc = [ByteField("table_id", 0),
                   X3BytesField("pad", 0),
                   StrFixedLenField("name", "", 32),
                   FlagsField("wildcards1", 0x003, 12, ["DL_VLAN_PCP",
                                                        "NW_TOS"]),
                   BitField("nw_dst_mask", 63, 6),        # 32 would be enough
                   BitField("nw_src_mask", 63, 6),
                   FlagsField("wildcards2", 0xff, 8, ["IN_PORT",
                                                      "DL_VLAN",
                                                      "DL_SRC",
                                                      "DL_DST",
                                                      "DL_TYPE",
                                                      "NW_PROTO",
                                                      "TP_SRC",
                                                      "TP_DST"]),
                   IntField("max_entries", 0),
                   IntField("active_count", 0),
                   LongField("lookup_count", 0),
                   LongField("matched_count", 0)]
Exemplo n.º 2
0
class SAPHDBSegment(PacketNoPadded):
    """SAP HANA SQL Command Network Protocol Segment

    This packet represents a segment within a HDB packet.

    The segment header is comprised of 24 byte, being the first 13 bytes always the same fields and the remaining 11
    bytes depend on the segment kind field.
    """
    name = "SAP HANA SQL Command Network Protocol Segment"
    fields_desc = [
        # Segment length needs to be calculated counting the segment header
        FieldLenField("segmentlength", None, length_of="parts", fmt="<i", adjust=lambda x, l:l+24),
        LESignedIntField("segmentofs", 0),
        FieldLenField("noofparts", None, count_of="parts", fmt="<h"),
        LESignedShortField("segmentno", 1),
        EnumField("segmentkind", 1, hdb_segmentkind_values, fmt="<b"),
        ConditionalField(EnumField("messagetype", 0, hdb_message_type_values, fmt="<b"), hdb_segment_is_request),
        ConditionalField(LESignedByteField("commit", 0), hdb_segment_is_request),
        ConditionalField(LESignedByteField("commandoptions", 0), hdb_segment_is_request),
        ConditionalField(LongField("reserved1", 0), hdb_segment_is_request),
        ConditionalField(ByteField("reserved2", 0), hdb_segment_is_reply),
        ConditionalField(EnumField("functioncode", 0, hdb_function_code_values, fmt="<h"), hdb_segment_is_reply),
        ConditionalField(LongField("reserved3", 0), hdb_segment_is_reply),
        ConditionalField(StrFixedLenField("reserved4", None, 11), lambda pkt: not (hdb_segment_is_reply(pkt) or hdb_segment_is_request(pkt))),
        PacketListField("parts", None, SAPHDBPart, count_from=lambda x: x.noofparts),
    ]
Exemplo n.º 3
0
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
Exemplo n.º 4
0
class OFPFlowStats(Packet):
    name = "OFP_FLOW_STATS"
    fields_desc = [
        ShortField("length", None),
        ByteField("table_id", 0),
        XByteField("pad1", 0),
        PacketField("match", OFPMatch(), OFPMatch),
        IntField("duration_sec", 0),
        IntField("duration_nsec", 0),
        ShortField("priority", 0),
        ShortField("idle_timeout", 0),
        ShortField("hard_timeout", 0),
        XBitField("pad2", 0, 48),
        LongField("cookie", 0),
        LongField("packet_count", 0),
        LongField("byte_count", 0),
        PacketListField("actions", [],
                        OFPAT,
                        ofp_action_cls,
                        length_from=lambda pkt: pkt.length - 88)
    ]

    def post_build(self, p, pay):
        if self.length is None:
            tmp_len = len(p) + len(pay)
            p = struct.pack("!H", tmp_len) + p[2:]
        return p + pay

    def extract_padding(self, s):
        return b"", s
Exemplo n.º 5
0
class OFPFlowStats(Packet):
    def post_build(self, p, pay):
        if self.length is None:
            l = len(p) + len(pay)
            p = struct.pack("!H", l) + p[2:]
        return p + pay

    name = "OFP_FLOW_STATS"
    fields_desc = [
        ShortField("length", None),
        ByteField("table_id", 0),
        XByteField("pad1", 0),
        PacketField("match", OFPMatch(), OFPMatch),
        IntField("duration_sec", 0),
        IntField("duration_nsec", 0),
        ShortField("priority", 0),
        ShortField("idle_timeout", 0),
        ShortField("hard_timeout", 0),
        XBitField("pad2", 0, 48),
        LongField("cookie", 0),
        LongField("packet_count", 0),
        LongField("byte_count", 0),
        ActionPacketListField("actions", [],
                              Packet,
                              length_from=lambda pkt: pkt.length - 88)
    ]  # noqa: E501
Exemplo n.º 6
0
class READDIRPLUS_Call(Packet):
    name = 'READDIRPLUS Call'
    fields_desc = [
        PacketField('filehandle', File_Object(), File_Object),
        LongField('cookie', 0),
        LongField('verifier', 0),
        IntField('dircount', 512),
        IntField('maxcount', 4096)
    ]
Exemplo n.º 7
0
class UNLOCK_Call(Packet):
    name = 'UNLOCK Call'
    fields_desc = [
        PacketField('cookie', NLM4_Cookie(), NLM4_Cookie),
        PacketField('caller', Object_Name(), Object_Name),
        PacketField('filehandle', File_Object(), File_Object),
        PacketField('owner', Object_Name(), Object_Name),
        IntField('svid', 0),
        LongField('l_offset', 0),
        LongField('l_len', 0)
    ]
Exemplo n.º 8
0
class File_From_Dir(Packet):
    name = 'File'
    fields_desc = [
        LongField('fileid', 0),
        PacketField('filename', Object_Name(), Object_Name),
        LongField('cookie', 0),
        IntField('value_follows', 0)
    ]

    def extract_padding(self, s):
        return '', s
Exemplo n.º 9
0
class OFPTStatsReplyAggregate(_ofp_header):
    name = "OFPST_STATS_REPLY_AGGREGATE"
    fields_desc = [ByteEnumField("version", 0x01, ofp_version),
                   ByteEnumField("type", 17, ofp_type),
                   ShortField("len", None),
                   IntField("xid", 0),
                   ShortEnumField("stats_type", 2, ofp_stats_types),
                   FlagsField("flags", 0, 16, []),
                   LongField("packet_count", 0),
                   LongField("byte_count", 0),
                   IntField("flow_count", 0),
                   XIntField("pad", 0)]
Exemplo n.º 10
0
class TEST_Call(Packet):
    name = 'TEST Call'
    fields_desc = [
        PacketField('cookie', NLM4_Cookie(), NLM4_Cookie),
        IntEnumField('exclusive', 0, {0: 'NO', 1: 'YES'}),
        PacketField('caller', Object_Name(), Object_Name),
        PacketField('filehandle', File_Object(), File_Object),
        PacketField('owner', Object_Name(), Object_Name),
        IntField('svid', 0),
        LongField('l_offset', 0),
        LongField('l_len', 0)
    ]
Exemplo n.º 11
0
class OFPTStatsReplyQueue(_ofp_header):
    name = "OFPST_STATS_REPLY_QUEUE"
    fields_desc = [ByteEnumField("version", 0x01, ofp_version),
                   ByteEnumField("type", 17, ofp_type),
                   ShortField("len", None),
                   IntField("xid", 0),
                   ShortEnumField("stats_type", 5, ofp_stats_types),
                   FlagsField("flags", 0, 16, []),
                   ShortEnumField("port_no", "NONE", ofp_port_no),
                   XShortField("pad", 0),
                   IntEnumField("queue_id", "ALL", ofp_queue),
                   LongField("tx_bytes", 0),
                   LongField("tx_packets", 0),
                   LongField("tx_errors", 0)]
Exemplo n.º 12
0
class OFPTFlowMod(_ofp_header):
    name = "OFPT_FLOW_MOD"
    fields_desc = [
        ByteEnumField("version", 0x01, ofp_version),
        ByteEnumField("type", 14, ofp_type),
        ShortField("len", None),
        IntField("xid", 0),
        PacketField("match", OFPMatch(), OFPMatch),
        LongField("cookie", 0),
        ShortEnumField(
            "cmd", 0, {
                0: "OFPFC_ADD",
                1: "OFPFC_MODIFY",
                2: "OFPFC_MODIFY_STRICT",
                3: "OFPFC_DELETE",
                4: "OFPFC_DELETE_STRICT"
            }),
        ShortField("idle_timeout", 0),
        ShortField("hard_timeout", 0),
        ShortField("priority", 0),
        IntEnumField("buffer_id", "NO_BUFFER", ofp_buffer),
        ShortEnumField("out_port", "NONE", ofp_port_no),
        FlagsField("flags", 0, 16,
                   ["SEND_FLOW_REM", "CHECK_OVERLAP", "EMERG"]),
        PacketListField("actions", [],
                        OFPAT,
                        ofp_action_cls,
                        length_from=lambda pkt: pkt.len - 72)
    ]
    overload_fields = {TCP: {"sport": 6653}}
Exemplo n.º 13
0
class READDIRPLUS_Reply(Packet):
    name = 'READDIRPLUS Reply'
    fields_desc = [
        IntEnumField('status', 0, nfsstat3),
        IntField('attributes_follow', 0),
        ConditionalField(PacketField('attributes', Fattr3(), Fattr3),
                         lambda pkt: pkt.attributes_follow == 1),
        ConditionalField(LongField('verifier', 0),
                         lambda pkt: pkt.status == 0),
        ConditionalField(IntField('value_follows', 0),
                         lambda pkt: pkt.status == 0),
        ConditionalField(
            PacketListField(
                'files',
                None,
                cls=File_From_Dir_Plus,
                next_cls_cb=lambda pkt, lst, cur, remain: File_From_Dir_Plus
                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)
    ]

    def extract_padding(self, s):
        return '', s
Exemplo n.º 14
0
class IE_MEI(gtp.IE_Base):
    name = "IE MEI"
    fields_desc = [ByteEnumField("ietype", 75, IEType),
                   ShortField("length", 0),
                   BitField("CR_flag", 0, 4),
                   BitField("instance", 0, 4),
                   LongField("MEI", 0)]
Exemplo n.º 15
0
class READ_Call(Packet):
    name = 'READ Call'
    fields_desc = [
        PacketField('filehandle', File_Object(), File_Object),
        LongField('offset', 0),
        IntField('count', 0)
    ]
Exemplo n.º 16
0
class PriorityQueueG(EntityClass):
    class_id = 277
    attributes = [
        ECA(ShortField("managed_entity_id", None), {AA.R}),
        ECA(ByteField("queue_configuration_option", None), {AA.R},
            range_check=lambda x: 0 <= x <= 1),
        ECA(ShortField("maximum_queue_size", None), {AA.R}),
        ECA(ShortField("allocated_queue_size", None), {AA.R, AA.W}),
        ECA(ShortField("discard_block_counter_reset_interval", None), {AA.R, AA.W}),
        ECA(ShortField("threshold_value_for_discarded_blocks", None), {AA.R, AA.W}),
        ECA(IntField("related_port", None), {AA.R}),
        ECA(ShortField("traffic_scheduler_pointer", 0), {AA.R, AA.W}),
        ECA(ByteField("weight", 1), {AA.R, AA.W}),
        ECA(ShortField("back_pressure_operation", 0), {AA.R, AA.W},
            range_check=lambda x: 0 <= x <= 1),
        ECA(IntField("back_pressure_time", 0), {AA.R, AA.W}),
        ECA(ShortField("back_pressure_occur_queue_threshold", None), {AA.R, AA.W}),
        ECA(ShortField("back_pressure_clear_queue_threshold", None), {AA.R, AA.W}),
        # TODO: Custom field of 4 2-byte values would help below
        ECA(LongField("packet_drop_queue_thresholds", None), {AA.R, AA.W},
            optional=True),
        ECA(ShortField("packet_drop_max_p", 0xFFFF), {AA.R, AA.W}, optional=True),
        ECA(ByteField("queue_drop_w_q", 9), {AA.R, AA.W}, optional=True),
        ECA(ByteField("drop_precedence_colour_marking", 0), {AA.R, AA.W},
            optional=True, range_check=lambda x: 0 <= x <= 7),
    ]
    mandatory_operations = {OP.Get, OP.Set}
    notifications = {OP.AlarmNotification}
Exemplo n.º 17
0
class FSINFO_Reply(Packet):
    name = 'FSINFO Reply'
    fields_desc = [
        IntEnumField('status', 0, nfsstat3),
        IntField('attributes_follow', 0),
        ConditionalField(
            PacketField('attributes', Fattr3(), Fattr3),
            lambda pkt: pkt.attributes_follow == 1
        ),
        ConditionalField(IntField('rtmax', 0), lambda pkt: pkt.status == 0),
        ConditionalField(IntField('rtpref', 0), lambda pkt: pkt.status == 0),
        ConditionalField(IntField('rtmult', 0), lambda pkt: pkt.status == 0),
        ConditionalField(IntField('wtmax', 0), lambda pkt: pkt.status == 0),
        ConditionalField(IntField('wtpref', 0), lambda pkt: pkt.status == 0),
        ConditionalField(IntField('wtmult', 0), lambda pkt: pkt.status == 0),
        ConditionalField(IntField('dtpref', 0), lambda pkt: pkt.status == 0),
        ConditionalField(
            LongField('maxfilesize', 0), lambda pkt: pkt.status == 0
        ),
        ConditionalField(
            IntField('timedelta_s', 0), lambda pkt: pkt.status == 0
        ),
        ConditionalField(
            IntField('timedelta_ns', 0), lambda pkt: pkt.status == 0
        ),
        ConditionalField(
            XIntField('properties', 0), lambda pkt: pkt.status == 0
        ),
    ]
Exemplo n.º 18
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), ]
Exemplo n.º 19
0
class Sattr3(Packet):
    name = 'Setattr3'
    fields_desc = [
        IntEnumField('set_mode', 0, attrs_enum),
        ConditionalField(OIntField('mode', 0), lambda pkt: pkt.set_mode == 1),
        IntEnumField('set_uid', 0, attrs_enum),
        ConditionalField(IntField('uid', 0), lambda pkt: pkt.set_uid == 1),
        IntEnumField('set_gid', 0, attrs_enum),
        ConditionalField(IntField('gid', 0), lambda pkt: pkt.set_gid == 1),
        IntEnumField('set_size', 0, attrs_enum),
        ConditionalField(LongField('size', 0), lambda pkt: pkt.set_size == 1),
        IntEnumField('set_atime', 0, times_enum),
        ConditionalField(IntField('atime_s', 0),
                         lambda pkt: pkt.set_atime == 2),
        ConditionalField(IntField('atime_ns', 0),
                         lambda pkt: pkt.set_atime == 2),
        IntEnumField('set_mtime', 0, times_enum),
        ConditionalField(IntField('mtime_s', 0),
                         lambda pkt: pkt.set_mtime == 2),
        ConditionalField(IntField('mtime_ns', 0),
                         lambda pkt: pkt.set_mtime == 2)
    ]

    def extract_padding(self, s):
        return '', s
Exemplo n.º 20
0
class File_From_Dir_Plus(Packet):
    name = 'File'
    fields_desc = [
        LongField('fileid', 0),
        PacketField('filename', Object_Name(), Object_Name),
        LongField('cookie', 0),
        IntField('attributes_follow', 0),
        ConditionalField(PacketField('attributes', Fattr3(), Fattr3),
                         lambda pkt: pkt.attributes_follow == 1),
        IntField('handle_follows', 0),
        ConditionalField(PacketField('filehandle', File_Object(), File_Object),
                         lambda pkt: pkt.handle_follows == 1),
        IntField('value_follows', 0)
    ]

    def extract_padding(self, s):
        return '', s
Exemplo n.º 21
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)
    ]
Exemplo n.º 22
0
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), ]
Exemplo n.º 23
0
class SenderInfo(Packet):
    name = "Sender info"
    fields_desc = [
        LongField('ntp_timestamp', None),
        IntField('rtp_timestamp', None),
        IntField('sender_packet_count', None),
        IntField('sender_octet_count', None)
    ]
Exemplo n.º 24
0
class AVSWLANHeader(Packet):
    """ iwpriv eth1 set_prismhdr 1 """
    name = "AVS WLAN Monitor Header"
    fields_desc = [IntField("version", 1),
                   IntField("len", 64),
                   LongField("mactime", 0),
                   LongField("hosttime", 0),
                   IntEnumField("phytype", 0, AVSWLANPhyType),
                   IntField("channel", 0),
                   IntField("datarate", 0),
                   IntField("antenna", 0),
                   IntField("priority", 0),
                   IntEnumField("ssi_type", 0, AVSWLANSSIType),
                   SignedIntField("ssi_signal", 0),
                   SignedIntField("ssi_noise", 0),
                   IntEnumField("preamble", 0, AVSWLANPreambleType),
                   IntEnumField("encoding", 0, AVSWLANEncodingType),
                   ]
Exemplo n.º 25
0
class ISIS_64bitAdministrativeTagSubTlv(ISIS_GenericSubTlv):
    name = "ISIS 64-bit Administrative Tag (S)"
    fields_desc = [
        ByteEnumField("type", 2, _isis_subtlv_names_2),
        FieldLenField("len", None, length_of="tags", fmt="B"),
        FieldListField("tags", [],
                       LongField("", 0),
                       count_from=lambda pkt: pkt.len // 8)
    ]  # noqa: E501
Exemplo n.º 26
0
class OFPTFlowRemoved(_ofp_header):
    name = "OFPT_FLOW_REMOVED"
    fields_desc = [ByteEnumField("version", 0x01, ofp_version),
                   ByteEnumField("type", 11, ofp_type),
                   ShortField("len", None),
                   IntField("xid", 0),
                   PacketField("match", OFPMatch(), OFPMatch),
                   LongField("cookie", 0),
                   ShortField("priority", 0),
                   ByteEnumField("reason", 0, {0: "OFPRR_IDLE_TIMEOUT",
                                               1: "OFPRR_HARD_TIMEOUT",
                                               2: "OFPRR_DELETE"}),
                   XByteField("pad1", 0),
                   IntField("duration_sec", 0),
                   IntField("duration_nsec", 0),
                   ShortField("idle_timeout", 0),
                   XShortField("pad2", 0),
                   LongField("packet_count", 0),
                   LongField("byte_count", 0)]
Exemplo n.º 27
0
class WRITE_Call(Packet):
    name = 'WRITE Call'
    fields_desc = [
        PacketField('filehandle', File_Object(), File_Object),
        LongField('offset', 0),
        IntField('count', 0),
        IntEnumField('stable', 0, {0: 'UNSTABLE', 1: 'STABLE'}),
        IntField('length', 0),
        StrLenField('contents', b'', length_from=lambda pkt: pkt.length),
        StrLenField('fill', b'', length_from=lambda pkt: (4 - pkt.length) % 4)
    ]
Exemplo n.º 28
0
class PWOSPF(Packet):
    name = "PWOSPF"
    fields_desc = [
        ByteField("version", None),
        ByteField("type", None),
        ShortField("length", None),
        IPField("routerID", None),
        IntField("areaID", None),
        ShortField("checksum", None),
        ShortField("auType", 0),
        LongField("auth", 0)
    ]
Exemplo n.º 29
0
class Pwospf(Packet):
    name = "Pwospf"
    fields_desc = [
        ByteField("version", 2),
        ByteField("type", None),
        ShortField("length", None),
        IntField("routerId", None),
        IntField("areaId", None),
        ShortField("checksum", None),
        ShortField("auType", 0),
        LongField("authentication", 0)
    ]
Exemplo n.º 30
0
class WCC_Attr(Packet):
    name = 'File Attributes'
    fields_desc = [
        LongField('size', 0),
        IntField('mtime_s', 0),
        IntField('mtime_ns', 0),
        IntField('ctime_s', 0),
        IntField('ctime_ns', 0)
    ]

    def extract_padding(self, s):
        return '', s