Exemple #1
0
	def withdraw (self,asn4=False,local_asn=None,remote_asn=None):
		if self.afi == AFI.ipv4 and self.safi in [SAFI.unicast, SAFI.multicast]:
			nlri = ''.join([route.nlri.pack() for route in self.routes])
			mp = ''
			attr = ''
		else:
			nlri = ''
			mp = MPURNLRI(self.routes).pack()
			attr = self.routes[0].attributes.bgp_announce(asn4,local_asn,remote_asn)
		return self._message(prefix(nlri) + prefix(attr + mp))
Exemple #2
0
	def announce (self,asn4,local_asn,remote_asn):
		if self.afi == AFI.ipv4 and self.safi in [SAFI.unicast, SAFI.multicast]:
			nlri = ''.join([route.nlri.pack() for route in self.routes])
			mp = ''
		else:
			nlri = ''
			mp = MPRNLRI(self.routes).pack()
			# FIXME: needs same fix as below for next hop ?
		attr = self.routes[0].attributes.bgp_announce(asn4,local_asn,remote_asn)
		return self._message(prefix('') + prefix(attr + mp) + nlri)
Exemple #3
0
 def withdraw(self, asn4=False, local_asn=None, remote_asn=None):
     if self.afi == AFI.ipv4 and self.safi in [
             SAFI.unicast, SAFI.multicast
     ]:
         nlri = ''.join([route.nlri.pack() for route in self.routes])
         mp = ''
         attr = ''
     else:
         nlri = ''
         mp = MPURNLRI(self.routes).pack()
         attr = self.routes[0].attributes.bgp_announce(
             asn4, local_asn, remote_asn)
     return self._message(prefix(nlri) + prefix(attr + mp))
Exemple #4
0
 def announce(self, asn4, local_asn, remote_asn):
     if self.afi == AFI.ipv4 and self.safi in [
             SAFI.unicast, SAFI.multicast
     ]:
         nlri = ''.join([route.nlri.pack() for route in self.routes])
         mp = ''
     else:
         nlri = ''
         mp = MPRNLRI(self.routes).pack()
         # FIXME: needs same fix as below for next hop ?
     attr = self.routes[0].attributes.bgp_announce(asn4, local_asn,
                                                   remote_asn)
     return self._message(prefix('') + prefix(attr + mp) + nlri)
Exemple #5
0
	def update (self,asn4,local_asn,remote_asn):
		
		if self.afi == AFI.ipv4 and self.safi in [SAFI.unicast, SAFI.multicast]:
			nlri = ''.join([route.nlri.pack() for route in self.routes])
			mp = ''
			attr = self.routes[0].attributes.bgp_announce(asn4,local_asn,remote_asn)
		else:
			nlri = ''
			#mp = MPURNLRI(self.routes).pack() + MPRNLRI(self.routes).pack()
			mp = MPRNLRI(self.routes).pack()
			# remove NEXT_HOP from attributes, because it's already been encoded in the MPNLRI
			
			if AttributeID.NEXT_HOP not in self.routes[0].attributes:
				raise Exception("Routes advertised need a NEXT_HOP attribute")

			attributes = deepcopy(self.routes[0].attributes)
			del attributes[AttributeID.NEXT_HOP]
			attr = attributes.bgp_announce(asn4,local_asn,remote_asn)
			
		return self._message(prefix(nlri) + prefix(attr + mp) + nlri)
Exemple #6
0
    def update(self, asn4, local_asn, remote_asn):

        if self.afi == AFI.ipv4 and self.safi in [
                SAFI.unicast, SAFI.multicast
        ]:
            nlri = ''.join([route.nlri.pack() for route in self.routes])
            mp = ''
            attr = self.routes[0].attributes.bgp_announce(
                asn4, local_asn, remote_asn)
        else:
            nlri = ''
            #mp = MPURNLRI(self.routes).pack() + MPRNLRI(self.routes).pack()
            mp = MPRNLRI(self.routes).pack()
            # remove NEXT_HOP from attributes, because it's already been encoded in the MPNLRI

            if AttributeID.NEXT_HOP not in self.routes[0].attributes:
                raise Exception("Routes advertised need a NEXT_HOP attribute")

            attributes = deepcopy(self.routes[0].attributes)
            del attributes[AttributeID.NEXT_HOP]
            attr = attributes.bgp_announce(asn4, local_asn, remote_asn)

        return self._message(prefix(nlri) + prefix(attr + mp) + nlri)