xref: /freebsd/share/man/man4/ng_ether.4 (revision b601c69bdbe8755d26570261d7fd4c02ee4eff74)
1.\" Copyright (c) 2000 Whistle Communications, Inc.
2.\" All rights reserved.
3.\"
4.\" Subject to the following obligations and disclaimer of warranty, use and
5.\" redistribution of this software, in source or object code forms, with or
6.\" without modifications are expressly permitted by Whistle Communications;
7.\" provided, however, that:
8.\" 1. Any and all reproductions of the source or object code must include the
9.\"    copyright notice above and the following disclaimer of warranties; and
10.\" 2. No rights are granted, in any manner or form, to use Whistle
11.\"    Communications, Inc. trademarks, including the mark "WHISTLE
12.\"    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
13.\"    such appears in the above copyright notice or in the software.
14.\"
15.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
16.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
17.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
18.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
19.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
20.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
21.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
22.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
23.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
24.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
25.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
27.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30.\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
31.\" OF SUCH DAMAGE.
32.\"
33.\" Author: Archie Cobbs <archie@whistle.com>
34.\"
35.\" $FreeBSD$
36.\"
37.Dd June 26, 2000
38.Dt NG_ETHER 4
39.Os FreeBSD
40.Sh NAME
41.Nm ng_ether
42.Nd Ethernet netgraph node type
43.Sh SYNOPSIS
44.Fd #include <netgraph/ng_ether.h>
45.Sh DESCRIPTION
46The
47.Nm ng_ether
48netgraph node type allows Ethernet interfaces to interact with
49the
50.Xr netgraph 4
51networking subsystem.
52Once the
53.Nm
54module is loaded in the kernel, a node is automatically created
55for each Ethernet interface in the system.
56Each node will attempt to name itself with the same name
57as the associated interface.
58All
59.Nm
60nodes are persistent for as long as the interface itself exists.
61.Pp
62Three hooks are supported:
63.Dv lower ,
64.Dv upper ,
65and
66.Dv orphans .
67The hook name
68.Dv divert
69may be used as an alias for
70.Dv lower ,
71and is provided for backward compatibility.
72In reality the two names represent the same hook.
73.Pp
74The
75.Dv lower
76hook is a connection to the raw Ethernet device.
77When connected, all incoming packets are diverted out this hook.
78Writing to this hook results in a raw Ethernet frame being transmitted
79by the device.
80Normal outgoing packets are not affected by
81.Dv lower
82being connected.
83.Pp
84The
85.Dv upper
86hook is a connection to the upper protocol layers.
87When connected, all outgoing packets are diverted out this hook.
88Writing to this hook results in a raw Ethernet frame being received by
89the kernel just as if it had come in over the wire.
90Normal incoming packets are not affected by
91.Dv upper
92being connected.
93.Pp
94The
95.Dv orphans
96hook is equivalent to
97.Dv lower ,
98except that only unrecognized packets (that would otherwise be discarded)
99are written to the hook, and normal incoming traffic is unaffected.
100At most one of
101.Dv orphans
102and
103.Dv lower
104may be connected at any time.
105.Pp
106In all cases, frames are raw Ethernet frames with the standard
10714 byte Ethernet header (but no checksum).
108.Pp
109When no hooks are connected,
110.Dv upper
111and
112.Dv lower
113are in effect connected together,
114so that packets flow normally upwards and downwards.
115.Sh HOOKS
116This node type supports the following hooks:
117.Pp
118.Bl -tag -width orphans
119.It Dv lower
120Connection to the lower device link layer.
121.It Dv upper
122Connection to the upper protocol layers.
123.It Dv orphans
124Like
125.Dv lower ,
126but only receives unrecognized packets.
127.El
128.Sh CONTROL MESSAGES
129This node type supports the generic control messages, plus the following:
130.Bl -tag -width foo
131.It Dv NGM_ETHER_GET_IFNAME
132Returns the name of the associated interface as a NUL-terminated ASCII string.
133Normally this is the same as the name of the node.
134.It Dv NGM_ETHER_GET_IFINDEX
135Returns the global index of the associated interface as a 32 bit integer.
136.El
137.Sh SHUTDOWN
138This node is persistent for as long as the interface exists.
139Upon receipt of a
140.Dv NGM_SHUTDOWN
141control message, all hooks are disconnected, but the node is not removed.
142If the interface itself is detached (e.g., because of PCCARD removal), the
143node disappears as well.
144.Sh EXAMPLE
145This command dumps all unrecognized packets received by the
146.Dv fxp0
147interface to standard output decoded in hex and ASCII:
148.Bd -literal -offset indent
149nghook -a fxp0: orphans
150.Ed
151.Pp
152This command sends the contents of
153.Dv foo.pkt
154out the interface
155.Dv ed0 :
156.Bd -literal -offset indent
157cat foo.pkt | nghook fxp0: orphans
158.Ed
159.Pp
160These commands insert an
161.Xr ng_tee 4
162node between the lower and upper protocol layers, which can be used for
163tracing packet flow, statistics, etc.:
164.Bd -literal -offset indent
165ngctl mkpeer fxp0: tee lower right
166ngctl connect fxp0: lower upper left
167.Ed
168.Sh SEE ALSO
169.Xr arp 4 ,
170.Xr netgraph 4 ,
171.Xr netintro 4 ,
172.Xr ifconfig 8 ,
173.Xr nghook 8 ,
174.Xr ngctl 8
175.Sh AUTHORS
176.An Julian Elischer Aq julian@FreeBSD.org
177.An Archie Cobbs Aq archie@FreeBSD.org
178