コード例 #1
0
class UDP(Packet):
    name = "UDP"
    fields_desc = [ ShortEnumField("sport", 53, UDP_SERVICES), #standard UDP
                    ShortEnumField("dport", 53, UDP_SERVICES),
                    ShortField("len", None),
                    XShortField("chksum", None), 
                    XByteField("ack",0), #Acknowlegment number - 8bit
                    X3BytesField("pkg",1)] #pakcage number -24 bit                
コード例 #2
0
class UdpInt(Packet):
    name = "UDP_INT"
    fields_desc = [
        ShortEnumField("sport", trans_sec.consts.UDP_INT_SRC_PORT,
                       UDP_SERVICES),
        ShortEnumField("dport", trans_sec.consts.UDP_INT_DST_PORT,
                       UDP_SERVICES),
        ShortField("len", None),
        XShortField("chksum", None),
    ]
コード例 #3
0
class DNSMXRR(DNSRR):
    name = "DNS MX Resource Record"
    show_indent = 0
    fields_desc = [
        DNSStrField("rrname", ""),
        ShortEnumField("type", 1, dnstypes),
        ShortEnumField("rclass", 1, dnsclasses),
        IntField("ttl", 0),
        RDLenField("rdlen"),
        ShortField("mxpriority", 0),
        RDataField("rdata", "", length_from=lambda pkt: pkt.rdlen - 2)
    ]
コード例 #4
0
class DNSSOARR(DNSRR):
    name = "DNS SOA Resource Record"
    show_indent = 0
    fields_desc = [
        DNSStrField("rrname", ""),
        ShortEnumField("type", 1, dnstypes),
        ShortEnumField("rclass", 1, dnsclasses),
        IntField("ttl", 0),
        ShortField("rdlen", 0),
        StrField("mname", ""),
        StrField("rname", ""),
        IntField("serial", 0),
        IntField("refresh", 0),
        IntField("retry", 0),
        IntField("expire", 0),
        IntField("minimum", 0)
    ]
コード例 #5
0
class FieldSpecifier(Packet):
    name = "Field Specifier"
    fields_desc = [
        ShortEnumField("informationElement", None, information_elements),
        ShortField("fieldLength", None),
    ]

    def extract_padding(self, s):
        return "", s
コード例 #6
0
class OpenFlowHello(Packet):
    name = "OpenFlowHello"
    fields_desc = [
        ShortEnumField("type", 1, OFP_HELLO_ELEM_TYPES),
        ShortField("length", None),
        XIntField("bitmap", 0x10)  #Field that stores a bitmap of supported
        #versions, script only supports
        #OF1.3 (0x04). Hence, set to
    ]

    def post_build(self, curr_layer, payload):
        if self.length is None:
            l = 8 + len(payload)
            curr_layer = curr_layer[:2] + pack("!H", l) + curr_layer[4:]
        return curr_layer + payload
コード例 #7
0
ファイル: PacketSnifferClasses.py プロジェクト: KenzK/Twister
class StatsRequestBody_v1_0(Packet):
    """
    OpenFlow Stats Request Body
    """

    name = 'StatsRequestBody_v1_0'

    fields_desc = [
        ShortEnumField('Type', None, ofp_v1_0_stats_requestreply_type),
        ShortField('Flags', None),
        _PacketField('<FlowMatchDescriptor>', None,
                     FlowMatchDescriptorField_v1_0, 40),
        ByteField('TableID', None),
        XByteField('Reserved', None),
        ShortField('EgressPortNumber', None)
    ]
コード例 #8
0
ファイル: send3.py プロジェクト: hotephen/p4-dev
class NSH(Packet):
    """Network Service Header.
       NSH MD-type 1 if there is no ContextHeaders"""
    name = "NSH"

    fields_desc = [
        BitField('Ver', 0, 2),
        BitField('OAM', 0, 1),
        BitField('Un1', 0, 1),
        BitField('TTL', 0, 6),
        BitField('Len', None, 6),
        BitField('Un2', 0, 4),
        BitField('MDType', 1, 4),
        ShortEnumField('NextProto', 3, {
            1: 'IPv4',
            2: 'IPv6',
            3: 'Ethernet',
            4: 'NSH',
            5: 'MPLS'
        }),
        X3BytesField('NSP', 1),
        ByteField('NSI', 255)
    ]
コード例 #9
0
ファイル: PacketSnifferClasses.py プロジェクト: KenzK/Twister
class StatsReplyBody_v1_0(Packet):
    """
    OpenFlow Stats Reply Body
    """

    name = 'StatsReplyBody_v1_0'

    fields_desc = [
        ShortEnumField('Type', None, ofp_v1_0_stats_requestreply_type),
        ShortField('Flags', None),

        # Description of this OpenFlow switch
        ConditionalField(
            StrFixedLenField('ManufacturerDescription', None, 256),
            lambda pkt: pkt.Type == 0),
        ConditionalField(StrFixedLenField('HardwareDescription', None, 256),
                         lambda pkt: pkt.Type == 0),
        ConditionalField(StrFixedLenField('SoftwareDescription', None, 256),
                         lambda pkt: pkt.Type == 0),
        ConditionalField(IntField('SerialNumberDescription', None),
                         lambda pkt: pkt.Type == 0),  ## ??

        # Individual flow statistical information /
        # Aggregate flow statistical information
        ConditionalField(ShortField('Length', None),
                         lambda pkt: pkt.Type == 1),
        ConditionalField(ByteField('TableID', None),
                         lambda pkt: pkt.Type == 1),
        ConditionalField(XByteField('Reserved', None),
                         lambda pkt: pkt.Type == 1),
        ConditionalField(
            _PacketField('<FlowMatchDescriptor>', None,
                         FlowMatchDescriptorField_v1_0, 40),
            lambda pkt: pkt.Type == 1),
        ConditionalField(IntField('LifetimeDuration', None),
                         lambda pkt: pkt.Type == 1),
        ConditionalField(ShortField('Priority', None),
                         lambda pkt: pkt.Type == 1),
        ConditionalField(ShortField('SoftLifetime', None),
                         lambda pkt: pkt.Type == 1),
        ConditionalField(ShortField('HardLifetime', None),
                         lambda pkt: pkt.Type == 1),
        ConditionalField(ShortField('Reserved', None),
                         lambda pkt: pkt.Type == 1),
        ConditionalField(LongField('NumberOfPacketsTransferred', None),
                         lambda pkt: pkt.Type in [1, 2]),
        ConditionalField(LongField('NumberOfOctetsTransferred', None),
                         lambda pkt: pkt.Type in [1, 2]),
        ConditionalField(
            _PacketField('<ActionDescriptors>', None,
                         ActionDescriptorField_v1_0),  ## ???? bytes
            lambda pkt: pkt.Type == 1),
        ConditionalField(IntField('NumberOfFlows', None),
                         lambda pkt: pkt.Type == 2),
        ConditionalField(IntField('Reserved', None),
                         lambda pkt: pkt.Type == 2),

        # Flow table statistical information
        ConditionalField(ByteField('Table_ID', None),
                         lambda pkt: pkt.Type == 1),
        ConditionalField(X3BytesField('Reserved', None),
                         lambda pkt: pkt.Type == 3),
        ConditionalField(StrFixedLenField('TableDescriptionString', None, 16),
                         lambda pkt: pkt.Type == 3),
        ConditionalField(IntField('<FlowWildcard>', None),
                         lambda pkt: pkt.Type == 3),
        ConditionalField(IntField('MaximumNumberOfFlowsSupported', None),
                         lambda pkt: pkt.Type == 3),
        ConditionalField(IntField('NumberOfFlowsInstalled', None),
                         lambda pkt: pkt.Type == 3),
        ConditionalField(IntField('NumberOfPacketsLookedUp', None),
                         lambda pkt: pkt.Type == 3),
        ConditionalField(IntField('NumberOfPacketsMatched', None),
                         lambda pkt: pkt.Type == 3),

        # Port statistical information
        ConditionalField(LongField('NumberOfPakctesReceived', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfPakctesTransmitted', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfOctetsReceived', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfOctetsTransmitted', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfPacketsDroppedInReception', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(
            LongField('NumberOfPacketsDroppedInTransmittion', None),
            lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfErrorsInReception', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfErrorsInTransmittion', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfAlignmentErrors', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfOverrunErrors', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfCRCErrors', None),
                         lambda pkt: pkt.Type == 4),
        ConditionalField(LongField('NumberOfCollisionErrors', None),
                         lambda pkt: pkt.Type == 4),
    ]