zeek / pysubnettree

A Python Module for CIDR Lookups
Other
50 stars 20 forks source link

Semantics of lookup of CIDR #9

Open dfn-certling opened 8 years ago

dfn-certling commented 8 years ago

I just found out that you can try to look up a CIDR in the SubnetTree. But it seems to just take the network part, complete it with zeros and look up that address. Is their some (documented or undocumented) semantics attached to this? It was a bit confusing for me to discover:

import SubnetTree
tree = SubnetTree.SubnetTree()
tree['10.0.0.0/16'] = 'Test net'
print t['10.0.0.0/8']
-> Test net
dfn-certling commented 8 years ago

Ok, it doesn't just zero out the host part.

import SubnetTree
tree = SubnetTree.SubnetTree()
tree['10.0.0.0/16'] = 'Test net'
'10.1.0.0/8' in tree
-> False

I'm still confused as for the semantics of the CIDR lookup. Is it something else than the same lookup without the slash part?