Disable the ability to change the system clock with a sysctl. More
[dragonfly.git] / sys / net / if_fddisubr.c
1 /*
2  * Copyright (c) 1995, 1996
3  *      Matt Thomas <matt@3am-software.com>.  All rights reserved.
4  * Copyright (c) 1982, 1989, 1993
5  *      The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by the University of
18  *      California, Berkeley and its contributors.
19  * 4. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *      from: if_ethersubr.c,v 1.5 1994/12/13 22:31:45 wollman Exp
36  * $FreeBSD: src/sys/net/if_fddisubr.c,v 1.41.2.8 2002/02/20 23:34:09 fjoe Exp $
37  * $DragonFly: src/sys/net/Attic/if_fddisubr.c,v 1.17 2005/05/08 18:11:02 joerg Exp $
38  */
39
40 #include "opt_atalk.h"
41 #include "opt_inet.h"
42 #include "opt_inet6.h"
43 #include "opt_ipx.h"
44
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/mbuf.h>
48 #include <sys/socket.h>
49 #include <sys/malloc.h>
50
51 #include <net/if.h>
52 #include <net/bpf.h>
53 #include <net/netisr.h>
54 #include <net/route.h>
55 #include <net/if_llc.h>
56 #include <net/if_dl.h>
57 #include <net/if_types.h>
58 #include <net/ifq_var.h>
59
60 #if defined(INET) || defined(INET6)
61 #include <netinet/in.h>
62 #include <netinet/in_var.h>
63 #include <netinet/if_ether.h>
64 #include <net/ethernet.h>
65 #endif
66 #ifdef INET6
67 #include <netinet6/nd6.h>
68 #endif
69 #if defined(__DragonFly__) || defined(__FreeBSD__)
70 #include <netinet/if_fddi.h>
71 #else
72 #include <net/if_fddi.h>
73 #endif
74
75 #ifdef IPX
76 #include <netproto/ipx/ipx.h>
77 #include <netproto/ipx/ipx_if.h>
78 #endif
79
80 #ifdef NS
81 #include <netns/ns.h>
82 #include <netns/ns_if.h>
83 #endif
84
85 #ifdef DECNET
86 #include <netdnet/dn.h>
87 #endif
88
89 #ifdef NETATALK
90 #include <netproto/atalk/at.h>
91 #include <netproto/atalk/at_var.h>
92 #include <netproto/atalk/at_extern.h>
93
94 #define llc_snap_org_code llc_un.type_snap.org_code
95 #define llc_snap_ether_type llc_un.type_snap.ether_type
96
97 extern u_char   at_org_code[ 3 ];
98 extern u_char   aarp_org_code[ 3 ];
99 #endif /* NETATALK */
100
101 static  int fddi_resolvemulti (struct ifnet *, struct sockaddr **,
102                                    struct sockaddr *);
103 static void     fddi_input(struct ifnet *, struct mbuf *);
104 static int      fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *,
105                             struct rtentry *);
106
107 #define senderr(e) { error = (e); goto bad;}
108
109 /*
110  * This really should be defined in if_llc.h but in case it isn't.
111  */
112 #ifndef llc_snap
113 #define llc_snap        llc_un.type_snap
114 #endif
115
116 #if defined(__DragonFly__)
117 #define RTALLOC1(a, b)          _rtlookup(a, b, b ? RTL_DOCLONE : RTL_DONTCLONE)
118 #define ARPRESOLVE(a, b, c, d, e, f)    arpresolve(a, b, c, d, e)
119 #elif defined(__FreeBSD__)
120 #define RTALLOC1(a, b)                  rtalloc1(a, b, 0UL)
121 #define ARPRESOLVE(a, b, c, d, e, f)    arpresolve(a, b, c, d, e, f)
122 #endif
123 /*
124  * FDDI output routine.
125  * Encapsulate a packet of type family for the local net.
126  * Use trailer local net encapsulation if enough data in first
127  * packet leaves a multiple of 512 bytes of data in remainder.
128  * Assumes that ifp is actually pointer to arpcom structure.
129  */
130 static int
131 fddi_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
132             struct rtentry *rt)
133 {
134         struct arpcom *ac = (struct arpcom *)ifp;
135         u_int16_t type;
136         u_char esrc[6], edst[6];
137         struct fddi_header *fh;
138         boolean_t hdrcmplt = FALSE;
139         int loop_copy = 0, error;
140         struct altq_pktattr pktattr;
141
142         if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
143                 senderr(ENETDOWN);
144
145         /*
146          * If the queueing discipline needs packet classification,
147          * do it before prepending link headers.
148          */
149         ifq_classify(&ifp->if_snd, m, dst->sa_family, &pktattr);
150
151         switch (dst->sa_family) {
152 #ifdef INET
153         case AF_INET: {
154                 if (!arpresolve(ifp, rt, m, dst, edst))
155                         return (0);     /* if not yet resolved */
156                 type = htons(ETHERTYPE_IP);
157                 break;
158         }
159 #endif
160 #ifdef INET6
161         case AF_INET6:
162                 if (!nd6_storelladdr(&ac->ac_if, rt, m, dst, (u_char *)edst)) {
163                         /* Something bad happened */
164                         return (0);
165                 }
166                 type = htons(ETHERTYPE_IPV6);
167                 break;
168 #endif
169 #ifdef IPX
170         case AF_IPX:
171                 type = htons(ETHERTYPE_IPX);
172                 bcopy(&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host), edst,
173                       sizeof edst);
174                 break;
175 #endif
176 #ifdef NETATALK
177         case AF_APPLETALK: {
178                 struct at_ifaddr *aa;
179
180                 if (!aarpresolve((struct arpcom *) ifp, m,
181                                  (struct sockaddr_at *)dst, edst))
182                         return (0);
183
184                 /*
185                  * ifaddr is the first thing in at_ifaddr
186                  */
187                 if ((aa = at_ifawithnet((struct sockaddr_at *)dst)) == NULL) {
188                         error = 0;      /* XXX */
189                         goto bad;
190                 }
191
192                 /*
193                  * In the phase 2 case, we need to prepend an mbuf
194                  * for the llc header.  Since we must preserve the
195                  * value of m, which is passed to us by value, we
196                  * m_copy() the first mbuf, and use it for our llc
197                  * header.
198                  */
199                 if (aa->aa_flags & AFA_PHASE2) {
200                         struct llc llc;
201
202                         M_PREPEND(m, sizeof(struct llc), MB_WAIT);
203                         if (m == NULL)
204                                 senderr(ENOBUFS);
205                         llc.llc_dsap = llc.llc_ssap = LLC_SNAP_LSAP;
206                         llc.llc_control = LLC_UI;
207                         bcopy(at_org_code, llc.llc_snap_org_code,
208                               sizeof at_org_code);
209                         llc.llc_snap_ether_type = htons(ETHERTYPE_AT);
210                         bcopy(&llc, mtod(m, caddr_t), sizeof(struct llc));
211                         type = 0;
212                 } else {
213                         type = htons(ETHERTYPE_AT);
214                 }
215                 break;
216         }
217 #endif /* NETATALK */
218 #ifdef NS
219         case AF_NS:
220                 type = htons(ETHERTYPE_NS);
221                 bcopy(&(((struct sockaddr_ns *)dst)->sns_addr.x_host), edst,
222                       sizeof edst);
223                 break;
224 #endif
225
226         case pseudo_AF_HDRCMPLT:
227         {
228                 struct ether_header *eh;
229
230                 hdrcmplt = TRUE;
231                 eh = (struct ether_header *)dst->sa_data;
232                 memcpy(esrc, eh->ether_shost, sizeof esrc);
233                 /* FALLTHROUGH */
234         }
235
236         case AF_UNSPEC:
237         {
238                 struct ether_header *eh;
239
240                 loop_copy = -1;
241                 eh = (struct ether_header *)dst->sa_data;
242                 memcpy(edst, eh->ether_dhost, sizeof edst);
243                 if (*edst & 1)
244                         m->m_flags |= (M_BCAST|M_MCAST);
245                 type = eh->ether_type;
246                 break;
247         }
248
249         case AF_IMPLINK:
250         {
251                 fh = mtod(m, struct fddi_header *);
252                 error = EPROTONOSUPPORT;
253                 switch (fh->fddi_fc & (FDDIFC_C|FDDIFC_L|FDDIFC_F)) {
254                         case FDDIFC_LLC_ASYNC: {
255                                 /* legal priorities are 0 through 7 */
256                                 if ((fh->fddi_fc & FDDIFC_Z) > 7)
257                                         goto bad;
258                                 break;
259                         }
260                         case FDDIFC_LLC_SYNC: {
261                                 /* FDDIFC_Z bits reserved, must be zero */
262                                 if (fh->fddi_fc & FDDIFC_Z)
263                                         goto bad;
264                                 break;
265                         }
266                         case FDDIFC_SMT: {
267                                 /* FDDIFC_Z bits must be non zero */
268                                 if ((fh->fddi_fc & FDDIFC_Z) == 0)
269                                         goto bad;
270                                 break;
271                         }
272                         default: {
273                                 /* anything else is too dangerous */
274                                 goto bad;
275                         }
276                 }
277                 error = 0;
278                 if (fh->fddi_dhost[0] & 1)
279                         m->m_flags |= (M_BCAST | M_MCAST);
280                 goto queue_it;
281         }
282         default:
283                 printf("%s: can't handle af%d\n", ifp->if_xname,
284                         dst->sa_family);
285                 senderr(EAFNOSUPPORT);
286         }
287
288         if (type != 0) {
289                 struct llc *l;
290
291                 M_PREPEND(m, sizeof(struct llc), MB_DONTWAIT);
292                 if (m == NULL)
293                         return (ENOBUFS);
294                 l = mtod(m, struct llc *);
295                 l->llc_control = LLC_UI;
296                 l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP;
297                 l->llc_snap.org_code[0] = l->llc_snap.org_code[1] =
298                     l->llc_snap.org_code[2] = 0;
299                 memcpy(&l->llc_snap.ether_type, &type, sizeof(u_int16_t));
300         }
301
302         /*
303          * Add local net header.  If no space in first mbuf,
304          * allocate another.
305          */
306         M_PREPEND(m, sizeof(struct fddi_header), MB_DONTWAIT);
307         if (m == NULL)
308                 return (ENOBUFS);
309         fh = mtod(m, struct fddi_header *);
310         fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4;
311         memcpy(fh->fddi_dhost, edst, sizeof edst);
312
313 queue_it:
314         if (hdrcmplt)
315                 memcpy(fh->fddi_shost, esrc, sizeof fh->fddi_shost);
316         else
317                 memcpy(fh->fddi_shost, ac->ac_enaddr, sizeof fh->fddi_shost);
318         /*
319                 memcpy(fh->fddi_shost, ac->ac_enaddr, sizeof fh->fddi_shost);
320          * Ethernet address or a broadcast address, loopback a copy.
321          * XXX To make a simplex device behave exactly like a duplex
322          * device, we should copy in the case of sending to our own
323          * ethernet address (thus letting the original actually appear
324          * on the wire). However, we don't do that here for security
325          * reasons and compatibility with the original behavior.
326          */
327         if ((ifp->if_flags & IFF_SIMPLEX) &&
328            (loop_copy != -1)) {
329                 if ((m->m_flags & M_BCAST) || loop_copy) {
330                         struct mbuf *n = m_copypacket(m, MB_DONTWAIT);
331
332                         if_simloop(ifp, n, dst->sa_family,
333                                    sizeof(struct fddi_header));
334                 } else if (bcmp(fh->fddi_dhost, fh->fddi_shost,
335                                 sizeof(fh->fddi_shost)) == 0) {
336                         if_simloop(ifp, m, dst->sa_family,
337                                    sizeof(struct fddi_header));
338                         senderr(0);     /* XXX */
339                 }
340         }
341
342         /*
343          * Dispatch the message to the interface.
344          */
345         return (ifq_handoff(ifp, m, &pktattr));
346
347 bad:
348         m_freem(m);
349         return (error);
350 }
351
352 /*
353  * Process a received FDDI packet;
354  * the packet is in the mbuf chain m without
355  * the fddi header, which is provided separately.
356  */
357 static void
358 fddi_input(struct ifnet *ifp, struct mbuf *m)
359 {
360         int isr;
361         struct llc *l;
362         struct fddi_header *fh = mtod(m, struct fddi_header *);
363
364         if (m->m_len < sizeof(struct fddi_header)) {
365                 /* XXX error in the caller. */
366                 m_freem(m);
367                 return;
368         }
369         m_adj(m, sizeof(struct fddi_header));
370         m->m_pkthdr.rcvif = ifp;
371
372         if (!(ifp->if_flags & IFF_UP)) {
373                 m_freem(m);
374                 return;
375         }
376         getmicrotime(&ifp->if_lastchange);
377         ifp->if_ibytes += m->m_pkthdr.len + sizeof *fh;
378         if (fh->fddi_dhost[0] & 1) {
379                 if (bcmp(ifp->if_broadcastaddr, fh->fddi_dhost,
380                          ifp->if_addrlen) == 0)
381                         m->m_flags |= M_BCAST;
382                 else
383                         m->m_flags |= M_MCAST;
384                 ifp->if_imcasts++;
385         } else if ((ifp->if_flags & IFF_PROMISC) &&
386             bcmp(((struct arpcom *)ifp)->ac_enaddr, fh->fddi_dhost,
387                  sizeof fh->fddi_dhost) != 0) {
388                 m_freem(m);
389                 return;
390         }
391
392 #ifdef M_LINK0
393         /*
394          * If this has a LLC priority of 0, then mark it so upper
395          * layers have a hint that it really came via a FDDI/Ethernet
396          * bridge.
397          */
398         if ((fh->fddi_fc & FDDIFC_LLC_PRIO7) == FDDIFC_LLC_PRIO0)
399                 m->m_flags |= M_LINK0;
400 #endif
401
402         l = mtod(m, struct llc *);
403         switch (l->llc_dsap) {
404 #if defined(INET) || defined(INET6) || defined(NS) || defined(DECNET) || defined(IPX) || defined(NETATALK)
405         case LLC_SNAP_LSAP:
406         {
407                 u_int16_t type;
408                 if (l->llc_control != LLC_UI || l->llc_ssap != LLC_SNAP_LSAP)
409                         goto dropanyway;
410 #ifdef NETATALK
411                 if (bcmp(&(l->llc_snap_org_code)[0], at_org_code,
412                          sizeof(at_org_code)) == 0 &&
413                     sizeof(at_org_code) == 0 &&
414                     ntohs(l->llc_snap_ether_type) == ETHERTYPE_AT) {
415                         m_adj(m, sizeof(struct llc));
416                         isr = NETISR_ATALK2;
417                         break;
418                 }
419
420                 if (bcmp(&(l->llc_snap_org_code)[0], aarp_org_code,
421                          sizeof(aarp_org_code)) == 0 &&
422                         ntohs(l->llc_snap_ether_type) == ETHERTYPE_AARP) {
423                     m_adj(m, sizeof(struct llc));
424                     isr = NETISR_AARP;
425                     break;
426                 }
427 #endif
428                 if (l->llc_snap.org_code[0] != 0 ||
429                     l->llc_snap.org_code[1] != 0 ||
430                     l->llc_snap.org_code[2] != 0)
431                         goto dropanyway;
432                 type = ntohs(l->llc_snap.ether_type);
433                 m_adj(m, 8);
434                 switch (type) {
435 #ifdef INET
436                 case ETHERTYPE_IP:
437                         if (ipflow_fastforward(m))
438                                 return;
439                         isr = NETISR_IP;
440                         break;
441
442                 case ETHERTYPE_ARP:
443                         if (ifp->if_flags & IFF_NOARP)
444                                 goto dropanyway;
445                         isr = NETISR_ARP;
446                         break;
447 #endif
448 #ifdef INET6
449                 case ETHERTYPE_IPV6:
450                         isr = NETISR_IPV6;
451                         break;
452 #endif
453 #ifdef IPX
454                 case ETHERTYPE_IPX:
455                         isr = NETISR_IPX;
456                         break;
457 #endif
458 #ifdef NS
459                 case ETHERTYPE_NS:
460                         isr = NETISR_NS;
461                         break;
462 #endif
463 #ifdef DECNET
464                 case ETHERTYPE_DECNET:
465                         isr = NETISR_DECNET;
466                         break;
467 #endif
468 #ifdef NETATALK
469                 case ETHERTYPE_AT:
470                         isr = NETISR_ATALK1;
471                         break;
472                 case ETHERTYPE_AARP:
473                         isr = NETISR_AARP;
474                         break;
475 #endif /* NETATALK */
476                 default:
477                         /* printf("fddi_input: unknown protocol 0x%x\n", type); */
478                         ifp->if_noproto++;
479                         goto dropanyway;
480                 }
481                 break;
482         }
483 #endif /* INET || NS */
484
485         default:
486                 /* printf("fddi_input: unknown dsap 0x%x\n", l->llc_dsap); */
487                 ifp->if_noproto++;
488         dropanyway:
489                 m_freem(m);
490                 return;
491         }
492
493         netisr_dispatch(isr, m);
494 }
495
496 /*
497  * Perform common duties while attaching to interface list
498  */
499 #ifdef __NetBSD__
500 #define ifa_next        ifa_list.tqe_next
501 #endif
502
503 void
504 fddi_ifattach(ifp)
505         struct ifnet *ifp;
506 {
507         struct ifaddr *ifa;
508         struct sockaddr_dl *sdl;
509
510         ifp->if_input = fddi_input;
511         ifp->if_output = fddi_output;
512         ifp->if_type = IFT_FDDI;
513         ifp->if_addrlen = 6;
514         ifp->if_broadcastaddr = fddibroadcastaddr;
515         ifp->if_hdrlen = 21;
516         ifp->if_mtu = FDDIMTU;
517         ifp->if_resolvemulti = fddi_resolvemulti;
518         ifp->if_baudrate = 100000000;
519 #ifdef IFF_NOTRAILERS
520         ifp->if_flags |= IFF_NOTRAILERS;
521 #endif
522         if_attach(ifp);
523 #if defined(__DragonFly__) || defined(__FreeBSD__)
524         ifa = ifnet_addrs[ifp->if_index - 1];
525         sdl = (struct sockaddr_dl *)ifa->ifa_addr;
526         sdl->sdl_type = IFT_FDDI;
527         sdl->sdl_alen = ifp->if_addrlen;
528         bcopy(((struct arpcom *)ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
529 #elif defined(__NetBSD__)
530         LIST_INIT(&((struct arpcom *)ifp)->ac_multiaddrs);
531         for (ifa = ifp->if_addrlist.tqh_first; ifa != NULL; ifa = ifa->ifa_list.tqe_next)
532 #else
533         for (ifa = ifp->if_addrlist; ifa != NULL; ifa = ifa->ifa_next)
534 #endif
535 #if !defined(__DragonFly__) && !defined(__FreeBSD__)
536                 if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&
537                     sdl->sdl_family == AF_LINK) {
538                         sdl->sdl_type = IFT_FDDI;
539                         sdl->sdl_alen = ifp->if_addrlen;
540                         bcopy(((struct arpcom *)ifp)->ac_enaddr, LLADDR(sdl),
541                               ifp->if_addrlen);
542                         break;
543                 }
544 #endif
545         bpfattach(ifp, DLT_FDDI, sizeof(struct fddi_header));
546 }
547
548 static int
549 fddi_resolvemulti(ifp, llsa, sa)
550         struct ifnet *ifp;
551         struct sockaddr **llsa;
552         struct sockaddr *sa;
553 {
554         struct sockaddr_dl *sdl;
555         struct sockaddr_in *sin;
556 #ifdef INET6
557         struct sockaddr_in6 *sin6;
558 #endif
559         u_char *e_addr;
560
561         switch(sa->sa_family) {
562         case AF_LINK:
563                 /*
564                  * No mapping needed. Just check that it's a valid MC address.
565                  */
566                 sdl = (struct sockaddr_dl *)sa;
567                 e_addr = LLADDR(sdl);
568                 if ((e_addr[0] & 1) != 1)
569                         return EADDRNOTAVAIL;
570                 *llsa = 0;
571                 return 0;
572
573 #ifdef INET
574         case AF_INET:
575                 sin = (struct sockaddr_in *)sa;
576                 if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr)))
577                         return EADDRNOTAVAIL;
578                 MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR,
579                        M_WAITOK);
580                 sdl->sdl_len = sizeof *sdl;
581                 sdl->sdl_family = AF_LINK;
582                 sdl->sdl_index = ifp->if_index;
583                 sdl->sdl_type = IFT_FDDI;
584                 sdl->sdl_nlen = 0;
585                 sdl->sdl_alen = ETHER_ADDR_LEN; /* XXX */
586                 sdl->sdl_slen = 0;
587                 e_addr = LLADDR(sdl);
588                 ETHER_MAP_IP_MULTICAST(&sin->sin_addr, e_addr);
589                 *llsa = (struct sockaddr *)sdl;
590                 return 0;
591 #endif
592 #ifdef INET6
593         case AF_INET6:
594                 sin6 = (struct sockaddr_in6 *)sa;
595                 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
596                         /*
597                          * An IP6 address of 0 means listen to all
598                          * of the Ethernet multicast address used for IP6.
599                          * (This is used for multicast routers.)
600                          */
601                         ifp->if_flags |= IFF_ALLMULTI;
602                         *llsa = 0;
603                         return 0;
604                 }
605                 if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
606                         return EADDRNOTAVAIL;
607                 MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR,
608                        M_WAITOK);
609                 sdl->sdl_len = sizeof *sdl;
610                 sdl->sdl_family = AF_LINK;
611                 sdl->sdl_index = ifp->if_index;
612                 sdl->sdl_type = IFT_FDDI;
613                 sdl->sdl_nlen = 0;
614                 sdl->sdl_alen = ETHER_ADDR_LEN; /* XXX */
615                 sdl->sdl_slen = 0;
616                 e_addr = LLADDR(sdl);
617                 ETHER_MAP_IPV6_MULTICAST(&sin6->sin6_addr, e_addr);
618                 *llsa = (struct sockaddr *)sdl;
619                 return 0;
620 #endif
621
622         default:
623                 /*
624                  * Well, the text isn't quite right, but it's the name
625                  * that counts...
626                  */
627                 return EAFNOSUPPORT;
628         }
629 }