From owner-freebsd-net@FreeBSD.ORG Thu Feb 19 01:55:15 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 44F0A16A4CE for ; Thu, 19 Feb 2004 01:55:15 -0800 (PST) Received: from trinity.gnist.org (trinity.critical-systems.no [194.143.111.171]) by mx1.FreeBSD.org (Postfix) with ESMTP id B920743D2D for ; Thu, 19 Feb 2004 01:55:06 -0800 (PST) (envelope-from andreto@olsr.org) Received: from localhost (unknown [127.0.0.1]) by trinity.gnist.org (Postfix) with ESMTP id 15E3D633099 for ; Thu, 19 Feb 2004 10:55:05 +0100 (CET) Received: from trinity.gnist.org ([127.0.0.1]) by localhost (trinity.gnist.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 58194-10 for ; Thu, 19 Feb 2004 10:54:54 +0100 (CET) Received: from olsr.org (unknown [80.239.6.50]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by trinity.gnist.org (Postfix) with ESMTP id 4C85E633096 for ; Thu, 19 Feb 2004 10:54:54 +0100 (CET) Message-ID: <403487B8.901@olsr.org> Date: Thu, 19 Feb 2004 10:54:00 +0100 From: Andreas T Organization: olsr.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040122 Debian/1.6-1 X-Accept-Language: en MIME-Version: 1.0 To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Binding sockets to devices in FreeBSD X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 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 Feb 2004 09:55:15 -0000 Hi all, I am developing an implementation of the Optimized LinkState Routing protocol(RFC3626) for Linux(www.olsr.org). OLSR is a routing protocol for mobile, multihop, wireless ad-hoc networks. I would really like to have my code compile on FreeBSD - but there is one major issue. OLSR sends control traffic broadcasted(IPv4) or multicasted(IPv6) on a pr.interface basis. That means that a node running OLSR on two interfaces a and b, would not always broadcast the same content in messages sent on a and b. This works fine using IPv4 and broadcast as long as the interfaces uses different broadcast addresses - but as soon as two interfaces is set up with the same broadcastaddress(or as soon as one uses IPv6 with the same multicastgroup) any message (sent on the broadcastsocket) will be transmitted on both interfaces. I hope this made some sense :) Bottom line is that one has to be able to control on which interface packets are sent. To do this in Linux i use the SO_BINDTODEVICE flag(with setsockopt(2)). That way I can have one socket for each interface OLSR is to use regradless of destinationaddress. In FreeBSD there is no SO_BINDTODEVICE or equalivant as far as I can see. To me it seems like BPF could provide the functioning I need. Is this so? Can BPF in some way help me control on which interface packets are transmitted? If so I would really appreciate some (pseudo or real)code examples to get me started or some links to such material - as I am totally new to the BPF interface(and the concept). If BPF is not the way to go I would appreciate any help in finding a way of doing this in FreeBSD. I could ofcause try to figure this out by myself - but as FreeBSD porting is not too high prioritized for now I figured I'd rather be lazy and ask you experts :) Thanks! regards, Andreas T -- Andreas Tønnesen(andreas@olsr.org) UniK University Graduation Center University of Oslo http://www.olsr.org