The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/net/if_fddisubr.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 /*
   26  * Copyright (c) 1995, 1996
   27  *      Matt Thomas <matt@3am-software.com>.  All rights reserved.
   28  * Copyright (c) 1982, 1989, 1993
   29  *      The Regents of the University of California.  All rights reserved.
   30  *
   31  * Redistribution and use in source and binary forms, with or without
   32  * modification, are permitted provided that the following conditions
   33  * are met:
   34  * 1. Redistributions of source code must retain the above copyright
   35  *    notice, this list of conditions and the following disclaimer.
   36  * 2. Redistributions in binary form must reproduce the above copyright
   37  *    notice, this list of conditions and the following disclaimer in the
   38  *    documentation and/or other materials provided with the distribution.
   39  * 3. All advertising materials mentioning features or use of this software
   40  *    must display the following acknowledgement:
   41  *      This product includes software developed by the University of
   42  *      California, Berkeley and its contributors.
   43  * 4. Neither the name of the University nor the names of its contributors
   44  *    may be used to endorse or promote products derived from this software
   45  *    without specific prior written permission.
   46  *
   47  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   48  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   50  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   51  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   52  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   53  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   54  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   55  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   56  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   57  * SUCH DAMAGE.
   58  *
   59  *      from: if_ethersubr.c,v 1.5 1994/12/13 22:31:45 wollman Exp
   60  */
   61 
   62 #include "opt_atalk.h"
   63 #include "opt_inet.h"
   64 #include "opt_ipx.h"
   65 
   66 #include <sys/param.h>
   67 #include <sys/systm.h>
   68 #include <sys/mbuf.h>
   69 #include <sys/socket.h>
   70 
   71 #include <net/if.h>
   72 #include <net/netisr.h>
   73 #include <net/route.h>
   74 #include <net/if_llc.h>
   75 #include <net/if_dl.h>
   76 #include <net/if_types.h>
   77 
   78 #if INET
   79 #include <netinet/in.h>
   80 #include <netinet/in_var.h>
   81 #include <netinet/if_ether.h>
   82 #endif
   83 #if defined(__FreeBSD__)
   84 #include <netinet/if_fddi.h>
   85 #else
   86 #include <net/if_fddi.h>
   87 #endif
   88 
   89 #if IPX
   90 #include <netipx/ipx.h> 
   91 #include <netipx/ipx_if.h>
   92 #endif
   93 
   94 #if DECNET
   95 #include <netdnet/dn.h>
   96 #endif
   97 
   98 #include "bpfilter.h"
   99 
  100 #define senderr(e) { error = (e); goto bad;}
  101 
  102 /*
  103  * This really should be defined in if_llc.h but in case it isn't.
  104  */
  105 #ifndef llc_snap
  106 #define llc_snap        llc_un.type_snap
  107 #endif
  108 
  109 #if defined(__bsdi__) || defined(__NetBSD__)
  110 #define RTALLOC1(a, b)                  rtalloc1(a, b)
  111 #define ARPRESOLVE(a, b, c, d, e, f)    arpresolve(a, b, c, d, e)
  112 #elif defined(__FreeBSD__)
  113 #define RTALLOC1(a, b)                  rtalloc1(a, b, 0UL)
  114 #define ARPRESOLVE(a, b, c, d, e, f)    arpresolve(a, b, c, d, e, f)
  115 #endif
  116 /*
  117  * FDDI output routine.
  118  * Encapsulate a packet of type family for the local net.
  119  * Use trailer local net encapsulation if enough data in first
  120  * packet leaves a multiple of 512 bytes of data in remainder.
  121  * Assumes that ifp is actually pointer to arpcom structure.
  122  */
  123 int
  124 fddi_output(ifp, m0, dst, rt0)
  125         register struct ifnet *ifp;
  126         struct mbuf *m0;
  127         struct sockaddr *dst;
  128         struct rtentry *rt0;
  129 {
  130         u_int16_t type;
  131         int s, loop_copy = 0, error = 0;
  132         u_char edst[6];
  133         register struct mbuf *m = m0;
  134         register struct rtentry *rt;
  135         register struct fddi_header *fh;
  136         struct arpcom *ac = (struct arpcom *)ifp;
  137 
  138         if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
  139                 senderr(ENETDOWN);
  140         getmicrotime(&ifp->if_lastchange);
  141 #if !defined(__bsdi__) || _BSDI_VERSION >= 199401
  142         if (rt = rt0) {
  143                 if ((rt->rt_flags & RTF_UP) == 0) {
  144                         if (rt0 = rt = RTALLOC1(dst, 1))
  145                                 rtunref(rt);
  146                         else 
  147                                 senderr(EHOSTUNREACH);
  148                 }
  149                 if (rt->rt_flags & RTF_GATEWAY) {
  150                         if (rt->rt_gwroute == 0)
  151                                 goto lookup;
  152                         if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) {
  153                                 rtfree(rt); rt = rt0;
  154                         lookup: rt->rt_gwroute = RTALLOC1(rt->rt_gateway, 1);
  155                                 if ((rt = rt->rt_gwroute) == 0)
  156                                         senderr(EHOSTUNREACH);
  157                         }
  158                 }
  159                 if (rt->rt_flags & RTF_REJECT)
  160                         if (rt->rt_rmx.rmx_expire == 0 ||
  161                             time_second < rt->rt_rmx.rmx_expire)
  162                                 senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
  163         }
  164 #endif
  165         switch (dst->sa_family) {
  166 
  167 #if INET
  168         case AF_INET: {
  169 #if !defined(__bsdi__) || _BSDI_VERSION >= 199401
  170                 if (!ARPRESOLVE(ac, rt, m, dst, edst, rt0))
  171                         return (0);     /* if not yet resolved */
  172 #else
  173                 int usetrailers;
  174                 if (!arpresolve(ac, m, &((struct sockaddr_in *)dst)->sin_addr, edst, &usetrailers))
  175                         return (0);     /* if not yet resolved */
  176 #endif
  177                 type = htons(ETHERTYPE_IP);
  178                 break;
  179         }
  180 #endif
  181 #if IPX
  182         case AF_IPX:
  183                 type = htons(ETHERTYPE_IPX);
  184                 bcopy((caddr_t)&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host),
  185                     (caddr_t)edst, sizeof (edst));
  186                 break;
  187 #endif
  188 
  189 #if NS
  190         case AF_NS:
  191                 type = htons(ETHERTYPE_NS);
  192                 bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
  193                     (caddr_t)edst, sizeof (edst));
  194                 break;
  195 #endif
  196 #if     ISO
  197         case AF_ISO: {
  198                 int     snpalen;
  199                 struct  llc *l;
  200                 register struct sockaddr_dl *sdl;
  201 
  202                 if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway) &&
  203                     sdl->sdl_family == AF_LINK && sdl->sdl_alen > 0) {
  204                         bcopy(LLADDR(sdl), (caddr_t)edst, sizeof(edst));
  205                 } else if (error =
  206                             iso_snparesolve(ifp, (struct sockaddr_iso *)dst,
  207                                             (char *)edst, &snpalen))
  208                         goto bad; /* Not Resolved */
  209                 /* If broadcasting on a simplex interface, loopback a copy */
  210                 if (*edst & 1)
  211                         m->m_flags |= (M_BCAST|M_MCAST);
  212                 M_PREPEND(m, 3, M_DONTWAIT);
  213                 if (m == NULL)
  214                         return (0);
  215                 type = 0;
  216                 l = mtod(m, struct llc *);
  217                 l->llc_dsap = l->llc_ssap = LLC_ISO_LSAP;
  218                 l->llc_control = LLC_UI;
  219                 IFDEBUG(D_ETHER)
  220                         int i;
  221                         printf("unoutput: sending pkt to: ");
  222                         for (i=0; i<6; i++)
  223                                 printf("%x ", edst[i] & 0xff);
  224                         printf("\n");
  225                 ENDDEBUG
  226                 } break;
  227 #endif /* ISO */
  228 #if     LLC
  229 /*      case AF_NSAP: */
  230         case AF_CCITT: {
  231                 register struct sockaddr_dl *sdl = 
  232                         (struct sockaddr_dl *) rt -> rt_gateway;
  233 
  234                 if (sdl && sdl->sdl_family != AF_LINK && sdl->sdl_alen <= 0)
  235                         goto bad; /* Not a link interface ? Funny ... */
  236                 bcopy(LLADDR(sdl), (char *)edst, sizeof(edst));
  237                 if (*edst & 1)
  238                         loop_copy = 1;
  239                 type = 0;
  240 #if LLC_DEBUG
  241                 {
  242                         int i;
  243                         register struct llc *l = mtod(m, struct llc *);
  244 
  245                         printf("fddi_output: sending LLC2 pkt to: ");
  246                         for (i=0; i<6; i++)
  247                                 printf("%x ", edst[i] & 0xff);
  248                         printf(" len 0x%x dsap 0x%x ssap 0x%x control 0x%x\n", 
  249                                type & 0xff, l->llc_dsap & 0xff, l->llc_ssap &0xff,
  250                                l->llc_control & 0xff);
  251 
  252                 }
  253 #endif /* LLC_DEBUG */
  254                 } break;
  255 #endif /* LLC */        
  256 
  257         case AF_UNSPEC:
  258         {
  259                 struct ether_header *eh;
  260                 loop_copy = -1;
  261                 eh = (struct ether_header *)dst->sa_data;
  262                 (void)memcpy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst));
  263                 if (*edst & 1)
  264                         m->m_flags |= (M_BCAST|M_MCAST);
  265                 type = eh->ether_type;
  266                 break;
  267         }
  268 
  269 #if NBPFILTER > 0
  270         case AF_IMPLINK:
  271         {
  272                 fh = mtod(m, struct fddi_header *);
  273                 error = EPROTONOSUPPORT;
  274                 switch (fh->fddi_fc & (FDDIFC_C|FDDIFC_L|FDDIFC_F)) {
  275                         case FDDIFC_LLC_ASYNC: {
  276                                 /* legal priorities are 0 through 7 */
  277                                 if ((fh->fddi_fc & FDDIFC_Z) > 7)
  278                                         goto bad;
  279                                 break;
  280                         }
  281                         case FDDIFC_LLC_SYNC: {
  282                                 /* FDDIFC_Z bits reserved, must be zero */
  283                                 if (fh->fddi_fc & FDDIFC_Z)
  284                                         goto bad;
  285                                 break;
  286                         }
  287                         case FDDIFC_SMT: {
  288                                 /* FDDIFC_Z bits must be non zero */
  289                                 if ((fh->fddi_fc & FDDIFC_Z) == 0)
  290                                         goto bad;
  291                                 break;
  292                         }
  293                         default: {
  294                                 /* anything else is too dangerous */
  295                                 goto bad;
  296                         }
  297                 }
  298                 error = 0;
  299                 if (fh->fddi_dhost[0] & 1)
  300                         m->m_flags |= (M_BCAST|M_MCAST);
  301                 goto queue_it;
  302         }
  303 #endif
  304         default:
  305                 printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit,
  306                         dst->sa_family);
  307                 senderr(EAFNOSUPPORT);
  308         }
  309 
  310         if (type != 0) {
  311                 register struct llc *l;
  312                 M_PREPEND(m, sizeof (struct llc), M_DONTWAIT);
  313                 if (m == 0)
  314                         senderr(ENOBUFS);
  315                 l = mtod(m, struct llc *);
  316                 l->llc_control = LLC_UI;
  317                 l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP;
  318                 l->llc_snap.org_code[0] = l->llc_snap.org_code[1] = l->llc_snap.org_code[2] = 0;
  319                 (void)memcpy((caddr_t) &l->llc_snap.ether_type, (caddr_t) &type,
  320                         sizeof(u_int16_t));
  321         }
  322 
  323         /*
  324          * Add local net header.  If no space in first mbuf,
  325          * allocate another.
  326          */
  327         M_PREPEND(m, sizeof (struct fddi_header), M_DONTWAIT);
  328         if (m == 0)
  329                 senderr(ENOBUFS);
  330         fh = mtod(m, struct fddi_header *);
  331         fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4;
  332         (void)memcpy((caddr_t)fh->fddi_dhost, (caddr_t)edst, sizeof (edst));
  333   queue_it:
  334         (void)memcpy((caddr_t)fh->fddi_shost, (caddr_t)ac->ac_enaddr,
  335             sizeof(fh->fddi_shost));
  336 
  337         /*
  338          * If a simplex interface, and the packet is being sent to our
  339          * Ethernet address or a broadcast address, loopback a copy.
  340          * XXX To make a simplex device behave exactly like a duplex
  341          * device, we should copy in the case of sending to our own
  342          * ethernet address (thus letting the original actually appear
  343          * on the wire). However, we don't do that here for security
  344          * reasons and compatibility with the original behavior.
  345          */
  346         if ((ifp->if_flags & IFF_SIMPLEX) &&
  347            (loop_copy != -1)) {
  348                 if ((m->m_flags & M_BCAST) || loop_copy) {
  349                         struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
  350 
  351                         (void) if_simloop(ifp,
  352                                 n, dst, sizeof(struct fddi_header));
  353                 } else if (bcmp(fh->fddi_dhost,
  354                     fh->fddi_shost, sizeof(fh->fddi_shost)) == 0) {
  355                         (void) if_simloop(ifp,
  356                                 m, dst, sizeof(struct fddi_header));
  357                         return(0);      /* XXX */
  358                 }
  359         }
  360 
  361         s = splimp();
  362         /*
  363          * Queue message on interface, and start output if interface
  364          * not yet active.
  365          */
  366         if (IF_QFULL(&ifp->if_snd)) {
  367                 IF_DROP(&ifp->if_snd);
  368                 splx(s);
  369                 senderr(ENOBUFS);
  370         }
  371         ifp->if_obytes += m->m_pkthdr.len;
  372         IF_ENQUEUE(&ifp->if_snd, m);
  373         if ((ifp->if_flags & IFF_OACTIVE) == 0)
  374                 (*ifp->if_start)(ifp);
  375         splx(s);
  376         if (m->m_flags & M_MCAST)
  377                 ifp->if_omcasts++;
  378         return (error);
  379 
  380 bad:
  381         if (m)
  382                 m_freem(m);
  383         return (error);
  384 }
  385 
  386 /*
  387  * Process a received FDDI packet;
  388  * the packet is in the mbuf chain m without
  389  * the fddi header, which is provided separately.
  390  */
  391 void
  392 fddi_input(ifp, fh, m)
  393         struct ifnet *ifp;
  394         register struct fddi_header *fh;
  395         struct mbuf *m;
  396 {
  397         register struct ifqueue *inq;
  398         register struct llc *l;
  399         int s;
  400 
  401         if ((ifp->if_flags & IFF_UP) == 0) {
  402                 m_freem(m);
  403                 return;
  404         }
  405         getmicrotime(&ifp->if_lastchange);
  406         ifp->if_ibytes += m->m_pkthdr.len + sizeof (*fh);
  407         if (fh->fddi_dhost[0] & 1) {
  408                 if (bcmp((caddr_t)fddibroadcastaddr, (caddr_t)fh->fddi_dhost,
  409                     sizeof(fddibroadcastaddr)) == 0)
  410                         m->m_flags |= M_BCAST;
  411                 else
  412                         m->m_flags |= M_MCAST;
  413                 ifp->if_imcasts++;
  414         } else if ((ifp->if_flags & IFF_PROMISC)
  415             && bcmp(((struct arpcom *)ifp)->ac_enaddr, (caddr_t)fh->fddi_dhost,
  416                     sizeof(fh->fddi_dhost)) != 0) {
  417                 m_freem(m);
  418                 return;
  419         }
  420 
  421 #ifdef M_LINK0
  422         /*
  423          * If this has a LLC priority of 0, then mark it so upper
  424          * layers have a hint that it really came via a FDDI/Ethernet
  425          * bridge.
  426          */
  427         if ((fh->fddi_fc & FDDIFC_LLC_PRIO7) == FDDIFC_LLC_PRIO0)
  428                 m->m_flags |= M_LINK0;
  429 #endif
  430 
  431         l = mtod(m, struct llc *);
  432         switch (l->llc_dsap) {
  433 #if defined(INET) || NS || IPX || defined(NETATALK)
  434         case LLC_SNAP_LSAP:
  435         {
  436                 u_int16_t type;
  437                 if (l->llc_control != LLC_UI || l->llc_ssap != LLC_SNAP_LSAP)
  438                         goto dropanyway;
  439 
  440                 if (l->llc_snap.org_code[0] != 0 || l->llc_snap.org_code[1] != 0|| l->llc_snap.org_code[2] != 0)
  441                         goto dropanyway;
  442                 type = ntohs(l->llc_snap.ether_type);
  443                 m_adj(m, 8);
  444                 switch (type) {
  445 #if INET
  446                 case ETHERTYPE_IP:
  447                         if (ipflow_fastforward(m))
  448                                 return;
  449                         schednetisr(NETISR_IP);
  450                         inq = &ipintrq;
  451                         break;
  452 
  453                 case ETHERTYPE_ARP:
  454 #if !defined(__bsdi__) || _BSDI_VERSION >= 199401
  455                         schednetisr(NETISR_ARP);
  456                         inq = &arpintrq;
  457                         break;
  458 #else
  459                         arpinput((struct arpcom *)ifp, m);
  460                         return;
  461 #endif
  462 #endif
  463 #if IPX      
  464                 case ETHERTYPE_IPX: 
  465                         schednetisr(NETISR_IPX);
  466                         inq = &ipxintrq;
  467                         break;  
  468 #endif   
  469 #if NS
  470                 case ETHERTYPE_NS:
  471                         schednetisr(NETISR_NS);
  472                         inq = &nsintrq;
  473                         break;
  474 #endif
  475 #if DECNET
  476                 case ETHERTYPE_DECNET:
  477                         schednetisr(NETISR_DECNET);
  478                         inq = &decnetintrq;
  479                         break;
  480 #endif
  481 
  482                 default:
  483                         /* printf("fddi_input: unknown protocol 0x%x\n", type); */
  484                         ifp->if_noproto++;
  485                         goto dropanyway;
  486                 }
  487                 break;
  488         }
  489 #endif /* INET || NS */
  490 #if     ISO
  491         case LLC_ISO_LSAP: 
  492                 switch (l->llc_control) {
  493                 case LLC_UI:
  494                         /* LLC_UI_P forbidden in class 1 service */
  495                         if ((l->llc_dsap == LLC_ISO_LSAP) &&
  496                             (l->llc_ssap == LLC_ISO_LSAP)) {
  497                                 /* LSAP for ISO */
  498                                 m->m_data += 3;         /* XXX */
  499                                 m->m_len -= 3;          /* XXX */
  500                                 m->m_pkthdr.len -= 3;   /* XXX */
  501                                 M_PREPEND(m, sizeof *fh, M_DONTWAIT);
  502                                 if (m == 0)
  503                                         return;
  504                                 *mtod(m, struct fddi_header *) = *fh;
  505                                 IFDEBUG(D_ETHER)
  506                                         printf("clnp packet");
  507                                 ENDDEBUG
  508                                 schednetisr(NETISR_ISO);
  509                                 inq = &clnlintrq;
  510                                 break;
  511                         }
  512                         goto dropanyway;
  513                         
  514                 case LLC_XID:
  515                 case LLC_XID_P:
  516                         if(m->m_len < 6)
  517                                 goto dropanyway;
  518                         l->llc_window = 0;
  519                         l->llc_fid = 9;
  520                         l->llc_class = 1;
  521                         l->llc_dsap = l->llc_ssap = 0;
  522                         /* Fall through to */
  523                 case LLC_TEST:
  524                 case LLC_TEST_P:
  525                 {
  526                         struct sockaddr sa;
  527                         register struct ether_header *eh;
  528                         struct arpcom *ac = (struct arpcom *) ifp;
  529                         int i;
  530                         u_char c = l->llc_dsap;
  531 
  532                         l->llc_dsap = l->llc_ssap;
  533                         l->llc_ssap = c;
  534                         if (m->m_flags & (M_BCAST | M_MCAST))
  535                                 bcopy((caddr_t)ac->ac_enaddr,
  536                                       (caddr_t)eh->ether_dhost, 6);
  537                         sa.sa_family = AF_UNSPEC;
  538                         sa.sa_len = sizeof(sa);
  539                         eh = (struct ether_header *)sa.sa_data;
  540                         for (i = 0; i < 6; i++) {
  541                                 eh->ether_shost[i] = fh->fddi_dhost[i];
  542                                 eh->ether_dhost[i] = fh->fddi_shost[i];
  543                         }
  544                         eh->ether_type = 0;
  545                         ifp->if_output(ifp, m, &sa, NULL);
  546                         return;
  547                 }
  548                 default:
  549                         m_freem(m);
  550                         return;
  551                 }
  552                 break;
  553 #endif /* ISO */
  554 #if LLC
  555         case LLC_X25_LSAP:
  556         {
  557                 M_PREPEND(m, sizeof(struct sdl_hdr) , M_DONTWAIT);
  558                 if (m == 0)
  559                         return;
  560                 if ( !sdl_sethdrif(ifp, fh->fddi_shost, LLC_X25_LSAP,
  561                                     fh->fddi_dhost, LLC_X25_LSAP, 6, 
  562                                     mtod(m, struct sdl_hdr *)))
  563                         panic("ETHER cons addr failure");
  564                 mtod(m, struct sdl_hdr *)->sdlhdr_len = m->m_pkthdr.len - sizeof(struct sdl_hdr);
  565 #if LLC_DEBUG
  566                 printf("llc packet\n");
  567 #endif /* LLC_DEBUG */
  568                 schednetisr(NETISR_CCITT);
  569                 inq = &llcintrq;
  570                 break;
  571         }
  572 #endif /* LLC */
  573                 
  574         default:
  575                 /* printf("fddi_input: unknown dsap 0x%x\n", l->llc_dsap); */
  576                 ifp->if_noproto++;
  577         dropanyway:
  578                 m_freem(m);
  579                 return;
  580         }
  581 
  582         s = splimp();
  583         if (IF_QFULL(inq)) {
  584                 IF_DROP(inq);
  585                 m_freem(m);
  586         } else
  587                 IF_ENQUEUE(inq, m);
  588         splx(s);
  589 }
  590 /*
  591  * Perform common duties while attaching to interface list
  592  */
  593 #ifdef __NetBSD__
  594 #define ifa_next        ifa_list.tqe_next
  595 #endif
  596 
  597 void
  598 fddi_ifattach(ifp)
  599         register struct ifnet *ifp;
  600 {
  601         register struct ifaddr *ifa;
  602         register struct sockaddr_dl *sdl;
  603 
  604         ifp->if_type = IFT_FDDI;
  605         ifp->if_addrlen = 6;
  606         ifp->if_hdrlen = 21;
  607         ifp->if_mtu = FDDIMTU;
  608         ifp->if_baudrate = 100000000;
  609 #if IFF_NOTRAILERS
  610         ifp->if_flags |= IFF_NOTRAILERS;
  611 #endif
  612 #if defined(__FreeBSD__)
  613         ifa = ifnet_addrs[ifp->if_index - 1];
  614         sdl = (struct sockaddr_dl *)ifa->ifa_addr;
  615         sdl->sdl_type = IFT_FDDI;
  616         sdl->sdl_alen = ifp->if_addrlen;
  617         bcopy(((struct arpcom *)ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
  618 #elif defined(__NetBSD__)
  619         LIST_INIT(&((struct arpcom *)ifp)->ac_multiaddrs);
  620         for (ifa = ifp->if_addrlist.tqh_first; ifa != NULL; ifa = ifa->ifa_list.tqe_next)
  621 #else
  622         for (ifa = ifp->if_addrlist; ifa != NULL; ifa = ifa->ifa_next)
  623 #endif
  624 #if !defined(__FreeBSD__)
  625                 if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&
  626                     sdl->sdl_family == AF_LINK) {
  627                         sdl->sdl_type = IFT_FDDI;
  628                         sdl->sdl_alen = ifp->if_addrlen;
  629                         bcopy((caddr_t)((struct arpcom *)ifp)->ac_enaddr,
  630                               LLADDR(sdl), ifp->if_addrlen);
  631                         break;
  632                 }
  633 #endif
  634 }

Cache object: 8424cee51a061cbc8f6e4445dcd9d64c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.