We have the iprange() function which helps to tell us if a host is in a subnet, but it is also useful to know if a given ip is in a range. For example it is not uncommon to have multiple interfaces on a host. Being able to see if a given ip is in range allows us to narrow that knowledge to determine if a specific interface is part of a specific network.
This can be used to adjust network settings for that interface. Another use case is to be able to lookup data based on a given interfaces ip being within a subnet range. For example, I might have a list of subnets that list country. But I may have a host that has an interface on two subnets that are assigned to different countries. What I really want to be able to do in this case is to check if sys.ipv4 or sys.ipv4[eth0] is within a given subnet. This would allow me to identify my "primary" country.
Perhaps ip_in_range(ip, range)
Where I could use it like this:
string => "$(data[$(subnets)][country])"
if => ip_in_range( $(sys.ipv4), $(subnets) );