From owner-freebsd-net@FreeBSD.ORG Thu Apr 19 09:32:20 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 E27FE106564A for ; Thu, 19 Apr 2012 09:32:20 +0000 (UTC) (envelope-from onwahe@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 6665A8FC1C for ; Thu, 19 Apr 2012 09:32:20 +0000 (UTC) Received: by lbbgm6 with SMTP id gm6so2491972lbb.13 for ; Thu, 19 Apr 2012 02:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=rGNMdTCYPcWaFhcA5mjQssD771sF3CosDxEt/eGOZjA=; b=e++brnlMw93JZdOO6Pubgfq2kb8GbK8kUn37A7ttGMHNRcxoQJXAt3f8IHk9pLxzod riWW1MJ6QSLF74oSqZE0fOTNkCV/t1qSzkvDX5/bDRFrgfktVYne+wjksXOtZwQjz0AW OUzHtYAzkna6wsl+cV2mnCnwboqN77cubZoMdgijtoalJ5Uv3hSjiOuPOACHbomSvP4R DGDDI/eVmAGtJ5pxrZ9zbhEx7SmS7djb1AExmPCP3TSqUCQYZaZVa7FO1GVxmLinlBTq CA0H2Gkx4PnJw3jhFeJaWTFTZjFTN9MCa1ZnS1rxeDbDSO81LVIJOq7/KF6V8hXBgidG +wUQ== MIME-Version: 1.0 Received: by 10.112.26.10 with SMTP id h10mr636926lbg.79.1334827938929; Thu, 19 Apr 2012 02:32:18 -0700 (PDT) Received: by 10.112.56.179 with HTTP; Thu, 19 Apr 2012 02:32:18 -0700 (PDT) In-Reply-To: <4F8FA591.4010503@fsn.hu> References: <4F8FA591.4010503@fsn.hu> Date: Thu, 19 Apr 2012 11:32:18 +0200 Message-ID: From: Svatopluk Kraus To: Attila Nagy Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: Thu, 19 Apr 2012 09:32:21 -0000 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: > > =A0 Hi, > =A0 I want to solve the classic problem of a DHCP server: listening for > =A0 broadcast UDP packets and figuring out what interface a packet has > =A0 come in. > =A0 The Linux solution is SO_BINDTODEVICE, which according to socket(7): > =A0 SO_BINDTODEVICE > =A0 =A0 =A0 =A0 =A0Bind this socket to a particular device like "eth0", a= s > =A0 =A0 =A0 =A0 =A0specified in the passed interface name. If the name is= an empty > =A0 =A0 =A0 =A0 =A0string or the option length is zero, the socket device= binding > =A0 =A0 =A0 =A0 =A0is removed. The passed option is a variable-length > =A0 =A0 =A0 =A0 =A0null-terminated interface name string with the maximum= size of > =A0 =A0 =A0 =A0 =A0IFNAMSIZ. If a socket is bound to an interface, only p= ackets > =A0 =A0 =A0 =A0 =A0received from that particular interface are processed = by the > =A0 =A0 =A0 =A0 =A0socket. Note that this only works for some socket type= s, > =A0 =A0 =A0 =A0 =A0particularly AF_INET sockets. It is not supported for = packet > =A0 =A0 =A0 =A0 =A0sockets (use normal [1]bind(2) there). > > =A0 This makes it possible to listen on selected interfaces for > =A0 (broadcast) packets. FreeBSD currently doesn't implement this feature= . > =A0 Any chances that somebody will do this? > =A0 What alternatives would you recommend? Raw packet access (like BPF an= d > =A0 RAW sockets) finally make the application to do more -mainly useless- > =A0 work. > =A0 Are there any other solutions, which doesn't require additional packe= t > =A0 parsing? > =A0 Thanks, > > References > > =A0 1. http://linux.die.net/man/2/bind > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"