(skiplist-rangesearch skiplist address)
This procedure searches for a matching MAC address range in the skip list if the supplied search address is a MAC address (macaddr? returning #t), or for matching IP address range if the supplied search address is an IP address. Mixing MAC addresses and IP addresses may lead to unecpected results and should be avoided. Also, overlapping ranges in the skip list may be confusing.
#f is returned if no matching range is found. If a matching range is found, its associated data is returned.
> (define macranges (skiplist-create))
macranges
> (skiplist-insert! macranges '00:00:00:00:00:00-00:00:00:FF:FF:FF "MAC address range A")
ok
> (skiplist-insert! macranges '10:00:00:00:00:00-10:00:00:FF:FF:FF "MAC address range B")
ok
> (skiplist-rangesearch macranges '00:00:00:11:11:11)
"MAC address range A"
> (skiplist-rangesearch macranges '10:00:00:11:11:11)
"MAC address range B"
> (skiplist-rangesearch macranges 'AA:00:00:11:11:11)
#f
> (define ipranges (skiplist-create))
ipranges
> (skiplist-insert! ipranges '10.0.0.0-10.0.0.255 "IP address range A")
ok
> (skiplist-insert! ipranges '::fe80:0000:0000-::fe80:0000:FFFF "IP address range B")
ok
> (skiplist-rangesearch ipranges '10.0.0.8)
"IP address range A"
> (skiplist-rangesearch ipranges '::ffff:10.0.0.200)
"IP address range A"
> (skiplist-rangesearch ipranges ::fe80:0000:00AA)
"IP address range B"
> (skiplist-rangesearch ipranges ::fe80:0000:FFFF)
"IP address range B"
> (skiplist-rangesearch ipranges ::fe80:0001:FFFF)
#f
>