if_fddisubr.c revision 111926
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 111926 2003-03-05 19:24:24Z peter $ 37 */ 38 39#include "opt_atalk.h" 40#include "opt_inet.h" 41#include "opt_inet6.h" 42#include "opt_ipx.h" 43#include "opt_mac.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/kernel.h> 48#include <sys/mac.h> 49#include <sys/malloc.h> 50#include <sys/mbuf.h> 51#include <sys/module.h> 52#include <sys/socket.h> 53#include <sys/sockio.h> 54 55#include <net/if.h> 56#include <net/if_llc.h> 57#include <net/if_dl.h> 58#include <net/if_types.h> 59#include <net/netisr.h> 60#include <net/route.h> 61#include <net/bpf.h> 62#include <net/fddi.h> 63 64#if defined(INET) || defined(INET6) 65#include <netinet/in.h> 66#include <netinet/in_var.h> 67#include <netinet/if_ether.h> 68#endif 69#ifdef INET6 70#include <netinet6/nd6.h> 71#endif 72 73#ifdef IPX 74#include <netipx/ipx.h> 75#include <netipx/ipx_if.h> 76#endif 77 78#ifdef DECNET 79#include <netdnet/dn.h> 80#endif 81 82#ifdef NETATALK 83#include <netatalk/at.h> 84#include <netatalk/at_var.h> 85#include <netatalk/at_extern.h> 86 87extern u_char at_org_code[ 3 ]; 88extern u_char aarp_org_code[ 3 ]; 89#endif /* NETATALK */ 90 91static u_char fddibroadcastaddr[FDDI_ADDR_LEN] = 92 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 93 94static int fddi_resolvemulti(struct ifnet *, struct sockaddr **, 95 struct sockaddr *); 96static int fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *, 97 struct rtentry *); 98static void fddi_input(struct ifnet *ifp, struct mbuf *m); 99 100 101#define IFP2AC(IFP) ((struct arpcom *)IFP) 102#define senderr(e) { error = (e); goto bad; } 103 104/* 105 * FDDI output routine. 106 * Encapsulate a packet of type family for the local net. 107 * Use trailer local net encapsulation if enough data in first 108 * packet leaves a multiple of 512 bytes of data in remainder. 109 * Assumes that ifp is actually pointer to arpcom structure. 110 */ 111static int 112fddi_output(ifp, m, dst, rt0) 113 struct ifnet *ifp; 114 struct mbuf *m; 115 struct sockaddr *dst; 116 struct rtentry *rt0; 117{ 118 u_int16_t type; 119 int loop_copy = 0, error = 0, hdrcmplt = 0; 120 u_char esrc[FDDI_ADDR_LEN], edst[FDDI_ADDR_LEN]; 121 struct rtentry *rt; 122 struct fddi_header *fh; 123 struct arpcom *ac = IFP2AC(ifp); 124 125#ifdef MAC 126 error = mac_check_ifnet_transmit(ifp, m); 127 if (error) 128 senderr(error); 129#endif 130 131 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 132 senderr(ENETDOWN); 133 getmicrotime(&ifp->if_lastchange); 134 135 error = rt_check(&rt, &rt0, dst); 136 if (error) 137 goto bad; 138 139 switch (dst->sa_family) { 140 141#ifdef INET 142 case AF_INET: { 143 if (!arpresolve(ifp, rt, m, dst, edst, rt0)) 144 return (0); /* if not yet resolved */ 145 type = htons(ETHERTYPE_IP); 146 break; 147 } 148#endif 149#ifdef INET6 150 case AF_INET6: 151 if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)edst)) { 152 /* Something bad happened */ 153 return (0); 154 } 155 type = htons(ETHERTYPE_IPV6); 156 break; 157#endif 158#ifdef IPX 159 case AF_IPX: 160 type = htons(ETHERTYPE_IPX); 161 bcopy((caddr_t)&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host), 162 (caddr_t)edst, FDDI_ADDR_LEN); 163 break; 164#endif 165#ifdef NETATALK 166 case AF_APPLETALK: { 167 struct at_ifaddr *aa; 168 if (!aarpresolve(ac, m, (struct sockaddr_at *)dst, edst)) 169 return (0); 170 /* 171 * ifaddr is the first thing in at_ifaddr 172 */ 173 if ((aa = at_ifawithnet( (struct sockaddr_at *)dst)) == 0) 174 goto bad; 175 176 /* 177 * In the phase 2 case, we need to prepend an mbuf for the llc header. 178 * Since we must preserve the value of m, which is passed to us by 179 * value, we m_copy() the first mbuf, and use it for our llc header. 180 */ 181 if (aa->aa_flags & AFA_PHASE2) { 182 struct llc llc; 183 184 M_PREPEND(m, LLC_SNAPFRAMELEN, M_TRYWAIT); 185 if (m == 0) 186 senderr(ENOBUFS); 187 llc.llc_dsap = llc.llc_ssap = LLC_SNAP_LSAP; 188 llc.llc_control = LLC_UI; 189 bcopy(at_org_code, llc.llc_snap.org_code, sizeof(at_org_code)); 190 llc.llc_snap.ether_type = htons(ETHERTYPE_AT); 191 bcopy(&llc, mtod(m, caddr_t), LLC_SNAPFRAMELEN); 192 type = 0; 193 } else { 194 type = htons(ETHERTYPE_AT); 195 } 196 break; 197 } 198#endif /* NETATALK */ 199 200 case pseudo_AF_HDRCMPLT: 201 { 202 struct ether_header *eh; 203 hdrcmplt = 1; 204 eh = (struct ether_header *)dst->sa_data; 205 bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, FDDI_ADDR_LEN); 206 /* FALLTHROUGH */ 207 } 208 209 case AF_UNSPEC: 210 { 211 struct ether_header *eh; 212 loop_copy = -1; 213 eh = (struct ether_header *)dst->sa_data; 214 bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, FDDI_ADDR_LEN); 215 if (*edst & 1) 216 m->m_flags |= (M_BCAST|M_MCAST); 217 type = eh->ether_type; 218 break; 219 } 220 221 case AF_IMPLINK: 222 { 223 fh = mtod(m, struct fddi_header *); 224 error = EPROTONOSUPPORT; 225 switch (fh->fddi_fc & (FDDIFC_C|FDDIFC_L|FDDIFC_F)) { 226 case FDDIFC_LLC_ASYNC: { 227 /* legal priorities are 0 through 7 */ 228 if ((fh->fddi_fc & FDDIFC_Z) > 7) 229 goto bad; 230 break; 231 } 232 case FDDIFC_LLC_SYNC: { 233 /* FDDIFC_Z bits reserved, must be zero */ 234 if (fh->fddi_fc & FDDIFC_Z) 235 goto bad; 236 break; 237 } 238 case FDDIFC_SMT: { 239 /* FDDIFC_Z bits must be non zero */ 240 if ((fh->fddi_fc & FDDIFC_Z) == 0) 241 goto bad; 242 break; 243 } 244 default: { 245 /* anything else is too dangerous */ 246 goto bad; 247 } 248 } 249 error = 0; 250 if (fh->fddi_dhost[0] & 1) 251 m->m_flags |= (M_BCAST|M_MCAST); 252 goto queue_it; 253 } 254 default: 255 if_printf(ifp, "can't handle af%d\n", dst->sa_family); 256 senderr(EAFNOSUPPORT); 257 } 258 259 /* 260 * Add LLC header. 261 */ 262 if (type != 0) { 263 struct llc *l; 264 M_PREPEND(m, LLC_SNAPFRAMELEN, M_DONTWAIT); 265 if (m == 0) 266 senderr(ENOBUFS); 267 l = mtod(m, struct llc *); 268 l->llc_control = LLC_UI; 269 l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP; 270 l->llc_snap.org_code[0] = l->llc_snap.org_code[1] = l->llc_snap.org_code[2] = 0; 271 bcopy((caddr_t)&type, (caddr_t)&l->llc_snap.ether_type, 272 sizeof(u_int16_t)); 273 } 274 275 /* 276 * Add local net header. If no space in first mbuf, 277 * allocate another. 278 */ 279 M_PREPEND(m, FDDI_HDR_LEN, M_DONTWAIT); 280 if (m == 0) 281 senderr(ENOBUFS); 282 fh = mtod(m, struct fddi_header *); 283 fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4; 284 bcopy((caddr_t)edst, (caddr_t)fh->fddi_dhost, FDDI_ADDR_LEN); 285 queue_it: 286 if (hdrcmplt) 287 bcopy((caddr_t)esrc, (caddr_t)fh->fddi_shost, FDDI_ADDR_LEN); 288 else 289 bcopy((caddr_t)ac->ac_enaddr, (caddr_t)fh->fddi_shost, 290 FDDI_ADDR_LEN); 291 292 /* 293 * If a simplex interface, and the packet is being sent to our 294 * Ethernet address or a broadcast address, loopback a copy. 295 * XXX To make a simplex device behave exactly like a duplex 296 * device, we should copy in the case of sending to our own 297 * ethernet address (thus letting the original actually appear 298 * on the wire). However, we don't do that here for security 299 * reasons and compatibility with the original behavior. 300 */ 301 if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) { 302 if ((m->m_flags & M_BCAST) || loop_copy) { 303 struct mbuf *n = m_copy(m, 0, (int)M_COPYALL); 304 305 (void) if_simloop(ifp, 306 n, dst->sa_family, FDDI_HDR_LEN); 307 } else if (bcmp(fh->fddi_dhost, 308 fh->fddi_shost, FDDI_ADDR_LEN) == 0) { 309 (void) if_simloop(ifp, 310 m, dst->sa_family, FDDI_HDR_LEN); 311 return (0); /* XXX */ 312 } 313 } 314 315 if (! IF_HANDOFF(&ifp->if_snd, m, ifp)) 316 senderr(ENOBUFS); 317 return (error); 318 319bad: 320 ifp->if_oerrors++; 321 if (m) 322 m_freem(m); 323 return (error); 324} 325 326/* 327 * Process a received FDDI packet; 328 * the packet is in the mbuf chain m without 329 * the fddi header, which is provided separately. 330 */ 331static void 332fddi_input(ifp, m) 333 struct ifnet *ifp; 334 struct mbuf *m; 335{ 336 int isr; 337 struct llc *l; 338 struct fddi_header *fh; 339 340 fh = mtod(m, struct fddi_header *); 341 342 /* 343 * Update interface statistics. 344 */ 345 ifp->if_ibytes += m->m_pkthdr.len; 346 getmicrotime(&ifp->if_lastchange); 347 348 /* 349 * Discard packet if interface is not up. 350 */ 351 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 352 goto dropanyway; 353 354#ifdef MAC 355 mac_create_mbuf_from_ifnet(ifp, m); 356#endif 357 358 /* 359 * Discard non local unicast packets when interface 360 * is in promiscuous mode. 361 */ 362 if ((ifp->if_flags & IFF_PROMISC) && ((fh->fddi_dhost[0] & 1) == 0) && 363 (bcmp(IFP2AC(ifp)->ac_enaddr, (caddr_t)fh->fddi_dhost, 364 FDDI_ADDR_LEN) != 0)) 365 goto dropanyway; 366 367 /* 368 * Set mbuf flags for bcast/mcast. 369 */ 370 if (fh->fddi_dhost[0] & 1) { 371 if (bcmp((caddr_t)ifp->if_broadcastaddr, 372 (caddr_t)fh->fddi_dhost, FDDI_ADDR_LEN) == 0) 373 m->m_flags |= M_BCAST; 374 else 375 m->m_flags |= M_MCAST; 376 ifp->if_imcasts++; 377 } 378 379#ifdef M_LINK0 380 /* 381 * If this has a LLC priority of 0, then mark it so upper 382 * layers have a hint that it really came via a FDDI/Ethernet 383 * bridge. 384 */ 385 if ((fh->fddi_fc & FDDIFC_LLC_PRIO7) == FDDIFC_LLC_PRIO0) 386 m->m_flags |= M_LINK0; 387#endif 388 389 /* Strip off FDDI header. */ 390 m_adj(m, FDDI_HDR_LEN); 391 392 m = m_pullup(m, LLC_SNAPFRAMELEN); 393 if (m == 0) { 394 ifp->if_ierrors++; 395 goto dropanyway; 396 } 397 l = mtod(m, struct llc *); 398 399 switch (l->llc_dsap) { 400 case LLC_SNAP_LSAP: 401 { 402 u_int16_t type; 403 if (l->llc_control != LLC_UI || l->llc_ssap != LLC_SNAP_LSAP) { 404 ifp->if_noproto++; 405 goto dropanyway; 406 } 407#ifdef NETATALK 408 if (Bcmp(&(l->llc_snap.org_code)[0], at_org_code, 409 sizeof(at_org_code)) == 0 && 410 ntohs(l->llc_snap.ether_type) == ETHERTYPE_AT) { 411 isr = NETISR_ATALK2; 412 m_adj(m, LLC_SNAPFRAMELEN); 413 break; 414 } 415 416 if (Bcmp(&(l->llc_snap.org_code)[0], aarp_org_code, 417 sizeof(aarp_org_code)) == 0 && 418 ntohs(l->llc_snap.ether_type) == ETHERTYPE_AARP) { 419 m_adj(m, LLC_SNAPFRAMELEN); 420 isr = NETISR_AARP; 421 break; 422 } 423#endif /* NETATALK */ 424 if (l->llc_snap.org_code[0] != 0 || 425 l->llc_snap.org_code[1] != 0 || 426 l->llc_snap.org_code[2] != 0) { 427 ifp->if_noproto++; 428 goto dropanyway; 429 } 430 431 type = ntohs(l->llc_snap.ether_type); 432 m_adj(m, LLC_SNAPFRAMELEN); 433 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 DECNET 459 case ETHERTYPE_DECNET: 460 isr = NETISR_DECNET; 461 break; 462#endif 463#ifdef NETATALK 464 case ETHERTYPE_AT: 465 isr = NETISR_ATALK1; 466 break; 467 case ETHERTYPE_AARP: 468 isr = NETISR_AARP; 469 break; 470#endif /* NETATALK */ 471 default: 472 /* printf("fddi_input: unknown protocol 0x%x\n", type); */ 473 ifp->if_noproto++; 474 goto dropanyway; 475 } 476 break; 477 } 478 479 default: 480 /* printf("fddi_input: unknown dsap 0x%x\n", l->llc_dsap); */ 481 ifp->if_noproto++; 482 goto dropanyway; 483 } 484 netisr_dispatch(isr, m); 485 return; 486 487dropanyway: 488 ifp->if_iqdrops++; 489 if (m) 490 m_freem(m); 491 return; 492} 493 494/* 495 * Perform common duties while attaching to interface list 496 */ 497void 498fddi_ifattach(ifp, bpf) 499 struct ifnet *ifp; 500 int bpf; 501{ 502 struct ifaddr *ifa; 503 struct sockaddr_dl *sdl; 504 505 ifp->if_type = IFT_FDDI; 506 ifp->if_addrlen = FDDI_ADDR_LEN; 507 ifp->if_hdrlen = 21; 508 509 if_attach(ifp); /* Must be called before additional assignments */ 510 511 ifp->if_mtu = FDDIMTU; 512 ifp->if_output = fddi_output; 513 ifp->if_input = fddi_input; 514 ifp->if_resolvemulti = fddi_resolvemulti; 515 ifp->if_broadcastaddr = fddibroadcastaddr; 516 ifp->if_baudrate = 100000000; 517#ifdef IFF_NOTRAILERS 518 ifp->if_flags |= IFF_NOTRAILERS; 519#endif 520 ifa = ifaddr_byindex(ifp->if_index); 521 if (ifa == NULL) { 522 printf("%s(): no lladdr for %s%d!\n", __FUNCTION__, 523 ifp->if_name, ifp->if_unit); 524 return; 525 } 526 527 sdl = (struct sockaddr_dl *)ifa->ifa_addr; 528 sdl->sdl_type = IFT_FDDI; 529 sdl->sdl_alen = ifp->if_addrlen; 530 bcopy(IFP2AC(ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen); 531 532 if (bpf) 533 bpfattach(ifp, DLT_FDDI, FDDI_HDR_LEN); 534 535 return; 536} 537 538void 539fddi_ifdetach(ifp, bpf) 540 struct ifnet *ifp; 541 int bpf; 542{ 543 544 if (bpf) 545 bpfdetach(ifp); 546 547 if_detach(ifp); 548 549 return; 550} 551 552int 553fddi_ioctl (ifp, command, data) 554 struct ifnet *ifp; 555 int command; 556 caddr_t data; 557{ 558 struct ifaddr *ifa; 559 struct ifreq *ifr; 560 int error; 561 562 ifa = (struct ifaddr *) data; 563 ifr = (struct ifreq *) data; 564 error = 0; 565 566 switch (command) { 567 case SIOCSIFADDR: 568 ifp->if_flags |= IFF_UP; 569 570 switch (ifa->ifa_addr->sa_family) { 571#ifdef INET 572 case AF_INET: /* before arpwhohas */ 573 ifp->if_init(ifp->if_softc); 574 arp_ifinit(ifp, ifa); 575 break; 576#endif 577#ifdef IPX 578 /* 579 * XXX - This code is probably wrong 580 */ 581 case AF_IPX: { 582 struct ipx_addr *ina; 583 struct arpcom *ac; 584 585 ina = &(IA_SIPX(ifa)->sipx_addr); 586 ac = IFP2AC(ifp); 587 588 if (ipx_nullhost(*ina)) { 589 ina->x_host = *(union ipx_host *) 590 ac->ac_enaddr; 591 } else { 592 bcopy((caddr_t) ina->x_host.c_host, 593 (caddr_t) ac->ac_enaddr, 594 sizeof(ac->ac_enaddr)); 595 } 596 597 /* 598 * Set new address 599 */ 600 ifp->if_init(ifp->if_softc); 601 } 602 break; 603#endif 604 default: 605 ifp->if_init(ifp->if_softc); 606 break; 607 } 608 case SIOCGIFADDR: { 609 struct sockaddr *sa; 610 611 sa = (struct sockaddr *) & ifr->ifr_data; 612 bcopy(IFP2AC(ifp)->ac_enaddr, 613 (caddr_t) sa->sa_data, FDDI_ADDR_LEN); 614 615 } 616 break; 617 case SIOCSIFMTU: 618 /* 619 * Set the interface MTU. 620 */ 621 if (ifr->ifr_mtu > FDDIMTU) { 622 error = EINVAL; 623 } else { 624 ifp->if_mtu = ifr->ifr_mtu; 625 } 626 break; 627 default: 628 break; 629 } 630 631 return (error); 632} 633 634static int 635fddi_resolvemulti(ifp, llsa, sa) 636 struct ifnet *ifp; 637 struct sockaddr **llsa; 638 struct sockaddr *sa; 639{ 640 struct sockaddr_dl *sdl; 641 struct sockaddr_in *sin; 642#ifdef INET6 643 struct sockaddr_in6 *sin6; 644#endif 645 u_char *e_addr; 646 647 switch(sa->sa_family) { 648 case AF_LINK: 649 /* 650 * No mapping needed. Just check that it's a valid MC address. 651 */ 652 sdl = (struct sockaddr_dl *)sa; 653 e_addr = LLADDR(sdl); 654 if ((e_addr[0] & 1) != 1) 655 return (EADDRNOTAVAIL); 656 *llsa = 0; 657 return (0); 658 659#ifdef INET 660 case AF_INET: 661 sin = (struct sockaddr_in *)sa; 662 if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) 663 return (EADDRNOTAVAIL); 664 MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR, 665 M_WAITOK); 666 sdl->sdl_len = sizeof *sdl; 667 sdl->sdl_family = AF_LINK; 668 sdl->sdl_index = ifp->if_index; 669 sdl->sdl_type = IFT_FDDI; 670 sdl->sdl_nlen = 0; 671 sdl->sdl_alen = FDDI_ADDR_LEN; 672 sdl->sdl_slen = 0; 673 e_addr = LLADDR(sdl); 674 ETHER_MAP_IP_MULTICAST(&sin->sin_addr, e_addr); 675 *llsa = (struct sockaddr *)sdl; 676 return (0); 677#endif 678#ifdef INET6 679 case AF_INET6: 680 sin6 = (struct sockaddr_in6 *)sa; 681 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { 682 /* 683 * An IP6 address of 0 means listen to all 684 * of the Ethernet multicast address used for IP6. 685 * (This is used for multicast routers.) 686 */ 687 ifp->if_flags |= IFF_ALLMULTI; 688 *llsa = 0; 689 return (0); 690 } 691 if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) 692 return (EADDRNOTAVAIL); 693 MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR, 694 M_WAITOK); 695 sdl->sdl_len = sizeof *sdl; 696 sdl->sdl_family = AF_LINK; 697 sdl->sdl_index = ifp->if_index; 698 sdl->sdl_type = IFT_FDDI; 699 sdl->sdl_nlen = 0; 700 sdl->sdl_alen = FDDI_ADDR_LEN; 701 sdl->sdl_slen = 0; 702 e_addr = LLADDR(sdl); 703 ETHER_MAP_IPV6_MULTICAST(&sin6->sin6_addr, e_addr); 704 *llsa = (struct sockaddr *)sdl; 705 return (0); 706#endif 707 708 default: 709 /* 710 * Well, the text isn't quite right, but it's the name 711 * that counts... 712 */ 713 return (EAFNOSUPPORT); 714 } 715 716 return (0); 717} 718 719static moduledata_t fddi_mod = { 720 "fddi", /* module name */ 721 NULL, /* event handler */ 722 0 /* extra data */ 723}; 724 725DECLARE_MODULE(fddi, fddi_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); 726MODULE_VERSION(fddi, 1); 727