if_arcsubr.c (109771) | if_arcsubr.c (110106) |
---|---|
1/* $NetBSD: if_arcsubr.c,v 1.36 2001/06/14 05:44:23 itojun Exp $ */ | 1/* $NetBSD: if_arcsubr.c,v 1.36 2001/06/14 05:44:23 itojun Exp $ */ |
2/* $FreeBSD: head/sys/net/if_arcsubr.c 109771 2003-01-24 01:32:20Z fjoe $ */ | 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 | 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 |
|
92#define senderr(e) { error = (e); goto bad;} 93#define SIN(s) ((struct sockaddr_in *)s) 94#define SIPX(s) ((struct sockaddr_ipx *)s) 95 96/* 97 * ARCnet output routine. 98 * Encapsulate a packet of type family for the local net. 99 * Assumes that ifp is actually pointer to arccom structure. --- 6 unchanged lines hidden (view full) --- 106 struct rtentry *rt0; 107{ 108 struct rtentry *rt; 109 struct arccom *ac; 110 struct arc_header *ah; 111 int error; 112 u_int8_t atype, adst; 113 int loop_copy = 0; | 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; |
|
114 115 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 116 return(ENETDOWN); /* m, m1 aren't initialized yet */ 117 118 error = 0; 119 ac = (struct arccom *)ifp; 120 121 if ((rt = rt0)) { --- 81 unchanged lines hidden (view full) --- 203 } 204 break; 205 206 default: 207 if_printf(ifp, "can't handle af%d\n", dst->sa_family); 208 senderr(EAFNOSUPPORT); 209 } 210 | 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 |
211 M_PREPEND(m, ARC_HDRLEN, M_NOWAIT); | 214 isphds = arc_isphds(atype); 215 M_PREPEND(m, isphds ? ARC_HDRNEWLEN : ARC_HDRLEN, M_NOWAIT); |
212 if (m == 0) 213 senderr(ENOBUFS); 214 ah = mtod(m, struct arc_header *); 215 ah->arc_type = atype; 216 ah->arc_dhost = adst; | 216 if (m == 0) 217 senderr(ENOBUFS); 218 ah = mtod(m, struct arc_header *); 219 ah->arc_type = atype; 220 ah->arc_dhost = adst; |
217 ah->arc_shost = *IF_LLADDR(ifp); | 221 ah->arc_shost = ARC_LLADDR(ifp); 222 if (isphds) { 223 ah->arc_flag = 0; 224 ah->arc_seqid = 0; 225 } |
218 219 if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) { 220 if ((m->m_flags & M_BCAST) || (loop_copy > 0)) { 221 struct mbuf *n = m_copy(m, 0, (int)M_COPYALL); 222 223 (void) if_simloop(ifp, n, dst->sa_family, ARC_HDRLEN); 224 } else if (ah->arc_dhost == ah->arc_shost) { 225 (void) if_simloop(ifp, m, dst->sa_family, ARC_HDRLEN); --- 51 unchanged lines hidden (view full) --- 277 tfrags = (m->m_pkthdr.len + ARC_MAX_DATA - 1) / ARC_MAX_DATA; 278 ac->fsflag = 2 * tfrags - 3; 279 ac->sflag = 0; 280 ac->rsflag = ac->fsflag; 281 ac->arc_dhost = ah->arc_dhost; 282 ac->arc_shost = ah->arc_shost; 283 ac->arc_type = ah->arc_type; 284 | 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 |
285 m_adj(m, ARC_HDRLEN); | 293 m_adj(m, ARC_HDRNEWLEN); |
286 ac->curr_frag = m; 287 } 288 289 /* split out next fragment and return it */ 290 if (ac->sflag < ac->fsflag) { 291 /* we CAN'T have short packets here */ 292 ac->curr_frag = m_split(m, ARC_MAX_DATA, M_NOWAIT); 293 if (ac->curr_frag == 0) { --- 236 unchanged lines hidden (view full) --- 530 m = arc_defrag(ifp, m); 531 if (m == NULL) 532 return; 533 534 BPF_MTAP(ifp, m); 535 536 ah = mtod(m, struct arc_header *); 537 /* does this belong to us? */ | 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? */ |
538 if ((ifp->if_flags & IFF_PROMISC) != 0 | 546 if ((ifp->if_flags & IFF_PROMISC) == 0 |
539 && ah->arc_dhost != arcbroadcastaddr | 547 && ah->arc_dhost != arcbroadcastaddr |
540 && ah->arc_dhost != *IF_LLADDR(ifp)) { | 548 && ah->arc_dhost != ARC_LLADDR(ifp)) { |
541 m_freem(m); 542 return; 543 } 544 545 ifp->if_ibytes += m->m_pkthdr.len; 546 547 if (ah->arc_dhost == arcbroadcastaddr) { 548 m->m_flags |= M_BCAST|M_MCAST; --- 72 unchanged lines hidden (view full) --- 621/* 622 * Register (new) link level address. 623 */ 624void 625arc_storelladdr(ifp, lla) 626 struct ifnet *ifp; 627 u_int8_t lla; 628{ | 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{ |
629 *IF_LLADDR(ifp) = lla; | 637 ARC_LLADDR(ifp) = lla; |
630} 631 632/* 633 * Perform common duties while attaching to interface list 634 */ 635void 636arc_ifattach(ifp, lla) 637 struct ifnet *ifp; --- 70 unchanged lines hidden (view full) --- 708 /* 709 * XXX This code is probably wrong 710 */ 711 case AF_IPX: 712 { 713 struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr); 714 715 if (ipx_nullhost(*ina)) | 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)) |
716 ina->x_host.c_host[5] = *IF_LLADDR(ifp); | 724 ina->x_host.c_host[5] = ARC_LLADDR(ifp); |
717 else 718 arc_storelladdr(ifp, ina->x_host.c_host[5]); 719 720 /* 721 * Set new address 722 */ 723 ifp->if_init(ifp->if_softc); 724 break; --- 5 unchanged lines hidden (view full) --- 730 } 731 break; 732 733 case SIOCGIFADDR: 734 { 735 struct sockaddr *sa; 736 737 sa = (struct sockaddr *) &ifr->ifr_data; | 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; |
738 bcopy(IF_LLADDR(ifp), 739 (caddr_t) sa->sa_data, ARC_ADDR_LEN); | 746 *(u_int8_t *)sa->sa_data = ARC_LLADDR(ifp); |
740 } 741 break; 742 743 case SIOCADDMULTI: 744 case SIOCDELMULTI: 745 if (ifr == NULL) 746 error = EAFNOSUPPORT; 747 else { --- 103 unchanged lines hidden --- | 747 } 748 break; 749 750 case SIOCADDMULTI: 751 case SIOCDELMULTI: 752 if (ifr == NULL) 753 error = EAFNOSUPPORT; 754 else { --- 103 unchanged lines hidden --- |