From owner-freebsd-current@FreeBSD.ORG Fri Jul 29 19:56:15 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8529916A41F; Fri, 29 Jul 2005 19:56:15 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from mailgate1b.savvis.net (mailgate1b.savvis.net [216.91.182.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id BF2BA43D4C; Fri, 29 Jul 2005 19:56:14 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgate1b.savvis.net (Postfix) with ESMTP id 9D12F3C09C; Fri, 29 Jul 2005 14:56:13 -0500 (CDT) Received: from mailgate1b.savvis.net ([127.0.0.1]) by localhost (mailgate1b.savvis.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 10488-01-23; Fri, 29 Jul 2005 14:56:13 -0500 (CDT) Received: from out002.email.savvis.net (out002.apptix.savvis.net [216.91.32.45]) by mailgate1b.savvis.net (Postfix) with ESMTP id 705043BE45; Fri, 29 Jul 2005 14:56:13 -0500 (CDT) Received: from s228130hz1ew171.apptix-01.savvis.net ([10.146.4.29]) by out002.email.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Fri, 29 Jul 2005 14:56:11 -0500 Received: from [10.254.186.111] ([64.14.1.106]) by s228130hz1ew171.apptix-01.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Fri, 29 Jul 2005 14:55:58 -0500 Message-ID: <42EA89CC.9050203@savvis.net> Date: Fri, 29 Jul 2005 12:55:56 -0700 From: Maksim Yevmenkin User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050404) X-Accept-Language: en-us, en MIME-Version: 1.0 To: snort Snort References: <20050729130135.81095.qmail@web54407.mail.yahoo.com> In-Reply-To: <20050729130135.81095.qmail@web54407.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 29 Jul 2005 19:55:58.0311 (UTC) FILETIME=[89C18F70:01C59477] X-Virus-Scanned: amavisd-new at savvis.net Cc: freebsd-current@freebsd.org, freebsd-stable@freebsd.org, Tobias Roth Subject: Re: Simple program use /dev/tap X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2005 19:56:15 -0000 Hello, >>>As I want to learn how to use /dev/tap in freebsd, >> >>I m >> >>>looking for a simple application that written for >>>/dev/tap. OpenVPN is a bit too complicated for a >>>newbie to get start. Can anyone tell me a link or >>>reference for some of these examples? >> >>There are examples that come with the distribution >>itself: >> >>http://vtun.sourceforge.net/tun/tun-1.1.tar.gz >> > > Is this only for tun device? > How much difference between tun and tap in terms of > programming when using the device? > > >>(and this question would be better suited for >>freebsd-questions, >>if for any FreBSD=specific list at all) >> > > Sorry, I currently don't have access to the > frebsd.misc newsgroup, so I need to post the question > here. this type of question comes up quite often. its really simple: a single read(2) call on /dev/tapX will return entire ethernet frame (if any) received by tap interface (minus ethernet crc). a single write(2) call on /dev/tapX will put entire ethernet frame (w/out ethernet crc) onto tap interface outgoing queue. so, the "buf" parameter to the write(2) call on /dev/tapX device should point to a buffer with *complete* ethernet frame, including ethernet header and payload. payload could be IP packet, but it does not have to be. any protocol that uses ethernet as transport can be tunneled with tap(4) (i.e. ipx). the above is true for tun(4) with exception that tun(4) operates on IP packets. so you have to write/read complete IP packets to/from /dev/tun. thanks, max