Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind_device_by_index fails on IPv6 #413

Open
bryanlarsen opened this issue Mar 17, 2023 · 5 comments
Open

bind_device_by_index fails on IPv6 #413

bryanlarsen opened this issue Mar 17, 2023 · 5 comments

Comments

@bryanlarsen
Copy link

Calling bind_device_by_index results in errno 22 if the socket is bound to an IPV6 address.

I'm using this code instead:

    unsafe { libc::setsockopt(socket.as_raw_fd(), libc::IPPROTO_IPV6, libc::IPV6_BOUND_IF, &index as *const u32 as *const libc::c_void, std::mem::size_of::<u32>() as u32) } ;

device_index has the same problem.

P.S. if somebody knows a better way of specifying a link-local scope ID when binding to an IPV6 socket, that would help me although the bug I opened is still valid.

@bryanlarsen
Copy link
Author

Of course as soon as I hit submit, I find out the obvious answer to my P.S.: SocketAddrV6 has a scope_id field.

@Thomasdezeeuw
Copy link
Collaborator

I suppose this should have been IPv4 and IPv6 specific methods.

@pinkisemils you contributed the code, any thoughts?

@pinkisemils
Copy link
Contributor

Yes, there should be an analogue IPv6 functions that would use IPV6_BOUND_IF and IPPROTO_IPV6. I'll make a small PR.

@Thomasdezeeuw
Copy link
Collaborator

We should probably add _v4 and _v6 methods, deprecating the no-suffix method.

@pinkisemils
Copy link
Contributor

pinkisemils commented Apr 11, 2023

Yes. I dropped the ball on this due to my immune system dropping the ball on me. I'll add a small PR tomorrow.

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

No branches or pull requests

3 participants