Skip to content

add interface_id in ScopedIpV4#439

Open
keepsimple1 wants to merge 2 commits intomainfrom
scoped-ipv4
Open

add interface_id in ScopedIpV4#439
keepsimple1 wants to merge 2 commits intomainfrom
scoped-ipv4

Conversation

@keepsimple1
Copy link
Owner

Help fixing issue #437

Problem

Currently for IPv4 there is no way to find out on which interface the service address(es) are found, while IPv6 doesn't have this problem.

Solution

Added interface_id() to ScopedIpV4 to match ScopedIpV6 that returns the interface on which a service address is found.

@hgomersall
Copy link
Contributor

It looks like this would certainly allow a workaround. I think probably by iterating over the interfaces from if_addrs and comparing each with the returned InterfaceId. That said, is there a reason the address can't be added to the interface ID directly from if_addrs to avoid the extra layer?

@keepsimple1
Copy link
Owner Author

That said, is there a reason the address can't be added to the interface ID directly from if_addrs to avoid the extra layer?

I didn't want to do that as it feels like against the design purpose of struct InterfaceId, but I think we could add a convenient method to do the legwork for the users. Please see the updated diff for get_addrs() method of InterfaceId. Would that work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants