Radix is build around using "sockaddr-like structures", which requires callers to fill in these structures during lookups. This, in turn, leads to the next-order function signatures build around sockaddrs. Sometimes this is useful, however in many cases sockaddrs are not used by the certain subsystem internally.
Lastly, there are quite a lot of alternative data structures providing LPM, that typically do not require using sockaddrs.
With that in mind, restructure rn_match() to accept both addresses and sockaddr-like structures as the lookup key. Convert the existing parts of fib(9) api to leverage these changes.
Once all customers of a routing are converted, rn_match() can be changed to accept key addresses as is.
Currently radix allows to use variable-length keys (such as phone numbers) by specifying the key (actually, the total SA) length in the first byte. However, all current uses of the radix by pf, ipfw, nfs and routing, rely on constant-sized keys where length is known in advance.
With that in mind:
- split int rn_Off byte offset field of radix_node into int16_t rn_Off and int16_t rn_Salen, where the latter indicates total structure length, similar to sa_len field in struct sockaddr.
- Fill in this field for root node by using additional argument in rn_inithead()
- Convert rn_match() and its helper functions to use the total len value from the tree root node instead of a key.
- Provide per-AF macro to pass a proper pointer to rn_match.