if_fddisubr.c revision 112266
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 112266 2003-03-15 15:09:11Z mdodd $ 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#define IFP2AC(IFP) ((struct arpcom *)IFP) 101#define senderr(e) { error = (e); goto bad; } 102 103/* 104 * FDDI output routine. 105 * Encapsulate a packet of type family for the local net. 106 * Use trailer local net encapsulation if enough data in first 107 * packet leaves a multiple of 512 bytes of data in remainder. 108 * Assumes that ifp is actually pointer to arpcom structure. 109 */ 110static int 111fddi_output(ifp, m, dst, rt0) 112 struct ifnet *ifp; 113 struct mbuf *m; 114 struct sockaddr *dst; 115 struct rtentry *rt0; 116{ 117 u_int16_t type; 118 int loop_copy = 0, error = 0, hdrcmplt = 0; 119 u_char esrc[FDDI_ADDR_LEN], edst[FDDI_ADDR_LEN]; 120 struct rtentry *rt; 121 struct fddi_header *fh; 122 struct arpcom *ac = IFP2AC(ifp); 123 124#ifdef MAC 125 error = mac_check_ifnet_transmit(ifp, m); 126 if (error) 127 senderr(error); 128#endif 129 130 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 131 senderr(ENETDOWN); 132 getmicrotime(&ifp->if_lastchange); 133 134 error = rt_check(&rt, &rt0, dst); 135 if (error) 136 goto bad; 137 138 switch (dst->sa_family) { 139#ifdef INET 140 case AF_INET: { 141 if (!arpresolve(ifp, rt, m, dst, edst, rt0)) 142 return (0); /* if not yet resolved */ 143 type = htons(ETHERTYPE_IP); 144 break; 145 } 146#endif /* INET */ 147#ifdef INET6 148 case AF_INET6: 149 if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)edst)) { 150 /* Something bad happened */ 151 return (0); 152 } 153 type = htons(ETHERTYPE_IPV6); 154 break; 155#endif /* INET6 */ 156#ifdef IPX 157 case AF_IPX: 158 type = htons(ETHERTYPE_IPX); 159 bcopy((caddr_t)&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host), 160 (caddr_t)edst, FDDI_ADDR_LEN); 161 break; 162#endif /* IPX */ 163#ifdef NETATALK 164 case AF_APPLETALK: { 165 struct at_ifaddr *aa; 166 if (!aarpresolve(ac, m, (struct sockaddr_at *)dst, edst)) 167 return (0); 168 /* 169 * ifaddr is the first thing in at_ifaddr 170 */ 171 if ((aa = at_ifawithnet( (struct sockaddr_at *)dst)) == 0) 172 goto bad; 173 174 /* 175 * In the phase 2 case, we need to prepend an mbuf for the llc header. 176 * Since we must preserve the value of m, which is passed to us by 177 * value, we m_copy() the first mbuf, and use it for our llc header. 178 */ 179 if (aa->aa_flags & AFA_PHASE2) { 180 struct llc llc; 181 182 M_PREPEND(m, LLC_SNAPFRAMELEN, M_TRYWAIT); 183 if (m == 0) 184 senderr(ENOBUFS); 185 llc.llc_dsap = llc.llc_ssap = LLC_SNAP_LSAP; 186 llc.llc_control = LLC_UI; 187 bcopy(at_org_code, llc.llc_snap.org_code, sizeof(at_org_code)); 188 llc.llc_snap.ether_type = htons(ETHERTYPE_AT); 189 bcopy(&llc, mtod(m, caddr_t), LLC_SNAPFRAMELEN); 190 type = 0; 191 } else { 192 type = htons(ETHERTYPE_AT); 193 } 194 break; 195 } 196#endif /* NETATALK */ 197 198 case pseudo_AF_HDRCMPLT: 199 { 200 struct ether_header *eh; 201 hdrcmplt = 1; 202 eh = (struct ether_header *)dst->sa_data; 203 bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, FDDI_ADDR_LEN); 204 /* FALLTHROUGH */ 205 } 206 207 case AF_UNSPEC: 208 { 209 struct ether_header *eh; 210 loop_copy = -1; 211 eh = (struct ether_header *)dst->sa_data; 212 bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, FDDI_ADDR_LEN); 213 if (*edst & 1) 214 m->m_flags |= (M_BCAST|M_MCAST); 215 type = eh->ether_type; 216 break; 217 } 218 219 case AF_IMPLINK: 220 { 221 fh = mtod(m, struct fddi_header *); 222 error = EPROTONOSUPPORT; 223 switch (fh->fddi_fc & (FDDIFC_C|FDDIFC_L|FDDIFC_F)) { 224 case FDDIFC_LLC_ASYNC: { 225 /* legal priorities are 0 through 7 */ 226 if ((fh->fddi_fc & FDDIFC_Z) > 7) 227 goto bad; 228 break; 229 } 230 case FDDIFC_LLC_SYNC: { 231 /* FDDIFC_Z bits reserved, must be zero */ 232 if (fh->fddi_fc & FDDIFC_Z) 233 goto bad; 234 break; 235 } 236 case FDDIFC_SMT: { 237 /* FDDIFC_Z bits must be non zero */ 238 if ((fh->fddi_fc & FDDIFC_Z) == 0) 239 goto bad; 240 break; 241 } 242 default: { 243 /* anything else is too dangerous */ 244 goto bad; 245 } 246 } 247 error = 0; 248 if (fh->fddi_dhost[0] & 1) 249 m->m_flags |= (M_BCAST|M_MCAST); 250 goto queue_it; 251 } 252 default: 253 if_printf(ifp, "can't handle af%d\n", dst->sa_family); 254 senderr(EAFNOSUPPORT); 255 } 256 257 /* 258 * Add LLC header. 259 */ 260 if (type != 0) { 261 struct llc *l; 262 M_PREPEND(m, LLC_SNAPFRAMELEN, M_DONTWAIT); 263 if (m == 0) 264 senderr(ENOBUFS); 265 l = mtod(m, struct llc *); 266 l->llc_control = LLC_UI; 267 l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP; 268 l->llc_snap.org_code[0] = 269 l->llc_snap.org_code[1] = 270 l->llc_snap.org_code[2] = 0; 271 l->llc_snap.ether_type = htons(type); 272 } 273 274 /* 275 * Add local net header. If no space in first mbuf, 276 * allocate another. 277 */ 278 M_PREPEND(m, FDDI_HDR_LEN, M_DONTWAIT); 279 if (m == 0) 280 senderr(ENOBUFS); 281 fh = mtod(m, struct fddi_header *); 282 fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4; 283 bcopy((caddr_t)edst, (caddr_t)fh->fddi_dhost, FDDI_ADDR_LEN); 284 queue_it: 285 if (hdrcmplt) 286 bcopy((caddr_t)esrc, (caddr_t)fh->fddi_shost, FDDI_ADDR_LEN); 287 else 288 bcopy((caddr_t)ac->ac_enaddr, (caddr_t)fh->fddi_shost, 289 FDDI_ADDR_LEN); 290 291 /* 292 * If a simplex interface, and the packet is being sent to our 293 * Ethernet address or a broadcast address, loopback a copy. 294 * XXX To make a simplex device behave exactly like a duplex 295 * device, we should copy in the case of sending to our own 296 * ethernet address (thus letting the original actually appear 297 * on the wire). However, we don't do that here for security 298 * reasons and compatibility with the original behavior. 299 */ 300 if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) { 301 if ((m->m_flags & M_BCAST) || loop_copy) { 302 struct mbuf *n = m_copy(m, 0, (int)M_COPYALL); 303 304 (void) if_simloop(ifp, 305 n, dst->sa_family, FDDI_HDR_LEN); 306 } else if (bcmp(fh->fddi_dhost, 307 fh->fddi_shost, FDDI_ADDR_LEN) == 0) { 308 (void) if_simloop(ifp, 309 m, dst->sa_family, FDDI_HDR_LEN); 310 return (0); /* XXX */ 311 } 312 } 313 314 if (! IF_HANDOFF(&ifp->if_snd, m, ifp)) 315 senderr(ENOBUFS); 316 return (error); 317 318bad: 319 ifp->if_oerrors++; 320 if (m) 321 m_freem(m); 322 return (error); 323} 324 325/* 326 * Process a received FDDI packet; 327 * the packet is in the mbuf chain m without 328 * the fddi header, which is provided separately. 329 */ 330static void 331fddi_input(ifp, m) 332 struct ifnet *ifp; 333 struct mbuf *m; 334{ 335 int isr; 336 struct llc *l; 337 struct fddi_header *fh; 338 339 fh = mtod(m, struct fddi_header *); 340 341 /* 342 * Update interface statistics. 343 */ 344 ifp->if_ibytes += m->m_pkthdr.len; 345 getmicrotime(&ifp->if_lastchange); 346 347 /* 348 * Discard packet if interface is not up. 349 */ 350 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 351 goto dropanyway; 352 353#ifdef MAC 354 mac_create_mbuf_from_ifnet(ifp, m); 355#endif 356 357 /* 358 * Discard non local unicast packets when interface 359 * is in promiscuous mode. 360 */ 361 if ((ifp->if_flags & IFF_PROMISC) && ((fh->fddi_dhost[0] & 1) == 0) && 362 (bcmp(IFP2AC(ifp)->ac_enaddr, (caddr_t)fh->fddi_dhost, 363 FDDI_ADDR_LEN) != 0)) 364 goto dropanyway; 365 366 /* 367 * Set mbuf flags for bcast/mcast. 368 */ 369 if (fh->fddi_dhost[0] & 1) { 370 if (bcmp((caddr_t)ifp->if_broadcastaddr, 371 (caddr_t)fh->fddi_dhost, FDDI_ADDR_LEN) == 0) 372 m->m_flags |= M_BCAST; 373 else 374 m->m_flags |= M_MCAST; 375 ifp->if_imcasts++; 376 } 377 378#ifdef M_LINK0 379 /* 380 * If this has a LLC priority of 0, then mark it so upper 381 * layers have a hint that it really came via a FDDI/Ethernet 382 * bridge. 383 */ 384 if ((fh->fddi_fc & FDDIFC_LLC_PRIO7) == FDDIFC_LLC_PRIO0) 385 m->m_flags |= M_LINK0; 386#endif 387 388 /* Strip off FDDI header. */ 389 m_adj(m, FDDI_HDR_LEN); 390 391 m = m_pullup(m, LLC_SNAPFRAMELEN); 392 if (m == 0) { 393 ifp->if_ierrors++; 394 goto dropanyway; 395 } 396 l = mtod(m, struct llc *); 397 398 switch (l->llc_dsap) { 399 case LLC_SNAP_LSAP: 400 { 401 u_int16_t type; 402 if ((l->llc_control != LLC_UI) || 403 (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