Exemple #1
0
def ip(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]
Exemple #2
0
def inet(tokeniser):
    ipmask = prefix(tokeniser)
    inet = INET(afi=IP.toafi(ipmask.top()),
                safi=IP.tosafi(ipmask.top()),
                action=OUT.UNSET)
    inet.cidr = CIDR(ipmask.ton(), ipmask.mask)

    return Change(inet, Attributes())
Exemple #3
0
def inet (tokeniser):
	ipmask = prefix(tokeniser)
	inet = INET(
		afi=IP.toafi(ipmask.top()),
		safi=IP.tosafi(ipmask.top()),
		action=OUT.UNSET
	)
	inet.cidr = CIDR(ipmask.ton(),ipmask.mask)

	return Change(
		inet,
		Attributes()
	)