mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 15:43:02 +02:00
admin@example:/> configure admin@example:/config/> edit routing control-plane-protocol static name default admin@example:/config/routing/control-plane-protocol/static/name/default/> set ipv6 route 2001:db8:3c4d:200::/64 next-hop next-hop-address 2001:db8:3c4d:1::1 admin@example:/config/routing/control-plane-protocol/static/name/default/> leave admin@example:/> admin@infix-00-01-00:/> show routes ipv6 PREFIX NEXT-HOP METRIC PROTOCOL 2001:db8:3c4d:50::/64 eth4 256 kernel 2001:db8:3c4d:200::1/128 lo 256 kernel fe80::/64 eth3 256 kernel fe80::/64 eth2 256 kernel fe80::/64 eth1 256 kernel fe80::/64 eth0 256 kernel fe80::/64 eth5 256 kernel fe80::/64 eth4 256 kernel ::/0 2001:db8:3c4d:50::1 20 static
23 lines
704 B
Python
23 lines
704 B
Python
def _get_routes(target,protocol):
|
|
xpath=f"/ietf-routing:routing"
|
|
rib = target.get_data(xpath)["routing"]["ribs"]["rib"]
|
|
for r in rib:
|
|
if r["name"] != protocol:
|
|
continue
|
|
return r.get("routes", {}).get("route",{})
|
|
return {}
|
|
|
|
def _exist_route(target,destination_prefix, protocol):
|
|
routes=_get_routes(target,protocol)
|
|
for r in routes:
|
|
if(r["destination-prefix"] == destination_prefix):
|
|
return True
|
|
|
|
return False
|
|
|
|
def ipv4_route_exist(target, destination_prefix):
|
|
return _exist_route(target,destination_prefix, "ipv4")
|
|
|
|
def ipv6_route_exist(target, destination_prefix):
|
|
return _exist_route(target,destination_prefix, "ipv6")
|