Exemplo n.º 1
0
    def unpack(data):
        # flags
        flags = ord(data[0])
        data = data[1:]

        # subtype
        subtype = ord(data[0])
        data = data[1:]

        # label
        label = LabelStackEntry.unpack(data[:3])
        data = data[3:]

        if subtype in tunnel_types_to_class:
            return tunnel_types_to_class[subtype].unpack(label, flags, data)
        else:
            return PMSITunnel(subtype, label, flags, data)
Exemplo n.º 2
0
    def unpack(data):
        #flags
        flags = ord(data[0])
        data = data[1:]

        #subtype
        subtype = ord(data[0])
        data = data[1:]

        #label
        label = LabelStackEntry.unpack(data[:3])
        data = data[3:]

        if subtype in tunnel_types_to_class:
            return tunnel_types_to_class[subtype].unpack(label, flags, data)
        else:
            return PMSITunnel(subtype, label, flags, data)
Exemplo n.º 3
0
    def unpack(data):

        rd = RouteDistinguisher.unpack(data[:8])
        data = data[8:]

        esi = EthernetSegmentIdentifier.unpack(data[:10])
        data = data[10:]

        etag = EthernetTag.unpack(data[:4])
        data = data[4:]

        maclen = ord(data[0])
        data = data[1:]

        mac = MAC.unpack(data[:6])
        data = data[6:]

        iplen = ord(data[0])
        data = data[1:]

        if iplen == 0:
            ip = None
            iplen_byte = 0
        elif iplen == 4 * 8:
            ip = socket.inet_ntop(socket.AF_INET, data[:4])
            iplen_byte = 4
        elif iplen == 16 * 8:
            ip = socket.inet_ntop(socket.AF_INET6, data[:16])
            iplen_byte = 16
        else:
            raise Exception(
                "IP field length is given as %d, but EVPN route currently support only IPv4"
                % iplen)
        data = data[iplen_byte:]

        label = LabelStackEntry.unpack(data[:3])

        return EVPNMACAdvertisement(rd, esi, etag, mac, label, ip, maclen)
Exemplo n.º 4
0
 def unpack(data):
     
     rd = RouteDistinguisher.unpack(data[:8])
     data=data[8:]
     
     esi = EthernetSegmentIdentifier.unpack(data[:10])
     data=data[10:]
     
     etag = EthernetTag.unpack(data[:4])
     data=data[4:]
     
     maclen = ord(data[0])
     data=data[1:]
     
     mac = MAC.unpack(data[:6])
     data=data[6:]
     
     iplen = ord(data[0])
     data=data[1:]
     
     if iplen == 0:
         ip = None
         iplen_byte=0
     elif iplen == 4*8:
         ip = socket.inet_ntop( socket.AF_INET, data[:4] )
         iplen_byte=4
     elif iplen == 16*8:
         ip = socket.inet_ntop( socket.AF_INET6, data[:16] )
         iplen_byte=16
     else:
         raise Exception("IP field length is given as %d, but EVPN route currently support only IPv4" % iplen)
     data=data[iplen_byte:]
     
     label = LabelStackEntry.unpack(data[:3])
     
     return EVPNMACAdvertisement(rd,esi,etag,mac,label,ip,maclen)