# SO_BINDTODEVICE undeclared on freebsd 12



## spring_64 (Jan 18, 2020)

Hi all,

What  can I use instead of SO_BINDTODEVICE? 

I'm on FreeBSD 12.1.

The linux code is:


```
ret = setsockopt(r->sock_rx, SOL_SOCKET, SO_BINDTODEVICE, r->vr->ifp->name, strlen(r->vr->ifp->name));
```


----------



## shkhln (Jan 18, 2020)

https://lists.freebsd.org/pipermail/freebsd-net/2012-April/032064.html? That took roughly 10-20 seconds to find by googling "SO_BINDTODEVICE alternatives". It's the second result from the top.


----------



## Crivens (Feb 26, 2021)

You are sure that will work?


----------



## SirDice (Feb 26, 2021)

shkhln said:


> https://lists.freebsd.org/pipermail/freebsd-net/2012-April/032064.html? That took roughly 10-20 seconds to find by googling "SO_BINDTODEVICE alternatives". It's the second result from the top.


A nine year old patch for 9.0 that never made it into the source tree?


----------



## zirias@ (Feb 26, 2021)

SirDice said:


> A nine year old patch for 9.0 that never made it into the source tree?


Depending on the purpose, IP_RECVIF might be enough (see ip(4)). It's of course not a drop-in replacement, some code refactoring will be needed.


----------

