ipx_input.c (111119) | ipx_input.c (111888) |
---|---|
1/* 2 * Copyright (c) 1995, Mike Mitchell 3 * Copyright (c) 1984, 1985, 1986, 1987, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 19 unchanged lines hidden (view full) --- 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)ipx_input.c 35 * | 1/* 2 * Copyright (c) 1995, Mike Mitchell 3 * Copyright (c) 1984, 1985, 1986, 1987, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 19 unchanged lines hidden (view full) --- 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)ipx_input.c 35 * |
36 * $FreeBSD: head/sys/netipx/ipx_input.c 111119 2003-02-19 05:47:46Z imp $ | 36 * $FreeBSD: head/sys/netipx/ipx_input.c 111888 2003-03-04 23:19:55Z jlemon $ |
37 */ 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/mbuf.h> 42#include <sys/protosw.h> 43#include <sys/socket.h> 44#include <sys/kernel.h> 45#include <sys/random.h> 46#include <sys/sysctl.h> 47 48#include <net/if.h> 49#include <net/route.h> 50#include <net/netisr.h> | 37 */ 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/mbuf.h> 42#include <sys/protosw.h> 43#include <sys/socket.h> 44#include <sys/kernel.h> 45#include <sys/random.h> 46#include <sys/sysctl.h> 47 48#include <net/if.h> 49#include <net/route.h> 50#include <net/netisr.h> |
51#include <net/intrq.h> | |
52 53#include <netipx/ipx.h> 54#include <netipx/spx.h> 55#include <netipx/ipx_if.h> 56#include <netipx/ipx_pcb.h> 57#include <netipx/ipx_var.h> 58 59int ipxcksum = 0; --- 22 unchanged lines hidden (view full) --- 82struct sockaddr_ipx ipx_netmask, ipx_hostmask; 83 84static u_short allones[] = {-1, -1, -1}; 85 86struct ipxpcb ipxpcb; 87struct ipxpcb ipxrawpcb; 88 89static int ipxqmaxlen = IFQ_MAXLEN; | 51 52#include <netipx/ipx.h> 53#include <netipx/spx.h> 54#include <netipx/ipx_if.h> 55#include <netipx/ipx_pcb.h> 56#include <netipx/ipx_var.h> 57 58int ipxcksum = 0; --- 22 unchanged lines hidden (view full) --- 81struct sockaddr_ipx ipx_netmask, ipx_hostmask; 82 83static u_short allones[] = {-1, -1, -1}; 84 85struct ipxpcb ipxpcb; 86struct ipxpcb ipxrawpcb; 87 88static int ipxqmaxlen = IFQ_MAXLEN; |
89static struct ifqueue ipxintrq; |
|
90 91long ipx_pexseq; 92 93static int ipx_do_route(struct ipx_addr *src, struct route *ro); 94static void ipx_undo_route(struct route *ro); 95static void ipx_forward(struct mbuf *m); | 90 91long ipx_pexseq; 92 93static int ipx_do_route(struct ipx_addr *src, struct route *ro); 94static void ipx_undo_route(struct route *ro); 95static void ipx_forward(struct mbuf *m); |
96static void ipxintr(struct mbuf *m); |
|
96 97/* 98 * IPX initialization. 99 */ 100 101void 102ipx_init() 103{ 104 ipx_broadnet = *(union ipx_net *)allones; 105 ipx_broadhost = *(union ipx_host *)allones; 106 107 read_random(&ipx_pexseq, sizeof ipx_pexseq); | 97 98/* 99 * IPX initialization. 100 */ 101 102void 103ipx_init() 104{ 105 ipx_broadnet = *(union ipx_net *)allones; 106 ipx_broadhost = *(union ipx_host *)allones; 107 108 read_random(&ipx_pexseq, sizeof ipx_pexseq); |
108 ipxintrq.ifq_maxlen = ipxqmaxlen; 109 mtx_init(&ipxintrq.ifq_mtx, "ipx_inq", NULL, MTX_DEF); 110 ipxintrq_present = 1; | |
111 ipxpcb.ipxp_next = ipxpcb.ipxp_prev = &ipxpcb; 112 ipxrawpcb.ipxp_next = ipxrawpcb.ipxp_prev = &ipxrawpcb; 113 114 ipx_netmask.sipx_len = 6; 115 ipx_netmask.sipx_addr.x_net = ipx_broadnet; 116 117 ipx_hostmask.sipx_len = 12; 118 ipx_hostmask.sipx_addr.x_net = ipx_broadnet; 119 ipx_hostmask.sipx_addr.x_host = ipx_broadhost; 120 | 109 ipxpcb.ipxp_next = ipxpcb.ipxp_prev = &ipxpcb; 110 ipxrawpcb.ipxp_next = ipxrawpcb.ipxp_prev = &ipxrawpcb; 111 112 ipx_netmask.sipx_len = 6; 113 ipx_netmask.sipx_addr.x_net = ipx_broadnet; 114 115 ipx_hostmask.sipx_len = 12; 116 ipx_hostmask.sipx_addr.x_net = ipx_broadnet; 117 ipx_hostmask.sipx_addr.x_host = ipx_broadhost; 118 |
121 register_netisr(NETISR_IPX, ipxintr); | 119 ipxintrq.ifq_maxlen = ipxqmaxlen; 120 mtx_init(&ipxintrq.ifq_mtx, "ipx_inq", NULL, MTX_DEF); 121 netisr_register(NETISR_IPX, ipxintr, &ipxintrq); |
122} 123 124/* 125 * IPX input routine. Pass to next level. 126 */ | 122} 123 124/* 125 * IPX input routine. Pass to next level. 126 */ |
127void 128ipxintr() | 127static void 128ipxintr(struct mbuf *m) |
129{ 130 register struct ipx *ipx; | 129{ 130 register struct ipx *ipx; |
131 register struct mbuf *m; | |
132 register struct ipxpcb *ipxp; 133 struct ipx_ifaddr *ia; | 131 register struct ipxpcb *ipxp; 132 struct ipx_ifaddr *ia; |
134 int len, s; | 133 int len; |
135 | 134 |
136next: | |
137 /* | 135 /* |
138 * Get next datagram off input queue and get IPX header 139 * in first mbuf. 140 */ 141 s = splimp(); 142 IF_DEQUEUE(&ipxintrq, m); 143 splx(s); 144 if (m == NULL) 145 return; 146 /* | |
147 * If no IPX addresses have been set yet but the interfaces 148 * are receiving, can't do anything with incoming packets yet. 149 */ 150 if (ipx_ifaddr == NULL) 151 goto bad; 152 153 ipxstat.ipxs_total++; 154 155 if ((m->m_flags & M_EXT || m->m_len < sizeof(struct ipx)) && 156 (m = m_pullup(m, sizeof(struct ipx))) == 0) { 157 ipxstat.ipxs_toosmall++; | 136 * If no IPX addresses have been set yet but the interfaces 137 * are receiving, can't do anything with incoming packets yet. 138 */ 139 if (ipx_ifaddr == NULL) 140 goto bad; 141 142 ipxstat.ipxs_total++; 143 144 if ((m->m_flags & M_EXT || m->m_len < sizeof(struct ipx)) && 145 (m = m_pullup(m, sizeof(struct ipx))) == 0) { 146 ipxstat.ipxs_toosmall++; |
158 goto next; | 147 return; |
159 } 160 161 /* 162 * Give any raw listeners a crack at the packet 163 */ 164 for (ipxp = ipxrawpcb.ipxp_next; ipxp != &ipxrawpcb; 165 ipxp = ipxp->ipxp_next) { 166 struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL); --- 29 unchanged lines hidden (view full) --- 196 197 /* 198 * Propagated (Netbios) packets (type 20) has to be handled 199 * different. :-( 200 */ 201 if (ipx->ipx_pt == IPXPROTO_NETBIOS) { 202 if (ipxnetbios) { 203 ipx_output_type20(m); | 148 } 149 150 /* 151 * Give any raw listeners a crack at the packet 152 */ 153 for (ipxp = ipxrawpcb.ipxp_next; ipxp != &ipxrawpcb; 154 ipxp = ipxp->ipxp_next) { 155 struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL); --- 29 unchanged lines hidden (view full) --- 185 186 /* 187 * Propagated (Netbios) packets (type 20) has to be handled 188 * different. :-( 189 */ 190 if (ipx->ipx_pt == IPXPROTO_NETBIOS) { 191 if (ipxnetbios) { 192 ipx_output_type20(m); |
204 goto next; | 193 return; |
205 } else 206 goto bad; 207 } 208 209 /* 210 * Is this a directed broadcast? 211 */ 212 if (ipx_hosteqnh(ipx_broadhost,ipx->ipx_dna.x_host)) { --- 18 unchanged lines hidden (view full) --- 231 * by physically broadcasted. 232 * Any very old packets eaten without forwarding 233 * would die anyway. 234 * 235 * Suggestion of Bill Nesheim, Cornell U. 236 */ 237 if (ipx->ipx_tc < IPX_MAXHOPS) { 238 ipx_forward(m); | 194 } else 195 goto bad; 196 } 197 198 /* 199 * Is this a directed broadcast? 200 */ 201 if (ipx_hosteqnh(ipx_broadhost,ipx->ipx_dna.x_host)) { --- 18 unchanged lines hidden (view full) --- 220 * by physically broadcasted. 221 * Any very old packets eaten without forwarding 222 * would die anyway. 223 * 224 * Suggestion of Bill Nesheim, Cornell U. 225 */ 226 if (ipx->ipx_tc < IPX_MAXHOPS) { 227 ipx_forward(m); |
239 goto next; | 228 return; |
240 } 241 } 242 /* 243 * Is this our packet? If not, forward. 244 */ 245 } else { 246 for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) 247 if (ipx_hosteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) && 248 (ipx_neteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) || 249 ipx_neteqnn(ipx->ipx_dna.x_net, ipx_zeronet))) 250 break; 251 252 if (ia == NULL) { 253 ipx_forward(m); | 229 } 230 } 231 /* 232 * Is this our packet? If not, forward. 233 */ 234 } else { 235 for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) 236 if (ipx_hosteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) && 237 (ipx_neteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) || 238 ipx_neteqnn(ipx->ipx_dna.x_net, ipx_zeronet))) 239 break; 240 241 if (ia == NULL) { 242 ipx_forward(m); |
254 goto next; | 243 return; |
255 } 256 } 257ours: 258 /* 259 * Locate pcb for datagram. 260 */ 261 ipxp = ipx_pcblookup(&ipx->ipx_sna, ipx->ipx_dna.x_port, IPX_WILDCARD); 262 /* 263 * Switch out to protocol's input routine. 264 */ 265 if (ipxp != NULL) { 266 ipxstat.ipxs_delivered++; 267 if ((ipxp->ipxp_flags & IPXP_ALL_PACKETS) == 0) 268 switch (ipx->ipx_pt) { | 244 } 245 } 246ours: 247 /* 248 * Locate pcb for datagram. 249 */ 250 ipxp = ipx_pcblookup(&ipx->ipx_sna, ipx->ipx_dna.x_port, IPX_WILDCARD); 251 /* 252 * Switch out to protocol's input routine. 253 */ 254 if (ipxp != NULL) { 255 ipxstat.ipxs_delivered++; 256 if ((ipxp->ipxp_flags & IPXP_ALL_PACKETS) == 0) 257 switch (ipx->ipx_pt) { |
269 270 case IPXPROTO_SPX: 271 spx_input(m, ipxp); 272 goto next; | 258 case IPXPROTO_SPX: 259 spx_input(m, ipxp); 260 return; |
273 } 274 ipx_input(m, ipxp); 275 } else 276 goto bad; 277 | 261 } 262 ipx_input(m, ipxp); 263 } else 264 goto bad; 265 |
278 goto next; | 266 return; |
279 280bad: 281 m_freem(m); | 267 268bad: 269 m_freem(m); |
282 goto next; | |
283} 284 285void 286ipx_ctlinput(cmd, arg_as_sa, dummy) 287 int cmd; 288 struct sockaddr *arg_as_sa; /* XXX should be swapped with dummy */ 289 void *dummy; 290{ --- 221 unchanged lines hidden --- | 270} 271 272void 273ipx_ctlinput(cmd, arg_as_sa, dummy) 274 int cmd; 275 struct sockaddr *arg_as_sa; /* XXX should be swapped with dummy */ 276 void *dummy; 277{ --- 221 unchanged lines hidden --- |