if_iso88025subr.c (139823) | if_iso88025subr.c (147256) |
---|---|
1/*- 2 * Copyright (c) 1998, Larry Lile 3 * All rights reserved. 4 * 5 * For latest sources and information on this driver, please 6 * go to http://anarchy.stdio.com. 7 * 8 * Questions, comments or suggestions should be directed to --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * | 1/*- 2 * Copyright (c) 1998, Larry Lile 3 * All rights reserved. 4 * 5 * For latest sources and information on this driver, please 6 * go to http://anarchy.stdio.com. 7 * 8 * Questions, comments or suggestions should be directed to --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * |
33 * $FreeBSD: head/sys/net/if_iso88025subr.c 139823 2005-01-07 01:45:51Z imp $ | 33 * $FreeBSD: head/sys/net/if_iso88025subr.c 147256 2005-06-10 16:49:24Z brooks $ |
34 * 35 */ 36 37/* 38 * 39 * General ISO 802.5 (Token Ring) support routines 40 * 41 */ --- 76 unchanged lines hidden (view full) --- 118 if (ifa == 0) { 119 if_printf(ifp, "%s() no lladdr!\n", __func__); 120 return; 121 } 122 123 sdl = (struct sockaddr_dl *)ifa->ifa_addr; 124 sdl->sdl_type = IFT_ISO88025; 125 sdl->sdl_alen = ifp->if_addrlen; | 34 * 35 */ 36 37/* 38 * 39 * General ISO 802.5 (Token Ring) support routines 40 * 41 */ --- 76 unchanged lines hidden (view full) --- 118 if (ifa == 0) { 119 if_printf(ifp, "%s() no lladdr!\n", __func__); 120 return; 121 } 122 123 sdl = (struct sockaddr_dl *)ifa->ifa_addr; 124 sdl->sdl_type = IFT_ISO88025; 125 sdl->sdl_alen = ifp->if_addrlen; |
126 bcopy(IFP2AC(ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen); | 126 bcopy(IFP2ENADDR(ifp), LLADDR(sdl), ifp->if_addrlen); |
127 128 if (bpf) 129 bpfattach(ifp, DLT_IEEE802, ISO88025_HDR_LEN); 130 131 return; 132} 133 134/* --- 36 unchanged lines hidden (view full) --- 171 break; 172#endif /* INET */ 173#ifdef IPX 174 /* 175 * XXX - This code is probably wrong 176 */ 177 case AF_IPX: { 178 struct ipx_addr *ina; | 127 128 if (bpf) 129 bpfattach(ifp, DLT_IEEE802, ISO88025_HDR_LEN); 130 131 return; 132} 133 134/* --- 36 unchanged lines hidden (view full) --- 171 break; 172#endif /* INET */ 173#ifdef IPX 174 /* 175 * XXX - This code is probably wrong 176 */ 177 case AF_IPX: { 178 struct ipx_addr *ina; |
179 struct arpcom *ac; | |
180 181 ina = &(IA_SIPX(ifa)->sipx_addr); | 179 180 ina = &(IA_SIPX(ifa)->sipx_addr); |
182 ac = IFP2AC(ifp); | |
183 184 if (ipx_nullhost(*ina)) 185 ina->x_host = *(union ipx_host *) | 181 182 if (ipx_nullhost(*ina)) 183 ina->x_host = *(union ipx_host *) |
186 ac->ac_enaddr; | 184 IFP2ENADDR(ifp); |
187 else 188 bcopy((caddr_t) ina->x_host.c_host, | 185 else 186 bcopy((caddr_t) ina->x_host.c_host, |
189 (caddr_t) ac->ac_enaddr, | 187 (caddr_t) IFP2ENADDR(ifp), |
190 ISO88025_ADDR_LEN); 191 192 /* 193 * Set new address 194 */ 195 ifp->if_init(ifp->if_softc); 196 } 197 break; 198#endif /* IPX */ 199 default: 200 ifp->if_init(ifp->if_softc); 201 break; 202 } 203 break; 204 205 case SIOCGIFADDR: { 206 struct sockaddr *sa; 207 208 sa = (struct sockaddr *) & ifr->ifr_data; | 188 ISO88025_ADDR_LEN); 189 190 /* 191 * Set new address 192 */ 193 ifp->if_init(ifp->if_softc); 194 } 195 break; 196#endif /* IPX */ 197 default: 198 ifp->if_init(ifp->if_softc); 199 break; 200 } 201 break; 202 203 case SIOCGIFADDR: { 204 struct sockaddr *sa; 205 206 sa = (struct sockaddr *) & ifr->ifr_data; |
209 bcopy(IFP2AC(ifp)->ac_enaddr, | 207 bcopy(IFP2ENADDR(ifp), |
210 (caddr_t) sa->sa_data, ISO88025_ADDR_LEN); 211 } 212 break; 213 214 case SIOCSIFMTU: 215 /* 216 * Set the interface MTU. 217 */ --- 49 unchanged lines hidden (view full) --- 267 268 if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway)) 269 if (SDL_ISO88025(sdl)->trld_rcf != 0) 270 rif_len = TR_RCF_RIFLEN(SDL_ISO88025(sdl)->trld_rcf); 271 272 /* Generate a generic 802.5 header for the packet */ 273 gen_th.ac = TR_AC; 274 gen_th.fc = TR_LLC_FRAME; | 208 (caddr_t) sa->sa_data, ISO88025_ADDR_LEN); 209 } 210 break; 211 212 case SIOCSIFMTU: 213 /* 214 * Set the interface MTU. 215 */ --- 49 unchanged lines hidden (view full) --- 265 266 if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway)) 267 if (SDL_ISO88025(sdl)->trld_rcf != 0) 268 rif_len = TR_RCF_RIFLEN(SDL_ISO88025(sdl)->trld_rcf); 269 270 /* Generate a generic 802.5 header for the packet */ 271 gen_th.ac = TR_AC; 272 gen_th.fc = TR_LLC_FRAME; |
275 (void)memcpy((caddr_t)gen_th.iso88025_shost, IFP2AC(ifp)->ac_enaddr, | 273 (void)memcpy((caddr_t)gen_th.iso88025_shost, IFP2ENADDR(ifp), |
276 ISO88025_ADDR_LEN); 277 if (rif_len) { 278 gen_th.iso88025_shost[0] |= TR_RII; 279 if (rif_len > 2) { 280 gen_th.rcf = SDL_ISO88025(sdl)->trld_rcf; 281 (void)memcpy((caddr_t)gen_th.rd, 282 (caddr_t)SDL_ISO88025(sdl)->trld_route, 283 rif_len - 2); --- 228 unchanged lines hidden (view full) --- 512 getmicrotime(&ifp->if_lastchange); 513 514 /* 515 * Discard non local unicast packets when interface 516 * is in promiscuous mode. 517 */ 518 if ((ifp->if_flags & IFF_PROMISC) && 519 ((th->iso88025_dhost[0] & 1) == 0) && | 274 ISO88025_ADDR_LEN); 275 if (rif_len) { 276 gen_th.iso88025_shost[0] |= TR_RII; 277 if (rif_len > 2) { 278 gen_th.rcf = SDL_ISO88025(sdl)->trld_rcf; 279 (void)memcpy((caddr_t)gen_th.rd, 280 (caddr_t)SDL_ISO88025(sdl)->trld_route, 281 rif_len - 2); --- 228 unchanged lines hidden (view full) --- 510 getmicrotime(&ifp->if_lastchange); 511 512 /* 513 * Discard non local unicast packets when interface 514 * is in promiscuous mode. 515 */ 516 if ((ifp->if_flags & IFF_PROMISC) && 517 ((th->iso88025_dhost[0] & 1) == 0) && |
520 (bcmp(IFP2AC(ifp)->ac_enaddr, (caddr_t) th->iso88025_dhost, | 518 (bcmp(IFP2ENADDR(ifp), (caddr_t) th->iso88025_dhost, |
521 ISO88025_ADDR_LEN) != 0)) 522 goto dropanyway; 523 524 /* 525 * Set mbuf flags for bcast/mcast. 526 */ 527 if (th->iso88025_dhost[0] & 1) { 528 if (bcmp(iso88025_broadcastaddr, th->iso88025_dhost, --- 104 unchanged lines hidden (view full) --- 633 case LLC_TEST_P: 634 { 635 struct sockaddr sa; 636 struct arpcom *ac; 637 struct iso88025_sockaddr_data *th2; 638 int i; 639 u_char c; 640 | 519 ISO88025_ADDR_LEN) != 0)) 520 goto dropanyway; 521 522 /* 523 * Set mbuf flags for bcast/mcast. 524 */ 525 if (th->iso88025_dhost[0] & 1) { 526 if (bcmp(iso88025_broadcastaddr, th->iso88025_dhost, --- 104 unchanged lines hidden (view full) --- 631 case LLC_TEST_P: 632 { 633 struct sockaddr sa; 634 struct arpcom *ac; 635 struct iso88025_sockaddr_data *th2; 636 int i; 637 u_char c; 638 |
641 ac = IFP2AC(ifp); | |
642 c = l->llc_dsap; 643 644 if (th->iso88025_shost[0] & TR_RII) { /* XXX */ 645 printf("iso88025_input: dropping source routed LLC_TEST\n"); 646 goto dropanyway; 647 } 648 l->llc_dsap = l->llc_ssap; 649 l->llc_ssap = c; 650 if (m->m_flags & (M_BCAST | M_MCAST)) | 639 c = l->llc_dsap; 640 641 if (th->iso88025_shost[0] & TR_RII) { /* XXX */ 642 printf("iso88025_input: dropping source routed LLC_TEST\n"); 643 goto dropanyway; 644 } 645 l->llc_dsap = l->llc_ssap; 646 l->llc_ssap = c; 647 if (m->m_flags & (M_BCAST | M_MCAST)) |
651 bcopy((caddr_t)ac->ac_enaddr, | 648 bcopy((caddr_t)IFP2ENADDR(ifp), |
652 (caddr_t)th->iso88025_dhost, 653 ISO88025_ADDR_LEN); 654 sa.sa_family = AF_UNSPEC; 655 sa.sa_len = sizeof(sa); 656 th2 = (struct iso88025_sockaddr_data *)sa.sa_data; 657 for (i = 0; i < ISO88025_ADDR_LEN; i++) { 658 th2->ether_shost[i] = c = th->iso88025_dhost[i]; 659 th2->ether_dhost[i] = th->iso88025_dhost[i] = --- 109 unchanged lines hidden (view full) --- 769 * that counts... 770 */ 771 return (EAFNOSUPPORT); 772 } 773 774 return (0); 775} 776 | 649 (caddr_t)th->iso88025_dhost, 650 ISO88025_ADDR_LEN); 651 sa.sa_family = AF_UNSPEC; 652 sa.sa_len = sizeof(sa); 653 th2 = (struct iso88025_sockaddr_data *)sa.sa_data; 654 for (i = 0; i < ISO88025_ADDR_LEN; i++) { 655 th2->ether_shost[i] = c = th->iso88025_dhost[i]; 656 th2->ether_dhost[i] = th->iso88025_dhost[i] = --- 109 unchanged lines hidden (view full) --- 766 * that counts... 767 */ 768 return (EAFNOSUPPORT); 769 } 770 771 return (0); 772} 773 |
774MALLOC_DEFINE(M_ISO88025, "arpcom", "802.5 interface internals"); 775 776static void* 777iso88025_alloc(u_char type, struct ifnet *ifp) 778{ 779 struct arpcom *ac; 780 781 ac = malloc(sizeof(struct arpcom), M_ISO88025, M_WAITOK | M_ZERO); 782 ac->ac_ifp = ifp; 783 784 return (ac); 785} 786 787static void 788iso88025_free(void *com, u_char type) 789{ 790 791 free(com, M_ISO88025); 792} 793 794static int 795iso88025_modevent(module_t mod, int type, void *data) 796{ 797 798 switch (type) { 799 case MOD_LOAD: 800 if_register_com_alloc(IFT_ISO88025, iso88025_alloc, 801 iso88025_free); 802 break; 803 case MOD_UNLOAD: 804 if_deregister_com_alloc(IFT_ISO88025); 805 break; 806 default: 807 return EOPNOTSUPP; 808 } 809 810 return (0); 811} 812 |
|
777static moduledata_t iso88025_mod = { 778 "iso88025", | 813static moduledata_t iso88025_mod = { 814 "iso88025", |
779 NULL, | 815 iso88025_modevent, |
780 0 781}; 782 783DECLARE_MODULE(iso88025, iso88025_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); 784MODULE_VERSION(iso88025, 1); | 816 0 817}; 818 819DECLARE_MODULE(iso88025, iso88025_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); 820MODULE_VERSION(iso88025, 1); |