Exemplo n.º 1
0
class entry_hdr(Packet):
    """ Entry Header """
    name = "entry"
    fields_desc = [
        BitField("frame_type", 0, 8),
        IntField("number_of_entries", 10),
        IntField("tree_id", 1),

        # BitField('flush', 0, 8),
        BitField('key0', 0, 128),
        BitField('value0', 0, 32),
        BitField('key1', 0, 128),
        BitField('value1', 0, 32),
        BitField('key2', 0, 128),
        BitField('value2', 0, 32),
        BitField('key3', 0, 128),
        BitField('value3', 0, 32),
        BitField('key4', 0, 128),
        BitField('value4', 0, 32),
        BitField('key5', 0, 128),
        BitField('value5', 0, 32),
        BitField('key6', 0, 128),
        BitField('value6', 0, 32),
        BitField('key7', 0, 128),
        BitField('value7', 0, 32),
        BitField('key8', 0, 128),
        BitField('value8', 0, 32),
        BitField('key9', 0, 128),
        BitField('value9', 0, 32),

    ]
Exemplo n.º 2
0
class KeyValPair(Packet):
    fields_desc = [
        IntField("schema", 0),
        IntField("key", 0),
        IntField("val", 0),
        BitField("unprocessed", 0, 8)
    ]  #add bit field
Exemplo n.º 3
0
class Payload(Packet):
    fields_desc = [
        IntField("data", None),
        IntField("encrypt", None),
        IntField("type", None),
        IntField("index", None)
    ]
Exemplo n.º 4
0
class preamble(Packet):
    """ preamble Header """
    name = "preamble"
    fields_desc = [
        IntField("number_of_entries", 10),
        IntField("seg_number", 0),
    ]
Exemplo n.º 5
0
class Query(Packet):
    name = "Query"
    fields_desc = [
        BitField("protocol", 0, 8),
        IntField("port2count", 0),
        IntField("port2size", 0),
        IntField("port3count", 0),
        IntField("port3size", 0)]
Exemplo n.º 6
0
class MetadataHeader_hoplatency(Packet):
    name = 'Metadata hop latency Header'
    fields_desc = [
        IntField('Hop_Latency1', 0),
        IntField('Hop_Latency2', 0),
        IntField('Hop_Latency3', 0),
        IntField('Hop_Latency4', 0)
    ]
Exemplo n.º 7
0
class PacketHeader(Packet):
    name = "PacketHeader"
    fields_desc = [
        IntField("type", 0),
        IntField("seq_num", 0),
        IntField("length", 0),
        SignedIntField("checksum", 0),
    ]
Exemplo n.º 8
0
class frame_type(Packet):
    """ Frame_type Header """
    name = "frame_type"
    fields_desc = [
        BitField("frame_type", 0, 8),
        IntField("number_of_entries", 10),
        IntField("tree_id", 1),
    ]
Exemplo n.º 9
0
class MetadataHeader_switchid(Packet):
    name = 'Metadata switch id Header'
    fields_desc = [
        IntField('SwitchID1', 0),
        IntField('SwitchID2', 0),
        IntField('SwitchID3', 0),
        IntField('SwitchID4', 0)
    ]
Exemplo n.º 10
0
class KeyValue(Packet):
    name = "KeyValue"
    fields_desc = [
        LongField("preamble", 1),
        ByteField("mtype", 0),
        IntField("key", 0),
        IntField("value", 0),
    ]
Exemplo n.º 11
0
class STATS(Packet):
    name = "STATS"
    fields_desc = [ 
                    IntField("port2", 0),
                    IntField("port3", 0),
                    ShortField("enable",0),
                    ShortField("prot_id", 0)
                ]
Exemplo n.º 12
0
class SwitchTrace(Packet):
    fields_desc = [ IntField("swid", 0),
                  IntField("qdepth", 0),
                  IntField("qlatency", 0),
                  IntField("plength", 0),
                  IntField("txtotal", 0)]
    def extract_padding(self, p):
                return "", p
Exemplo n.º 13
0
class P4calc(Packet):
    name = "P4calc"
    fields_desc = [
        StrFixedLenField("op", "+", length=1),
        IntField("operand_a", 0),
        IntField("operand_b", 0),
        IntField("result", 0)
    ]
class SwitchTrace(Packet):
    fields_desc = [
        IntField("swid", 0),
        IntField("qdepth", 0),
        IntField("qtdelta", 0)
    ]

    def extract_padding(self, p):
        return "", p
Exemplo n.º 15
0
class NetChain(Packet):
    name = "KeyValue"
    fields_desc = [
        LongField("preamble", 2),
        ByteField("mtype", 0),
        ByteField("dest", 0),
        IntField("key", 0),
        IntField("value", 0),
    ]
Exemplo n.º 16
0
class CoLoR_Data(Packet):
    name = 'CoLoR_Data'
    fields_desc = [
        BitField("Version", 7, 4, tot_size=1),
        BitField("Package", 3, 4, end_tot_size=1),
        ByteField("TTL", 64),
        LEShortField("pkg_length", None),
        XShortField("checksum", None),
        ByteField("header_length", None),
        ByteField("PID_pt", None),
        FieldLenField("PID_num",
                      None,
                      fmt="B",
                      count_of="PIDs",
                      adjust=lambda pkt, x: x - (pkt.Flags.R == True)),
        FlagsField("Flags", 0, 8, "rSCQMRBF"),
        ConditionalField(ShortField("Minimal_PID_CP", None),
                         lambda pkt: pkt.Flags.M),
        StrFixedLenField("N_sid", "", 16),
        StrFixedLenField("L_sid", "", 20),
        StrFixedLenField("nid_cus", "", 16),
        ConditionalField(
            StrFixedLenField("nid_pro", "", 16),
            lambda pkt: pkt.Flags.B == False and pkt.Flags.R == True),
        ConditionalField(
            FieldLenField("QoS_len",
                          None,
                          fmt="B",
                          length_of="QoS_requirements"),
            lambda pkt: pkt.Flags.Q == True),
        ConditionalField(
            StrLenField("QoS_requirements",
                        "",
                        length_from=lambda pkt: pkt.QoS_len),
            lambda pkt: pkt.Flags.Q == True),
        ConditionalField(IntField("HMAC", None),
                         lambda pkt: pkt.Flags.C == True),
        ConditionalField(IntField("Seg_ID", None),
                         lambda pkt: pkt.Flags.S == True),
        FieldListField("PIDs", [""],
                       StrFixedLenField("", "", 4),
                       count_from=lambda pkt: pkt.PID_num +
                       (pkt.Flags.R == True))
    ]

    def post_build(self, pkt, pay):
        if self.header_length is None:
            self.header_length = len(pkt)
            pkt = pkt[:6] + int2Bytes(self.header_length, 1) + pkt[7:]
        if self.pkg_length is None:
            self.pkg_length = len(pkt) + len(pay)
            pkt = pkt[:2] + int2BytesLE(self.pkg_length, 2) + pkt[4:]
        if self.checksum is None:
            self.checksum = CalcChecksum(pkt)
            pkt = pkt[:4] + int2Bytes(self.checksum, 2) + pkt[6:]
        # print(self.pkg_length, self.header_length, self.checksum)
        return pkt + pay
Exemplo n.º 17
0
class ECMP(Packet):
    name = "ECMP"
    fields_desc = [
        ShortField("is_load_balance", 1),
        ShortField("type", 0),
        ShortField("is_track", 0),
        IntField("port2_bytes", 0),
        IntField("port3_bytes", 0)
    ]
Exemplo n.º 18
0
class P4calc(Packet):
    name = "P4calc"
    fields_desc = [ StrFixedLenField("P", "P", length=1),
                    StrFixedLenField("Four", "4", length=1),
                    XByteField("version", 0x01),
                    StrFixedLenField("op", "+", length=1),
                    IntField("operand_a", 0),
                    IntField("operand_b", 0),
                    IntField("result", 0xDEADBABE)]
Exemplo n.º 19
0
class IPFIX(Packet):
    name = "IPFIX"
    fields_desc = [
        ShortField("version", 10),
        ShortField("length", None),
        IntField("exportTime", None),
        IntField("sequenceNumber", 1),
        IntField("observationDomainID", 1),
    ]
Exemplo n.º 20
0
class MetadataHeader(Packet):
    name = 'Metadata Header'
    fields_desc = [
        IntField('SwitchID', 0),
        #ShortField('IngressPort', 0),
        #ShortField('EgressPort', 0), # ShortField means 16 bytes
        IntField('Hop_Latency', 0),
        ByteField('qid', 0),
        BitField('qdepth', 0, 24)
    ]
Exemplo n.º 21
0
class KeyValue(Packet):
    name = "KeyValue"
    fields_desc = [
        LongField("preamble", 1),  #set to 1
        IntField("num_valid", 1),
        ByteField("port", 0),
        ByteField("mtype", 0),
        IntField("key", 0),
        IntField("value", 0),
    ]
Exemplo n.º 22
0
class P4inc(Packet):
    name = "P4inc"
    fields_desc = [
        StrFixedLenField("P", "P", length=1),  # P
        StrFixedLenField("Four", "4", length=1),  # 4
        XByteField("version", 0x01),  # version
        XByteField("bos", 0x00),  # bottom of stack, last packet 0/1
        IntField("data", 0),  # data packet
        IntField("result", 112)
    ]  # aggregated data
Exemplo n.º 23
0
class P4inc(Packet):
    name = "P4inc"
    fields_desc = [
        StrFixedLenField("P", "P", length=1),  # P
        StrFixedLenField("Four", "4", length=1),  # 4
        XByteField("version", 0x01),  # version
        XByteField("bos", 0x00),
        IntField("data", 0),
        IntField("result", 0)
    ]
Exemplo n.º 24
0
class Migration(Packet):
    name = "Migration"
    fields_desc = [BitField("protocol", 0, 8),
        BitField("stage", 0, 8),
        ShortField("index", 0),
        IntField("state", 0),
        BitField("mac", 0, 64),
        IntField("verify", 0),
        ShortField("mainProg", 0),
        ShortField("deltaProg", 0)]
Exemplo n.º 25
0
class P4tcp(Packet):
    name = "P4tcp"
    fields_desc = [ StrFixedLenField("P", "P", length=1),
                    StrFixedLenField("Four", "4", length=1),
                    XByteField("version", 0x01),
                    StrFixedLenField("packetType", "D", length=1),
                    StrFixedLenField("srcPort", "0", length=2),
                    StrFixedLenField("dstPort", "0", length=2),
                    IntField("seqNo", 0),
                    IntField("ackNo", 0),
                    StrFixedLenField("dataPayload", "", length=PAYLOAD_LENGTH)]
Exemplo n.º 26
0
class preamble(Packet):
    """ preamble Header """
    name = "preamble"
    fields_desc = [
        BitField("k", 0, 7),
        BitField("end", 0, 1),
        BitField("worker_id", 1, 8),
        BitField("epoch", 1, 16),
        IntField("seg_number", 0),
        BitField("pool_version", 1, 8),
        IntField("pool_index", 1),
    ]
Exemplo n.º 27
0
class OpenFlowMeterBand_v1_3(Packet):
    """
    OpenFlow Meter Band Field
    """

    name = 'OpenFlowMeterBand_v1_3'

    fields_desc = [
        ShortField('Type', None),
        ShortField('Length', None),
        IntField('Rate', None),
        IntField('BurstSize', None),
    ]
Exemplo n.º 28
0
class IPOption_MRI(IPOption):
    name = "MRI"
    option = 31
    fields_desc = [ _IPOption_HDR,
                    FieldLenField("length", None, fmt="B",
                                  length_of="swtraces",
                                  adjust=lambda pkt,l:l*2+4),
                    ShortField("count", 0),
                    IntField("pathid", 0),
                    IntField("pcount", 0),
                    PacketListField("swtraces",
                                   [],
                                   SwitchTrace,
                                   count_from=lambda pkt:(pkt.count*1)) ]
Exemplo n.º 29
0
class NSH(Packet):
    """Define the NSH protocol for the packet analysis."""
    name = "nsh"
    fields_desc = [
        XBitField("flags", 0x0, 10),
        XBitField("length", 0x6, 6),
        XByteField("MDtype", 0x1),
        XByteField("nextproto", 0x3),
        IntField("nsp_nsi", 0),
        IntField("c1", 0),
        IntField("c2", 0),
        IntField("c3", 0),
        IntField("c4", 0)
    ]
Exemplo n.º 30
0
class OpenFlowPacketQueue_v1_3(Packet):
    """
    OpenFlow Bucket Field
    """

    name = 'OpenFlowBucket_v1_3'

    fields_desc = [
        IntField('QueueID', None),
        IntField('Port', None),
        ShortField('Length', None),
        XByteField('Pad', None),
        _PacketField('QueueProprieties', None, OpenFlowQueueProprieties_v1_3,
                     5),
    ]