Created
December 4, 2016 08:15
-
-
Save tcuthbert/80b6edf693873540b52443d36f9fa027 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if IPAddress(ip_addr_src) and IPAddress(ip_addr_dst): | |
def plot_path(dot): | |
def lookup_addr_routing_table(src_addr, dst_addr, routing_table): | |
root = None | |
seen = None | |
# Find the root node. | |
for route, advertisers in routing_table.items(): | |
if IPAddress(src_addr) in IPNetwork(route): | |
for advertiser in advertisers: | |
if advertiser.nexthopip == '': | |
root = advertiser | |
if IPAddress(dst_addr) in IPNetwork(route): | |
seen = advertisers | |
# Now we have found our root node, find nexthop from root node to | |
# dst_addr. | |
for advertiser in seen: | |
if advertiser.hostname == root.hostname: | |
if advertiser.nexthopip == '': | |
return advertiser | |
else: | |
return lookup_addr_routing_table(advertiser.nexthopip, dst_addr, d) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment