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 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 = ParseIP.action.get(command, '') if action == 'attribute-add': change.attributes.add(ParseIP.known[command](tokeniser)) elif action == 'nlri-set': change.nlri.assign(ParseIP.assign[command], ParseIP.known[command](tokeniser)) elif action == 'nexthop-and-attribute': nexthop, attribute = ParseIP.known[command](tokeniser) change.nlri.nexthop = nexthop change.attributes.add(attribute) else: raise ValueError('route: unknown command "%s"' % command) return [change]
def ip_unicast(tokeniser, afi, safi): action = OUT.ANNOUNCE if tokeniser.announce else OUT.WITHDRAW ipmask = prefix(tokeniser) nlri = INET(afi, safi, action) nlri.cidr = CIDR(ipmask.pack(), ipmask.mask) change = Change(nlri, Attributes()) while True: command = tokeniser() if not command: break action = AnnouncePath.action.get(command, '') if action == 'attribute-add': change.attributes.add(AnnouncePath.known[command](tokeniser)) elif action == 'nlri-set': change.nlri.assign(AnnouncePath.assign[command], AnnouncePath.known[command](tokeniser)) elif action == 'nexthop-and-attribute': nexthop, attribute = AnnouncePath.known[command](tokeniser) change.nlri.nexthop = nexthop change.attributes.add(attribute) else: raise ValueError('unknown command "%s"' % command) if not AnnouncePath.check(change, afi): raise ValueError('invalid announcement (missing next-hop ?)') return [change]