I'd like to locate a library or tool to facilitate enumeration of IP address blocks within ranges. Say I have any two non-overlapping ranges, and I want to find out what's the minimum set of IP address blocks that fully covers the interstitial space between them.
Here are some examples:
Between 0.0.0.0/8 and 10.0.0.0/8 (edges not included) lie: 1.0.0.0/8, 2.0.0.0/7, 4.0.0.0/6 and 8.0.0.0/7, and that occupies all the space and it is the minimum expression.
Between 10.0.0.0/8 and 127.0.0.0/8 (edges not included) lie: 11.0.0.0/8, 12.0.0.0/6, 16.0.0.0/4, 32.0.0.0/3, 64.0.0.0/3, 96.0.0.0/4, 112.0.0.0/5, 120.0.0.0/6, 124.0.0.0/7 and 126.0.0.0/8, and that occupies all the space and it is the minimum expression.
Between 127.0.0.0/8 and 169.254.0.0/16 (edges not included) lie: 128.0.0.0/3, 160.0.0.0/5, 168.0.0.0/8, 169.0.0.0/9, 169.128.0.0/10, 169.192.0.0/11, 169.224.0.0/12, 169.240.0.0/13, 169.248.0.0/14 and 169.252.0.0/15, and that occupies all the space and it is the minimum expression.
At the moment I'm calculating this by hand, but it does get tedious and error-prone. I'd like to hear perhaps of some function, in any programming language, probably belonging to a subnet calculator, or failing that a web page, to help calculate this. I thought I'd ask before I write my own function.