1/*
2 * Copyright (c) 1982, 1986, 1991, 1993, 1995
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 * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
34 * $FreeBSD: head/sys/netinet/in_pcb.c 87275 2001-12-03 16:12:27Z rwatson $
35 */
36
37#include "opt_ipsec.h"
38#include "opt_inet6.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/malloc.h>
--- 457 unchanged lines hidden (view full) ---
500 struct sockaddr_in *sin = (struct sockaddr_in *)nam;
501 struct sockaddr_in sa;
502 struct ucred *cred;
503 int error;
504
505 cred = inp->inp_socket->so_cred;
506 if (inp->inp_laddr.s_addr == INADDR_ANY && jailed(cred)) {
507 bzero(&sa, sizeof (sa));
508 sa.sin_addr.s_addr = htonl(prison_getip(cred));
509 sa.sin_len=sizeof (sa);
510 sa.sin_family = AF_INET;
511 error = in_pcbbind(inp, (struct sockaddr *)&sa, td);
512 if (error)
513 return (error);
514 }
515 /*
516 * Call inner routine, to assign local interface address.
--- 510 unchanged lines hidden (view full) ---
1027 inp->inp_pcbinfo->ipi_count--;
1028}
1029
1030int
1031prison_xinpcb(struct proc *p, struct inpcb *inp)
1032{
1033 if (!jailed(p->p_ucred))
1034 return (0);
1035 if (ntohl(inp->inp_laddr.s_addr) == prison_getip(p->p_ucred))
1036 return (0);
1037 return (1);
1038}
2 * Copyright (c) 1982, 1986, 1991, 1993, 1995
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 * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
34 * $FreeBSD: head/sys/netinet/in_pcb.c 87275 2001-12-03 16:12:27Z rwatson $
35 */
36
37#include "opt_ipsec.h"
38#include "opt_inet6.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/malloc.h>
--- 457 unchanged lines hidden (view full) ---
500 struct sockaddr_in *sin = (struct sockaddr_in *)nam;
501 struct sockaddr_in sa;
502 struct ucred *cred;
503 int error;
504
505 cred = inp->inp_socket->so_cred;
506 if (inp->inp_laddr.s_addr == INADDR_ANY && jailed(cred)) {
507 bzero(&sa, sizeof (sa));
508 sa.sin_addr.s_addr = htonl(prison_getip(cred));
509 sa.sin_len=sizeof (sa);
510 sa.sin_family = AF_INET;
511 error = in_pcbbind(inp, (struct sockaddr *)&sa, td);
512 if (error)
513 return (error);
514 }
515 /*
516 * Call inner routine, to assign local interface address.
--- 510 unchanged lines hidden (view full) ---
1027 inp->inp_pcbinfo->ipi_count--;
1028}
1029
1030int
1031prison_xinpcb(struct proc *p, struct inpcb *inp)
1032{
1033 if (!jailed(p->p_ucred))
1034 return (0);
1035 if (ntohl(inp->inp_laddr.s_addr) == prison_getip(p->p_ucred))
1036 return (0);
1037 return (1);
1038}