Deleted Added
sdiff udiff text old ( 127504 ) new ( 127505 )
full compact
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

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 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
34 * $FreeBSD: head/sys/netinet/tcp_usrreq.c 127505 2004-03-27 21:05:46Z pjd $
35 */
36
37#include "opt_ipsec.h"
38#include "opt_inet.h"
39#include "opt_inet6.h"
40#include "opt_tcpdebug.h"
41
42#include <sys/param.h>

--- 204 unchanged lines hidden (view full) ---

247 sinp = (struct sockaddr_in *)nam;
248 if (nam->sa_len != sizeof (*sinp))
249 return (EINVAL);
250 if (sinp->sin_family == AF_INET &&
251 IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
252 error = EAFNOSUPPORT;
253 goto out;
254 }
255 error = in_pcbbind(inp, nam, td->td_ucred);
256 if (error)
257 goto out;
258 COMMON_END(PRU_BIND);
259}
260
261#ifdef INET6
262static int
263tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)

--- 25 unchanged lines hidden (view full) ---

289 if (IN6_IS_ADDR_UNSPECIFIED(&sin6p->sin6_addr))
290 inp->inp_vflag |= INP_IPV4;
291 else if (IN6_IS_ADDR_V4MAPPED(&sin6p->sin6_addr)) {
292 struct sockaddr_in sin;
293
294 in6_sin6_2_sin(&sin, sin6p);
295 inp->inp_vflag |= INP_IPV4;
296 inp->inp_vflag &= ~INP_IPV6;
297 error = in_pcbbind(inp, (struct sockaddr *)&sin,
298 td->td_ucred);
299 goto out;
300 }
301 }
302 error = in6_pcbbind(inp, nam, td->td_ucred);
303 if (error)
304 goto out;
305 COMMON_END(PRU_BIND);
306}
307#endif /* INET6 */
308
309/*
310 * Prepare to accept connections.

--- 4 unchanged lines hidden (view full) ---

315 int s = splnet();
316 int error = 0;
317 struct inpcb *inp;
318 struct tcpcb *tp;
319 const int inirw = INI_WRITE;
320
321 COMMON_START();
322 if (inp->inp_lport == 0)
323 error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
324 if (error == 0)
325 tp->t_state = TCPS_LISTEN;
326 COMMON_END(PRU_LISTEN);
327}
328
329#ifdef INET6
330static int
331tcp6_usr_listen(struct socket *so, struct thread *td)

--- 4 unchanged lines hidden (view full) ---

336 struct tcpcb *tp;
337 const int inirw = INI_WRITE;
338
339 COMMON_START();
340 if (inp->inp_lport == 0) {
341 inp->inp_vflag &= ~INP_IPV4;
342 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0)
343 inp->inp_vflag |= INP_IPV4;
344 error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
345 }
346 if (error == 0)
347 tp->t_state = TCPS_LISTEN;
348 COMMON_END(PRU_LISTEN);
349}
350#endif /* INET6 */
351
352/*

--- 508 unchanged lines hidden (view full) ---

861 struct rmxp_tao tao;
862 struct in_addr laddr;
863 u_short lport;
864 int error;
865
866 bzero(&tao, sizeof(tao));
867
868 if (inp->inp_lport == 0) {
869 error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
870 if (error)
871 return error;
872 }
873
874 /*
875 * Cannot simply call in_pcbconnect, because there might be an
876 * earlier incarnation of this same connection still in
877 * TIME_WAIT state, creating an ADDRINUSE error.
878 */
879 laddr = inp->inp_laddr;
880 lport = inp->inp_lport;
881 error = in_pcbconnect_setup(inp, nam, &laddr.s_addr, &lport,
882 &inp->inp_faddr.s_addr, &inp->inp_fport, &oinp, td->td_ucred);
883 if (error && oinp == NULL)
884 return error;
885 if (oinp) {
886 if (oinp != inp &&
887 (oinp->inp_vflag & INP_TIMEWAIT) &&
888 (ticks - (otw = intotw(oinp))->t_starttime) < tcp_msl &&
889 otw->cc_recv != 0) {
890 inp->inp_faddr = oinp->inp_faddr;

--- 54 unchanged lines hidden (view full) ---

945 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
946 struct in6_addr *addr6;
947 struct rmxp_tao tao;
948 int error;
949
950 bzero(&tao, sizeof(tao));
951
952 if (inp->inp_lport == 0) {
953 error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
954 if (error)
955 return error;
956 }
957
958 /*
959 * Cannot simply call in_pcbconnect, because there might be an
960 * earlier incarnation of this same connection still in
961 * TIME_WAIT state, creating an ADDRINUSE error.

--- 349 unchanged lines hidden ---