nix icon indicating copy to clipboard operation
nix copied to clipboard

How to use `SockLevel` for `setsockopt` and IP_MULTICAST_IF

Open keepsimple1 opened this issue 4 years ago • 2 comments
trafficstars

https://github.com/nix-rust/nix/blob/d922c72a765640c5e190fb01129f712e6ac513df/src/sys/socket/mod.rs#L1585

I cannot find how SockLevel is used in the code. For example, setsockopt did not have a level argument:

https://github.com/nix-rust/nix/blob/d922c72a765640c5e190fb01129f712e6ac513df/src/sys/socket/mod.rs#L1639

How can we use SockLevel? I have a use case that needs to do something like this (not real code):

setsockopt(IPPROTO_IP, IP_MULTICAST_IF, <value>);

I cannot find IP_MULTICAST_IF in Nix either. Did I miss it somewhere? Thanks.

keepsimple1 avatar Dec 15 '20 01:12 keepsimple1

Ooh, great question! SockLevel is actually dead code. AFAICT, its use was eliminated way back in PR #133 . So we should delete it. But what you probably ought to do is submit a PR that adds this socket option using sockopt_impl! to src/sys/socket/sockopt.rs.

asomers avatar Dec 15 '20 02:12 asomers

thanks @asomers for opening PR #1362 to remove SockLevel. I will submit a PR to add IP_MULTICAST_IF .

keepsimple1 avatar Dec 15 '20 03:12 keepsimple1