1995-03-14 09:16:07 +00:00
|
|
|
/*
|
1997-01-17 23:54:45 +00:00
|
|
|
* Copyright (c) 1995, 1996
|
|
|
|
* Matt Thomas <matt@3am-software.com>. All rights reserved.
|
1995-03-14 09:16:07 +00:00
|
|
|
* Copyright (c) 1982, 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1995-03-14 22:15:36 +00:00
|
|
|
* from: if_ethersubr.c,v 1.5 1994/12/13 22:31:45 wollman Exp
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1995-03-14 09:16:07 +00:00
|
|
|
*/
|
|
|
|
|
1998-01-09 00:51:57 +00:00
|
|
|
#include "opt_atalk.h"
|
1998-01-08 23:42:31 +00:00
|
|
|
#include "opt_inet.h"
|
1999-12-07 17:39:16 +00:00
|
|
|
#include "opt_inet6.h"
|
1997-12-15 20:31:25 +00:00
|
|
|
#include "opt_ipx.h"
|
2002-10-20 22:27:59 +00:00
|
|
|
#include "opt_mac.h"
|
1997-12-15 20:31:25 +00:00
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2002-03-29 09:37:56 +00:00
|
|
|
#include <sys/kernel.h>
|
2002-10-20 22:27:59 +00:00
|
|
|
#include <sys/mac.h>
|
2002-03-29 09:37:56 +00:00
|
|
|
#include <sys/malloc.h>
|
1995-03-14 09:16:07 +00:00
|
|
|
#include <sys/mbuf.h>
|
2002-03-29 09:37:56 +00:00
|
|
|
#include <sys/module.h>
|
1995-03-14 09:16:07 +00:00
|
|
|
#include <sys/socket.h>
|
2002-03-29 09:37:56 +00:00
|
|
|
#include <sys/sockio.h>
|
1997-01-17 23:54:45 +00:00
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_llc.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_types.h>
|
2002-03-29 09:37:56 +00:00
|
|
|
#include <net/netisr.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <net/bpf.h>
|
2002-03-29 08:51:42 +00:00
|
|
|
#include <net/fddi.h>
|
1995-03-14 09:16:07 +00:00
|
|
|
|
1999-12-07 17:39:16 +00:00
|
|
|
#if defined(INET) || defined(INET6)
|
1995-03-14 09:16:07 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/if_ether.h>
|
1998-01-08 23:42:31 +00:00
|
|
|
#endif
|
1999-12-07 17:39:16 +00:00
|
|
|
#ifdef INET6
|
|
|
|
#include <netinet6/nd6.h>
|
|
|
|
#endif
|
1995-03-14 09:16:07 +00:00
|
|
|
|
1995-10-26 20:31:59 +00:00
|
|
|
#ifdef IPX
|
1997-01-17 23:54:45 +00:00
|
|
|
#include <netipx/ipx.h>
|
1995-10-26 20:31:59 +00:00
|
|
|
#include <netipx/ipx_if.h>
|
|
|
|
#endif
|
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
#ifdef NS
|
|
|
|
#include <netns/ns.h>
|
|
|
|
#include <netns/ns_if.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DECNET
|
|
|
|
#include <netdnet/dn.h>
|
|
|
|
#endif
|
|
|
|
|
1997-01-17 23:54:45 +00:00
|
|
|
#ifdef NETATALK
|
|
|
|
#include <netatalk/at.h>
|
|
|
|
#include <netatalk/at_var.h>
|
|
|
|
#include <netatalk/at_extern.h>
|
|
|
|
|
|
|
|
extern u_char at_org_code[ 3 ];
|
|
|
|
extern u_char aarp_org_code[ 3 ];
|
|
|
|
#endif /* NETATALK */
|
|
|
|
|
2002-03-29 10:40:35 +00:00
|
|
|
static u_char fddibroadcastaddr[FDDI_ADDR_LEN] =
|
|
|
|
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
|
|
|
|
2002-03-29 11:22:22 +00:00
|
|
|
static int fddi_resolvemulti(struct ifnet *, struct sockaddr **,
|
2002-03-24 09:34:04 +00:00
|
|
|
struct sockaddr *);
|
2002-03-29 11:22:22 +00:00
|
|
|
static int fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *,
|
|
|
|
struct rtentry *);
|
|
|
|
|
2000-11-01 16:57:01 +00:00
|
|
|
|
2002-03-29 08:04:36 +00:00
|
|
|
#define IFP2AC(IFP) ((struct arpcom *)IFP)
|
|
|
|
#define senderr(e) { error = (e); goto bad; }
|
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
/*
|
|
|
|
* FDDI output routine.
|
|
|
|
* Encapsulate a packet of type family for the local net.
|
|
|
|
* Use trailer local net encapsulation if enough data in first
|
|
|
|
* packet leaves a multiple of 512 bytes of data in remainder.
|
|
|
|
* Assumes that ifp is actually pointer to arpcom structure.
|
|
|
|
*/
|
2002-03-29 11:22:22 +00:00
|
|
|
static int
|
1999-12-19 01:55:37 +00:00
|
|
|
fddi_output(ifp, m, dst, rt0)
|
2002-03-29 07:12:10 +00:00
|
|
|
struct ifnet *ifp;
|
1999-12-19 01:55:37 +00:00
|
|
|
struct mbuf *m;
|
1995-03-14 09:16:07 +00:00
|
|
|
struct sockaddr *dst;
|
|
|
|
struct rtentry *rt0;
|
|
|
|
{
|
1997-01-17 23:54:45 +00:00
|
|
|
u_int16_t type;
|
Lock down the network interface queues. The queue mutex must be obtained
before adding/removing packets from the queue. Also, the if_obytes and
if_omcasts fields should only be manipulated under protection of the mutex.
IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on
the queue. An IF_LOCK macro is provided, as well as the old (mutex-less)
versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which
needs them, but their use is discouraged.
Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF,
which takes care of locking/enqueue, and also statistics updating/start
if necessary.
2000-11-25 07:35:38 +00:00
|
|
|
int loop_copy = 0, error = 0, hdrcmplt = 0;
|
2002-03-29 08:51:42 +00:00
|
|
|
u_char esrc[FDDI_ADDR_LEN], edst[FDDI_ADDR_LEN];
|
2002-03-29 07:12:10 +00:00
|
|
|
struct rtentry *rt;
|
|
|
|
struct fddi_header *fh;
|
2002-03-29 08:04:36 +00:00
|
|
|
struct arpcom *ac = IFP2AC(ifp);
|
1995-03-14 09:16:07 +00:00
|
|
|
|
2002-10-20 22:27:59 +00:00
|
|
|
#ifdef MAC
|
|
|
|
error = mac_check_ifnet_transmit(ifp, m);
|
|
|
|
if (error)
|
|
|
|
senderr(error);
|
|
|
|
#endif
|
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
|
|
|
|
senderr(ENETDOWN);
|
1998-03-30 09:56:58 +00:00
|
|
|
getmicrotime(&ifp->if_lastchange);
|
1999-01-27 22:42:27 +00:00
|
|
|
if ((rt = rt0) != NULL) {
|
1995-03-14 09:16:07 +00:00
|
|
|
if ((rt->rt_flags & RTF_UP) == 0) {
|
2002-03-29 08:04:36 +00:00
|
|
|
if ((rt0 = rt = rtalloc1(dst, 1, 0UL)) != NULL)
|
1995-03-14 09:16:07 +00:00
|
|
|
rt->rt_refcnt--;
|
1997-01-17 23:54:45 +00:00
|
|
|
else
|
1995-03-14 09:16:07 +00:00
|
|
|
senderr(EHOSTUNREACH);
|
|
|
|
}
|
|
|
|
if (rt->rt_flags & RTF_GATEWAY) {
|
|
|
|
if (rt->rt_gwroute == 0)
|
|
|
|
goto lookup;
|
|
|
|
if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) {
|
|
|
|
rtfree(rt); rt = rt0;
|
2002-03-29 08:04:36 +00:00
|
|
|
lookup: rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1, 0UL);
|
1995-03-14 09:16:07 +00:00
|
|
|
if ((rt = rt->rt_gwroute) == 0)
|
|
|
|
senderr(EHOSTUNREACH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rt->rt_flags & RTF_REJECT)
|
|
|
|
if (rt->rt_rmx.rmx_expire == 0 ||
|
1998-03-30 09:56:58 +00:00
|
|
|
time_second < rt->rt_rmx.rmx_expire)
|
1995-03-14 09:16:07 +00:00
|
|
|
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
|
|
|
|
}
|
|
|
|
switch (dst->sa_family) {
|
|
|
|
|
|
|
|
#ifdef INET
|
1997-01-17 23:54:45 +00:00
|
|
|
case AF_INET: {
|
2002-03-29 08:04:36 +00:00
|
|
|
if (!arpresolve(ifp, rt, m, dst, edst, rt0))
|
1995-03-14 09:16:07 +00:00
|
|
|
return (0); /* if not yet resolved */
|
1997-01-17 23:54:45 +00:00
|
|
|
type = htons(ETHERTYPE_IP);
|
1995-03-14 09:16:07 +00:00
|
|
|
break;
|
1997-01-17 23:54:45 +00:00
|
|
|
}
|
1995-03-14 09:16:07 +00:00
|
|
|
#endif
|
1999-12-07 17:39:16 +00:00
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
2002-03-29 09:37:56 +00:00
|
|
|
if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)edst)) {
|
2001-03-11 05:31:45 +00:00
|
|
|
/* Something bad happened */
|
2002-03-29 08:04:36 +00:00
|
|
|
return (0);
|
1999-12-07 17:39:16 +00:00
|
|
|
}
|
|
|
|
type = htons(ETHERTYPE_IPV6);
|
|
|
|
break;
|
|
|
|
#endif
|
1995-10-26 20:31:59 +00:00
|
|
|
#ifdef IPX
|
|
|
|
case AF_IPX:
|
1997-01-17 23:54:45 +00:00
|
|
|
type = htons(ETHERTYPE_IPX);
|
1995-10-26 20:31:59 +00:00
|
|
|
bcopy((caddr_t)&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host),
|
2002-03-29 08:51:42 +00:00
|
|
|
(caddr_t)edst, FDDI_ADDR_LEN);
|
1995-10-26 20:31:59 +00:00
|
|
|
break;
|
|
|
|
#endif
|
1997-01-17 23:54:45 +00:00
|
|
|
#ifdef NETATALK
|
|
|
|
case AF_APPLETALK: {
|
|
|
|
struct at_ifaddr *aa;
|
1998-06-12 03:48:19 +00:00
|
|
|
if (!aarpresolve(ac, m, (struct sockaddr_at *)dst, edst))
|
1997-01-17 23:54:45 +00:00
|
|
|
return (0);
|
|
|
|
/*
|
|
|
|
* ifaddr is the first thing in at_ifaddr
|
|
|
|
*/
|
1997-10-29 07:59:27 +00:00
|
|
|
if ((aa = at_ifawithnet( (struct sockaddr_at *)dst)) == 0)
|
1997-01-17 23:54:45 +00:00
|
|
|
goto bad;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In the phase 2 case, we need to prepend an mbuf for the llc header.
|
|
|
|
* Since we must preserve the value of m, which is passed to us by
|
|
|
|
* value, we m_copy() the first mbuf, and use it for our llc header.
|
|
|
|
*/
|
|
|
|
if (aa->aa_flags & AFA_PHASE2) {
|
|
|
|
struct llc llc;
|
|
|
|
|
2002-03-29 08:51:42 +00:00
|
|
|
M_PREPEND(m, LLC_SNAPFRAMELEN, M_TRYWAIT);
|
1997-01-17 23:54:45 +00:00
|
|
|
if (m == 0)
|
|
|
|
senderr(ENOBUFS);
|
|
|
|
llc.llc_dsap = llc.llc_ssap = LLC_SNAP_LSAP;
|
|
|
|
llc.llc_control = LLC_UI;
|
2002-03-29 08:14:29 +00:00
|
|
|
bcopy(at_org_code, llc.llc_snap.org_code, sizeof(at_org_code));
|
|
|
|
llc.llc_snap.ether_type = htons(ETHERTYPE_AT);
|
2002-03-29 08:51:42 +00:00
|
|
|
bcopy(&llc, mtod(m, caddr_t), LLC_SNAPFRAMELEN);
|
1997-01-17 23:54:45 +00:00
|
|
|
type = 0;
|
|
|
|
} else {
|
|
|
|
type = htons(ETHERTYPE_AT);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif /* NETATALK */
|
1995-03-14 09:16:07 +00:00
|
|
|
#ifdef NS
|
|
|
|
case AF_NS:
|
1997-01-17 23:54:45 +00:00
|
|
|
type = htons(ETHERTYPE_NS);
|
1995-03-14 09:16:07 +00:00
|
|
|
bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
|
2002-03-29 08:51:42 +00:00
|
|
|
(caddr_t)edst, FDDI_ADDR_LEN);
|
1995-03-14 09:16:07 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
1999-10-15 05:07:00 +00:00
|
|
|
case pseudo_AF_HDRCMPLT:
|
|
|
|
{
|
2002-03-29 09:41:03 +00:00
|
|
|
struct ether_header *eh;
|
1999-10-15 05:07:00 +00:00
|
|
|
hdrcmplt = 1;
|
2002-03-29 09:41:03 +00:00
|
|
|
eh = (struct ether_header *)dst->sa_data;
|
|
|
|
bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, FDDI_ADDR_LEN);
|
1999-10-15 05:07:00 +00:00
|
|
|
/* FALLTHROUGH */
|
|
|
|
}
|
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
case AF_UNSPEC:
|
|
|
|
{
|
|
|
|
struct ether_header *eh;
|
1998-06-14 20:58:17 +00:00
|
|
|
loop_copy = -1;
|
1995-03-14 09:16:07 +00:00
|
|
|
eh = (struct ether_header *)dst->sa_data;
|
2002-03-29 09:37:56 +00:00
|
|
|
bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, FDDI_ADDR_LEN);
|
1995-03-14 09:16:07 +00:00
|
|
|
if (*edst & 1)
|
|
|
|
m->m_flags |= (M_BCAST|M_MCAST);
|
|
|
|
type = eh->ether_type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case AF_IMPLINK:
|
|
|
|
{
|
|
|
|
fh = mtod(m, struct fddi_header *);
|
|
|
|
error = EPROTONOSUPPORT;
|
|
|
|
switch (fh->fddi_fc & (FDDIFC_C|FDDIFC_L|FDDIFC_F)) {
|
|
|
|
case FDDIFC_LLC_ASYNC: {
|
|
|
|
/* legal priorities are 0 through 7 */
|
|
|
|
if ((fh->fddi_fc & FDDIFC_Z) > 7)
|
|
|
|
goto bad;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FDDIFC_LLC_SYNC: {
|
|
|
|
/* FDDIFC_Z bits reserved, must be zero */
|
|
|
|
if (fh->fddi_fc & FDDIFC_Z)
|
|
|
|
goto bad;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FDDIFC_SMT: {
|
|
|
|
/* FDDIFC_Z bits must be non zero */
|
|
|
|
if ((fh->fddi_fc & FDDIFC_Z) == 0)
|
|
|
|
goto bad;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
/* anything else is too dangerous */
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
error = 0;
|
|
|
|
if (fh->fddi_dhost[0] & 1)
|
|
|
|
m->m_flags |= (M_BCAST|M_MCAST);
|
|
|
|
goto queue_it;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit,
|
|
|
|
dst->sa_family);
|
|
|
|
senderr(EAFNOSUPPORT);
|
|
|
|
}
|
|
|
|
|
2002-03-29 10:23:42 +00:00
|
|
|
/*
|
|
|
|
* Add LLC header.
|
|
|
|
*/
|
1995-03-14 09:16:07 +00:00
|
|
|
if (type != 0) {
|
2002-03-29 07:12:10 +00:00
|
|
|
struct llc *l;
|
2002-03-29 08:51:42 +00:00
|
|
|
M_PREPEND(m, LLC_SNAPFRAMELEN, M_DONTWAIT);
|
1995-03-14 09:16:07 +00:00
|
|
|
if (m == 0)
|
|
|
|
senderr(ENOBUFS);
|
|
|
|
l = mtod(m, struct llc *);
|
|
|
|
l->llc_control = LLC_UI;
|
|
|
|
l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP;
|
|
|
|
l->llc_snap.org_code[0] = l->llc_snap.org_code[1] = l->llc_snap.org_code[2] = 0;
|
2002-03-29 09:37:56 +00:00
|
|
|
bcopy((caddr_t)&type, (caddr_t)&l->llc_snap.ether_type,
|
1997-01-17 23:54:45 +00:00
|
|
|
sizeof(u_int16_t));
|
1995-03-14 09:16:07 +00:00
|
|
|
}
|
1998-06-12 03:48:19 +00:00
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
/*
|
|
|
|
* Add local net header. If no space in first mbuf,
|
|
|
|
* allocate another.
|
|
|
|
*/
|
2002-03-29 08:51:42 +00:00
|
|
|
M_PREPEND(m, FDDI_HDR_LEN, M_DONTWAIT);
|
1995-03-14 09:16:07 +00:00
|
|
|
if (m == 0)
|
|
|
|
senderr(ENOBUFS);
|
|
|
|
fh = mtod(m, struct fddi_header *);
|
|
|
|
fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4;
|
2002-03-29 09:37:56 +00:00
|
|
|
bcopy((caddr_t)edst, (caddr_t)fh->fddi_dhost, FDDI_ADDR_LEN);
|
1995-03-14 09:16:07 +00:00
|
|
|
queue_it:
|
1999-10-15 05:07:00 +00:00
|
|
|
if (hdrcmplt)
|
2002-03-29 09:37:56 +00:00
|
|
|
bcopy((caddr_t)esrc, (caddr_t)fh->fddi_shost, FDDI_ADDR_LEN);
|
1999-10-15 05:07:00 +00:00
|
|
|
else
|
2002-03-29 09:37:56 +00:00
|
|
|
bcopy((caddr_t)ac->ac_enaddr, (caddr_t)fh->fddi_shost,
|
2002-03-29 08:51:42 +00:00
|
|
|
FDDI_ADDR_LEN);
|
2002-03-29 09:52:01 +00:00
|
|
|
|
1998-06-12 03:48:19 +00:00
|
|
|
/*
|
|
|
|
* If a simplex interface, and the packet is being sent to our
|
|
|
|
* Ethernet address or a broadcast address, loopback a copy.
|
|
|
|
* XXX To make a simplex device behave exactly like a duplex
|
|
|
|
* device, we should copy in the case of sending to our own
|
|
|
|
* ethernet address (thus letting the original actually appear
|
|
|
|
* on the wire). However, we don't do that here for security
|
|
|
|
* reasons and compatibility with the original behavior.
|
|
|
|
*/
|
2002-03-29 09:52:01 +00:00
|
|
|
if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) {
|
1998-06-12 03:48:19 +00:00
|
|
|
if ((m->m_flags & M_BCAST) || loop_copy) {
|
|
|
|
struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
|
|
|
|
|
|
|
|
(void) if_simloop(ifp,
|
2002-03-29 08:51:42 +00:00
|
|
|
n, dst->sa_family, FDDI_HDR_LEN);
|
1998-06-12 03:48:19 +00:00
|
|
|
} else if (bcmp(fh->fddi_dhost,
|
2002-03-29 08:51:42 +00:00
|
|
|
fh->fddi_shost, FDDI_ADDR_LEN) == 0) {
|
1998-06-12 03:48:19 +00:00
|
|
|
(void) if_simloop(ifp,
|
2002-03-29 08:51:42 +00:00
|
|
|
m, dst->sa_family, FDDI_HDR_LEN);
|
2002-03-29 08:04:36 +00:00
|
|
|
return (0); /* XXX */
|
1998-06-12 03:48:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Lock down the network interface queues. The queue mutex must be obtained
before adding/removing packets from the queue. Also, the if_obytes and
if_omcasts fields should only be manipulated under protection of the mutex.
IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on
the queue. An IF_LOCK macro is provided, as well as the old (mutex-less)
versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which
needs them, but their use is discouraged.
Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF,
which takes care of locking/enqueue, and also statistics updating/start
if necessary.
2000-11-25 07:35:38 +00:00
|
|
|
if (! IF_HANDOFF(&ifp->if_snd, m, ifp))
|
1995-03-14 09:16:07 +00:00
|
|
|
senderr(ENOBUFS);
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
bad:
|
2002-03-29 10:17:06 +00:00
|
|
|
ifp->if_oerrors++;
|
1995-03-14 09:16:07 +00:00
|
|
|
if (m)
|
|
|
|
m_freem(m);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process a received FDDI packet;
|
|
|
|
* the packet is in the mbuf chain m without
|
|
|
|
* the fddi header, which is provided separately.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
fddi_input(ifp, fh, m)
|
|
|
|
struct ifnet *ifp;
|
2002-03-29 07:12:10 +00:00
|
|
|
struct fddi_header *fh;
|
1995-03-14 09:16:07 +00:00
|
|
|
struct mbuf *m;
|
|
|
|
{
|
2002-03-29 07:12:10 +00:00
|
|
|
struct ifqueue *inq;
|
|
|
|
struct llc *l;
|
1995-03-14 09:16:07 +00:00
|
|
|
|
2002-03-29 10:17:06 +00:00
|
|
|
/*
|
|
|
|
* Discard packet if interface is not up.
|
|
|
|
*/
|
|
|
|
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
|
|
|
|
goto dropanyway;
|
|
|
|
|
2002-10-20 22:27:59 +00:00
|
|
|
#ifdef MAC
|
|
|
|
mac_create_mbuf_from_ifnet(ifp, m);
|
|
|
|
#endif
|
|
|
|
|
2002-03-29 10:17:06 +00:00
|
|
|
/*
|
|
|
|
* Discard non local unicast packets when interface
|
|
|
|
* is in promiscuous mode.
|
|
|
|
*/
|
|
|
|
if ((ifp->if_flags & IFF_PROMISC) && ((fh->fddi_dhost[0] & 1) == 0) &&
|
|
|
|
(bcmp(IFP2AC(ifp)->ac_enaddr, (caddr_t)fh->fddi_dhost,
|
|
|
|
FDDI_ADDR_LEN) != 0))
|
|
|
|
goto dropanyway;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set mbuf flags for bcast/mcast.
|
|
|
|
*/
|
1997-01-17 23:54:45 +00:00
|
|
|
if (fh->fddi_dhost[0] & 1) {
|
2002-03-29 10:29:10 +00:00
|
|
|
if (bcmp((caddr_t)ifp->if_broadcastaddr,
|
|
|
|
(caddr_t)fh->fddi_dhost, FDDI_ADDR_LEN) == 0)
|
1997-01-17 23:54:45 +00:00
|
|
|
m->m_flags |= M_BCAST;
|
|
|
|
else
|
|
|
|
m->m_flags |= M_MCAST;
|
1995-03-14 09:16:07 +00:00
|
|
|
ifp->if_imcasts++;
|
1997-01-17 23:54:45 +00:00
|
|
|
}
|
|
|
|
|
2002-03-29 10:17:06 +00:00
|
|
|
/*
|
|
|
|
* Update interface statistics.
|
|
|
|
*/
|
|
|
|
getmicrotime(&ifp->if_lastchange);
|
|
|
|
ifp->if_ibytes += (m->m_pkthdr.len + FDDI_HDR_LEN);
|
|
|
|
|
1997-01-17 23:54:45 +00:00
|
|
|
#ifdef M_LINK0
|
|
|
|
/*
|
|
|
|
* If this has a LLC priority of 0, then mark it so upper
|
|
|
|
* layers have a hint that it really came via a FDDI/Ethernet
|
|
|
|
* bridge.
|
|
|
|
*/
|
|
|
|
if ((fh->fddi_fc & FDDIFC_LLC_PRIO7) == FDDIFC_LLC_PRIO0)
|
|
|
|
m->m_flags |= M_LINK0;
|
|
|
|
#endif
|
1995-03-14 09:16:07 +00:00
|
|
|
|
2002-03-29 10:17:06 +00:00
|
|
|
m = m_pullup(m, sizeof(struct llc));
|
|
|
|
if (m == 0) {
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
goto dropanyway;
|
|
|
|
}
|
1995-03-14 09:16:07 +00:00
|
|
|
l = mtod(m, struct llc *);
|
2002-03-29 09:52:01 +00:00
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
switch (l->llc_dsap) {
|
|
|
|
case LLC_SNAP_LSAP:
|
|
|
|
{
|
1997-01-17 23:54:45 +00:00
|
|
|
u_int16_t type;
|
2002-03-29 10:17:06 +00:00
|
|
|
if (l->llc_control != LLC_UI || l->llc_ssap != LLC_SNAP_LSAP) {
|
|
|
|
ifp->if_noproto++;
|
1995-03-14 09:16:07 +00:00
|
|
|
goto dropanyway;
|
2002-03-29 10:17:06 +00:00
|
|
|
}
|
1997-01-17 23:54:45 +00:00
|
|
|
#ifdef NETATALK
|
2002-03-29 08:14:29 +00:00
|
|
|
if (Bcmp(&(l->llc_snap.org_code)[0], at_org_code,
|
1997-01-17 23:54:45 +00:00
|
|
|
sizeof(at_org_code)) == 0 &&
|
2002-03-29 08:14:29 +00:00
|
|
|
ntohs(l->llc_snap.ether_type) == ETHERTYPE_AT) {
|
1997-01-17 23:54:45 +00:00
|
|
|
inq = &atintrq2;
|
2002-03-29 08:51:42 +00:00
|
|
|
m_adj(m, LLC_SNAPFRAMELEN);
|
1997-01-17 23:54:45 +00:00
|
|
|
schednetisr(NETISR_ATALK);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-03-29 08:14:29 +00:00
|
|
|
if (Bcmp(&(l->llc_snap.org_code)[0], aarp_org_code,
|
1997-01-17 23:54:45 +00:00
|
|
|
sizeof(aarp_org_code)) == 0 &&
|
2002-03-29 08:14:29 +00:00
|
|
|
ntohs(l->llc_snap.ether_type) == ETHERTYPE_AARP) {
|
2002-03-29 08:51:42 +00:00
|
|
|
m_adj(m, LLC_SNAPFRAMELEN);
|
2002-03-29 08:04:36 +00:00
|
|
|
aarpinput(IFP2AC(ifp), m); /* XXX */
|
1997-01-17 23:54:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif /* NETATALK */
|
2002-03-29 09:52:01 +00:00
|
|
|
if (l->llc_snap.org_code[0] != 0 ||
|
|
|
|
l->llc_snap.org_code[1] != 0 ||
|
2002-03-29 10:17:06 +00:00
|
|
|
l->llc_snap.org_code[2] != 0) {
|
|
|
|
ifp->if_noproto++;
|
1995-03-14 09:16:07 +00:00
|
|
|
goto dropanyway;
|
2002-03-29 10:17:06 +00:00
|
|
|
}
|
2002-03-29 09:52:01 +00:00
|
|
|
|
1997-01-17 23:54:45 +00:00
|
|
|
type = ntohs(l->llc_snap.ether_type);
|
2002-03-29 09:52:01 +00:00
|
|
|
m_adj(m, LLC_SNAPFRAMELEN);
|
|
|
|
|
1997-01-17 23:54:45 +00:00
|
|
|
switch (type) {
|
1995-03-14 09:16:07 +00:00
|
|
|
#ifdef INET
|
|
|
|
case ETHERTYPE_IP:
|
1998-05-21 00:33:16 +00:00
|
|
|
if (ipflow_fastforward(m))
|
1998-05-19 14:04:36 +00:00
|
|
|
return;
|
1995-03-14 09:16:07 +00:00
|
|
|
schednetisr(NETISR_IP);
|
|
|
|
inq = &ipintrq;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ETHERTYPE_ARP:
|
2001-06-15 21:00:32 +00:00
|
|
|
if (ifp->if_flags & IFF_NOARP)
|
|
|
|
goto dropanyway;
|
1995-03-14 09:16:07 +00:00
|
|
|
schednetisr(NETISR_ARP);
|
|
|
|
inq = &arpintrq;
|
|
|
|
break;
|
|
|
|
#endif
|
1999-12-07 17:39:16 +00:00
|
|
|
#ifdef INET6
|
|
|
|
case ETHERTYPE_IPV6:
|
|
|
|
schednetisr(NETISR_IPV6);
|
|
|
|
inq = &ip6intrq;
|
|
|
|
break;
|
|
|
|
#endif
|
1997-01-17 23:54:45 +00:00
|
|
|
#ifdef IPX
|
|
|
|
case ETHERTYPE_IPX:
|
|
|
|
schednetisr(NETISR_IPX);
|
|
|
|
inq = &ipxintrq;
|
|
|
|
break;
|
|
|
|
#endif
|
1995-03-14 09:16:07 +00:00
|
|
|
#ifdef NS
|
|
|
|
case ETHERTYPE_NS:
|
|
|
|
schednetisr(NETISR_NS);
|
|
|
|
inq = &nsintrq;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef DECNET
|
1997-01-17 23:54:45 +00:00
|
|
|
case ETHERTYPE_DECNET:
|
1995-03-14 09:16:07 +00:00
|
|
|
schednetisr(NETISR_DECNET);
|
|
|
|
inq = &decnetintrq;
|
|
|
|
break;
|
|
|
|
#endif
|
1997-01-17 23:54:45 +00:00
|
|
|
#ifdef NETATALK
|
|
|
|
case ETHERTYPE_AT:
|
|
|
|
schednetisr(NETISR_ATALK);
|
|
|
|
inq = &atintrq1;
|
|
|
|
break;
|
|
|
|
case ETHERTYPE_AARP:
|
|
|
|
/* probably this should be done with a NETISR as well */
|
2002-03-29 08:04:36 +00:00
|
|
|
aarpinput(IFP2AC(ifp), m); /* XXX */
|
1997-01-17 23:54:45 +00:00
|
|
|
return;
|
|
|
|
#endif /* NETATALK */
|
1995-03-14 09:16:07 +00:00
|
|
|
default:
|
1997-01-17 23:54:45 +00:00
|
|
|
/* printf("fddi_input: unknown protocol 0x%x\n", type); */
|
1995-03-14 09:16:07 +00:00
|
|
|
ifp->if_noproto++;
|
|
|
|
goto dropanyway;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1997-01-17 23:54:45 +00:00
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
default:
|
1997-01-17 23:54:45 +00:00
|
|
|
/* printf("fddi_input: unknown dsap 0x%x\n", l->llc_dsap); */
|
1995-03-14 09:16:07 +00:00
|
|
|
ifp->if_noproto++;
|
2002-03-29 09:52:01 +00:00
|
|
|
goto dropanyway;
|
1995-03-14 09:16:07 +00:00
|
|
|
}
|
|
|
|
|
Lock down the network interface queues. The queue mutex must be obtained
before adding/removing packets from the queue. Also, the if_obytes and
if_omcasts fields should only be manipulated under protection of the mutex.
IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on
the queue. An IF_LOCK macro is provided, as well as the old (mutex-less)
versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which
needs them, but their use is discouraged.
Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF,
which takes care of locking/enqueue, and also statistics updating/start
if necessary.
2000-11-25 07:35:38 +00:00
|
|
|
(void) IF_HANDOFF(inq, m, NULL);
|
2002-03-29 09:52:01 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
dropanyway:
|
|
|
|
ifp->if_iqdrops++;
|
|
|
|
if (m)
|
|
|
|
m_freem(m);
|
|
|
|
return;
|
1995-03-14 09:16:07 +00:00
|
|
|
}
|
2002-03-29 10:23:42 +00:00
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
/*
|
|
|
|
* Perform common duties while attaching to interface list
|
|
|
|
*/
|
|
|
|
void
|
2002-03-29 11:22:22 +00:00
|
|
|
fddi_ifattach(ifp, bpf)
|
2002-03-29 07:12:10 +00:00
|
|
|
struct ifnet *ifp;
|
2002-03-29 11:22:22 +00:00
|
|
|
int bpf;
|
1995-03-14 09:16:07 +00:00
|
|
|
{
|
2002-03-29 07:12:10 +00:00
|
|
|
struct ifaddr *ifa;
|
|
|
|
struct sockaddr_dl *sdl;
|
1995-03-14 09:16:07 +00:00
|
|
|
|
|
|
|
ifp->if_type = IFT_FDDI;
|
2002-03-29 08:51:42 +00:00
|
|
|
ifp->if_addrlen = FDDI_ADDR_LEN;
|
1995-03-14 09:16:07 +00:00
|
|
|
ifp->if_hdrlen = 21;
|
2002-03-29 10:17:06 +00:00
|
|
|
|
|
|
|
if_attach(ifp); /* Must be called before additional assignments */
|
|
|
|
|
1995-03-14 09:16:07 +00:00
|
|
|
ifp->if_mtu = FDDIMTU;
|
2002-03-29 10:17:06 +00:00
|
|
|
ifp->if_output = fddi_output;
|
2000-11-01 16:57:01 +00:00
|
|
|
ifp->if_resolvemulti = fddi_resolvemulti;
|
2002-03-29 10:17:06 +00:00
|
|
|
ifp->if_broadcastaddr = fddibroadcastaddr;
|
1996-06-01 23:25:10 +00:00
|
|
|
ifp->if_baudrate = 100000000;
|
1997-01-17 23:54:45 +00:00
|
|
|
#ifdef IFF_NOTRAILERS
|
|
|
|
ifp->if_flags |= IFF_NOTRAILERS;
|
|
|
|
#endif
|
2002-03-29 10:17:06 +00:00
|
|
|
ifa = ifaddr_byindex(ifp->if_index);
|
|
|
|
if (ifa == NULL) {
|
|
|
|
printf("%s(): no lladdr for %s%d!\n", __FUNCTION__,
|
|
|
|
ifp->if_name, ifp->if_unit);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-01-17 23:56:20 +00:00
|
|
|
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
|
|
|
|
sdl->sdl_type = IFT_FDDI;
|
|
|
|
sdl->sdl_alen = ifp->if_addrlen;
|
2002-03-29 08:04:36 +00:00
|
|
|
bcopy(IFP2AC(ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
|
2002-03-29 10:17:06 +00:00
|
|
|
|
2002-03-29 11:22:22 +00:00
|
|
|
if (bpf)
|
|
|
|
bpfattach(ifp, DLT_FDDI, FDDI_HDR_LEN);
|
|
|
|
|
2002-03-29 10:17:06 +00:00
|
|
|
return;
|
1995-03-14 09:16:07 +00:00
|
|
|
}
|
2000-11-01 16:57:01 +00:00
|
|
|
|
2002-03-29 10:40:35 +00:00
|
|
|
void
|
|
|
|
fddi_ifdetach(ifp, bpf)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
int bpf;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (bpf)
|
|
|
|
bpfdetach(ifp);
|
|
|
|
|
|
|
|
if_detach(ifp);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
fddi_ioctl (ifp, command, data)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
int command;
|
|
|
|
caddr_t data;
|
|
|
|
{
|
|
|
|
struct ifaddr *ifa;
|
|
|
|
struct ifreq *ifr;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
ifa = (struct ifaddr *) data;
|
|
|
|
ifr = (struct ifreq *) data;
|
|
|
|
error = 0;
|
|
|
|
|
|
|
|
switch (command) {
|
|
|
|
case SIOCSIFADDR:
|
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
|
|
|
|
switch (ifa->ifa_addr->sa_family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET: /* before arpwhohas */
|
|
|
|
ifp->if_init(ifp->if_softc);
|
|
|
|
arp_ifinit(ifp, ifa);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef IPX
|
|
|
|
/*
|
|
|
|
* XXX - This code is probably wrong
|
|
|
|
*/
|
|
|
|
case AF_IPX: {
|
|
|
|
struct ipx_addr *ina;
|
|
|
|
struct arpcom *ac;
|
|
|
|
|
|
|
|
ina = &(IA_SIPX(ifa)->sipx_addr);
|
|
|
|
ac = IFP2AC(ifp);
|
|
|
|
|
|
|
|
if (ipx_nullhost(*ina)) {
|
|
|
|
ina->x_host = *(union ipx_host *)
|
|
|
|
ac->ac_enaddr;
|
|
|
|
} else {
|
|
|
|
bcopy((caddr_t) ina->x_host.c_host,
|
|
|
|
(caddr_t) ac->ac_enaddr,
|
|
|
|
sizeof(ac->ac_enaddr));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set new address
|
|
|
|
*/
|
|
|
|
ifp->if_init(ifp->if_softc);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
ifp->if_init(ifp->if_softc);
|
|
|
|
break;
|
2002-10-01 15:48:31 +00:00
|
|
|
}
|
2002-03-29 10:40:35 +00:00
|
|
|
case SIOCGIFADDR: {
|
|
|
|
struct sockaddr *sa;
|
|
|
|
|
|
|
|
sa = (struct sockaddr *) & ifr->ifr_data;
|
|
|
|
bcopy(IFP2AC(ifp)->ac_enaddr,
|
|
|
|
(caddr_t) sa->sa_data, FDDI_ADDR_LEN);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SIOCSIFMTU:
|
|
|
|
/*
|
|
|
|
* Set the interface MTU.
|
|
|
|
*/
|
|
|
|
if (ifr->ifr_mtu > FDDIMTU) {
|
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
ifp->if_mtu = ifr->ifr_mtu;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2000-11-01 16:57:01 +00:00
|
|
|
static int
|
|
|
|
fddi_resolvemulti(ifp, llsa, sa)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
struct sockaddr **llsa;
|
|
|
|
struct sockaddr *sa;
|
|
|
|
{
|
|
|
|
struct sockaddr_dl *sdl;
|
|
|
|
struct sockaddr_in *sin;
|
|
|
|
#ifdef INET6
|
|
|
|
struct sockaddr_in6 *sin6;
|
|
|
|
#endif
|
|
|
|
u_char *e_addr;
|
|
|
|
|
|
|
|
switch(sa->sa_family) {
|
|
|
|
case AF_LINK:
|
|
|
|
/*
|
|
|
|
* No mapping needed. Just check that it's a valid MC address.
|
|
|
|
*/
|
|
|
|
sdl = (struct sockaddr_dl *)sa;
|
|
|
|
e_addr = LLADDR(sdl);
|
|
|
|
if ((e_addr[0] & 1) != 1)
|
2002-03-29 08:04:36 +00:00
|
|
|
return (EADDRNOTAVAIL);
|
2000-11-01 16:57:01 +00:00
|
|
|
*llsa = 0;
|
2002-03-29 08:04:36 +00:00
|
|
|
return (0);
|
2000-11-01 16:57:01 +00:00
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
sin = (struct sockaddr_in *)sa;
|
|
|
|
if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr)))
|
2002-03-29 08:04:36 +00:00
|
|
|
return (EADDRNOTAVAIL);
|
2000-11-01 16:57:01 +00:00
|
|
|
MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR,
|
|
|
|
M_WAITOK);
|
|
|
|
sdl->sdl_len = sizeof *sdl;
|
|
|
|
sdl->sdl_family = AF_LINK;
|
|
|
|
sdl->sdl_index = ifp->if_index;
|
|
|
|
sdl->sdl_type = IFT_FDDI;
|
|
|
|
sdl->sdl_nlen = 0;
|
2002-03-29 09:37:56 +00:00
|
|
|
sdl->sdl_alen = FDDI_ADDR_LEN;
|
2000-11-01 16:57:01 +00:00
|
|
|
sdl->sdl_slen = 0;
|
|
|
|
e_addr = LLADDR(sdl);
|
|
|
|
ETHER_MAP_IP_MULTICAST(&sin->sin_addr, e_addr);
|
|
|
|
*llsa = (struct sockaddr *)sdl;
|
2002-03-29 08:04:36 +00:00
|
|
|
return (0);
|
2000-11-01 16:57:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
|
|
|
sin6 = (struct sockaddr_in6 *)sa;
|
|
|
|
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
|
|
|
|
/*
|
|
|
|
* An IP6 address of 0 means listen to all
|
|
|
|
* of the Ethernet multicast address used for IP6.
|
|
|
|
* (This is used for multicast routers.)
|
|
|
|
*/
|
|
|
|
ifp->if_flags |= IFF_ALLMULTI;
|
|
|
|
*llsa = 0;
|
2002-03-29 08:04:36 +00:00
|
|
|
return (0);
|
2000-11-01 16:57:01 +00:00
|
|
|
}
|
|
|
|
if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
|
2002-03-29 08:04:36 +00:00
|
|
|
return (EADDRNOTAVAIL);
|
2000-11-01 16:57:01 +00:00
|
|
|
MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR,
|
|
|
|
M_WAITOK);
|
|
|
|
sdl->sdl_len = sizeof *sdl;
|
|
|
|
sdl->sdl_family = AF_LINK;
|
|
|
|
sdl->sdl_index = ifp->if_index;
|
|
|
|
sdl->sdl_type = IFT_FDDI;
|
|
|
|
sdl->sdl_nlen = 0;
|
2002-03-29 09:37:56 +00:00
|
|
|
sdl->sdl_alen = FDDI_ADDR_LEN;
|
2000-11-01 16:57:01 +00:00
|
|
|
sdl->sdl_slen = 0;
|
|
|
|
e_addr = LLADDR(sdl);
|
|
|
|
ETHER_MAP_IPV6_MULTICAST(&sin6->sin6_addr, e_addr);
|
|
|
|
*llsa = (struct sockaddr *)sdl;
|
2002-03-29 08:04:36 +00:00
|
|
|
return (0);
|
2000-11-01 16:57:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* Well, the text isn't quite right, but it's the name
|
|
|
|
* that counts...
|
|
|
|
*/
|
2002-03-29 08:04:36 +00:00
|
|
|
return (EAFNOSUPPORT);
|
2000-11-01 16:57:01 +00:00
|
|
|
}
|
2002-03-29 09:37:56 +00:00
|
|
|
|
|
|
|
return (0);
|
2000-11-01 16:57:01 +00:00
|
|
|
}
|
2002-03-29 09:37:56 +00:00
|
|
|
|
|
|
|
static moduledata_t fddi_mod = {
|
|
|
|
"fddi", /* module name */
|
|
|
|
NULL, /* event handler */
|
|
|
|
0 /* extra data */
|
|
|
|
};
|
|
|
|
|
|
|
|
DECLARE_MODULE(fddi, fddi_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
|
|
|
|
MODULE_VERSION(fddi, 1);
|