if_fddisubr.c revision 112298
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 112298 2003-03-15 23:02:36Z 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_dl.h> 57#include <net/if_llc.h> 58#include <net/if_types.h> 59 60#include <net/netisr.h> 61#include <net/route.h> 62#include <net/bpf.h> 63#include <net/fddi.h> 64 65#if defined(INET) || defined(INET6) 66#include <netinet/in.h> 67#include <netinet/in_var.h> 68#include <netinet/if_ether.h> 69#endif 70#ifdef INET6 71#include <netinet6/nd6.h> 72#endif 73 74#ifdef IPX 75#include <netipx/ipx.h> 76#include <netipx/ipx_if.h> 77#endif 78 79#ifdef DECNET 80#include <netdnet/dn.h> 81#endif 82 83#ifdef NETATALK 84#include <netatalk/at.h> 85#include <netatalk/at_var.h> 86#include <netatalk/at_extern.h> 87 88extern u_char at_org_code[ 3 ]; 89extern u_char aarp_org_code[ 3 ]; 90#endif /* NETATALK */ 91 92static u_char fddibroadcastaddr[FDDI_ADDR_LEN] = 93 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 94 95static int fddi_resolvemulti(struct ifnet *, struct sockaddr **, 96 struct sockaddr *); 97static int fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *, 98 struct rtentry *); 99static void fddi_input(struct ifnet *ifp, struct mbuf *m); 100 101#define IFP2AC(IFP) ((struct arpcom *)IFP) 102#define senderr(e) do { error = (e); goto bad; } while (0) 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#ifdef INET 141 case AF_INET: { 142 if (!arpresolve(ifp, rt, m, dst, edst, rt0)) 143 return (0); /* if not yet resolved */ 144 type = htons(ETHERTYPE_IP); 145 break; 146 } 147#endif /* INET */ 148#ifdef INET6 149 case AF_INET6: 150 if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)edst)) { 151 /* Something bad happened */ 152 return (0); 153 } 154 type = htons(ETHERTYPE_IPV6); 155 break; 156#endif /* INET6 */ 157#ifdef IPX 158 case AF_IPX: 159 type = htons(ETHERTYPE_IPX); 160 bcopy((caddr_t)&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host), 161 (caddr_t)edst, FDDI_ADDR_LEN); 162 break; 163#endif /* IPX */ 164#ifdef NETATALK 165 case AF_APPLETALK: { 166 struct at_ifaddr *aa; 167 if (!aarpresolve(ac, m, (struct sockaddr_at *)dst, edst)) 168 return (0); 169 /* 170 * ifaddr is the first thing in at_ifaddr 171 */ 172 if ((aa = at_ifawithnet( (struct sockaddr_at *)dst)) == 0) 173 goto bad; 174 175 /* 176 * In the phase 2 case, we need to prepend an mbuf for the llc header. 177 * Since we must preserve the value of m, which is passed to us by 178 * value, we m_copy() the first mbuf, and use it for our llc header. 179 */ 180 if (aa->aa_flags & AFA_PHASE2) { 181 struct llc llc; 182 183 M_PREPEND(m, LLC_SNAPFRAMELEN, M_TRYWAIT); 184 if (m == 0) 185 senderr(ENOBUFS); 186 llc.llc_dsap = llc.llc_ssap = LLC_SNAP_LSAP; 187 llc.llc_control = LLC_UI; 188 bcopy(at_org_code, llc.llc_snap.org_code, sizeof(at_org_code)); 189 llc.llc_snap.ether_type = htons(ETHERTYPE_AT); 190 bcopy(&llc, mtod(m, caddr_t), LLC_SNAPFRAMELEN); 191 type = 0; 192 } else { 193 type = htons(ETHERTYPE_AT); 194 } 195 break; 196 } 197#endif /* NETATALK */ 198 199 case pseudo_AF_HDRCMPLT: 200 { 201 struct ether_header *eh; 202 hdrcmplt = 1; 203 eh = (struct ether_header *)dst->sa_data; 204 bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, FDDI_ADDR_LEN); 205 /* FALLTHROUGH */ 206 } 207 208 case AF_UNSPEC: 209 { 210 struct ether_header *eh; 211 loop_copy = -1; 212 eh = (struct ether_header *)dst->sa_data; 213 bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, FDDI_ADDR_LEN); 214 if (*edst & 1) 215 m->m_flags |= (M_BCAST|M_MCAST); 216 type = eh->ether_type; 217 break; 218 } 219 220 case AF_IMPLINK: 221 { 222 fh = mtod(m, struct fddi_header *); 223 error = EPROTONOSUPPORT; 224 switch (fh->fddi_fc & (FDDIFC_C|FDDIFC_L|FDDIFC_F)) { 225 case FDDIFC_LLC_ASYNC: { 226 /* legal priorities are 0 through 7 */ 227 if ((fh->fddi_fc & FDDIFC_Z) > 7) 228 goto bad; 229 break; 230 } 231 case FDDIFC_LLC_SYNC: { 232 /* FDDIFC_Z bits reserved, must be zero */ 233 if (fh->fddi_fc & FDDIFC_Z) 234 goto bad; 235 break; 236 } 237 case FDDIFC_SMT: { 238 /* FDDIFC_Z bits must be non zero */ 239 if ((fh->fddi_fc & FDDIFC_Z) == 0) 240 goto bad; 241 break; 242 } 243 default: { 244 /* anything else is too dangerous */ 245 goto bad; 246 } 247 } 248 error = 0; 249 if (fh->fddi_dhost[0] & 1) 250 m->m_flags |= (M_BCAST|M_MCAST); 251 goto queue_it; 252 } 253 default: 254 if_printf(ifp, "can't handle af%d\n", dst->sa_family); 255 senderr(EAFNOSUPPORT); 256 } 257 258 /* 259 * Add LLC header. 260 */ 261 if (type != 0) { 262 struct llc *l; 263 M_PREPEND(m, LLC_SNAPFRAMELEN, M_DONTWAIT); 264 if (m == 0) 265 senderr(ENOBUFS); 266 l = mtod(m, struct llc *); 267 l->llc_control = LLC_UI; 268 l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP; 269 l->llc_snap.org_code[0] = 270 l->llc_snap.org_code[1] = 271 l->llc_snap.org_code[2] = 0; 272 l->llc_snap.ether_type = htons(type); 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 > 0)) { 303 struct mbuf *n; 304 n = m_copy(m, 0, (int)M_COPYALL); 305 (void) if_simloop(ifp, n, dst->sa_family, 306 FDDI_HDR_LEN); 307 } else if (bcmp(fh->fddi_dhost, fh->fddi_shost, 308 FDDI_ADDR_LEN) == 0) { 309 (void) if_simloop(ifp, m, dst->sa_family, 310 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 * Discard packet if interface is not up. 344 */ 345 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 346 goto dropanyway; 347 348#ifdef MAC 349 mac_create_mbuf_from_ifnet(ifp, m); 350#endif 351 352 /* 353 * Update interface statistics. 354 */ 355 ifp->if_ibytes += m->m_pkthdr.len; 356 getmicrotime(&ifp->if_lastchange); 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) || 404 (l->llc_ssap != LLC_SNAP_LSAP)) { 405 ifp->if_noproto++; 406 goto dropanyway; 407 } 408#ifdef NETATALK 409 if (Bcmp(&(l->llc_snap.org_code)[0], at_org_code, 410 sizeof(at_org_code)) == 0 && 411 ntohs(l->llc_snap.ether_type) == ETHERTYPE_AT) { 412 isr = NETISR_ATALK2; 413 m_adj(m, LLC_SNAPFRAMELEN); 414 break; 415 } 416 417 if (Bcmp(&(l->llc_snap.org_code)[0], aarp_org_code, 418 sizeof(aarp_org_code)) == 0 && 419 ntohs(l->llc_snap.ether_type) == ETHERTYPE_AARP) { 420 m_adj(m, LLC_SNAPFRAMELEN); 421 isr = NETISR_AARP; 422 break; 423 } 424#endif /* NETATALK */ 425 if (l->llc_snap.org_code[0] != 0 || 426 l->llc_snap.org_code[1] != 0 || 427 l->llc_snap.org_code[2] != 0) { 428 ifp->if_noproto++; 429 goto dropanyway; 430 } 431 432 type = ntohs(l->llc_snap.ether_type); 433 m_adj(m, LLC_SNAPFRAMELEN); 434 435 switch (type) { 436#ifdef INET 437 case ETHERTYPE_IP: 438 if (ipflow_fastforward(m)) 439 return; 440 isr = NETISR_IP; 441 break; 442 443 case ETHERTYPE_ARP: 444 if (ifp->if_flags & IFF_NOARP) 445 goto dropanyway; 446 isr = NETISR_ARP; 447 break; 448#endif 449#ifdef INET6 450 case ETHERTYPE_IPV6: 451 isr = NETISR_IPV6; 452 break; 453#endif 454#ifdef IPX 455 case ETHERTYPE_IPX: 456 isr = NETISR_IPX; 457 break; 458#endif 459#ifdef DECNET 460 case ETHERTYPE_DECNET: 461 isr = NETISR_DECNET; 462 break; 463#endif 464#ifdef NETATALK 465 case ETHERTYPE_AT: 466 isr = NETISR_ATALK1; 467 break; 468 case ETHERTYPE_AARP: 469 isr = NETISR_AARP; 470 break; 471#endif /* NETATALK */ 472 default: 473 /* printf("fddi_input: unknown protocol 0x%x\n", type); */ 474 ifp->if_noproto++; 475 goto dropanyway; 476 } 477 break; 478 } 479 480 default: 481 /* printf("fddi_input: unknown dsap 0x%x\n", l->llc_dsap); */ 482 ifp->if_noproto++; 483 goto dropanyway; 484 } 485 netisr_dispatch(isr, m); 486 return; 487 488dropanyway: 489 ifp->if_iqdrops++; 490 if (m) 491 m_freem(m); 492 return; 493} 494 495/* 496 * Perform common duties while attaching to interface list 497 */ 498void 499fddi_ifattach(ifp, bpf) 500 struct ifnet *ifp; 501 int bpf; 502{ 503 struct ifaddr *ifa; 504 struct sockaddr_dl *sdl; 505 506 ifp->if_type = IFT_FDDI; 507 ifp->if_addrlen = FDDI_ADDR_LEN; 508 ifp->if_hdrlen = 21; 509 510 if_attach(ifp); /* Must be called before additional assignments */ 511 512 ifp->if_mtu = FDDIMTU; 513 ifp->if_output = fddi_output; 514 ifp->if_input = fddi_input; 515 ifp->if_resolvemulti = fddi_resolvemulti; 516 ifp->if_broadcastaddr = fddibroadcastaddr; 517 ifp->if_baudrate = 100000000; 518#ifdef IFF_NOTRAILERS 519 ifp->if_flags |= IFF_NOTRAILERS; 520#endif 521 ifa = ifaddr_byindex(ifp->if_index); 522 if (ifa == NULL) { 523 if_printf(ifp, "%s() no lladdr!\n", __func__); 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