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