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: 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> |
43#include <sys/proc.h> 44#include <sys/protosw.h> |
45#include <sys/errno.h> 46#include <sys/socket.h> 47#include <sys/socketvar.h> |
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 |
59ipx_pcballoc(so, head, p) |
60 struct socket *so; 61 struct ipxpcb *head; |
62 struct proc *p; |
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 |
78ipx_pcbbind(ipxp, nam, p) |
79 register struct ipxpcb *ipxp; 80 struct mbuf *nam; |
81 struct proc *p; |
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; |
105 106 if (aport < IPXPORT_MAX && |
107 p && (error = suser(p->p_ucred, &p->p_acflag)) != 0) 108 return (error); |
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 |
131ipx_pcbconnect(ipxp, nam, p) |
132 struct ipxpcb *ipxp; 133 struct mbuf *nam; |
134 struct proc *p; |
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) |
223 (void) ipx_pcbbind(ipxp, (struct mbuf *)0, p); |
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 --- |