in_pcb.c (12296) | in_pcb.c (13491) |
---|---|
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 | 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 * $Id: in_pcb.c,v 1.14 1995/10/29 15:32:25 phk Exp $ | 34 * $Id: in_pcb.c,v 1.15 1995/11/14 20:33:59 phk Exp $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/malloc.h> 40#include <sys/mbuf.h> 41#include <sys/protosw.h> 42#include <sys/socket.h> 43#include <sys/socketvar.h> 44#include <sys/ioctl.h> 45#include <sys/errno.h> 46#include <sys/time.h> 47#include <sys/proc.h> 48#include <sys/queue.h> | 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/malloc.h> 40#include <sys/mbuf.h> 41#include <sys/protosw.h> 42#include <sys/socket.h> 43#include <sys/socketvar.h> 44#include <sys/ioctl.h> 45#include <sys/errno.h> 46#include <sys/time.h> 47#include <sys/proc.h> 48#include <sys/queue.h> |
49#include <sys/kernel.h> 50#include <sys/sysctl.h> |
|
49 50#include <net/if.h> 51#include <net/route.h> 52 53#include <netinet/in.h> 54#include <netinet/in_systm.h> 55#include <netinet/ip.h> 56#include <netinet/in_pcb.h> 57#include <netinet/in_var.h> 58#include <netinet/ip_var.h> 59 60struct in_addr zeroin_addr; 61 | 51 52#include <net/if.h> 53#include <net/route.h> 54 55#include <netinet/in.h> 56#include <netinet/in_systm.h> 57#include <netinet/ip.h> 58#include <netinet/in_pcb.h> 59#include <netinet/in_var.h> 60#include <netinet/ip_var.h> 61 62struct in_addr zeroin_addr; 63 |
64/* 65 * These configure the range of local port addresses assigned to 66 * "unspecified" outgoing connections/packets/whatever. 67 */ 68static int ipport_firstauto = IPPORT_FIRSTAUTO; 69static int ipport_lastauto = IPPORT_LASTAUTO; 70 71SYSCTL_INT(_net_inet_ip, OID_AUTO, port_first_auto, CTLFLAG_RW, 72 &ipport_firstauto, 0, ""); 73SYSCTL_INT(_net_inet_ip, OID_AUTO, port_last_auto, CTLFLAG_RW, 74 &ipport_lastauto, 0, ""); 75 |
|
62static void in_pcbinshash __P((struct inpcb *)); 63static void in_rtchange __P((struct inpcb *, int)); 64 65int 66in_pcballoc(so, pcbinfo) 67 struct socket *so; 68 struct inpcbinfo *pcbinfo; 69{ --- 76 unchanged lines hidden (view full) --- 146 if (t && (reuseport & t->inp_socket->so_options) == 0) 147 return (EADDRINUSE); 148 } 149 inp->inp_laddr = sin->sin_addr; 150 } 151 if (lport == 0) 152 do { 153 ++*lastport; | 76static void in_pcbinshash __P((struct inpcb *)); 77static void in_rtchange __P((struct inpcb *, int)); 78 79int 80in_pcballoc(so, pcbinfo) 81 struct socket *so; 82 struct inpcbinfo *pcbinfo; 83{ --- 76 unchanged lines hidden (view full) --- 160 if (t && (reuseport & t->inp_socket->so_options) == 0) 161 return (EADDRINUSE); 162 } 163 inp->inp_laddr = sin->sin_addr; 164 } 165 if (lport == 0) 166 do { 167 ++*lastport; |
154 if (*lastport < IPPORT_RESERVED || 155 *lastport > IPPORT_USERRESERVED) 156 *lastport = IPPORT_RESERVED; | 168 if (*lastport < ipport_firstauto || 169 *lastport > ipport_lastauto) 170 *lastport = ipport_firstauto; |
157 lport = htons(*lastport); 158 } while (in_pcblookup(head, 159 zeroin_addr, 0, inp->inp_laddr, lport, wild)); 160 inp->inp_lport = lport; 161 in_pcbrehash(inp); 162 return (0); 163} 164 --- 462 unchanged lines hidden --- | 171 lport = htons(*lastport); 172 } while (in_pcblookup(head, 173 zeroin_addr, 0, inp->inp_laddr, lport, wild)); 174 inp->inp_lport = lport; 175 in_pcbrehash(inp); 176 return (0); 177} 178 --- 462 unchanged lines hidden --- |