Exemple #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)
Exemple #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)
Exemple #3
0
    def generateVifBGPRoute(self, macAddress, ipPrefix, prefixLen, label):
        # Generate BGP route and advertise it...

        assert (prefixLen == 32)

        # label parameter ignored, we want the instance label
        lse = LabelStackEntry(self.instanceLabel, True)
        etag = None

        route = Route(
            EVPNMACAdvertisement(
                RouteDistinguisher(RouteDistinguisher.TYPE_IP_LOC, None,
                                   self.dataplaneDriver.getLocalAddress(),
                                   self.instanceId),
                EthernetSegmentIdentifier(), etag, MAC(macAddress), lse,
                ipPrefix))

        return self._newRouteEntry(self.afi, self.safi, self.exportRTs,
                                   route.nlri, route.attributes)
Exemple #4
0
    def __init__(self, *args, **kwargs):

        VPNInstance.__init__(self, *args, **kwargs)

        self.gwPort = None

        # Advertise route to receive multi-destination traffic
        self.log.info("Generating BGP route for broadcast/multicast traffic")

        etag = None
        label = LabelStackEntry(self.instanceLabel)

        route = Route(
            EVPNMulticast(
                RouteDistinguisher(RouteDistinguisher.TYPE_IP_LOC, None,
                                   self.bgpManager.getLocalAddress(),
                                   self.instanceId), etag,
                self.bgpManager.getLocalAddress()))

        route.attributes.add(self._genExtendedCommunities())

        # add PMSI Tunnel Attribute route
        pmsi_tunnel_attribute = PMSITunnelIngressReplication(
            self.dataplaneDriver.getLocalAddress(), label)
        route.attributes.add(pmsi_tunnel_attribute)

        nh = Inet(
            1,
            socket.inet_pton(socket.AF_INET,
                             self.dataplaneDriver.getLocalAddress()))
        route.attributes.add(NextHop(nh))

        self.multicastRouteEntry = self._newRouteEntry(self.afi, self.safi,
                                                       self.exportRTs,
                                                       route.nlri,
                                                       route.attributes)

        self._pushEvent(
            RouteEvent(RouteEvent.ADVERTISE, self.multicastRouteEntry))
Exemple #5
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)
Exemple #6
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)
Exemple #7
0
 def _routeFrom(self, prefix, label, rd):
     return Route(
         VPNLabelledPrefix(self.afi, self.safi, prefix, rd,
                           [LabelStackEntry(label, True)]))