if_fddisubr.c (93377) | if_fddisubr.c (93379) |
---|---|
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 --- 19 unchanged lines hidden (view full) --- 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 | 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 --- 19 unchanged lines hidden (view full) --- 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 93377 2002-03-29 09:52:01Z mdodd $ | 36 * $FreeBSD: head/sys/net/if_fddisubr.c 93379 2002-03-29 10:17:06Z mdodd $ |
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> --- 279 unchanged lines hidden (view full) --- 324 } 325 } 326 327 if (! IF_HANDOFF(&ifp->if_snd, m, ifp)) 328 senderr(ENOBUFS); 329 return (error); 330 331bad: | 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> --- 279 unchanged lines hidden (view full) --- 324 } 325 } 326 327 if (! IF_HANDOFF(&ifp->if_snd, m, ifp)) 328 senderr(ENOBUFS); 329 return (error); 330 331bad: |
332 ifp->if_oerrors++; |
|
332 if (m) 333 m_freem(m); 334 return (error); 335} 336 337/* 338 * Process a received FDDI packet; 339 * the packet is in the mbuf chain m without 340 * the fddi header, which is provided separately. 341 */ 342void 343fddi_input(ifp, fh, m) 344 struct ifnet *ifp; 345 struct fddi_header *fh; 346 struct mbuf *m; 347{ 348 struct ifqueue *inq; 349 struct llc *l; 350 | 333 if (m) 334 m_freem(m); 335 return (error); 336} 337 338/* 339 * Process a received FDDI packet; 340 * the packet is in the mbuf chain m without 341 * the fddi header, which is provided separately. 342 */ 343void 344fddi_input(ifp, fh, m) 345 struct ifnet *ifp; 346 struct fddi_header *fh; 347 struct mbuf *m; 348{ 349 struct ifqueue *inq; 350 struct llc *l; 351 |
351 if ((ifp->if_flags & IFF_UP) == 0) { 352 m_freem(m); 353 return; 354 } 355 getmicrotime(&ifp->if_lastchange); 356 ifp->if_ibytes += m->m_pkthdr.len + sizeof (*fh); | 352 /* 353 * Discard packet if interface is not up. 354 */ 355 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 356 goto dropanyway; 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 */ |
357 if (fh->fddi_dhost[0] & 1) { 358 if (bcmp((caddr_t)fddibroadcastaddr, (caddr_t)fh->fddi_dhost, 359 FDDI_ADDR_LEN) == 0) 360 m->m_flags |= M_BCAST; 361 else 362 m->m_flags |= M_MCAST; 363 ifp->if_imcasts++; | 370 if (fh->fddi_dhost[0] & 1) { 371 if (bcmp((caddr_t)fddibroadcastaddr, (caddr_t)fh->fddi_dhost, 372 FDDI_ADDR_LEN) == 0) 373 m->m_flags |= M_BCAST; 374 else 375 m->m_flags |= M_MCAST; 376 ifp->if_imcasts++; |
364 } else if ((ifp->if_flags & IFF_PROMISC) 365 && bcmp(IFP2AC(ifp)->ac_enaddr, (caddr_t)fh->fddi_dhost, 366 FDDI_ADDR_LEN) != 0) { 367 m_freem(m); 368 return; | |
369 } 370 | 377 } 378 |
379 /* 380 * Update interface statistics. 381 */ 382 getmicrotime(&ifp->if_lastchange); 383 ifp->if_ibytes += (m->m_pkthdr.len + FDDI_HDR_LEN); 384 |
|
371#ifdef M_LINK0 372 /* 373 * If this has a LLC priority of 0, then mark it so upper 374 * layers have a hint that it really came via a FDDI/Ethernet 375 * bridge. 376 */ 377 if ((fh->fddi_fc & FDDIFC_LLC_PRIO7) == FDDIFC_LLC_PRIO0) 378 m->m_flags |= M_LINK0; 379#endif 380 | 385#ifdef M_LINK0 386 /* 387 * If this has a LLC priority of 0, then mark it so upper 388 * layers have a hint that it really came via a FDDI/Ethernet 389 * bridge. 390 */ 391 if ((fh->fddi_fc & FDDIFC_LLC_PRIO7) == FDDIFC_LLC_PRIO0) 392 m->m_flags |= M_LINK0; 393#endif 394 |
395 m = m_pullup(m, sizeof(struct llc)); 396 if (m == 0) { 397 ifp->if_ierrors++; 398 goto dropanyway; 399 } |
|
381 l = mtod(m, struct llc *); 382 383 switch (l->llc_dsap) { 384#if defined(INET) || defined(INET6) || defined(NS) || defined(DECNET) || defined(IPX) || defined(NETATALK) 385 case LLC_SNAP_LSAP: 386 { 387 u_int16_t type; | 400 l = mtod(m, struct llc *); 401 402 switch (l->llc_dsap) { 403#if defined(INET) || defined(INET6) || defined(NS) || defined(DECNET) || defined(IPX) || defined(NETATALK) 404 case LLC_SNAP_LSAP: 405 { 406 u_int16_t type; |
388 if (l->llc_control != LLC_UI || l->llc_ssap != LLC_SNAP_LSAP) | 407 if (l->llc_control != LLC_UI || l->llc_ssap != LLC_SNAP_LSAP) { 408 ifp->if_noproto++; |
389 goto dropanyway; | 409 goto dropanyway; |
410 } |
|
390#ifdef NETATALK 391 if (Bcmp(&(l->llc_snap.org_code)[0], at_org_code, 392 sizeof(at_org_code)) == 0 && 393 ntohs(l->llc_snap.ether_type) == ETHERTYPE_AT) { 394 inq = &atintrq2; 395 m_adj(m, LLC_SNAPFRAMELEN); 396 schednetisr(NETISR_ATALK); 397 break; --- 4 unchanged lines hidden (view full) --- 402 ntohs(l->llc_snap.ether_type) == ETHERTYPE_AARP) { 403 m_adj(m, LLC_SNAPFRAMELEN); 404 aarpinput(IFP2AC(ifp), m); /* XXX */ 405 return; 406 } 407#endif /* NETATALK */ 408 if (l->llc_snap.org_code[0] != 0 || 409 l->llc_snap.org_code[1] != 0 || | 411#ifdef NETATALK 412 if (Bcmp(&(l->llc_snap.org_code)[0], at_org_code, 413 sizeof(at_org_code)) == 0 && 414 ntohs(l->llc_snap.ether_type) == ETHERTYPE_AT) { 415 inq = &atintrq2; 416 m_adj(m, LLC_SNAPFRAMELEN); 417 schednetisr(NETISR_ATALK); 418 break; --- 4 unchanged lines hidden (view full) --- 423 ntohs(l->llc_snap.ether_type) == ETHERTYPE_AARP) { 424 m_adj(m, LLC_SNAPFRAMELEN); 425 aarpinput(IFP2AC(ifp), m); /* XXX */ 426 return; 427 } 428#endif /* NETATALK */ 429 if (l->llc_snap.org_code[0] != 0 || 430 l->llc_snap.org_code[1] != 0 || |
410 l->llc_snap.org_code[2] != 0) | 431 l->llc_snap.org_code[2] != 0) { 432 ifp->if_noproto++; |
411 goto dropanyway; | 433 goto dropanyway; |
434 } |
|
412 413 type = ntohs(l->llc_snap.ether_type); 414 m_adj(m, LLC_SNAPFRAMELEN); 415 416 switch (type) { 417#ifdef INET 418 case ETHERTYPE_IP: 419 if (ipflow_fastforward(m)) --- 75 unchanged lines hidden (view full) --- 495 struct ifnet *ifp; 496{ 497 struct ifaddr *ifa; 498 struct sockaddr_dl *sdl; 499 500 ifp->if_type = IFT_FDDI; 501 ifp->if_addrlen = FDDI_ADDR_LEN; 502 ifp->if_hdrlen = 21; | 435 436 type = ntohs(l->llc_snap.ether_type); 437 m_adj(m, LLC_SNAPFRAMELEN); 438 439 switch (type) { 440#ifdef INET 441 case ETHERTYPE_IP: 442 if (ipflow_fastforward(m)) --- 75 unchanged lines hidden (view full) --- 518 struct ifnet *ifp; 519{ 520 struct ifaddr *ifa; 521 struct sockaddr_dl *sdl; 522 523 ifp->if_type = IFT_FDDI; 524 ifp->if_addrlen = FDDI_ADDR_LEN; 525 ifp->if_hdrlen = 21; |
526 527 if_attach(ifp); /* Must be called before additional assignments */ 528 |
|
503 ifp->if_mtu = FDDIMTU; | 529 ifp->if_mtu = FDDIMTU; |
530 ifp->if_output = fddi_output; |
|
504 ifp->if_resolvemulti = fddi_resolvemulti; | 531 ifp->if_resolvemulti = fddi_resolvemulti; |
532 ifp->if_broadcastaddr = fddibroadcastaddr; |
|
505 ifp->if_baudrate = 100000000; 506#ifdef IFF_NOTRAILERS 507 ifp->if_flags |= IFF_NOTRAILERS; 508#endif 509 ifp->if_broadcastaddr = fddibroadcastaddr; 510 ifa = ifaddr_byindex(ifp->if_index); | 533 ifp->if_baudrate = 100000000; 534#ifdef IFF_NOTRAILERS 535 ifp->if_flags |= IFF_NOTRAILERS; 536#endif 537 ifp->if_broadcastaddr = fddibroadcastaddr; 538 ifa = ifaddr_byindex(ifp->if_index); |
539 if (ifa == NULL) { 540 printf("%s(): no lladdr for %s%d!\n", __FUNCTION__, 541 ifp->if_name, ifp->if_unit); 542 return; 543 } 544 545 ifa = ifaddr_byindex(ifp->if_index); |
|
511 sdl = (struct sockaddr_dl *)ifa->ifa_addr; 512 sdl->sdl_type = IFT_FDDI; 513 sdl->sdl_alen = ifp->if_addrlen; 514 bcopy(IFP2AC(ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen); | 546 sdl = (struct sockaddr_dl *)ifa->ifa_addr; 547 sdl->sdl_type = IFT_FDDI; 548 sdl->sdl_alen = ifp->if_addrlen; 549 bcopy(IFP2AC(ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen); |
550 551 return; |
|
515} 516 517static int 518fddi_resolvemulti(ifp, llsa, sa) 519 struct ifnet *ifp; 520 struct sockaddr **llsa; 521 struct sockaddr *sa; 522{ --- 87 unchanged lines hidden --- | 552} 553 554static int 555fddi_resolvemulti(ifp, llsa, sa) 556 struct ifnet *ifp; 557 struct sockaddr **llsa; 558 struct sockaddr *sa; 559{ --- 87 unchanged lines hidden --- |