1a6086278SArchie Cobbs.\" Copyright (c) 2000 Whistle Communications, Inc. 2a6086278SArchie Cobbs.\" All rights reserved. 3a6086278SArchie Cobbs.\" 4a6086278SArchie Cobbs.\" Subject to the following obligations and disclaimer of warranty, use and 5a6086278SArchie Cobbs.\" redistribution of this software, in source or object code forms, with or 6a6086278SArchie Cobbs.\" without modifications are expressly permitted by Whistle Communications; 7a6086278SArchie Cobbs.\" provided, however, that: 8a6086278SArchie Cobbs.\" 1. Any and all reproductions of the source or object code must include the 9a6086278SArchie Cobbs.\" copyright notice above and the following disclaimer of warranties; and 10a6086278SArchie Cobbs.\" 2. No rights are granted, in any manner or form, to use Whistle 11a6086278SArchie Cobbs.\" Communications, Inc. trademarks, including the mark "WHISTLE 12a6086278SArchie Cobbs.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as 13a6086278SArchie Cobbs.\" such appears in the above copyright notice or in the software. 14a6086278SArchie Cobbs.\" 15a6086278SArchie Cobbs.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 16a6086278SArchie Cobbs.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 17a6086278SArchie Cobbs.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 18a6086278SArchie Cobbs.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 19a6086278SArchie Cobbs.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 20a6086278SArchie Cobbs.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 21a6086278SArchie Cobbs.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 22a6086278SArchie Cobbs.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 23a6086278SArchie Cobbs.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 24a6086278SArchie Cobbs.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 25a6086278SArchie Cobbs.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 26a6086278SArchie Cobbs.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 27a6086278SArchie Cobbs.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 28a6086278SArchie Cobbs.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29a6086278SArchie Cobbs.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30a6086278SArchie Cobbs.\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 31a6086278SArchie Cobbs.\" OF SUCH DAMAGE. 32a6086278SArchie Cobbs.\" 33eddc45e7SJeroen Ruigrok van der Werven.\" Author: Archie Cobbs <archie@FreeBSD.org> 34a6086278SArchie Cobbs.\" 35a6086278SArchie Cobbs.\" $FreeBSD$ 36a6086278SArchie Cobbs.\" 37b3fed38dSArchie Cobbs.Dd June 26, 2000 3895d7878cSArchie Cobbs.Dt NG_ETHER 4 39a6086278SArchie Cobbs.Os FreeBSD 40a6086278SArchie Cobbs.Sh NAME 41a6086278SArchie Cobbs.Nm ng_ether 42a6086278SArchie Cobbs.Nd Ethernet netgraph node type 43a6086278SArchie Cobbs.Sh SYNOPSIS 44a6086278SArchie Cobbs.Fd #include <netgraph/ng_ether.h> 45a6086278SArchie Cobbs.Sh DESCRIPTION 46a6086278SArchie CobbsThe 47b3fed38dSArchie Cobbs.Nm ng_ether 48a6086278SArchie Cobbsnetgraph node type allows Ethernet interfaces to interact with 49a6086278SArchie Cobbsthe 50a6086278SArchie Cobbs.Xr netgraph 4 51b3fed38dSArchie Cobbsnetworking subsystem. 52b3fed38dSArchie CobbsOnce the 53b3fed38dSArchie Cobbs.Nm 54b3fed38dSArchie Cobbsmodule is loaded in the kernel, a node is automatically created 55b3fed38dSArchie Cobbsfor each Ethernet interface in the system. 56b3fed38dSArchie CobbsEach node will attempt to name itself with the same name 57b3fed38dSArchie Cobbsas the associated interface. 58b3fed38dSArchie CobbsAll 59b3fed38dSArchie Cobbs.Nm 60b3fed38dSArchie Cobbsnodes are persistent for as long as the interface itself exists. 61a6086278SArchie Cobbs.Pp 62b3fed38dSArchie CobbsThree hooks are supported: 63b3fed38dSArchie Cobbs.Dv lower , 64b3fed38dSArchie Cobbs.Dv upper , 65b3fed38dSArchie Cobbsand 66b3fed38dSArchie Cobbs.Dv orphans . 67b3fed38dSArchie CobbsThe hook name 68a6086278SArchie Cobbs.Dv divert 69b3fed38dSArchie Cobbsmay be used as an alias for 70b3fed38dSArchie Cobbs.Dv lower , 71b3fed38dSArchie Cobbsand is provided for backward compatibility. 72b3fed38dSArchie CobbsIn reality the two names represent the same hook. 73a6086278SArchie Cobbs.Pp 74b3fed38dSArchie CobbsThe 75b3fed38dSArchie Cobbs.Dv lower 76b3fed38dSArchie Cobbshook is a connection to the raw Ethernet device. 77b3fed38dSArchie CobbsWhen connected, all incoming packets are diverted out this hook. 78b3fed38dSArchie CobbsWriting to this hook results in a raw Ethernet frame being transmitted 79b3fed38dSArchie Cobbsby the device. 80b3fed38dSArchie CobbsNormal outgoing packets are not affected by 81b3fed38dSArchie Cobbs.Dv lower 82b3fed38dSArchie Cobbsbeing connected. 83b3fed38dSArchie Cobbs.Pp 84b3fed38dSArchie CobbsThe 85b3fed38dSArchie Cobbs.Dv upper 86b3fed38dSArchie Cobbshook is a connection to the upper protocol layers. 87b3fed38dSArchie CobbsWhen connected, all outgoing packets are diverted out this hook. 88b3fed38dSArchie CobbsWriting to this hook results in a raw Ethernet frame being received by 89b3fed38dSArchie Cobbsthe kernel just as if it had come in over the wire. 90b3fed38dSArchie CobbsNormal incoming packets are not affected by 91b3fed38dSArchie Cobbs.Dv upper 92b3fed38dSArchie Cobbsbeing connected. 93b3fed38dSArchie Cobbs.Pp 94b3fed38dSArchie CobbsThe 95b3fed38dSArchie Cobbs.Dv orphans 96b3fed38dSArchie Cobbshook is equivalent to 97b3fed38dSArchie Cobbs.Dv lower , 98b3fed38dSArchie Cobbsexcept that only unrecognized packets (that would otherwise be discarded) 99b3fed38dSArchie Cobbsare written to the hook, and normal incoming traffic is unaffected. 100b3fed38dSArchie CobbsAt most one of 101b3fed38dSArchie Cobbs.Dv orphans 102b3fed38dSArchie Cobbsand 103b3fed38dSArchie Cobbs.Dv lower 104b3fed38dSArchie Cobbsmay be connected at any time. 105b3fed38dSArchie Cobbs.Pp 106b3fed38dSArchie CobbsIn all cases, frames are raw Ethernet frames with the standard 107a6086278SArchie Cobbs14 byte Ethernet header (but no checksum). 108b3fed38dSArchie Cobbs.Pp 109b3fed38dSArchie CobbsWhen no hooks are connected, 110b3fed38dSArchie Cobbs.Dv upper 111b3fed38dSArchie Cobbsand 112b3fed38dSArchie Cobbs.Dv lower 113b3fed38dSArchie Cobbsare in effect connected together, 114b3fed38dSArchie Cobbsso that packets flow normally upwards and downwards. 115a6086278SArchie Cobbs.Sh HOOKS 116a6086278SArchie CobbsThis node type supports the following hooks: 117a6086278SArchie Cobbs.Pp 118a6086278SArchie Cobbs.Bl -tag -width orphans 119b3fed38dSArchie Cobbs.It Dv lower 120b3fed38dSArchie CobbsConnection to the lower device link layer. 121b3fed38dSArchie Cobbs.It Dv upper 122b3fed38dSArchie CobbsConnection to the upper protocol layers. 123a6086278SArchie Cobbs.It Dv orphans 124b3fed38dSArchie CobbsLike 125b3fed38dSArchie Cobbs.Dv lower , 126b3fed38dSArchie Cobbsbut only receives unrecognized packets. 127a6086278SArchie Cobbs.El 128a6086278SArchie Cobbs.Sh CONTROL MESSAGES 129b3fed38dSArchie CobbsThis node type supports the generic control messages, plus the following: 130b3fed38dSArchie Cobbs.Bl -tag -width foo 131b3fed38dSArchie Cobbs.It Dv NGM_ETHER_GET_IFNAME 132b3fed38dSArchie CobbsReturns the name of the associated interface as a NUL-terminated ASCII string. 133b3fed38dSArchie CobbsNormally this is the same as the name of the node. 134b3fed38dSArchie Cobbs.It Dv NGM_ETHER_GET_IFINDEX 135b3fed38dSArchie CobbsReturns the global index of the associated interface as a 32 bit integer. 1361623d682SArchie Cobbs.It Dv NGM_ETHER_GET_ENADDR 1371623d682SArchie CobbsReturns the device's unique six byte Ethernet address. 13881e88a06SArchie Cobbs.It Dv NGM_ETHER_SET_ENADDR 13981e88a06SArchie CobbsSets the device's unique six byte Ethernet address. 14081e88a06SArchie CobbsThis control message is equivalent to using the 14181e88a06SArchie Cobbs.Dv SIOCSIFLLADDR 14281e88a06SArchie Cobbs.Xr ioctl 2 14381e88a06SArchie Cobbssystem call. 1441623d682SArchie Cobbs.It Dv NGM_ETHER_SET_PROMISC 1451623d682SArchie CobbsEnable or disable promiscuous mode. 1461623d682SArchie CobbsThis message includes a single 32 bit integer flag that enables or 1471623d682SArchie Cobbsdisables promiscuous mode on the interface. 14881e88a06SArchie Cobbs.It Dv NGM_ETHER_GET_PROMISC 14981e88a06SArchie CobbsGet the current value of the node's promiscuous flag. 15081e88a06SArchie CobbsThe returned value is always either one or zero. 15181e88a06SArchie CobbsNote that this flag reflects the node's own promiscuous setting 15281e88a06SArchie Cobbsand does not necessarily reflect the promiscuous state of the actual 15381e88a06SArchie Cobbsinterface, which can be affected by other means (e.g., 15481e88a06SArchie Cobbs.Xr bpf 4 ) . 1551623d682SArchie Cobbs.It Dv NGM_ETHER_SET_AUTOSRC 1561623d682SArchie CobbsSets the automatic source address override flag. 157320089a0SArchie CobbsThis message includes a single 32 bit integer flag that causes 1581623d682SArchie Cobbsall outgoing packets to have their source Ethernet 1591623d682SArchie Cobbsaddress field overwritten with the device's unique Ethernet address. 1601623d682SArchie CobbsIf this flag is set to zero, the source address in outgoing packets 1611623d682SArchie Cobbsis not modified. 1621623d682SArchie CobbsThe default setting for this flag is enabled. 16381e88a06SArchie Cobbs.It Dv NGM_ETHER_GET_AUTOSRC 16481e88a06SArchie CobbsGet the current value of the node's source address override flag. 16581e88a06SArchie CobbsThe returned value is always either one or zero. 166b3fed38dSArchie Cobbs.El 167a6086278SArchie Cobbs.Sh SHUTDOWN 168b3fed38dSArchie CobbsThis node is persistent for as long as the interface exists. 169b3fed38dSArchie CobbsUpon receipt of a 170a6086278SArchie Cobbs.Dv NGM_SHUTDOWN 1711623d682SArchie Cobbscontrol message, all hooks are disconnected, promiscuous mode is disabled, 1721623d682SArchie Cobbsand the source address override flag is reenabled, 1731623d682SArchie Cobbsbut the node is not removed. 174b3fed38dSArchie CobbsIf the interface itself is detached (e.g., because of PCCARD removal), the 175b3fed38dSArchie Cobbsnode disappears as well. 176251c176fSRuslan Ermilov.Sh EXAMPLES 177b3fed38dSArchie CobbsThis command dumps all unrecognized packets received by the 178a6086278SArchie Cobbs.Dv fxp0 179b3fed38dSArchie Cobbsinterface to standard output decoded in hex and ASCII: 180ac4a79b0SArchie Cobbs.Bd -literal -offset indent 181b3fed38dSArchie Cobbsnghook -a fxp0: orphans 182b3fed38dSArchie Cobbs.Ed 183b3fed38dSArchie Cobbs.Pp 184b3fed38dSArchie CobbsThis command sends the contents of 185b3fed38dSArchie Cobbs.Dv foo.pkt 186b3fed38dSArchie Cobbsout the interface 187b3fed38dSArchie Cobbs.Dv ed0 : 188b3fed38dSArchie Cobbs.Bd -literal -offset indent 189b3fed38dSArchie Cobbscat foo.pkt | nghook fxp0: orphans 190b3fed38dSArchie Cobbs.Ed 191b3fed38dSArchie Cobbs.Pp 192b3fed38dSArchie CobbsThese commands insert an 193b3fed38dSArchie Cobbs.Xr ng_tee 4 194b3fed38dSArchie Cobbsnode between the lower and upper protocol layers, which can be used for 195b3fed38dSArchie Cobbstracing packet flow, statistics, etc.: 196b3fed38dSArchie Cobbs.Bd -literal -offset indent 197b3fed38dSArchie Cobbsngctl mkpeer fxp0: tee lower right 198b3fed38dSArchie Cobbsngctl connect fxp0: lower upper left 199ac4a79b0SArchie Cobbs.Ed 200a6086278SArchie Cobbs.Sh SEE ALSO 201a6086278SArchie Cobbs.Xr arp 4 , 202a6086278SArchie Cobbs.Xr netgraph 4 , 203a6086278SArchie Cobbs.Xr netintro 4 , 204a6086278SArchie Cobbs.Xr ifconfig 8 , 205a6086278SArchie Cobbs.Xr nghook 8 , 206a6086278SArchie Cobbs.Xr ngctl 8 207b3fed38dSArchie Cobbs.Sh AUTHORS 208d905b0b6SMike Pritchard.An Julian Elischer Aq julian@FreeBSD.org 209b3fed38dSArchie Cobbs.An Archie Cobbs Aq archie@FreeBSD.org 210