コード例 #1
0
ファイル: label.py プロジェクト: steiler/exabgp
def ip_label (tokeniser,afi,safi):
	ipmask = prefix(tokeniser)

	nlri = Label(afi,safi,OUT.ANNOUNCE)
	nlri.cidr = CIDR(ipmask.pack(),ipmask.mask)

	change = Change(
		nlri,
		Attributes()
	)

	while True:
		command = tokeniser()

		if not command:
			break

		action = ParseLabel.action.get(command,'')

		if action == 'attribute-add':
			change.attributes.add(ParseLabel.known[command](tokeniser))
		elif action == 'nlri-set':
			change.nlri.assign(ParseLabel.assign[command],ParseLabel.known[command](tokeniser))
		elif action == 'nexthop-and-attribute':
			nexthop,attribute = ParseLabel.known[command](tokeniser)
			change.nlri.nexthop = nexthop
			change.attributes.add(attribute)
		else:
			raise ValueError('route: unknown command "%s"' % command)

	return [change]
コード例 #2
0
def ip_label(tokeniser, afi, safi):
    action = OUT.ANNOUNCE if tokeniser.announce else OUT.WITHDRAW
    ipmask = prefix(tokeniser)

    nlri = Label(afi, safi, action)
    nlri.cidr = CIDR(ipmask.pack(), ipmask.mask)

    change = Change(nlri, Attributes())

    while True:
        command = tokeniser()

        if not command:
            break

        action = AnnounceLabel.action.get(command, '')

        if action == 'attribute-add':
            change.attributes.add(AnnounceLabel.known[command](tokeniser))
        elif action == 'nlri-set':
            change.nlri.assign(AnnounceLabel.assign[command],
                               AnnounceLabel.known[command](tokeniser))
        elif action == 'nexthop-and-attribute':
            nexthop, attribute = AnnounceLabel.known[command](tokeniser)
            change.nlri.nexthop = nexthop
            change.attributes.add(attribute)
        else:
            raise ValueError('unknown command "%s"' % command)

    if not AnnounceLabel.check(change, afi):
        raise ValueError('invalid announcement (missing next-hop or label ?)')

    return [change]
コード例 #3
0
 def __eq__(self, other):
     return \
      Label.__eq__(self, other) and \
      self.rd == other.rd and \
      Label.__eq__(self,other)
コード例 #4
0
 def __len__(self):
     return Label.__len__(self) + len(self.rd)
コード例 #5
0
 def extensive(self):
     return "%s%s" % (Label.extensive(self), str(self.rd))
コード例 #6
0
 def __init__(self, afi, safi, action=OUT.UNSET):
     Label.__init__(self, afi, safi, action)
     self.rd = RouteDistinguisher.NORD
コード例 #7
0
 def _internal(self, announced=True):
     r = Label._internal(self, announced)
     if announced and self.rd:
         r.append(self.rd.json())
     return r
コード例 #8
0
ファイル: ipvpn.py プロジェクト: Exa-Networks/exabgp
	def _internal (self, announced=True):
		r = Label._internal(self,announced)
		if announced and self.rd:
			r.append(self.rd.json())
		return r
コード例 #9
0
ファイル: ipvpn.py プロジェクト: Exa-Networks/exabgp
	def __eq__ (self, other):
		return \
			Label.__eq__(self, other) and \
			self.rd == other.rd and \
			Label.__eq__(self,other)
コード例 #10
0
ファイル: ipvpn.py プロジェクト: Exa-Networks/exabgp
	def __len__ (self):
		return Label.__len__(self) + len(self.rd)
コード例 #11
0
ファイル: ipvpn.py プロジェクト: Exa-Networks/exabgp
	def extensive (self):
		return "%s%s" % (Label.extensive(self),str(self.rd))
コード例 #12
0
ファイル: ipvpn.py プロジェクト: Exa-Networks/exabgp
	def __init__ (self, afi, safi, action=OUT.UNSET):
		Label.__init__(self, afi, safi, action)
		self.rd = RouteDistinguisher.NORD
コード例 #13
0
 def __eq__(self, other):
     return Label.__eq__(
         self, other) and self.rd == other.rd and Label.__eq__(self, other)