-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42553f1
commit 8318b8e
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
process announce-routes { | ||
run ./run/api-rr.run; | ||
encoder json; | ||
} | ||
|
||
neighbor 127.0.0.1 { | ||
router-id 1.2.3.4; | ||
local-address 127.0.0.1; | ||
local-as 1; | ||
peer-as 1; | ||
group-updates false; | ||
|
||
family { | ||
ipv4 unicast; | ||
} | ||
|
||
capability { | ||
route-refresh; | ||
} | ||
api { | ||
processes [ announce-routes ]; | ||
receive { | ||
parsed; | ||
update; | ||
} | ||
send { | ||
packets; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
import time | ||
|
||
def check_ok(): | ||
line = sys.stdin.readline().strip() | ||
if line != 'done': | ||
sys.stdout.write(f'debug expected "done" not "{line}"\n') | ||
sys.stdout.write('announce route 255.255.255.255/32 next-hop 255.255.255.255\n') | ||
sys.stdout.flush() | ||
|
||
try: | ||
time.sleep(0.2) | ||
|
||
sys.stdout.write('announce route 192.168.0.0/32 next-hop 10.0.0.0\n') | ||
sys.stdout.flush() | ||
time.sleep(0.2) | ||
check_ok() | ||
|
||
sys.stdout.write('announce route 192.168.0.1/32 next-hop 10.0.0.1\n') | ||
sys.stdout.flush() | ||
time.sleep(0.2) | ||
check_ok() | ||
|
||
sys.stdout.write('announce route-refresh ipv4 unicast\n') | ||
sys.stdout.flush() | ||
time.sleep(0.2) | ||
check_ok() | ||
|
||
valid = True | ||
|
||
rr = sys.stdin.readline() | ||
if '"nlri": "192.168.0.0/32"' not in rr: | ||
valid = False | ||
sys.stdout.write("debug " + rr + '\n') | ||
sys.stdout.flush() | ||
|
||
rr = sys.stdin.readline() | ||
if '"nlri": "192.168.0.1/32"' not in rr: | ||
valid = False | ||
sys.stdout.write("debug " + rr + '\n') | ||
sys.stdout.flush() | ||
|
||
if valid: | ||
sys.stdout.write('announce route 192.168.0.2/32 next-hop 10.0.0.1\n') | ||
else: | ||
sys.stdout.write('announce route 255.255.255.255/32 next-hop 255.255.255.255\n') | ||
sys.stdout.flush() | ||
|
||
now = time.time() | ||
while os.getppid() != 1 and time.time() < now + 15: | ||
line = sys.stdin.readline().strip() | ||
if not line or 'shutdown' in line: | ||
break | ||
time.sleep(1) | ||
except IOError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
api-rr.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
1:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0017:02:00000000 | ||
2:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0031:02:00000015400101004002004003040A0000004005040000006420C0A80000 | ||
2:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0031:02:00000015400101004002004003040A0000014005040000006420C0A80001 | ||
3:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0017:05:00010001 | ||
4:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0031:02:00000015400101004002004003040A0000014005040000006420C0A80002 |