common_cells
common_cells copied to clipboard
`multiaddr_decode`: Add default port logic
In the case of the multi-address decoder, it makes sense to forward a request to the default port if the request's address set is not fully contained in the union of all rules' address sets, i.e. if the intersection is non-empty.
To simplify the module, we expect this union to be externally defined and passed to the module as a parameter.
This PR implements the logic required to implement a default port for the multi-address decoder.
@niwis thanks for your feedback.
It's not always easy to calculate the union, and I suspect the set of address sets representable with the (addr, mask) encoding is not even closed under the union operation.
Nonetheless, I can provide some functions to e.g. convert rules between (start, end) and (addr, mask) forms, perform unions and so on in the most common cases, perhaps guarded somehow with assertions.
Where would you suggest adding these?