xref: /netbsd-src/share/man/man9/ethersubr.9 (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1.\"	$NetBSD: ethersubr.9,v 1.5 1997/11/27 06:17:59 mikel 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.Dd March 3, 1997
34.Dt ETHERSUBR 9
35.Os NetBSD
36.Sh NAME
37.Nm ethersubr ,
38.Nm ether_ifattach ,
39.Nm ether_addmulti ,
40.Nm ether_delmulti ,
41.Nm ETHER_FIRST_MULTI ,
42.Nm ETHER_NEXT_MULTI ,
43.Nm ETHER_IS_MULTICAST ,
44.Nm fddi_ifattach ,
45.Nm fddi_addmulti ,
46.Nm fddi_delmulti
47.Nd Ethernet and FDDI driver support functions and macros
48.Sh SYNOPSIS
49.Fd #include <net/if_ether.h>
50.Ft void
51.Fn ether_ifattach "struct ifnet *ifp" "u_int8_t *lla"
52.Ft int
53.Fn ether_addmulti "struct ifrequest *ifr" "struct ethercom *ec"
54.Ft int
55.Fn ether_delmulti "struct ifrequest *ifr" "struct ethercom *ec"
56.Ft void
57.Fn ETHER_FIRST_MULTI "struct ether_multistep step" "struct ethercom *ec" "struct ether_multi *enm"
58.Ft void
59.Fn ETHER_NEXT_MULTI  "struct ether_multistep step" "struct ether_multi *enm"
60.Ft int
61.Fn ETHER_IS_MULTICAST "u_int8_t *addr"
62.Fd #include <net/if_fddi.h>
63.Ft void
64.Fn fddi_ifattach "struct ifnet *ifp" "u_int8_t *lla"
65.Ft int
66.Fn fddi_addmulti "struct ifrequest *ifr" "struct ethercom *ec"
67.Ft int
68.Fn fddi_delmulti "struct ifrequest *ifr" "struct ethercom *ec"
69.Sh DESCRIPTION
70The
71.Nm
72functions provide the interface between the
73.Nm
74module and the network drivers which need Ethernet support. Such
75drivers must request the "ether" attribute in their "files" declaration
76and call the appropriate functions as specified below.
77.Pp
78FDDI drivers must request the "fddi" attribute in their "files"
79declaration and call the functions tagged with "fddi_" or "FDDI_"
80instead, where different. Some macros are shared.
81.Pp
82Note that you also need the
83.Xr arp 9
84stuff to support IPv4 on your hardware.
85.Bl -tag -width compact
86.It Fn ether_ifattach
87Perform the device-independent, but Ethernet-specific initialization of
88the interface pointed to by
89.Fa ifp .
90.Pp
91Among other duties, this function creates a record for the link level
92address in the interface's address list and records the link level address
93pointed to by
94.Fa lla
95there.
96.Pp
97You must call this function from the driver's attach function.
98.It Fn fddi_ifattach
99corresponding function for FDDI devices.
100.It Fn ether_addmulti
101.It Fn ether_delmulti
102Add
103.Pq Fn ether_addmulti
104or delete
105.Pq Fn ether_delmulti
106the address described by the
107.Fa ifr
108pointer to the Ethernet multicast list belonging to
109.Fa ec .
110.Pp
111These functions must be called from the driver's ioctl function to
112handle
113.Dv SIOCADDMULTI
114and
115.Dv SIOCDELMULTI
116requests. If they return
117.Er ENETRESET ,
118the hardware multicast filter must be reinitialized.
119.Pp
120These functions accept
121.Dv AF_UNSPEC
122addresses, which are interpreted as Ethernet addresses, or
123.Dv AF_INET
124addresses. In the latter case,
125.Dv INADDR_ANY
126is mapped to a range describing all the Ethernet address
127space reserved for IPv4 multicast addresses.
128.Pp
129.Fn ether_addmulti
130returns
131.Er EAFNOSUPPORT
132if an unsupported address family is specified,
133.Er EINVAL
134if a non-multicast address is specified, or
135.Er ENETRESET
136if
137the multicast list really changed and the driver should synchronize
138its hardware filter with it.
139.Pp
140.Fn ether_delmulti
141returns, in addition to the above errors,
142.Er ENXIO
143if the specified address
144can't be found in the list of multicast addresses.
145.It Fn fddi_addmulti
146.It Fn fddi_delmulti
147corresponding functions for FDDI devices.
148.It Fn ETHER_NEXT_MULTI
149is a macro to step through all of the ether_multi records, one at a time.
150The current position is remembered in
151.Fa step ,
152which the caller must provide.
153.It Fn ETHER_FIRST_MULTI
154must be called to initialize
155.Fa step
156and get the first record.  Both macros return a
157.Dv NULL
158.Fa enm
159when there are no remaining records.
160.It Fn ETHER_IS_MULTICAST
161returns 1, if
162.Fa addr
163points to an Ethernet/FDDI multicast (or broadcast) address.
164Implemented as a macro.
165.El
166.Sh SEE ALSO
167.Xr arp 9 .
168.Sh AUTHORS
169UCB CSRG (original implementation)
170.br
171Ignatios Souvatzis (support for new ARP system)
172.Sh CODE REFERENCES
173Ethernet support functions are declared in
174.Aq Pa net/if_ether.h
175and defined (if not implemented as macro) in
176.Pa /usr/src/sys/net/if_ethersubr.c .
177.Pp
178FDDI support functions are declared in
179.Aq Pa net/if_fddi.h
180and defined (if not implemented as macro) in
181.Pa /usr/src/sys/net/if_fddisubr.c .
182.Sh HISTORY
183Rewritten to attach to the new ARP system in
184.Nx 1.3 .
185