def ip_multicast (tokeniser,afi,safi): ipmask = prefix(tokeniser) nlri = INET(afi,safi,OUT.ANNOUNCE) nlri.cidr = CIDR(ipmask.pack(),ipmask.mask) change = Change( nlri, Attributes() ) while True: command = tokeniser() if not command: break action = AnnounceIP.action.get(command,'') if action == 'attribute-add': change.attributes.add(AnnounceIP.known[command](tokeniser)) elif action == 'nlri-set': change.nlri.assign(AnnounceIP.assign[command],AnnounceIP.known[command](tokeniser)) elif action == 'nexthop-and-attribute': nexthop,attribute = AnnounceIP.known[command](tokeniser) change.nlri.nexthop = nexthop change.attributes.add(attribute) else: raise ValueError('route: unknown command "%s"' % command) return [change]
def _internal (self, announced=True): r = INET._internal(self,announced) if announced and self.labels: r.append(self.labels.json()) return r
def prefix (self): return "%s%s" % (INET.prefix(self),str(self.labels))
def __eq__ (self, other): return \ INET.__eq__(self, other) and \ self.labels == other.labels
def __len__ (self): return INET.__len__(self) + len(self.labels)
def __init__ (self, afi, safi, action): INET.__init__(self, afi, safi, action) self.labels = Labels.NOLABEL