Deleted Added
sdiff udiff text old ( 109771 ) new ( 110106 )
full compact
1/* $NetBSD: if_arcsubr.c,v 1.36 2001/06/14 05:44:23 itojun Exp $ */
2/* $FreeBSD: head/sys/net/if_arcsubr.c 110106 2003-01-30 15:55:02Z fjoe $ */
3
4/*
5 * Copyright (c) 1994, 1995 Ignatios Souvatzis
6 * Copyright (c) 1982, 1989, 1993
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions

--- 73 unchanged lines hidden (view full) ---

84#define ARCNET_ALLOW_BROKEN_ARP
85
86static struct mbuf *arc_defrag(struct ifnet *, struct mbuf *);
87static int arc_resolvemulti(struct ifnet *, struct sockaddr **,
88 struct sockaddr *);
89
90u_int8_t arcbroadcastaddr = 0;
91
92#define ARC_LLADDR(ifp) (*(u_int8_t *)IF_LLADDR(ifp))
93
94#define senderr(e) { error = (e); goto bad;}
95#define SIN(s) ((struct sockaddr_in *)s)
96#define SIPX(s) ((struct sockaddr_ipx *)s)
97
98/*
99 * ARCnet output routine.
100 * Encapsulate a packet of type family for the local net.
101 * Assumes that ifp is actually pointer to arccom structure.

--- 6 unchanged lines hidden (view full) ---

108 struct rtentry *rt0;
109{
110 struct rtentry *rt;
111 struct arccom *ac;
112 struct arc_header *ah;
113 int error;
114 u_int8_t atype, adst;
115 int loop_copy = 0;
116 int isphds;
117
118 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
119 return(ENETDOWN); /* m, m1 aren't initialized yet */
120
121 error = 0;
122 ac = (struct arccom *)ifp;
123
124 if ((rt = rt0)) {

--- 81 unchanged lines hidden (view full) ---

206 }
207 break;
208
209 default:
210 if_printf(ifp, "can't handle af%d\n", dst->sa_family);
211 senderr(EAFNOSUPPORT);
212 }
213
214 isphds = arc_isphds(atype);
215 M_PREPEND(m, isphds ? ARC_HDRNEWLEN : ARC_HDRLEN, M_NOWAIT);
216 if (m == 0)
217 senderr(ENOBUFS);
218 ah = mtod(m, struct arc_header *);
219 ah->arc_type = atype;
220 ah->arc_dhost = adst;
221 ah->arc_shost = ARC_LLADDR(ifp);
222 if (isphds) {
223 ah->arc_flag = 0;
224 ah->arc_seqid = 0;
225 }
226
227 if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) {
228 if ((m->m_flags & M_BCAST) || (loop_copy > 0)) {
229 struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
230
231 (void) if_simloop(ifp, n, dst->sa_family, ARC_HDRLEN);
232 } else if (ah->arc_dhost == ah->arc_shost) {
233 (void) if_simloop(ifp, m, dst->sa_family, ARC_HDRLEN);

--- 51 unchanged lines hidden (view full) ---

285 tfrags = (m->m_pkthdr.len + ARC_MAX_DATA - 1) / ARC_MAX_DATA;
286 ac->fsflag = 2 * tfrags - 3;
287 ac->sflag = 0;
288 ac->rsflag = ac->fsflag;
289 ac->arc_dhost = ah->arc_dhost;
290 ac->arc_shost = ah->arc_shost;
291 ac->arc_type = ah->arc_type;
292
293 m_adj(m, ARC_HDRNEWLEN);
294 ac->curr_frag = m;
295 }
296
297 /* split out next fragment and return it */
298 if (ac->sflag < ac->fsflag) {
299 /* we CAN'T have short packets here */
300 ac->curr_frag = m_split(m, ARC_MAX_DATA, M_NOWAIT);
301 if (ac->curr_frag == 0) {

--- 236 unchanged lines hidden (view full) ---

538 m = arc_defrag(ifp, m);
539 if (m == NULL)
540 return;
541
542 BPF_MTAP(ifp, m);
543
544 ah = mtod(m, struct arc_header *);
545 /* does this belong to us? */
546 if ((ifp->if_flags & IFF_PROMISC) == 0
547 && ah->arc_dhost != arcbroadcastaddr
548 && ah->arc_dhost != ARC_LLADDR(ifp)) {
549 m_freem(m);
550 return;
551 }
552
553 ifp->if_ibytes += m->m_pkthdr.len;
554
555 if (ah->arc_dhost == arcbroadcastaddr) {
556 m->m_flags |= M_BCAST|M_MCAST;

--- 72 unchanged lines hidden (view full) ---

629/*
630 * Register (new) link level address.
631 */
632void
633arc_storelladdr(ifp, lla)
634 struct ifnet *ifp;
635 u_int8_t lla;
636{
637 ARC_LLADDR(ifp) = lla;
638}
639
640/*
641 * Perform common duties while attaching to interface list
642 */
643void
644arc_ifattach(ifp, lla)
645 struct ifnet *ifp;

--- 70 unchanged lines hidden (view full) ---

716 /*
717 * XXX This code is probably wrong
718 */
719 case AF_IPX:
720 {
721 struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr);
722
723 if (ipx_nullhost(*ina))
724 ina->x_host.c_host[5] = ARC_LLADDR(ifp);
725 else
726 arc_storelladdr(ifp, ina->x_host.c_host[5]);
727
728 /*
729 * Set new address
730 */
731 ifp->if_init(ifp->if_softc);
732 break;

--- 5 unchanged lines hidden (view full) ---

738 }
739 break;
740
741 case SIOCGIFADDR:
742 {
743 struct sockaddr *sa;
744
745 sa = (struct sockaddr *) &ifr->ifr_data;
746 *(u_int8_t *)sa->sa_data = ARC_LLADDR(ifp);
747 }
748 break;
749
750 case SIOCADDMULTI:
751 case SIOCDELMULTI:
752 if (ifr == NULL)
753 error = EAFNOSUPPORT;
754 else {

--- 103 unchanged lines hidden ---