示例#1
0
	def __new_extended_communities (self,data):
		communities = ECommunities()
		while data:
			community = data[:8]
			data = data[8:]
			if data and len(data) < 8:
				raise Notify(3,1,'could not decode extended community %s' % str([hex(ord(_)) for _ in data]))
			communities.add(ECommunity.unpackFrom(community))
		return communities
示例#2
0
    def _genExtendedCommunities(self):
        ecommunities = ECommunities(copy(self.exportRTs))
        for encap in self.dataplaneDriver.supportedEncaps():
            if not isinstance(encap, Encapsulation):
                raise Exception("dataplaneDriver.supportedEncaps() should "
                                "return a list of Encapsulation objects")

            if encap != Encapsulation(Encapsulation.DEFAULT):
                ecommunities.add(encap)
        # FIXME: si DEFAULT + xxx => adv MPLS
        return ecommunities
    def _genExtendedCommunities(self):
        ecommunities = ECommunities(copy(self.exportRTs))
        for encap in self.dataplaneDriver.supportedEncaps():
            if not isinstance(encap, Encapsulation):
                raise Exception("dataplaneDriver.supportedEncaps() should "
                                "return a list of Encapsulation objects")

            if encap != Encapsulation(Encapsulation.DEFAULT):
                ecommunities.add(encap)
        # FIXME: si DEFAULT + xxx => adv MPLS
        return ecommunities
示例#4
0
 def __new_extended_communities(self, data):
     communities = ECommunities()
     while data:
         community = data[:8]
         data = data[8:]
         if data and len(data) < 8:
             raise Notify(
                 3, 1, 'could not decode extended community %s' %
                 str([hex(ord(_)) for _ in data]))
         communities.add(ECommunity.unpackFrom(community))
     return communities
示例#5
0
	def _route_extended_community (self,scope,tokens):
		extended_communities = ECommunities()
		extended_community = tokens.pop(0)
		try:
			if extended_community == '[':
				while True:
					try:
						extended_community = tokens.pop(0)
					except IndexError:
						self._error = self._str_route_error
						if self.debug: raise
						return False
					if extended_community == ']':
						break
					extended_communities.add(self._parse_extended_community(scope,extended_community))
			else:
				extended_communities.add(self._parse_extended_community(scope,extended_community))
		except ValueError:
			self._error = self._str_route_error
			if self.debug: raise
			return False
		scope[-1]['routes'][-1].attributes.add(extended_communities)
		return True
示例#6
0
    def _routeForReAdvertisement(self, prefix, label):
        route = self._routeFrom(prefix, label, self._getRDFromLabel(label))

        nh = Inet(
            1,
            socket.inet_pton(socket.AF_INET,
                             self.dataplane.driver.getLocalAddress()))

        route.attributes.add(NextHop(nh))

        route.attributes.add(ECommunities(self.readvertiseToRTs))

        routeEntry = self._newRouteEntry(self.afi, self.safi,
                                         self.readvertiseToRTs, route.nlri,
                                         route.attributes)
        return routeEntry
示例#7
0
 def __init__(self, afi=AFI.ipv4, safi=SAFI.flow_ipv4):
     self.attributes = Attributes()
     self.nlri = _FlowNLRI(afi, safi)
     self.attributes[AttributeID.EXTENDED_COMMUNITY] = ECommunities()