1.\" $NetBSD: ethersubr.9,v 1.2 1997/05/25 17:58:22 is Exp $ 2.\" 3.\" Copyright (c) 1997 Ignatios Souvatzis. 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed for the NetBSD Project 17.\" by Ignatios Souvatzis 18.\" 4. The name of the author may not be used to endorse or promote products 19.\" derived from this software without specific prior written permission. 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" SUCH DAMAGE. 32.\" 33 34.Dd Mar 3, 1997 35.Dt ETHERSUBR 9 36.Os NetBSD 37.Sh NAME 38.Nm ETHERSUBR 39.Nd Ethernet and FDDI driver support functions and macros 40.Sh SYNOPSIS 41.Fd #include <net/if_ether.h> 42.Ft void 43.Fn ether_ifattach "struct ifnet *ifp" "u_int8_t *lla" 44.Ft int 45.Fn ether_addmulti "struct ifrequest *ifr" "struct ethercom *ec" 46.Ft int 47.Fn ether_delmulti "struct ifrequest *ifr" "struct ethercom *ec" 48.Ft void 49.Fn ETHER_FIRST_MULTI "struct ether_multistep step" "struct ethercom *ec" "struct ether_multi *enm" 50.Ft void 51.Fn ETHER_NEXT_MULTI "struct ether_multistep step" "struct ether_multi *enm" 52.Ft int 53.Fn ETHER_IS_MULTICAST "u_int8_t *addr" 54 55.Fd #include <net/if_fddi.h> 56.Ft void 57.Fn fddi_ifattach "struct ifnet *ifp" "u_int8_t *lla" 58.Ft int 59.Fn fddi_addmulti "struct ifrequest *ifr" "struct ethercom *ec" 60.Ft int 61.Fn fddi_delmulti "struct ifrequest *ifr" "struct ethercom *ec" 62 63.Sh DESCRIPTION 64The 65.Nm 66functions provide the interface between the 67.Nm 68module and the network drivers which need Ethernet support. Such 69drivers must request the "ether" attribute in their "files" declaration 70and call the appropriate functions as specified below. 71 72FDDI drivers must request the "fddi" attribute in their "files" 73declaration and call the functions tagged with "fddi_" or "FDDI_" 74instead, where different. Some macros are shared. 75 76Note that you also need the 77.Xr ARP 9 78stuff to support IPv4 on your hardware. 79 80.Bl -tag -width compact 81 82.It Fn ether_ifattach 83 84Perform the device independent, but Ethernet specific initialization of 85the interface pointed to by 86.Fa ifp . 87 88Among other duties, this function creates a record for the link level 89address in the interfaces' address list and records the link level address 90pointed to by 91.Fa lla 92there. 93 94You must call this function from the drivers' attach function. 95 96.It Fn fddi_ifattach 97 98corresponding function for FDDI devices. 99 100.It Fn ether_addmulti 101.It Fn ether_delmulti 102 103Add ( 104.Fn ether_addmulti ) 105or delete ( 106.Fn ether_delmulti ) 107the address described by the 108.Fa ifr 109pointer to the Ethernet multicast list belonging to 110.Fa ec . 111 112These functions must be called from the drivers' ioctl function to 113handle SIOCADDMULTI and SIOCDELMULTI requests. If they return 114ENETRESET, the hardware multicast filter must be reinitialized. 115 116These functions accept AF_UNSPEC addresses, which are interpreted as 117Ethernet addresses, or AF_INET addresses. In the latter case, 118INADDR_ANY is mapped to a range describing all the Ethernet address 119space reserved for IPv4 multicast addresses. 120 121.Fn ether_addmulti 122 123returns EAFNOSUPPORT if an unsupportedd address family is specified, 124or EINVAL, if a non-multicast address is specified, or ENETRESET, if 125the multicast list really changed and the driver should synchronize 126its hardware filter with it. 127 128.Fn ether_delmulti 129 130returns, in addition to the above errors, ENXIO, if the specified address 131can't be found in the list of multicast addresses. 132 133.It Fn fddi_addmulti 134.It Fn fddi_delmulti 135corresponding functions for FDDI devices. 136 137.It Fn ETHER_NEXT_MULTI 138is a macro to step through all of the ether_multi records, one at a time. 139The current position is remembered in 140.Fa step , 141which the caller must provide. 142.It Fn ETHER_FIRST_MULTI 143must be called to initialize 144.Fa step 145and get the first record. Both macros return a NULL 146.Fa enm 147when there are no remaining records. 148 149.It Fn ETHER_IS_MULTICAST 150 151returns 1, if 152.Fa addr 153points to an Ethernet/FDDI multicast (or broadcast) address. 154Implemented as a macro. 155 156.El 157 158 159.\" .Sh ERRORS 160 161.Sh SEE ALSO 162.Xr arp 9 . 163 164.Sh AUTHORS 165UCB CSRG (original implementation) 166.br 167Ignatios Souvatzis (support for new ARP system) 168 169.\" .Sh BUGS 170 171.\" .Sh STANDARDS 172 173.Sh CODE REFERENCES 174 175Ethernet support functions are declared in /usr/src/sys/net/if_ether.h 176and defined (if not implemented as macro) in 177/usr/src/sys/net/if_ethersubr.c. 178 179FDDI support functions are declared in /usr/src/sys/net/if_fddi.h and 180defined (if not implemented as macro) in /usr/src/sys/net/if_fddisubr.c. 181 182 183.Sh HISTORY 184Rewritten to attach to the new ARP system in 185.Nx 1.2d . 186