コード例 #1
0
    def generateVifBGPRoute(self, macAdress, ipPrefix, prefixLen, label):
        # Generate BGP route and advertise it...
        route = self._routeFrom(
            Prefix(self.afi, ipPrefix, prefixLen), label,
            RouteDistinguisher(RouteDistinguisher.TYPE_IP_LOC, None,
                               self.bgpManager.getLocalAddress(),
                               self.instanceId))
        self.log.debug("route attributes: %s", route.attributes)

        return self._newRouteEntry(self.afi, self.safi, self.exportRTs,
                                   route.nlri, route.attributes)
コード例 #2
0
ファイル: __init__.py プロジェクト: taheri0/MPLS-over-GRE
    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)
コード例 #3
0
ファイル: evpn.py プロジェクト: HackLinux/bagpipe-bgp
 def unpack(data):
     
     rd = RouteDistinguisher.unpack(data[:8])
     data=data[8:]
           
     etag = EthernetTag.unpack(data[:4])
     data=data[4:]
             
     iplen = ord(data[0])
     data=data[1:]
     
     if iplen == 4*8:
         ip = socket.inet_ntop( socket.AF_INET, data[:4] )
     elif iplen == 16*8:
         ip = socket.inet_ntop( socket.AF_INET6, data[:16] )
     else:
         raise Exception("IP len is %d, but EVPN route currently support only IPv4" % iplen)
     data=data[iplen:]
     
     return EVPNMulticast(rd,etag,ip)
コード例 #4
0
ファイル: __init__.py プロジェクト: taheri0/MPLS-over-GRE
    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))
コード例 #5
0
    def unpack(data):

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

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

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

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

        return EVPNMulticast(rd, etag, ip)
コード例 #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)
コード例 #7
0
ファイル: evpn.py プロジェクト: HackLinux/bagpipe-bgp
 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)
コード例 #8
0
 def _getRDFromLabel(self, label):
     # FIXME: this is a crude hack that will break beyond 10000 VRFs
     return RouteDistinguisher(RouteDistinguisher.TYPE_IP_LOC, None,
                               self.bgpManager.getLocalAddress(),
                               10000 + label)