ipx_pcb.c (22975) | ipx_pcb.c (25345) |
---|---|
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_pcb.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_pcb.c 35 * |
36 * $Id$ | 36 * $Id: ipx_pcb.c,v 1.7 1997/02/22 09:41:56 peter Exp $ |
37 */ 38 39#include <sys/param.h> 40#include <sys/queue.h> 41#include <sys/systm.h> 42#include <sys/mbuf.h> | 37 */ 38 39#include <sys/param.h> 40#include <sys/queue.h> 41#include <sys/systm.h> 42#include <sys/mbuf.h> |
43#include <sys/proc.h> 44#include <sys/protosw.h> |
|
43#include <sys/errno.h> 44#include <sys/socket.h> 45#include <sys/socketvar.h> | 45#include <sys/errno.h> 46#include <sys/socket.h> 47#include <sys/socketvar.h> |
46#include <sys/protosw.h> | |
47 48#include <net/if.h> 49#include <net/route.h> 50 51#include <netipx/ipx.h> 52#include <netipx/ipx_if.h> 53#include <netipx/ipx_pcb.h> 54 55struct ipx_addr zeroipx_addr; 56 57int | 48 49#include <net/if.h> 50#include <net/route.h> 51 52#include <netipx/ipx.h> 53#include <netipx/ipx_if.h> 54#include <netipx/ipx_pcb.h> 55 56struct ipx_addr zeroipx_addr; 57 58int |
58ipx_pcballoc(so, head) | 59ipx_pcballoc(so, head, p) |
59 struct socket *so; 60 struct ipxpcb *head; | 60 struct socket *so; 61 struct ipxpcb *head; |
62 struct proc *p; |
|
61{ 62 struct mbuf *m; 63 register struct ipxpcb *ipxp; 64 65 m = m_getclr(M_DONTWAIT, MT_PCB); 66 if (m == NULL) 67 return (ENOBUFS); 68 ipxp = mtod(m, struct ipxpcb *); 69 ipxp->ipxp_socket = so; 70 insque(ipxp, head); 71 so->so_pcb = (caddr_t)ipxp; 72 return (0); 73} 74 75int | 63{ 64 struct mbuf *m; 65 register struct ipxpcb *ipxp; 66 67 m = m_getclr(M_DONTWAIT, MT_PCB); 68 if (m == NULL) 69 return (ENOBUFS); 70 ipxp = mtod(m, struct ipxpcb *); 71 ipxp->ipxp_socket = so; 72 insque(ipxp, head); 73 so->so_pcb = (caddr_t)ipxp; 74 return (0); 75} 76 77int |
76ipx_pcbbind(ipxp, nam) | 78ipx_pcbbind(ipxp, nam, p) |
77 register struct ipxpcb *ipxp; 78 struct mbuf *nam; | 79 register struct ipxpcb *ipxp; 80 struct mbuf *nam; |
81 struct proc *p; |
|
79{ 80 register struct sockaddr_ipx *sipx; 81 u_short lport = 0; 82 83 if (ipxp->ipxp_lport || !ipx_nullhost(ipxp->ipxp_laddr)) 84 return (EINVAL); 85 if (nam == 0) 86 goto noname; --- 6 unchanged lines hidden (view full) --- 93 sipx->sipx_port = 0; /* yech... */ 94 if (ifa_ifwithaddr((struct sockaddr *)sipx) == 0) 95 return (EADDRNOTAVAIL); 96 sipx->sipx_port = tport; 97 } 98 lport = sipx->sipx_port; 99 if (lport) { 100 u_short aport = ntohs(lport); | 82{ 83 register struct sockaddr_ipx *sipx; 84 u_short lport = 0; 85 86 if (ipxp->ipxp_lport || !ipx_nullhost(ipxp->ipxp_laddr)) 87 return (EINVAL); 88 if (nam == 0) 89 goto noname; --- 6 unchanged lines hidden (view full) --- 96 sipx->sipx_port = 0; /* yech... */ 97 if (ifa_ifwithaddr((struct sockaddr *)sipx) == 0) 98 return (EADDRNOTAVAIL); 99 sipx->sipx_port = tport; 100 } 101 lport = sipx->sipx_port; 102 if (lport) { 103 u_short aport = ntohs(lport); |
104 int error; |
|
101 102 if (aport < IPXPORT_MAX && | 105 106 if (aport < IPXPORT_MAX && |
103 (ipxp->ipxp_socket->so_state & SS_PRIV) == 0) 104 return (EACCES); | 107 p && (error = suser(p->p_ucred, &p->p_acflag)) != 0) 108 return (error); |
105 if (ipx_pcblookup(&zeroipx_addr, lport, 0)) 106 return (EADDRINUSE); 107 } 108 ipxp->ipxp_laddr = sipx->sipx_addr; 109noname: 110 if (lport == 0) 111 do { 112 if (ipxpcb.ipxp_lport++ < IPXPORT_MAX) --- 6 unchanged lines hidden (view full) --- 119 120/* 121 * Connect from a socket to a specified address. 122 * Both address and port must be specified in argument sipx. 123 * If don't have a local address for this socket yet, 124 * then pick one. 125 */ 126int | 109 if (ipx_pcblookup(&zeroipx_addr, lport, 0)) 110 return (EADDRINUSE); 111 } 112 ipxp->ipxp_laddr = sipx->sipx_addr; 113noname: 114 if (lport == 0) 115 do { 116 if (ipxpcb.ipxp_lport++ < IPXPORT_MAX) --- 6 unchanged lines hidden (view full) --- 123 124/* 125 * Connect from a socket to a specified address. 126 * Both address and port must be specified in argument sipx. 127 * If don't have a local address for this socket yet, 128 * then pick one. 129 */ 130int |
127ipx_pcbconnect(ipxp, nam) | 131ipx_pcbconnect(ipxp, nam, p) |
128 struct ipxpcb *ipxp; 129 struct mbuf *nam; | 132 struct ipxpcb *ipxp; 133 struct mbuf *nam; |
134 struct proc *p; |
|
130{ 131 struct ipx_ifaddr *ia; 132 register struct sockaddr_ipx *sipx = mtod(nam, struct sockaddr_ipx *); 133 register struct ipx_addr *dst; 134 register struct route *ro; 135 struct ifnet *ifp; 136 137 if (nam->m_len != sizeof (*sipx)) --- 72 unchanged lines hidden (view full) --- 210 return (EADDRNOTAVAIL); 211 } 212 ipxp->ipxp_laddr.x_net = satoipx_addr(ia->ia_addr).x_net; 213 } 214 if (ipx_pcblookup(&sipx->sipx_addr, ipxp->ipxp_lport, 0)) 215 return (EADDRINUSE); 216 if (ipx_nullhost(ipxp->ipxp_laddr)) { 217 if (ipxp->ipxp_lport == 0) | 135{ 136 struct ipx_ifaddr *ia; 137 register struct sockaddr_ipx *sipx = mtod(nam, struct sockaddr_ipx *); 138 register struct ipx_addr *dst; 139 register struct route *ro; 140 struct ifnet *ifp; 141 142 if (nam->m_len != sizeof (*sipx)) --- 72 unchanged lines hidden (view full) --- 215 return (EADDRNOTAVAIL); 216 } 217 ipxp->ipxp_laddr.x_net = satoipx_addr(ia->ia_addr).x_net; 218 } 219 if (ipx_pcblookup(&sipx->sipx_addr, ipxp->ipxp_lport, 0)) 220 return (EADDRINUSE); 221 if (ipx_nullhost(ipxp->ipxp_laddr)) { 222 if (ipxp->ipxp_lport == 0) |
218 (void) ipx_pcbbind(ipxp, (struct mbuf *)0); | 223 (void) ipx_pcbbind(ipxp, (struct mbuf *)0, p); |
219 ipxp->ipxp_laddr.x_host = ipx_thishost; 220 } 221 ipxp->ipxp_faddr = sipx->sipx_addr; 222 /* Includes ipxp->ipxp_fport = sipx->sipx_port; */ 223 return (0); 224} 225 226void --- 151 unchanged lines hidden --- | 224 ipxp->ipxp_laddr.x_host = ipx_thishost; 225 } 226 ipxp->ipxp_faddr = sipx->sipx_addr; 227 /* Includes ipxp->ipxp_fport = sipx->sipx_port; */ 228 return (0); 229} 230 231void --- 151 unchanged lines hidden --- |