Deleted Added
sdiff udiff text old ( 22975 ) new ( 25345 )
full compact
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$
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/errno.h>
44#include <sys/socket.h>
45#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
58ipx_pcballoc(so, head)
59 struct socket *so;
60 struct ipxpcb *head;
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
76ipx_pcbbind(ipxp, nam)
77 register struct ipxpcb *ipxp;
78 struct mbuf *nam;
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);
101
102 if (aport < IPXPORT_MAX &&
103 (ipxp->ipxp_socket->so_state & SS_PRIV) == 0)
104 return (EACCES);
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
127ipx_pcbconnect(ipxp, nam)
128 struct ipxpcb *ipxp;
129 struct mbuf *nam;
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)
218 (void) ipx_pcbbind(ipxp, (struct mbuf *)0);
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 ---