Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Sep 1999 21:34:02 +0700 (JAVT)
From:      waskita adijarto <waskita@ee.itb.ac.id>
To:        "Cain, Michael E." <mcain@mediaone.com>
Cc:        "'freebsd-net@freebsd.org'" <freebsd-net@freebsd.org>
Subject:   Re: Reading and writing raw Ethernet frames
Message-ID:  <Pine.BSF.3.96.990902212312.21965A-100000@elka.ee.itb.ac.id>
In-Reply-To: <B147CE8D09F1D111BD7100805F19B1C04D8E43@coexch01.mediaone.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Wed, 1 Sep 1999, Cain, Michael E. wrote:

> Date: Wed, 1 Sep 1999 15:43:58 -0400
> From: "Cain, Michael E." <mcain@mediaone.com>
> To: "'freebsd-net@freebsd.org'" <freebsd-net@freebsd.org>
> Subject: Reading and writing raw Ethernet frames
> 
> I have an existing application, developed for Linux, that emulates various
> IP network impairments.  One of the key enablers for the app is the ability
> to read and write raw Ethernet frames (sometimes after making appropriate
> changes in the source and destination addresses at both the IP and Ethernet
> level).  On Linux, accessing the raw frames was easily accomplished by
> opening a socket of type SOCK_PACKET instead of SOCK_STREAM or SOCK_DGRAM.
> In the case of a Linux box with multiple Ethernet interfaces, it is
> straightforward to know the interface on which the frame was received or to
> specify the interface on which it should be written.
> 
> I'm interested in porting the application to FreeBSD, and was wondering if
> there was an equivalent mechanism.  To summarize, I need to be able to read
> and write raw Ethernet frames (arbitrarily constructed by me in the worst
> case) and support for multiple Ethernet interfaces while doing so.

I asked similar question about a month ago, and I got 2 answers. I think I
must hack bpf code from NetBSD to FreeBSD to enable raw packet writing,
but I haven't got time to do it. 

talking about libpcap, I think it's just a generic interface to bpf. 

also, linux has something called EtherTAP that can read & write raw
ethernet packets.

-w-

my question:
********************************************************************

Date: Tue, 27 Jul 1999 11:44:33 +0700 (JAVT)
From: waskita adijarto <waskita@ee.itb.ac.id>
To: freebsd-net@FreeBSD.ORG
Subject: writing raw ethernet packet in FreeBSD.


I want to read & write raw ethernet packet. I can read raw ethernet
packet with bpf, but writing to bpf device is not so successful. the
ethernet source address always follow the interface's address. Is this the
normal behavior of bpf ? I am thinking that I should look at
/usr/src/sys/net/bridge.c  to create raw ethernet packet ...

My FreeBSD box is 2.2.8, my interface card is 3C509 (ep0) & ed0 (some
NE2000 compatible)

-w-

first answer:
********************************************************************

Date: Tue, 27 Jul 1999 09:17:47 -0700
From: Darcy Buskermolen <darcy@ok-connect.com>
To: freebsd-net@freebsd.org
Subject: Re: writing raw ethernet packet in FreeBSD.

Have a look at the following URL it contains examples form a rather good
book on how to write raw datagrams using libpcap.
http://www.kohala.com/~rstevens/unpv12e.html


//DB

At 11:44 AM 7/27/99 +0700, you wrote:
>
>I want to read & write raw ethernet packet. I can read raw ethernet
>packet with bpf, but writing to bpf device is not so successful. the
>ethernet source address always follow the interface's address. Is this
the
>normal behavior of bpf ? I am thinking that I should look at
>/usr/src/sys/net/bridge.c  to create raw ethernet packet ...
>
>My FreeBSD box is 2.2.8, my interface card is 3C509 (ep0) & ed0 (some
>NE2000 compatible)
>
>-w-

second answer:
********************************************************************

Date: Tue, 27 Jul 1999 11:02:18 -0700
From: "Gregory P. Smith" <greg@nas.nasa.gov>
To: waskita adijarto <waskita@ee.itb.ac.id>
Cc: freebsd-net@freebsd.org
Subject: Re: writing raw ethernet packet in FreeBSD.


> I want to read & write raw ethernet packet. I can read raw ethernet
> packet with bpf, but writing to bpf device is not so successful. the
> ethernet source address always follow the interface's address. Is this
the
> normal behavior of bpf ? I am thinking that I should look at
> /usr/src/sys/net/bridge.c  to create raw ethernet packet ...
>
> My FreeBSD box is 2.2.8, my interface card is 3C509 (ep0) & ed0 (some
> NE2000 compatible)

It sounds like you want to write a -completely- raw packet using your
own ethernet address?  If so, look in the NetBSD bpf.h/bpf.c sources
for the BIOC{S,G}HDRCMPLT ioctls.  (it doesn't look like anyone ever
added this to FreeBSD; its real simple to apply)

It allows you to tell the Ethernet driver not to rewrite the device's
hardware address into the packet before sending it to the card.

Greg

********************************************************************










To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.990902212312.21965A-100000>