if_iso88025subr.c revision 112296
1189462Semax/* 2189462Semax * Copyright (c) 1998, Larry Lile 3189462Semax * All rights reserved. 4189462Semax * 5189462Semax * For latest sources and information on this driver, please 6189462Semax * go to http://anarchy.stdio.com. 7189462Semax * 8189462Semax * Questions, comments or suggestions should be directed to 9189462Semax * Larry Lile <lile@stdio.com>. 10189462Semax * 11189462Semax * Redistribution and use in source and binary forms, with or without 12189462Semax * modification, are permitted provided that the following conditions 13189462Semax * are met: 14189462Semax * 1. Redistributions of source code must retain the above copyright 15189462Semax * notice unmodified, this list of conditions, and the following 16189462Semax * disclaimer. 17189462Semax * 2. Redistributions in binary form must reproduce the above copyright 18189462Semax * notice, this list of conditions and the following disclaimer in the 19189462Semax * documentation and/or other materials provided with the distribution. 20189462Semax * 21189462Semax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 22189462Semax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23189462Semax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24189462Semax * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 25189462Semax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26189462Semax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27189462Semax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28189462Semax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29189462Semax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30189462Semax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31189462Semax * SUCH DAMAGE. 32189462Semax * 33281210Stakawata * $FreeBSD: head/sys/net/if_iso88025subr.c 112296 2003-03-15 22:37:11Z mdodd $ 34189462Semax * 35189462Semax */ 36189462Semax 37189462Semax/* 38189462Semax * 39189462Semax * General ISO 802.5 (Token Ring) support routines 40189462Semax * 41189462Semax */ 42189462Semax 43189462Semax#include "opt_inet.h" 44189462Semax#include "opt_inet6.h" 45189462Semax#include "opt_ipx.h" 46189462Semax#include "opt_mac.h" 47189462Semax 48189462Semax#include <sys/param.h> 49189462Semax#include <sys/systm.h> 50189462Semax#include <sys/kernel.h> 51189462Semax#include <sys/mac.h> 52189462Semax#include <sys/malloc.h> 53189462Semax#include <sys/mbuf.h> 54189462Semax#include <sys/module.h> 55189462Semax#include <sys/socket.h> 56189462Semax#include <sys/sockio.h> 57189462Semax 58189462Semax#include <net/if.h> 59189462Semax#include <net/if_dl.h> 60189462Semax#include <net/if_llc.h> 61189462Semax#include <net/if_types.h> 62189462Semax 63189462Semax#include <net/netisr.h> 64189462Semax#include <net/route.h> 65189462Semax#include <net/bpf.h> 66189462Semax#include <net/iso88025.h> 67189462Semax 68189462Semax#if defined(INET) || defined(INET6) 69189462Semax#include <netinet/in.h> 70189462Semax#include <netinet/in_var.h> 71189462Semax#include <netinet/if_ether.h> 72189462Semax#endif 73189462Semax#ifdef INET6 74189462Semax#include <netinet6/nd6.h> 75189462Semax#endif 76189462Semax 77189462Semax#ifdef IPX 78189462Semax#include <netipx/ipx.h> 79189462Semax#include <netipx/ipx_if.h> 80189462Semax#endif 81189462Semax 82189462Semaxstatic u_char iso88025_broadcastaddr[ISO88025_ADDR_LEN] = 83189462Semax { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 84189462Semax 85189462Semaxstatic int iso88025_resolvemulti (struct ifnet *, struct sockaddr **, 86189462Semax struct sockaddr *); 87189462Semax 88189462Semax#define IFP2AC(IFP) ((struct arpcom *)IFP) 89189462Semax#define senderr(e) do { error = (e); goto bad; } while (0) 90189462Semax 91189462Semaxvoid 92189462Semaxiso88025_ifattach(struct ifnet *ifp) 93189462Semax{ 94189462Semax struct ifaddr *ifa; 95189462Semax struct sockaddr_dl *sdl; 96189462Semax 97 ifa = NULL; 98 99 ifp->if_type = IFT_ISO88025; 100 ifp->if_addrlen = ISO88025_ADDR_LEN; 101 ifp->if_hdrlen = ISO88025_HDR_LEN; 102 if (ifp->if_baudrate == 0) 103 ifp->if_baudrate = TR_16MBPS; /* 16Mbit should be a safe default */ 104 if (ifp->if_mtu == 0) 105 ifp->if_mtu = ISO88025_DEFAULT_MTU; 106 ifp->if_broadcastaddr = iso88025_broadcastaddr; 107 108 ifa = ifaddr_byindex(ifp->if_index); 109 if (ifa == 0) { 110 printf("iso88025_ifattach: no lladdr!\n"); 111 return; 112 } 113 sdl = (struct sockaddr_dl *)ifa->ifa_addr; 114 sdl->sdl_type = IFT_ISO88025; 115 sdl->sdl_alen = ifp->if_addrlen; 116 bcopy(IFP2AC(ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen); 117} 118 119/* 120 * Perform common duties while detaching a Token Ring interface 121 */ 122void 123iso88025_ifdetach(ifp, bpf) 124 struct ifnet *ifp; 125 int bpf; 126{ 127 128 if (bpf) 129 bpfdetach(ifp); 130 131 if_detach(ifp); 132 133 return; 134} 135 136int 137iso88025_ioctl(struct ifnet *ifp, int command, caddr_t data) 138{ 139 struct ifaddr *ifa; 140 struct ifreq *ifr; 141 int error; 142 143 ifa = (struct ifaddr *) data; 144 ifr = (struct ifreq *) data; 145 error = 0; 146 147 switch (command) { 148 case SIOCSIFADDR: 149 ifp->if_flags |= IFF_UP; 150 151 switch (ifa->ifa_addr->sa_family) { 152#ifdef INET 153 case AF_INET: 154 ifp->if_init(ifp->if_softc); /* before arpwhohas */ 155 arp_ifinit(ifp, ifa); 156 break; 157#endif /* INET */ 158#ifdef IPX 159 /* 160 * XXX - This code is probably wrong 161 */ 162 case AF_IPX: 163 { 164 struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr); 165 struct arpcom *ac = IFP2AC(ifp); 166 167 if (ipx_nullhost(*ina)) 168 ina->x_host = *(union ipx_host *)ac->ac_enaddr; 169 else { 170 bcopy((caddr_t) ina->x_host.c_host, 171 (caddr_t) ac->ac_enaddr, 172 ISO88025_ADDR_LEN); 173 } 174 175 /* 176 * Set new address 177 */ 178 ifp->if_init(ifp->if_softc); 179 break; 180 } 181#endif /* IPX */ 182 default: 183 ifp->if_init(ifp->if_softc); 184 break; 185 } 186 break; 187 188 case SIOCGIFADDR: 189 { 190 struct sockaddr *sa; 191 192 sa = (struct sockaddr *) & ifr->ifr_data; 193 bcopy(IFP2AC(ifp)->ac_enaddr, 194 (caddr_t) sa->sa_data, ISO88025_ADDR_LEN); 195 } 196 break; 197 198 case SIOCSIFMTU: 199 /* 200 * Set the interface MTU. 201 */ 202 if (ifr->ifr_mtu > ISO88025_MAX_MTU) { 203 error = EINVAL; 204 } else { 205 ifp->if_mtu = ifr->ifr_mtu; 206 } 207 break; 208 default: 209 error = EINVAL; /* XXX netbsd has ENOTTY??? */ 210 break; 211 } 212 213 return (error); 214} 215 216/* 217 * ISO88025 encapsulation 218 */ 219int 220iso88025_output(ifp, m, dst, rt0) 221 struct ifnet *ifp; 222 struct mbuf *m; 223 struct sockaddr *dst; 224 struct rtentry *rt0; 225{ 226 u_int16_t snap_type = 0; 227 int loop_copy = 0, error = 0, rif_len = 0; 228 u_char edst[ISO88025_ADDR_LEN]; 229 struct iso88025_header *th; 230 struct iso88025_header gen_th; 231 struct sockaddr_dl *sdl = NULL; 232 struct rtentry *rt; 233 struct arpcom *ac = (struct arpcom *)ifp; 234 235#ifdef MAC 236 error = mac_check_ifnet_transmit(ifp, m); 237 if (error) 238 senderr(error); 239#endif 240 241 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 242 senderr(ENETDOWN); 243 getmicrotime(&ifp->if_lastchange); 244 245 error = rt_check(&rt, &rt0, dst); 246 if (error) 247 goto bad; 248 249 /* Calculate routing info length based on arp table entry */ 250 if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway)) 251 if (SDL_ISO88025(sdl)->trld_rcf != 0) 252 rif_len = TR_RCF_RIFLEN(SDL_ISO88025(sdl)->trld_rcf); 253 254 /* Generate a generic 802.5 header for the packet */ 255 gen_th.ac = TR_AC; 256 gen_th.fc = TR_LLC_FRAME; 257 (void)memcpy((caddr_t)gen_th.iso88025_shost, (caddr_t)ac->ac_enaddr, 258 ISO88025_ADDR_LEN); 259 if (rif_len) { 260 gen_th.iso88025_shost[0] |= TR_RII; 261 if (rif_len > 2) { 262 gen_th.rcf = SDL_ISO88025(sdl)->trld_rcf; 263 (void)memcpy((caddr_t)gen_th.rd, 264 (caddr_t)SDL_ISO88025(sdl)->trld_route, 265 rif_len - 2); 266 } 267 } 268 269 switch (dst->sa_family) { 270#ifdef INET 271 case AF_INET: 272 if (!arpresolve(ifp, rt, m, dst, edst, rt0)) 273 return (0); /* if not yet resolved */ 274 snap_type = ETHERTYPE_IP; 275 break; 276#endif /* INET */ 277#ifdef NOT_YET 278#ifdef INET6 279 case AF_INET6: 280 if (!nd6_storelladdr(&ac->ac_if, rt, m, dst, (u_char *)edst)) { 281 /* Something bad happened */ 282 return(0); 283 } 284 snap_type = ETHERTYPE_IPV6; 285 break; 286#endif /* INET6 */ 287#endif /* NOT_YET */ 288#ifdef IPX 289 case AF_IPX: 290 { 291 u_int8_t *cp; 292 293 bcopy((caddr_t)&(satoipx_addr(dst).x_host), (caddr_t)edst, 294 ISO88025_ADDR_LEN); 295 296 M_PREPEND(m, 3, M_TRYWAIT); 297 if (m == 0) 298 senderr(ENOBUFS); 299 m = m_pullup(m, 3); 300 if (m == 0) 301 senderr(ENOBUFS); 302 cp = mtod(m, u_int8_t *); 303 *cp++ = ETHERTYPE_IPX_8022; 304 *cp++ = ETHERTYPE_IPX_8022; 305 *cp++ = LLC_UI; 306 } 307 break; 308#endif /* IPX */ 309 case AF_UNSPEC: 310 { 311 struct iso88025_sockaddr_data *sd; 312 /* 313 * For AF_UNSPEC sockaddr.sa_data must contain all of the 314 * mac information needed to send the packet. This allows 315 * full mac, llc, and source routing function to be controlled. 316 * llc and source routing information must already be in the 317 * mbuf provided, ac/fc are set in sa_data. sockaddr.sa_data 318 * should be an iso88025_sockaddr_data structure see iso88025.h 319 */ 320 loop_copy = -1; 321 sd = (struct iso88025_sockaddr_data *)dst->sa_data; 322 gen_th.ac = sd->ac; 323 gen_th.fc = sd->fc; 324 (void)memcpy((caddr_t)edst, (caddr_t)sd->ether_dhost, 325 ISO88025_ADDR_LEN); 326 (void)memcpy((caddr_t)gen_th.iso88025_shost, 327 (caddr_t)sd->ether_shost, ISO88025_ADDR_LEN); 328 rif_len = 0; 329 break; 330 } 331 default: 332 if_printf(ifp, "can't handle af%d\n", dst->sa_family); 333 senderr(EAFNOSUPPORT); 334 break; 335 } 336 337 /* 338 * Add LLC header. 339 */ 340 if (snap_type != 0) { 341 struct llc *l; 342 M_PREPEND(m, LLC_SNAPFRAMELEN, M_DONTWAIT); 343 if (m == 0) 344 senderr(ENOBUFS); 345 l = mtod(m, struct llc *); 346 l->llc_control = LLC_UI; 347 l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP; 348 l->llc_snap.org_code[0] = 349 l->llc_snap.org_code[1] = 350 l->llc_snap.org_code[2] = 0; 351 l->llc_snap.ether_type = htons(snap_type); 352 } 353 354 /* 355 * Add local net header. If no space in first mbuf, 356 * allocate another. 357 */ 358 M_PREPEND(m, ISO88025_HDR_LEN + rif_len, M_DONTWAIT); 359 if (m == 0) 360 senderr(ENOBUFS); 361 th = mtod(m, struct iso88025_header *); 362 bcopy((caddr_t)edst, (caddr_t)&gen_th.iso88025_dhost, ISO88025_ADDR_LEN); 363 364 /* Copy as much of the generic header as is needed into the mbuf */ 365 memcpy(th, &gen_th, ISO88025_HDR_LEN + rif_len); 366 367 /* 368 * If a simplex interface, and the packet is being sent to our 369 * Ethernet address or a broadcast address, loopback a copy. 370 * XXX To make a simplex device behave exactly like a duplex 371 * device, we should copy in the case of sending to our own 372 * ethernet address (thus letting the original actually appear 373 * on the wire). However, we don't do that here for security 374 * reasons and compatibility with the original behavior. 375 */ 376 if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) { 377 if ((m->m_flags & M_BCAST) || (loop_copy > 0)) { 378 struct mbuf *n; 379 n = m_copy(m, 0, (int)M_COPYALL); 380 (void) if_simloop(ifp, n, dst->sa_family, 381 ISO88025_HDR_LEN); 382 } else if (bcmp(th->iso88025_dhost, th->iso88025_shost, 383 ETHER_ADDR_LEN) == 0) { 384 (void) if_simloop(ifp, m, dst->sa_family, 385 ISO88025_HDR_LEN); 386 return(0); /* XXX */ 387 } 388 } 389 390 if (! IF_HANDOFF_ADJ(&ifp->if_snd, m, ifp, ISO88025_HDR_LEN + LLC_SNAPFRAMELEN) ) { 391 printf("iso88025_output: packet dropped QFULL.\n"); 392 senderr(ENOBUFS); 393 } 394 return (error); 395 396bad: 397 ifp->if_oerrors++; 398 if (m) 399 m_freem(m); 400 return (error); 401} 402 403/* 404 * ISO 88025 de-encapsulation 405 */ 406void 407iso88025_input(ifp, th, m) 408 struct ifnet *ifp; 409 struct iso88025_header *th; 410 struct mbuf *m; 411{ 412 int isr; 413 struct llc *l; 414 415 /* 416 * Discard packet if interface is not up. 417 */ 418 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 419 goto dropanyway; 420 421#ifdef MAC 422 mac_create_mbuf_from_ifnet(ifp, m); 423#endif 424 425 /* 426 * Update interface statistics. 427 */ 428 ifp->if_ibytes += m->m_pkthdr.len + sizeof(*th); 429 getmicrotime(&ifp->if_lastchange); 430 431 /* 432 * Discard non local unicast packets when interface 433 * is in promiscuous mode. 434 */ 435 if ((ifp->if_flags & IFF_PROMISC) && 436 ((th->iso88025_dhost[0] & 1) == 0) && 437 (bcmp(IFP2AC(ifp)->ac_enaddr, (caddr_t) th->iso88025_dhost, 438 ISO88025_ADDR_LEN) != 0)) 439 goto dropanyway; 440 441 /* 442 * Set mbuf flags for bcast/mcast. 443 */ 444 if (th->iso88025_dhost[0] & 1) { 445 if (bcmp((caddr_t)iso88025_broadcastaddr, 446 (caddr_t)th->iso88025_dhost, ISO88025_ADDR_LEN) == 0) 447 m->m_flags |= M_BCAST; 448 else 449 m->m_flags |= M_MCAST; 450 ifp->if_imcasts++; 451 } 452 453 l = mtod(m, struct llc *); 454 455 switch (l->llc_dsap) { 456#ifdef IPX 457 case ETHERTYPE_IPX_8022: /* Thanks a bunch Novell */ 458 if ((l->llc_control != LLC_UI) || 459 (l->llc_ssap != ETHERTYPE_IPX_8022)) { 460 ifp->if_noproto++; 461 goto dropanyway; 462 } 463 464 th->iso88025_shost[0] &= ~(TR_RII); 465 m_adj(m, 3); 466 isr = NETISR_IPX; 467 break; 468#endif /* IPX */ 469 case LLC_SNAP_LSAP: { 470 u_int16_t type; 471 if ((l->llc_control != LLC_UI) || 472 (l->llc_ssap != LLC_SNAP_LSAP)) { 473 ifp->if_noproto++; 474 goto dropanyway; 475 } 476 477 if (l->llc_snap.org_code[0] != 0 || 478 l->llc_snap.org_code[1] != 0 || 479 l->llc_snap.org_code[2] != 0) { 480 ifp->if_noproto++; 481 goto dropanyway; 482 } 483 484 type = ntohs(l->llc_snap.ether_type); 485 m_adj(m, LLC_SNAPFRAMELEN); 486 switch (type) { 487#ifdef INET 488 case ETHERTYPE_IP: 489 th->iso88025_shost[0] &= ~(TR_RII); 490 if (ipflow_fastforward(m)) 491 return; 492 isr = NETISR_IP; 493 break; 494 495 case ETHERTYPE_ARP: 496 if (ifp->if_flags & IFF_NOARP) 497 goto dropanyway; 498 isr = NETISR_ARP; 499 break; 500#endif /* INET */ 501#ifdef IPX_SNAP /* XXX: Not supported! */ 502 case ETHERTYPE_IPX: 503 th->iso88025_shost[0] &= ~(TR_RII); 504 isr = NETISR_IPX; 505 break; 506#endif /* IPX_SNAP */ 507#ifdef NOT_YET 508#ifdef INET6 509 case ETHERTYPE_IPV6: 510 th->iso88025_shost[0] &= ~(TR_RII); 511 isr = NETISR_IPV6; 512 break; 513#endif /* INET6 */ 514#endif /* NOT_YET */ 515 default: 516 printf("iso88025_input: unexpected llc_snap ether_type 0x%02x\n", type); 517 ifp->if_noproto++; 518 goto dropanyway; 519 } 520 break; 521 } 522#ifdef ISO 523 case LLC_ISO_LSAP: 524 switch (l->llc_control) { 525 case LLC_UI: 526 ifp->if_noproto++; 527 goto dropanyway; 528 break; 529 case LLC_XID: 530 case LLC_XID_P: 531 if(m->m_len < ISO88025_ADDR_LEN) 532 goto dropanyway; 533 l->llc_window = 0; 534 l->llc_fid = 9; 535 l->llc_class = 1; 536 l->llc_dsap = l->llc_ssap = 0; 537 /* Fall through to */ 538 case LLC_TEST: 539 case LLC_TEST_P: 540 { 541 struct sockaddr sa; 542 struct arpcom *ac; 543 struct iso88025_sockaddr_data *th2; 544 int i; 545 u_char c; 546 547 ac = (struct arpcom *)ifp; 548 c = l->llc_dsap; 549 550 if (th->iso88025_shost[0] & TR_RII) { /* XXX */ 551 printf("iso88025_input: dropping source routed LLC_TEST\n"); 552 goto dropanyway; 553 } 554 l->llc_dsap = l->llc_ssap; 555 l->llc_ssap = c; 556 if (m->m_flags & (M_BCAST | M_MCAST)) 557 bcopy((caddr_t)ac->ac_enaddr, 558 (caddr_t)th->iso88025_dhost, 559 ISO88025_ADDR_LEN); 560 sa.sa_family = AF_UNSPEC; 561 sa.sa_len = sizeof(sa); 562 th2 = (struct iso88025_sockaddr_data *)sa.sa_data; 563 for (i = 0; i < ISO88025_ADDR_LEN; i++) { 564 th2->ether_shost[i] = c = th->iso88025_dhost[i]; 565 th2->ether_dhost[i] = th->iso88025_dhost[i] = 566 th->iso88025_shost[i]; 567 th->iso88025_shost[i] = c; 568 } 569 th2->ac = TR_AC; 570 th2->fc = TR_LLC_FRAME; 571 ifp->if_output(ifp, m, &sa, NULL); 572 return; 573 } 574 default: 575 printf("iso88025_input: unexpected llc control 0x%02x\n", l->llc_control); 576 ifp->if_noproto++; 577 goto dropanyway; 578 break; 579 } 580 break; 581#endif /* ISO */ 582 default: 583 printf("iso88025_input: unknown dsap 0x%x\n", l->llc_dsap); 584 ifp->if_noproto++; 585 goto dropanyway; 586 break; 587 } 588 589 netisr_dispatch(isr, m); 590 return; 591 592dropanyway: 593 ifp->if_iqdrops++; 594 if (m) 595 m_freem(m); 596 return; 597} 598 599static int 600iso88025_resolvemulti (ifp, llsa, sa) 601 struct ifnet *ifp; 602 struct sockaddr **llsa; 603 struct sockaddr *sa; 604{ 605 struct sockaddr_dl *sdl; 606 struct sockaddr_in *sin; 607#ifdef INET6 608 struct sockaddr_in6 *sin6; 609#endif 610 u_char *e_addr; 611 612 switch(sa->sa_family) { 613 case AF_LINK: 614 /* 615 * No mapping needed. Just check that it's a valid MC address. 616 */ 617 sdl = (struct sockaddr_dl *)sa; 618 e_addr = LLADDR(sdl); 619 if ((e_addr[0] & 1) != 1) { 620 return (EADDRNOTAVAIL); 621 } 622 *llsa = 0; 623 return (0); 624 625#ifdef INET 626 case AF_INET: 627 sin = (struct sockaddr_in *)sa; 628 if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) { 629 return (EADDRNOTAVAIL); 630 } 631 MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR, 632 M_WAITOK|M_ZERO); 633 sdl->sdl_len = sizeof *sdl; 634 sdl->sdl_family = AF_LINK; 635 sdl->sdl_index = ifp->if_index; 636 sdl->sdl_type = IFT_ISO88025; 637 sdl->sdl_alen = ISO88025_ADDR_LEN; 638 e_addr = LLADDR(sdl); 639 ETHER_MAP_IP_MULTICAST(&sin->sin_addr, e_addr); 640 *llsa = (struct sockaddr *)sdl; 641 return (0); 642#endif 643#ifdef INET6 644 case AF_INET6: 645 sin6 = (struct sockaddr_in6 *)sa; 646 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { 647 /* 648 * An IP6 address of 0 means listen to all 649 * of the Ethernet multicast address used for IP6. 650 * (This is used for multicast routers.) 651 */ 652 ifp->if_flags |= IFF_ALLMULTI; 653 *llsa = 0; 654 return (0); 655 } 656 if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { 657 return (EADDRNOTAVAIL); 658 } 659 MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR, 660 M_WAITOK|M_ZERO); 661 sdl->sdl_len = sizeof *sdl; 662 sdl->sdl_family = AF_LINK; 663 sdl->sdl_index = ifp->if_index; 664 sdl->sdl_type = IFT_ISO88025; 665 sdl->sdl_alen = ISO88025_ADDR_LEN; 666 e_addr = LLADDR(sdl); 667 ETHER_MAP_IPV6_MULTICAST(&sin6->sin6_addr, e_addr); 668 *llsa = (struct sockaddr *)sdl; 669 return (0); 670#endif 671 672 default: 673 /* 674 * Well, the text isn't quite right, but it's the name 675 * that counts... 676 */ 677 return (EAFNOSUPPORT); 678 } 679 680 return (0); 681} 682 683static moduledata_t iso88025_mod = { 684 "iso88025", 685 NULL, 686 0 687}; 688 689DECLARE_MODULE(iso88025, iso88025_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); 690MODULE_VERSION(iso88025, 1); 691