Subject: Re: data link access mechanism?
To: =?utf-8?B?66y47ISx?= <seong@etri.re.kr>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-net
Date: 11/21/2001 04:07:42
> I'm looking for the mechanism that suppots following requirements.

> 1. the way that an application can send the ethernet frame to the
> ethernet device driver - ether_input() - directly.

As far as I know this does not exist.  It would be trivial to add,
though, as a character special device driver.

> 2. the way that an application can receive the ethernet frame
> directly and then the ethernet frame should not be passed in the
> above network layer.

As you discovered, bpf for the first part.  I wanted the second part
too, and I added an interface flag BPFONLY for it - if an interface is
set BPFONLY, it receives packets for bpf purposes but never passes them
anywhere else.

If you want the BPFONLY patches, see the patch tree in
ftp.netbsd.org:/pub/NetBSD/misc/mouse/patch-tree/ - you want
src/sbin/ifconfig/ifconfig.8, src/sbin/ifconfig/ifconfig.c,
src/sys/net/if.h, and src/sys/net/if_ethersubr.c.  (Actually, you may
want only parts of some of those, and there's some chance you may want
something else; they're just what grepping for bpfonly turned up.  I
think the change was pretty much self-contained....)

As for the ether_input() interface, what you really want is something
tun(4)-like but that works at the Ethernet level rather than the IP
level.  You could probably start by copying if_tun.c and hacking on it
to use ether_input rather than enqueueing stuff on ipintrq....

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B