p_tracep -> p_tracenode, tracking changes made in recent commits.
[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.21 2006/01/14 11:05:17 swildner 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 #include <sys/serialize.h>
51
52 #include <net/if.h>
53 #include <net/bpf.h>
54 #include <net/netisr.h>
55 #include <net/route.h>
56 #include <net/if_llc.h>
57 #include <net/if_dl.h>
58 #include <net/if_types.h>
59 #include <net/ifq_var.h>
60
61 #if defined(INET) || defined(INET6)
62 #include <netinet/in.h>
63 #include <netinet/in_var.h>
64 #include <netinet/if_ether.h>
65 #include <net/ethernet.h>
66 #endif
67 #ifdef INET6
68 #include <netinet6/nd6.h>
69 #endif
70 #if defined(__DragonFly__) || defined(__FreeBSD__)
71 #include <netinet/if_fddi.h>
72 #else
73 #include <net/if_fddi.h>
74 #endif
75
76 #ifdef IPX
77 #include <netproto/ipx/ipx.h>
78 #include <netproto/ipx/ipx_if.h>
79 #endif
80
81 #ifdef NS
82 #include <netns/ns.h>
83 #include <netns/ns_if.h>
84 #endif
85
86 #ifdef DECNET
87 #include <netdnet/dn.h>
88 #endif
89
90 #ifdef NETATALK
91 #include <netproto/atalk/at.h>
92 #include <netproto/atalk/at_var.h>
93 #include <netproto/atalk/at_extern.h>
94
95 #define llc_snap_org_code llc_un.type_snap.org_code
96 #define llc_snap_ether_type llc_un.type_snap.ether_type
97
98 extern u_char   at_org_code[ 3 ];
99 extern u_char   aarp_org_code[ 3 ];
100 #endif /* NETATALK */
101
102 static  int fddi_resolvemulti (struct ifnet *, struct sockaddr **,
103                                    struct sockaddr *);
104 static void     fddi_input(struct ifnet *, struct mbuf *);
105 static int      fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *,
106                             struct rtentry *);
107
108 #define senderr(e) { error = (e); goto bad;}
109
110 /*
111  * This really should be defined in if_llc.h but in case it isn't.
112  */
113 #ifndef llc_snap
114 #define llc_snap        llc_un.type_snap
115 #endif
116
117 #if defined(__DragonFly__)
118 #define RTALLOC1(a, b)          _rtlookup(a, b, b ? RTL_DOCLONE : RTL_DONTCLONE)
119 #define ARPRESOLVE(a, b, c, d, e, f)    arpresolve(a, b, c, d, e)
120 #elif defined(__FreeBSD__)
121 #define RTALLOC1(a, b)                  rtalloc1(a, b, 0UL)
122 #define ARPRESOLVE(a, b, c, d, e, f)    arpresolve(a, b, c, d, e, f)
123 #endif
124 /*
125  * FDDI output routine.
126  * Encapsulate a packet of type family for the local net.
127  * Use trailer local net encapsulation if enough data in first
128  * packet leaves a multiple of 512 bytes of data in remainder.
129  * Assumes that ifp is actually pointer to arpcom structure.
130  */
131 static int
132 fddi_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
133             struct rtentry *rt)
134 {
135         struct arpcom *ac = (struct arpcom *)ifp;
136         u_int16_t type;
137         u_char esrc[6], edst[6];
138         struct fddi_header *fh;
139         boolean_t hdrcmplt = FALSE;
140         int loop_copy = 0, error;
141         struct altq_pktattr pktattr;
142
143         if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
144                 senderr(ENETDOWN);
145
146         /*
147          * If the queueing discipline needs packet classification,
148          * do it before prepending link headers.
149          */
150         ifq_classify(&ifp->if_snd, m, dst->sa_family, &pktattr);
151
152         switch (dst->sa_family) {
153 #ifdef INET
154         case AF_INET: {
155                 if (!arpresolve(ifp, rt, m, dst, edst))
156                         return (0);     /* if not yet resolved */
157                 type = htons(ETHERTYPE_IP);
158                 break;
159         }
160 #endif
161 #ifdef INET6
162         case AF_INET6:
163                 if (!nd6_storelladdr(&ac->ac_if, rt, m, dst, (u_char *)edst)) {
164                         /* Something bad happened */
165                         return (0);
166                 }
167                 type = htons(ETHERTYPE_IPV6);
168                 break;
169 #endif
170 #ifdef IPX
171         case AF_IPX:
172                 type = htons(ETHERTYPE_IPX);
173                 bcopy(&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host), edst,
174                       sizeof edst);
175                 break;
176 #endif
177 #ifdef NETATALK
178         case AF_APPLETALK: {
179                 struct at_ifaddr *aa;
180
181                 if (!aarpresolve((struct arpcom *) ifp, m,
182                                  (struct sockaddr_at *)dst, edst))
183                         return (0);
184
185                 /*
186                  * ifaddr is the first thing in at_ifaddr
187                  */
188                 if ((aa = at_ifawithnet((struct sockaddr_at *)dst)) == NULL) {
189                         error = 0;      /* XXX */
190                         goto bad;
191                 }
192
193                 /*
194                  * In the phase 2 case, we need to prepend an mbuf
195                  * for the llc header.  Since we must preserve the
196                  * value of m, which is passed to us by value, we
197                  * m_copy() the first mbuf, and use it for our llc
198                  * header.
199                  */
200                 if (aa->aa_flags & AFA_PHASE2) {
201                         struct llc llc;
202
203                         M_PREPEND(m, sizeof(struct llc), MB_WAIT);
204                         if (m == NULL)
205                                 senderr(ENOBUFS);
206                         llc.llc_dsap = llc.llc_ssap = LLC_SNAP_LSAP;
207                         llc.llc_control = LLC_UI;
208                         bcopy(at_org_code, llc.llc_snap_org_code,
209                               sizeof at_org_code);
210                         llc.llc_snap_ether_type = htons(ETHERTYPE_AT);
211                         bcopy(&llc, mtod(m, caddr_t), sizeof(struct llc));
212                         type = 0;
213                 } else {
214                         type = htons(ETHERTYPE_AT);
215                 }
216                 break;
217         }
218 #endif /* NETATALK */
219 #ifdef NS
220         case AF_NS:
221                 type = htons(ETHERTYPE_NS);
222                 bcopy(&(((struct sockaddr_ns *)dst)->sns_addr.x_host), edst,
223                       sizeof edst);
224                 break;
225 #endif
226
227         case pseudo_AF_HDRCMPLT:
228         {
229                 struct ether_header *eh;
230
231                 hdrcmplt = TRUE;
232                 eh = (struct ether_header *)dst->sa_data;
233                 memcpy(esrc, eh->ether_shost, sizeof esrc);
234                 /* FALLTHROUGH */
235         }
236
237         case AF_UNSPEC:
238         {
239                 struct ether_header *eh;
240
241                 loop_copy = -1;
242                 eh = (struct ether_header *)dst->sa_data;
243                 memcpy(edst, eh->ether_dhost, sizeof edst);
244                 if (*edst & 1)
245                         m->m_flags |= (M_BCAST|M_MCAST);
246                 type = eh->ether_type;
247                 break;
248         }
249
250         case AF_IMPLINK:
251         {
252                 fh = mtod(m, struct fddi_header *);
253                 error = EPROTONOSUPPORT;
254                 switch (fh->fddi_fc & (FDDIFC_C|FDDIFC_L|FDDIFC_F)) {
255                         case FDDIFC_LLC_ASYNC: {
256                                 /* legal priorities are 0 through 7 */
257                                 if ((fh->fddi_fc & FDDIFC_Z) > 7)
258                                         goto bad;
259                                 break;
260                         }
261                         case FDDIFC_LLC_SYNC: {
262                                 /* FDDIFC_Z bits reserved, must be zero */
263                                 if (fh->fddi_fc & FDDIFC_Z)
264                                         goto bad;
265                                 break;
266                         }
267                         case FDDIFC_SMT: {
268                                 /* FDDIFC_Z bits must be non zero */
269                                 if ((fh->fddi_fc & FDDIFC_Z) == 0)
270                                         goto bad;
271                                 break;
272                         }
273                         default: {
274                                 /* anything else is too dangerous */
275                                 goto bad;
276                         }
277                 }
278                 error = 0;
279                 if (fh->fddi_dhost[0] & 1)
280                         m->m_flags |= (M_BCAST | M_MCAST);
281                 goto queue_it;
282         }
283         default:
284                 printf("%s: can't handle af%d\n", ifp->if_xname,
285                         dst->sa_family);
286                 senderr(EAFNOSUPPORT);
287         }
288
289         if (type != 0) {
290                 struct llc *l;
291
292                 M_PREPEND(m, sizeof(struct llc), MB_DONTWAIT);
293                 if (m == NULL)
294                         return (ENOBUFS);
295                 l = mtod(m, struct llc *);
296                 l->llc_control = LLC_UI;
297                 l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP;
298                 l->llc_snap.org_code[0] = l->llc_snap.org_code[1] =
299                     l->llc_snap.org_code[2] = 0;
300                 memcpy(&l->llc_snap.ether_type, &type, sizeof(u_int16_t));
301         }
302
303         /*
304          * Add local net header.  If no space in first mbuf,
305          * allocate another.
306          */
307         M_PREPEND(m, sizeof(struct fddi_header), MB_DONTWAIT);
308         if (m == NULL)
309                 return (ENOBUFS);
310         fh = mtod(m, struct fddi_header *);
311         fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4;
312         memcpy(fh->fddi_dhost, edst, sizeof edst);
313
314 queue_it:
315         if (hdrcmplt)
316                 memcpy(fh->fddi_shost, esrc, sizeof fh->fddi_shost);
317         else
318                 memcpy(fh->fddi_shost, ac->ac_enaddr, sizeof fh->fddi_shost);
319         /*
320                 memcpy(fh->fddi_shost, ac->ac_enaddr, sizeof fh->fddi_shost);
321          * Ethernet address or a broadcast address, loopback a copy.
322          * XXX To make a simplex device behave exactly like a duplex
323          * device, we should copy in the case of sending to our own
324          * ethernet address (thus letting the original actually appear
325          * on the wire). However, we don't do that here for security
326          * reasons and compatibility with the original behavior.
327          */
328         if ((ifp->if_flags & IFF_SIMPLEX) &&
329            (loop_copy != -1)) {
330                 if ((m->m_flags & M_BCAST) || loop_copy) {
331                         struct mbuf *n = m_copypacket(m, MB_DONTWAIT);
332
333                         if_simloop(ifp, n, dst->sa_family,
334                                    sizeof(struct fddi_header));
335                 } else if (bcmp(fh->fddi_dhost, fh->fddi_shost,
336                                 sizeof(fh->fddi_shost)) == 0) {
337                         if_simloop(ifp, m, dst->sa_family,
338                                    sizeof(struct fddi_header));
339                         senderr(0);     /* XXX */
340                 }
341         }
342
343         /*
344          * Dispatch the message to the interface.
345          */
346         return (ifq_handoff(ifp, m, &pktattr));
347
348 bad:
349         m_freem(m);
350         return (error);
351 }
352
353 /*
354  * Process a received FDDI packet;
355  * the packet is in the mbuf chain m without
356  * the fddi header, which is provided separately.
357  */
358 static void
359 fddi_input(struct ifnet *ifp, struct mbuf *m)
360 {
361         int isr;
362         struct llc *l;
363         struct fddi_header *fh = mtod(m, struct fddi_header *);
364
365         ASSERT_SERIALIZED(ifp->if_serializer);
366
367         if (m->m_len < sizeof(struct fddi_header)) {
368                 /* XXX error in the caller. */
369                 m_freem(m);
370                 return;
371         }
372         m_adj(m, sizeof(struct fddi_header));
373         m->m_pkthdr.rcvif = ifp;
374
375         if (!(ifp->if_flags & IFF_UP)) {
376                 m_freem(m);
377                 return;
378         }
379         getmicrotime(&ifp->if_lastchange);
380         ifp->if_ibytes += m->m_pkthdr.len + sizeof *fh;
381         if (fh->fddi_dhost[0] & 1) {
382                 if (bcmp(ifp->if_broadcastaddr, fh->fddi_dhost,
383                          ifp->if_addrlen) == 0)
384                         m->m_flags |= M_BCAST;
385                 else
386                         m->m_flags |= M_MCAST;
387                 ifp->if_imcasts++;
388         } else if ((ifp->if_flags & IFF_PROMISC) &&
389             bcmp(((struct arpcom *)ifp)->ac_enaddr, fh->fddi_dhost,
390                  sizeof fh->fddi_dhost) != 0) {
391                 m_freem(m);
392                 return;
393         }
394
395 #ifdef M_LINK0
396         /*
397          * If this has a LLC priority of 0, then mark it so upper
398          * layers have a hint that it really came via a FDDI/Ethernet
399          * bridge.
400          */
401         if ((fh->fddi_fc & FDDIFC_LLC_PRIO7) == FDDIFC_LLC_PRIO0)
402                 m->m_flags |= M_LINK0;
403 #endif
404
405         l = mtod(m, struct llc *);
406         switch (l->llc_dsap) {
407 #if defined(INET) || defined(INET6) || defined(NS) || defined(DECNET) || defined(IPX) || defined(NETATALK)
408         case LLC_SNAP_LSAP:
409         {
410                 u_int16_t type;
411                 if (l->llc_control != LLC_UI || l->llc_ssap != LLC_SNAP_LSAP)
412                         goto dropanyway;
413 #ifdef NETATALK
414                 if (bcmp(&(l->llc_snap_org_code)[0], at_org_code,
415                          sizeof(at_org_code)) == 0 &&
416                     sizeof(at_org_code) == 0 &&
417                     ntohs(l->llc_snap_ether_type) == ETHERTYPE_AT) {
418                         m_adj(m, sizeof(struct llc));
419                         isr = NETISR_ATALK2;
420                         break;
421                 }
422
423                 if (bcmp(&(l->llc_snap_org_code)[0], aarp_org_code,
424                          sizeof(aarp_org_code)) == 0 &&
425                         ntohs(l->llc_snap_ether_type) == ETHERTYPE_AARP) {
426                     m_adj(m, sizeof(struct llc));
427                     isr = NETISR_AARP;
428                     break;
429                 }
430 #endif
431                 if (l->llc_snap.org_code[0] != 0 ||
432                     l->llc_snap.org_code[1] != 0 ||
433                     l->llc_snap.org_code[2] != 0)
434                         goto dropanyway;
435                 type = ntohs(l->llc_snap.ether_type);
436                 m_adj(m, 8);
437                 switch (type) {
438 #ifdef INET
439                 case ETHERTYPE_IP:
440                         if (ipflow_fastforward(m, ifp->if_serializer))
441                                 return;
442                         isr = NETISR_IP;
443                         break;
444
445                 case ETHERTYPE_ARP:
446                         if (ifp->if_flags & IFF_NOARP)
447                                 goto dropanyway;
448                         isr = NETISR_ARP;
449                         break;
450 #endif
451 #ifdef INET6
452                 case ETHERTYPE_IPV6:
453                         isr = NETISR_IPV6;
454                         break;
455 #endif
456 #ifdef IPX
457                 case ETHERTYPE_IPX:
458                         isr = NETISR_IPX;
459                         break;
460 #endif
461 #ifdef NS
462                 case ETHERTYPE_NS:
463                         isr = NETISR_NS;
464                         break;
465 #endif
466 #ifdef DECNET
467                 case ETHERTYPE_DECNET:
468                         isr = NETISR_DECNET;
469                         break;
470 #endif
471 #ifdef NETATALK
472                 case ETHERTYPE_AT:
473                         isr = NETISR_ATALK1;
474                         break;
475                 case ETHERTYPE_AARP:
476                         isr = NETISR_AARP;
477                         break;
478 #endif /* NETATALK */
479                 default:
480                         /* printf("fddi_input: unknown protocol 0x%x\n", type); */
481                         ifp->if_noproto++;
482                         goto dropanyway;
483                 }
484                 break;
485         }
486 #endif /* INET || NS */
487
488         default:
489                 /* printf("fddi_input: unknown dsap 0x%x\n", l->llc_dsap); */
490                 ifp->if_noproto++;
491         dropanyway:
492                 m_freem(m);
493                 return;
494         }
495
496         netisr_dispatch(isr, m);
497 }
498
499 /*
500  * Perform common duties while attaching to interface list
501  */
502 #ifdef __NetBSD__
503 #define ifa_next        ifa_list.tqe_next
504 #endif
505
506 void
507 fddi_ifattach(struct ifnet *ifp, lwkt_serialize_t serializer)
508 {
509         struct sockaddr_dl *sdl;
510
511         ifp->if_input = fddi_input;
512         ifp->if_output = fddi_output;
513         ifp->if_type = IFT_FDDI;
514         ifp->if_addrlen = 6;
515         ifp->if_broadcastaddr = fddibroadcastaddr;
516         ifp->if_hdrlen = 21;
517         ifp->if_mtu = FDDIMTU;
518         ifp->if_resolvemulti = fddi_resolvemulti;
519         ifp->if_baudrate = 100000000;
520 #ifdef IFF_NOTRAILERS
521         ifp->if_flags |= IFF_NOTRAILERS;
522 #endif
523         if_attach(ifp, serializer);
524 #if defined(__DragonFly__) || defined(__FreeBSD__)
525         sdl = IF_LLSOCKADDR(ifp);
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(struct ifnet *ifp, struct sockaddr **llsa, struct sockaddr *sa)
550 {
551         struct sockaddr_dl *sdl;
552         struct sockaddr_in *sin;
553 #ifdef INET6
554         struct sockaddr_in6 *sin6;
555 #endif
556         u_char *e_addr;
557
558         switch(sa->sa_family) {
559         case AF_LINK:
560                 /*
561                  * No mapping needed. Just check that it's a valid MC address.
562                  */
563                 sdl = (struct sockaddr_dl *)sa;
564                 e_addr = LLADDR(sdl);
565                 if ((e_addr[0] & 1) != 1)
566                         return EADDRNOTAVAIL;
567                 *llsa = 0;
568                 return 0;
569
570 #ifdef INET
571         case AF_INET:
572                 sin = (struct sockaddr_in *)sa;
573                 if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr)))
574                         return EADDRNOTAVAIL;
575                 MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR,
576                        M_WAITOK);
577                 sdl->sdl_len = sizeof *sdl;
578                 sdl->sdl_family = AF_LINK;
579                 sdl->sdl_index = ifp->if_index;
580                 sdl->sdl_type = IFT_FDDI;
581                 sdl->sdl_nlen = 0;
582                 sdl->sdl_alen = ETHER_ADDR_LEN; /* XXX */
583                 sdl->sdl_slen = 0;
584                 e_addr = LLADDR(sdl);
585                 ETHER_MAP_IP_MULTICAST(&sin->sin_addr, e_addr);
586                 *llsa = (struct sockaddr *)sdl;
587                 return 0;
588 #endif
589 #ifdef INET6
590         case AF_INET6:
591                 sin6 = (struct sockaddr_in6 *)sa;
592                 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
593                         /*
594                          * An IP6 address of 0 means listen to all
595                          * of the Ethernet multicast address used for IP6.
596                          * (This is used for multicast routers.)
597                          */
598                         ifp->if_flags |= IFF_ALLMULTI;
599                         *llsa = 0;
600                         return 0;
601                 }
602                 if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
603                         return EADDRNOTAVAIL;
604                 MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR,
605                        M_WAITOK);
606                 sdl->sdl_len = sizeof *sdl;
607                 sdl->sdl_family = AF_LINK;
608                 sdl->sdl_index = ifp->if_index;
609                 sdl->sdl_type = IFT_FDDI;
610                 sdl->sdl_nlen = 0;
611                 sdl->sdl_alen = ETHER_ADDR_LEN; /* XXX */
612                 sdl->sdl_slen = 0;
613                 e_addr = LLADDR(sdl);
614                 ETHER_MAP_IPV6_MULTICAST(&sin6->sin6_addr, e_addr);
615                 *llsa = (struct sockaddr *)sdl;
616                 return 0;
617 #endif
618
619         default:
620                 /*
621                  * Well, the text isn't quite right, but it's the name
622                  * that counts...
623                  */
624                 return EAFNOSUPPORT;
625         }
626 }