Deleted Added
sdiff udiff text old ( 51646 ) new ( 52248 )
full compact
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 51646 1999-09-25 12:06:01Z phk $
37 */
38
39#include "opt_atalk.h"
40#include "opt_inet.h"
41#include "opt_ipx.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/mbuf.h>
46#include <sys/socket.h>
47
48#include <net/if.h>
49#include <net/netisr.h>
50#include <net/route.h>
51#include <net/if_llc.h>
52#include <net/if_dl.h>
53#include <net/if_types.h>
54
55#ifdef INET
56#include <netinet/in.h>
57#include <netinet/in_var.h>
58#include <netinet/if_ether.h>
59#endif
60#if defined(__FreeBSD__)
61#include <netinet/if_fddi.h>
62#else
63#include <net/if_fddi.h>
64#endif
65
66#ifdef IPX
67#include <netipx/ipx.h>
68#include <netipx/ipx_if.h>
69#endif
70
71#ifdef NS
72#include <netns/ns.h>
73#include <netns/ns_if.h>
74#endif
75
76#ifdef DECNET
77#include <netdnet/dn.h>
78#endif
79
80#ifdef ISO
81#include <netiso/argo_debug.h>
82#include <netiso/iso.h>
83#include <netiso/iso_var.h>
84#include <netiso/iso_snpac.h>
85#endif
86
87#ifdef LLC
88#include <netccitt/dll.h>
89#include <netccitt/llc_var.h>
90#endif
91
92#ifdef NETATALK
93#include <netatalk/at.h>
94#include <netatalk/at_var.h>
95#include <netatalk/at_extern.h>
96
97#define llc_snap_org_code llc_un.type_snap.org_code
98#define llc_snap_ether_type llc_un.type_snap.ether_type
99
100extern u_char at_org_code[ 3 ];
101extern u_char aarp_org_code[ 3 ];
102#endif /* NETATALK */
103
104#if defined(LLC) && defined(CCITT)
105extern struct ifqueue pkintrq;
106#endif
107
108#define senderr(e) { error = (e); goto bad;}
109
110/*
111 * This really should be defined in if_llc.h but in case it isn't.
112 */
113#ifndef llc_snap
114#define llc_snap llc_un.type_snap
115#endif
116
117#if defined(__bsdi__) || defined(__NetBSD__)
118#define RTALLOC1(a, b) rtalloc1(a, b)
119#define ARPRESOLVE(a, b, c, d, e, f) arpresolve(a, b, c, d, e)
120#elif defined(__FreeBSD__)
121#define RTALLOC1(a, b) rtalloc1(a, b, 0UL)
122#define ARPRESOLVE(a, b, c, d, e, f) arpresolve(a, b, c, d, e, f)
123#endif
124/*
125 * FDDI output routine.
126 * Encapsulate a packet of type family for the local net.
127 * Use trailer local net encapsulation if enough data in first
128 * packet leaves a multiple of 512 bytes of data in remainder.
129 * Assumes that ifp is actually pointer to arpcom structure.
130 */
131int
132fddi_output(ifp, m0, dst, rt0)
133 register struct ifnet *ifp;
134 struct mbuf *m0;
135 struct sockaddr *dst;
136 struct rtentry *rt0;
137{
138 u_int16_t type;
139 int s, loop_copy = 0, error = 0;
140 u_char edst[6];
141 register struct mbuf *m = m0;
142 register struct rtentry *rt;
143 register struct fddi_header *fh;
144 struct arpcom *ac = (struct arpcom *)ifp;
145
146 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
147 senderr(ENETDOWN);
148 getmicrotime(&ifp->if_lastchange);
149#if !defined(__bsdi__) || _BSDI_VERSION >= 199401
150 if ((rt = rt0) != NULL) {
151 if ((rt->rt_flags & RTF_UP) == 0) {
152 if ((rt0 = rt = RTALLOC1(dst, 1)) != NULL)
153 rt->rt_refcnt--;
154 else
155 senderr(EHOSTUNREACH);
156 }
157 if (rt->rt_flags & RTF_GATEWAY) {
158 if (rt->rt_gwroute == 0)
159 goto lookup;
160 if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) {
161 rtfree(rt); rt = rt0;
162 lookup: rt->rt_gwroute = RTALLOC1(rt->rt_gateway, 1);
163 if ((rt = rt->rt_gwroute) == 0)
164 senderr(EHOSTUNREACH);
165 }
166 }
167 if (rt->rt_flags & RTF_REJECT)
168 if (rt->rt_rmx.rmx_expire == 0 ||
169 time_second < rt->rt_rmx.rmx_expire)
170 senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
171 }
172#endif
173 switch (dst->sa_family) {
174
175#ifdef INET
176 case AF_INET: {
177#if !defined(__bsdi__) || _BSDI_VERSION >= 199401
178 if (!ARPRESOLVE(ac, rt, m, dst, edst, rt0))
179 return (0); /* if not yet resolved */
180#else
181 int usetrailers;
182 if (!arpresolve(ac, m, &((struct sockaddr_in *)dst)->sin_addr, edst, &usetrailers))
183 return (0); /* if not yet resolved */
184#endif
185 type = htons(ETHERTYPE_IP);
186 break;
187 }
188#endif
189#ifdef IPX
190 case AF_IPX:
191 type = htons(ETHERTYPE_IPX);
192 bcopy((caddr_t)&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host),
193 (caddr_t)edst, sizeof (edst));
194 break;
195#endif
196#ifdef NETATALK
197 case AF_APPLETALK: {
198 struct at_ifaddr *aa;
199 if (!aarpresolve(ac, m, (struct sockaddr_at *)dst, edst))
200 return (0);
201 /*
202 * ifaddr is the first thing in at_ifaddr
203 */
204 if ((aa = at_ifawithnet( (struct sockaddr_at *)dst)) == 0)
205 goto bad;
206
207 /*
208 * In the phase 2 case, we need to prepend an mbuf for the llc header.
209 * Since we must preserve the value of m, which is passed to us by
210 * value, we m_copy() the first mbuf, and use it for our llc header.
211 */
212 if (aa->aa_flags & AFA_PHASE2) {
213 struct llc llc;
214
215 M_PREPEND(m, sizeof(struct llc), M_WAIT);
216 if (m == 0)
217 senderr(ENOBUFS);
218 llc.llc_dsap = llc.llc_ssap = LLC_SNAP_LSAP;
219 llc.llc_control = LLC_UI;
220 bcopy(at_org_code, llc.llc_snap_org_code, sizeof(at_org_code));
221 llc.llc_snap_ether_type = htons(ETHERTYPE_AT);
222 bcopy(&llc, mtod(m, caddr_t), sizeof(struct llc));
223 type = 0;
224 } else {
225 type = htons(ETHERTYPE_AT);
226 }
227 break;
228 }
229#endif /* NETATALK */
230#ifdef NS
231 case AF_NS:
232 type = htons(ETHERTYPE_NS);
233 bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
234 (caddr_t)edst, sizeof (edst));
235 break;
236#endif
237#ifdef ISO
238 case AF_ISO: {
239 int snpalen;
240 struct llc *l;
241 register struct sockaddr_dl *sdl;
242
243 if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway) &&
244 sdl->sdl_family == AF_LINK && sdl->sdl_alen > 0) {
245 bcopy(LLADDR(sdl), (caddr_t)edst, sizeof(edst));
246 } else if (error =
247 iso_snparesolve(ifp, (struct sockaddr_iso *)dst,
248 (char *)edst, &snpalen))
249 goto bad; /* Not Resolved */
250 /* If broadcasting on a simplex interface, loopback a copy */
251 if (*edst & 1)
252 m->m_flags |= (M_BCAST|M_MCAST);
253 M_PREPEND(m, 3, M_DONTWAIT);
254 if (m == NULL)
255 return (0);
256 type = 0;
257 l = mtod(m, struct llc *);
258 l->llc_dsap = l->llc_ssap = LLC_ISO_LSAP;
259 l->llc_control = LLC_UI;
260 IFDEBUG(D_ETHER)
261 int i;
262 printf("unoutput: sending pkt to: ");
263 for (i=0; i<6; i++)
264 printf("%x ", edst[i] & 0xff);
265 printf("\n");
266 ENDDEBUG
267 } break;
268#endif /* ISO */
269#ifdef LLC
270/* case AF_NSAP: */
271 case AF_CCITT: {
272 register struct sockaddr_dl *sdl =
273 (struct sockaddr_dl *) rt -> rt_gateway;
274
275 if (sdl && sdl->sdl_family != AF_LINK && sdl->sdl_alen <= 0)
276 goto bad; /* Not a link interface ? Funny ... */
277 bcopy(LLADDR(sdl), (char *)edst, sizeof(edst));
278 if (*edst & 1)
279 loop_copy = 1;
280 type = 0;
281#ifdef LLC_DEBUG
282 {
283 int i;
284 register struct llc *l = mtod(m, struct llc *);
285
286 printf("fddi_output: sending LLC2 pkt to: ");
287 for (i=0; i<6; i++)
288 printf("%x ", edst[i] & 0xff);
289 printf(" len 0x%x dsap 0x%x ssap 0x%x control 0x%x\n",
290 type & 0xff, l->llc_dsap & 0xff, l->llc_ssap &0xff,
291 l->llc_control & 0xff);
292
293 }
294#endif /* LLC_DEBUG */
295 } break;
296#endif /* LLC */
297
298 case AF_UNSPEC:
299 {
300 struct ether_header *eh;
301 loop_copy = -1;
302 eh = (struct ether_header *)dst->sa_data;
303 (void)memcpy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst));
304 if (*edst & 1)
305 m->m_flags |= (M_BCAST|M_MCAST);
306 type = eh->ether_type;
307 break;
308 }
309
310 case AF_IMPLINK:
311 {
312 fh = mtod(m, struct fddi_header *);
313 error = EPROTONOSUPPORT;
314 switch (fh->fddi_fc & (FDDIFC_C|FDDIFC_L|FDDIFC_F)) {
315 case FDDIFC_LLC_ASYNC: {
316 /* legal priorities are 0 through 7 */
317 if ((fh->fddi_fc & FDDIFC_Z) > 7)
318 goto bad;
319 break;
320 }
321 case FDDIFC_LLC_SYNC: {
322 /* FDDIFC_Z bits reserved, must be zero */
323 if (fh->fddi_fc & FDDIFC_Z)
324 goto bad;
325 break;
326 }
327 case FDDIFC_SMT: {
328 /* FDDIFC_Z bits must be non zero */
329 if ((fh->fddi_fc & FDDIFC_Z) == 0)
330 goto bad;
331 break;
332 }
333 default: {
334 /* anything else is too dangerous */
335 goto bad;
336 }
337 }
338 error = 0;
339 if (fh->fddi_dhost[0] & 1)
340 m->m_flags |= (M_BCAST|M_MCAST);
341 goto queue_it;
342 }
343 default:
344 printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit,
345 dst->sa_family);
346 senderr(EAFNOSUPPORT);
347 }
348
349 if (type != 0) {
350 register struct llc *l;
351 M_PREPEND(m, sizeof (struct llc), M_DONTWAIT);
352 if (m == 0)
353 senderr(ENOBUFS);
354 l = mtod(m, struct llc *);
355 l->llc_control = LLC_UI;
356 l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP;
357 l->llc_snap.org_code[0] = l->llc_snap.org_code[1] = l->llc_snap.org_code[2] = 0;
358 (void)memcpy((caddr_t) &l->llc_snap.ether_type, (caddr_t) &type,
359 sizeof(u_int16_t));
360 }
361
362 /*
363 * Add local net header. If no space in first mbuf,
364 * allocate another.
365 */
366 M_PREPEND(m, sizeof (struct fddi_header), M_DONTWAIT);
367 if (m == 0)
368 senderr(ENOBUFS);
369 fh = mtod(m, struct fddi_header *);
370 fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4;
371 (void)memcpy((caddr_t)fh->fddi_dhost, (caddr_t)edst, sizeof (edst));
372 queue_it:
373 (void)memcpy((caddr_t)fh->fddi_shost, (caddr_t)ac->ac_enaddr,
374 sizeof(fh->fddi_shost));
375
376 /*
377 * If a simplex interface, and the packet is being sent to our
378 * Ethernet address or a broadcast address, loopback a copy.
379 * XXX To make a simplex device behave exactly like a duplex
380 * device, we should copy in the case of sending to our own
381 * ethernet address (thus letting the original actually appear
382 * on the wire). However, we don't do that here for security
383 * reasons and compatibility with the original behavior.
384 */
385 if ((ifp->if_flags & IFF_SIMPLEX) &&
386 (loop_copy != -1)) {
387 if ((m->m_flags & M_BCAST) || loop_copy) {
388 struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
389
390 (void) if_simloop(ifp,
391 n, dst, sizeof(struct fddi_header));
392 } else if (bcmp(fh->fddi_dhost,
393 fh->fddi_shost, sizeof(fh->fddi_shost)) == 0) {
394 (void) if_simloop(ifp,
395 m, dst, sizeof(struct fddi_header));
396 return(0); /* XXX */
397 }
398 }
399
400 s = splimp();
401 /*
402 * Queue message on interface, and start output if interface
403 * not yet active.
404 */
405 if (IF_QFULL(&ifp->if_snd)) {
406 IF_DROP(&ifp->if_snd);
407 splx(s);
408 senderr(ENOBUFS);
409 }
410 ifp->if_obytes += m->m_pkthdr.len;
411 IF_ENQUEUE(&ifp->if_snd, m);
412 if ((ifp->if_flags & IFF_OACTIVE) == 0)
413 (*ifp->if_start)(ifp);
414 splx(s);
415 if (m->m_flags & M_MCAST)
416 ifp->if_omcasts++;
417 return (error);
418
419bad:
420 if (m)
421 m_freem(m);
422 return (error);
423}
424
425/*
426 * Process a received FDDI packet;
427 * the packet is in the mbuf chain m without
428 * the fddi header, which is provided separately.
429 */
430void
431fddi_input(ifp, fh, m)
432 struct ifnet *ifp;
433 register struct fddi_header *fh;
434 struct mbuf *m;
435{
436 register struct ifqueue *inq;
437 register struct llc *l;
438 int s;
439
440 if ((ifp->if_flags & IFF_UP) == 0) {
441 m_freem(m);
442 return;
443 }
444 getmicrotime(&ifp->if_lastchange);
445 ifp->if_ibytes += m->m_pkthdr.len + sizeof (*fh);
446 if (fh->fddi_dhost[0] & 1) {
447 if (bcmp((caddr_t)fddibroadcastaddr, (caddr_t)fh->fddi_dhost,
448 sizeof(fddibroadcastaddr)) == 0)
449 m->m_flags |= M_BCAST;
450 else
451 m->m_flags |= M_MCAST;
452 ifp->if_imcasts++;
453 } else if ((ifp->if_flags & IFF_PROMISC)
454 && bcmp(((struct arpcom *)ifp)->ac_enaddr, (caddr_t)fh->fddi_dhost,
455 sizeof(fh->fddi_dhost)) != 0) {
456 m_freem(m);
457 return;
458 }
459
460#ifdef M_LINK0
461 /*
462 * If this has a LLC priority of 0, then mark it so upper
463 * layers have a hint that it really came via a FDDI/Ethernet
464 * bridge.
465 */
466 if ((fh->fddi_fc & FDDIFC_LLC_PRIO7) == FDDIFC_LLC_PRIO0)
467 m->m_flags |= M_LINK0;
468#endif
469
470 l = mtod(m, struct llc *);
471 switch (l->llc_dsap) {
472#if defined(INET) || defined(NS) || defined(DECNET) || defined(IPX) || defined(NETATALK)
473 case LLC_SNAP_LSAP:
474 {
475 u_int16_t type;
476 if (l->llc_control != LLC_UI || l->llc_ssap != LLC_SNAP_LSAP)
477 goto dropanyway;
478#ifdef NETATALK
479 if (Bcmp(&(l->llc_snap_org_code)[0], at_org_code,
480 sizeof(at_org_code)) == 0 &&
481 ntohs(l->llc_snap_ether_type) == ETHERTYPE_AT) {
482 inq = &atintrq2;
483 m_adj( m, sizeof( struct llc ));
484 schednetisr(NETISR_ATALK);
485 break;
486 }
487
488 if (Bcmp(&(l->llc_snap_org_code)[0], aarp_org_code,
489 sizeof(aarp_org_code)) == 0 &&
490 ntohs(l->llc_snap_ether_type) == ETHERTYPE_AARP) {
491 m_adj( m, sizeof( struct llc ));
492 aarpinput((struct arpcom *)ifp, m); /* XXX */
493 return;
494 }
495#endif /* NETATALK */
496 if (l->llc_snap.org_code[0] != 0 || l->llc_snap.org_code[1] != 0|| l->llc_snap.org_code[2] != 0)
497 goto dropanyway;
498 type = ntohs(l->llc_snap.ether_type);
499 m_adj(m, 8);
500 switch (type) {
501#ifdef INET
502 case ETHERTYPE_IP:
503 if (ipflow_fastforward(m))
504 return;
505 schednetisr(NETISR_IP);
506 inq = &ipintrq;
507 break;
508
509 case ETHERTYPE_ARP:
510#if !defined(__bsdi__) || _BSDI_VERSION >= 199401
511 schednetisr(NETISR_ARP);
512 inq = &arpintrq;
513 break;
514#else
515 arpinput((struct arpcom *)ifp, m);
516 return;
517#endif
518#endif
519#ifdef IPX
520 case ETHERTYPE_IPX:
521 schednetisr(NETISR_IPX);
522 inq = &ipxintrq;
523 break;
524#endif
525#ifdef NS
526 case ETHERTYPE_NS:
527 schednetisr(NETISR_NS);
528 inq = &nsintrq;
529 break;
530#endif
531#ifdef DECNET
532 case ETHERTYPE_DECNET:
533 schednetisr(NETISR_DECNET);
534 inq = &decnetintrq;
535 break;
536#endif
537#ifdef NETATALK
538 case ETHERTYPE_AT:
539 schednetisr(NETISR_ATALK);
540 inq = &atintrq1;
541 break;
542 case ETHERTYPE_AARP:
543 /* probably this should be done with a NETISR as well */
544 aarpinput((struct arpcom *)ifp, m); /* XXX */
545 return;
546#endif /* NETATALK */
547 default:
548 /* printf("fddi_input: unknown protocol 0x%x\n", type); */
549 ifp->if_noproto++;
550 goto dropanyway;
551 }
552 break;
553 }
554#endif /* INET || NS */
555#ifdef ISO
556 case LLC_ISO_LSAP:
557 switch (l->llc_control) {
558 case LLC_UI:
559 /* LLC_UI_P forbidden in class 1 service */
560 if ((l->llc_dsap == LLC_ISO_LSAP) &&
561 (l->llc_ssap == LLC_ISO_LSAP)) {
562 /* LSAP for ISO */
563 m->m_data += 3; /* XXX */
564 m->m_len -= 3; /* XXX */
565 m->m_pkthdr.len -= 3; /* XXX */
566 M_PREPEND(m, sizeof *fh, M_DONTWAIT);
567 if (m == 0)
568 return;
569 *mtod(m, struct fddi_header *) = *fh;
570 IFDEBUG(D_ETHER)
571 printf("clnp packet");
572 ENDDEBUG
573 schednetisr(NETISR_ISO);
574 inq = &clnlintrq;
575 break;
576 }
577 goto dropanyway;
578
579 case LLC_XID:
580 case LLC_XID_P:
581 if(m->m_len < 6)
582 goto dropanyway;
583 l->llc_window = 0;
584 l->llc_fid = 9;
585 l->llc_class = 1;
586 l->llc_dsap = l->llc_ssap = 0;
587 /* Fall through to */
588 case LLC_TEST:
589 case LLC_TEST_P:
590 {
591 struct sockaddr sa;
592 register struct ether_header *eh;
593 struct arpcom *ac = (struct arpcom *) ifp;
594 int i;
595 u_char c = l->llc_dsap;
596
597 l->llc_dsap = l->llc_ssap;
598 l->llc_ssap = c;
599 if (m->m_flags & (M_BCAST | M_MCAST))
600 bcopy((caddr_t)ac->ac_enaddr,
601 (caddr_t)eh->ether_dhost, 6);
602 sa.sa_family = AF_UNSPEC;
603 sa.sa_len = sizeof(sa);
604 eh = (struct ether_header *)sa.sa_data;
605 for (i = 0; i < 6; i++) {
606 eh->ether_shost[i] = fh->fddi_dhost[i];
607 eh->ether_dhost[i] = fh->fddi_shost[i];
608 }
609 eh->ether_type = 0;
610 ifp->if_output(ifp, m, &sa, NULL);
611 return;
612 }
613 default:
614 m_freem(m);
615 return;
616 }
617 break;
618#endif /* ISO */
619#ifdef LLC
620 case LLC_X25_LSAP:
621 {
622 M_PREPEND(m, sizeof(struct sdl_hdr) , M_DONTWAIT);
623 if (m == 0)
624 return;
625 if ( !sdl_sethdrif(ifp, fh->fddi_shost, LLC_X25_LSAP,
626 fh->fddi_dhost, LLC_X25_LSAP, 6,
627 mtod(m, struct sdl_hdr *)))
628 panic("ETHER cons addr failure");
629 mtod(m, struct sdl_hdr *)->sdlhdr_len = m->m_pkthdr.len - sizeof(struct sdl_hdr);
630#ifdef LLC_DEBUG
631 printf("llc packet\n");
632#endif /* LLC_DEBUG */
633 schednetisr(NETISR_CCITT);
634 inq = &llcintrq;
635 break;
636 }
637#endif /* LLC */
638
639 default:
640 /* printf("fddi_input: unknown dsap 0x%x\n", l->llc_dsap); */
641 ifp->if_noproto++;
642 dropanyway:
643 m_freem(m);
644 return;
645 }
646
647 s = splimp();
648 if (IF_QFULL(inq)) {
649 IF_DROP(inq);
650 m_freem(m);
651 } else
652 IF_ENQUEUE(inq, m);
653 splx(s);
654}
655/*
656 * Perform common duties while attaching to interface list
657 */
658#ifdef __NetBSD__
659#define ifa_next ifa_list.tqe_next
660#endif
661
662void
663fddi_ifattach(ifp)
664 register struct ifnet *ifp;
665{
666 register struct ifaddr *ifa;
667 register struct sockaddr_dl *sdl;
668
669 ifp->if_type = IFT_FDDI;
670 ifp->if_addrlen = 6;
671 ifp->if_hdrlen = 21;
672 ifp->if_mtu = FDDIMTU;
673 ifp->if_baudrate = 100000000;
674#ifdef IFF_NOTRAILERS
675 ifp->if_flags |= IFF_NOTRAILERS;
676#endif
677#if defined(__FreeBSD__)
678 ifa = ifnet_addrs[ifp->if_index - 1];
679 sdl = (struct sockaddr_dl *)ifa->ifa_addr;
680 sdl->sdl_type = IFT_FDDI;
681 sdl->sdl_alen = ifp->if_addrlen;
682 bcopy(((struct arpcom *)ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
683#elif defined(__NetBSD__)
684 LIST_INIT(&((struct arpcom *)ifp)->ac_multiaddrs);
685 for (ifa = ifp->if_addrlist.tqh_first; ifa != NULL; ifa = ifa->ifa_list.tqe_next)
686#else
687 for (ifa = ifp->if_addrlist; ifa != NULL; ifa = ifa->ifa_next)
688#endif
689#if !defined(__FreeBSD__)
690 if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&
691 sdl->sdl_family == AF_LINK) {
692 sdl->sdl_type = IFT_FDDI;
693 sdl->sdl_alen = ifp->if_addrlen;
694 bcopy((caddr_t)((struct arpcom *)ifp)->ac_enaddr,
695 LLADDR(sdl), ifp->if_addrlen);
696 break;
697 }
698#endif
699}