Date: Thu, 19 Apr 2012 07:41:37 +0200 From: Attila Nagy <bra@fsn.hu> To: freebsd-net@freebsd.org Subject: SO_BINDTODEVICE or equivalent? Message-ID: <4F8FA591.4010503@fsn.hu>
next in thread | raw e-mail | index | archive | help
Hi, I want to solve the classic problem of a DHCP server: listening for broadcast UDP packets and figuring out what interface a packet has come in. The Linux solution is SO_BINDTODEVICE, which according to socket(7): SO_BINDTODEVICE Bind this socket to a particular device like "eth0", as specified in the passed interface name. If the name is an empty string or the option length is zero, the socket device binding is removed. The passed option is a variable-length null-terminated interface name string with the maximum size of IFNAMSIZ. If a socket is bound to an interface, only packets received from that particular interface are processed by the socket. Note that this only works for some socket types, particularly AF_INET sockets. It is not supported for packet sockets (use normal [1]bind(2) there). This makes it possible to listen on selected interfaces for (broadcast) packets. FreeBSD currently doesn't implement this feature. Any chances that somebody will do this? What alternatives would you recommend? Raw packet access (like BPF and RAW sockets) finally make the application to do more -mainly useless- work. Are there any other solutions, which doesn't require additional packet parsing? Thanks, References 1. http://linux.die.net/man/2/bind
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F8FA591.4010503>