From owner-freebsd-net@FreeBSD.ORG Fri Apr 20 12:53:25 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A87B9106566C for ; Fri, 20 Apr 2012 12:53:25 +0000 (UTC) (envelope-from bra@fsn.hu) Received: from people.fsn.hu (people.fsn.hu [195.228.252.137]) by mx1.freebsd.org (Postfix) with ESMTP id 5714E8FC17 for ; Fri, 20 Apr 2012 12:53:25 +0000 (UTC) Received: by people.fsn.hu (Postfix, from userid 1001) id 6FBDACC99A1; Fri, 20 Apr 2012 14:53:18 +0200 (CEST) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MF-ACE0E1EA [pR: 18.9094] X-CRM114-CacheID: sfid-20120420_14531_BFA48C09 X-CRM114-Status: Good ( pR: 18.9094 ) X-DSPAM-Result: Whitelisted X-DSPAM-Processed: Fri Apr 20 14:53:18 2012 X-DSPAM-Confidence: 0.9967 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 4f915c3e539961563918857 X-DSPAM-Factors: 27, From*Attila Nagy , 0.00010, FreeBSD, 0.00047, FreeBSD, 0.00047, >+On, 0.00080, >+Hi, 0.00150, wrote+>, 0.00178, wrote+>>, 0.00197, >+I, 0.00228, Hi+>, 0.00237, >+>, 0.00294, >+>, 0.00294, I+>, 0.00316, string, 0.00356, string, 0.00356, References*mail.gmail.com>, 0.00362, On+Thu, 0.00379, In-Reply-To*mail.gmail.com>, 0.00386, >>+>>, 0.00449, socket, 0.00474, socket, 0.00474, the+patch, 0.00474, wrote, 0.00507, wrote, 0.00507, References*fsn.hu>, 0.00517, >>+I, 0.00517, supported, 0.00541, X-Spambayes-Classification: ham; 0.00 Received: from japan.t-online.private (japan.t-online.co.hu [195.228.243.99]) by people.fsn.hu (Postfix) with ESMTPSA id 08331CC9993; Fri, 20 Apr 2012 14:53:18 +0200 (CEST) Message-ID: <4F915C3D.5070908@fsn.hu> Date: Fri, 20 Apr 2012 14:53:17 +0200 From: Attila Nagy User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.23) Gecko/20090817 Thunderbird/2.0.0.23 Mnenhy/0.7.6.0 MIME-Version: 1.0 To: Svatopluk Kraus References: <4F8FA591.4010503@fsn.hu> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org Subject: Re: SO_BINDTODEVICE or equivalent? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Apr 2012 12:53:25 -0000 Hi, Never heard of it, thanks! On 04/19/12 11:32, Svatopluk Kraus wrote: > Hi, > > Use IP_RECVIF option. > > For IP_SENDIF look at > http://lists.freebsd.org/pipermail/freebsd-net/2007-March/013510.html > I used the patch on my embedded FreeBSD 9.0 boxes and it works fine. I > modificated it slightly to match 9.0. > > Svata > > On Thu, Apr 19, 2012 at 7:41 AM, Attila Nagy wrote: >> 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