It might be helpful to know a little bit more about the intended use.
- Will you be keeping track of seemingly random addresses and ranges, or a list of networks with known netmasks? (e.g. ones associated with your organization)
- How many entries are we talking about; a few, thousands or millions?
- Will the database be used mostly for searches/lookups or will there be a lot of insert/delete operations?
- Will you be using range exceptions such as "A..Z except P-Q"?
If you know the netmasks then it seems to me that you could simplyfy the matching greatly by using bitwise operations and not a range based approach like spanning.
--
Time flies when you don't know what you're doing