From owner-freebsd-hackers Wed Mar 31 11:27:18 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mailer.syr.edu (mailer.syr.edu [128.230.18.29]) by hub.freebsd.org (Postfix) with ESMTP id ACC10155E8 for ; Wed, 31 Mar 1999 11:27:16 -0800 (PST) (envelope-from cmsedore@mailbox.syr.edu) Received: from rodan.syr.edu by mailer.syr.edu (LSMTP for Windows NT v1.1a) with SMTP id <0.87643990@mailer.syr.edu>; Wed, 31 Mar 1999 14:26:57 -0500 Received: from localhost (cmsedore@localhost) by rodan.syr.edu (8.8.7/8.8.7) with SMTP id OAA29423; Wed, 31 Mar 1999 14:26:47 -0500 (EST) X-Authentication-Warning: rodan.syr.edu: cmsedore owned process doing -bs Date: Wed, 31 Mar 1999 14:26:47 -0500 (EST) From: Christopher Sedore X-Sender: cmsedore@rodan.syr.edu To: Tom Brown Cc: Graham Wheeler , hackers@FreeBSD.ORG Subject: Re: How do I write to the /dev/bpf0 interface? In-Reply-To: <370268D7.68012311@heliox.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 31 Mar 1999, Tom Brown wrote: > So my supposition that I could write to it like any other file handle > was correct ? > > > So I can just write the following to the interface for example: > > > ddddddddddddXXXXXXXXXXXXiiiiiiiiiiiiiiiiiiiiiiiiiii..... > d=destination address > X=don't care > i=information > > Bash# ethergenerator.pl>/dev/bpf0 > > Is that correct? Yes, though worth note is that most ethernet packets we care about (IP for instance) have the following wire format [dest, 6 bytes][src, 6 bytes][type, 2 bytes][data, up to 1500 bytes] Depending on who you're talking to, you might want to make sure that the two type bytes are not used by another protocol (0800 for IP, 0806 for ARP, 8137 for IPX, etc) so you don't bother any existing protocol stacks. > > What happens if I want to put in a source MAC address? It is silently overwritten, at least in 3.1. I haven't checked what happens in 2.x.x. > You also mentioned that it might be a bug with 2.2.8, which > combination's of card / operating systems might work? If you look on the FreeBSD Gnats page, you'll see (toward the very bottom of the page in the non-critical catagory) a bug report from me on this problem. Included in that bug report is a patch which fixed the problem for me (and should fix it in general). After applying that patch, you must put the source address in the packet (the way it should be IMHO). -Chris > > Christopher Sedore wrote: > > > > On Wed, 31 Mar 1999, Graham Wheeler wrote: > > > > > Christopher Sedore wrote: > > > > > > > > On Wed, 31 Mar 1999, Graham Wheeler wrote: > > > > > > > > > Tom Brown wrote: > > > > > > > > > > > Can anyone please tell me how to post a packet onto my LAN via this > > > > > > interface. > > > > > > > > > > You should just be able to write the frame. Make sure everything is in > > > > > network-byte order. You needn't put in a source Ethernet address as that > > > > > will get filled in, but you do need to put in a destination. > > > > > > > > Note that this is probably a bug in the bpf implementation. BPF/the > > > > kernel shouldn't be messing with the packet on a write to a bpf > > > > descriptor. I've filed a bug report (with patch) that addresses this. > > > > > > > > > > It probably isn't the bpf code that is doing this, but the NIC driver > > > code... > > > > Actually, its a cooperative effort by bpfwrite() and ether_output(). > > > > -Chris > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message