in_proto.c revision 1.23 1 1.23 jonathan /* $NetBSD: in_proto.c,v 1.23 1998/07/05 06:49:17 jonathan Exp $ */
2 1.9 cgd
3 1.1 cgd /*
4 1.8 mycroft * Copyright (c) 1982, 1986, 1993
5 1.8 mycroft * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * Redistribution and use in source and binary forms, with or without
8 1.1 cgd * modification, are permitted provided that the following conditions
9 1.1 cgd * are met:
10 1.1 cgd * 1. Redistributions of source code must retain the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer.
12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer in the
14 1.1 cgd * documentation and/or other materials provided with the distribution.
15 1.1 cgd * 3. All advertising materials mentioning features or use of this software
16 1.1 cgd * must display the following acknowledgement:
17 1.1 cgd * This product includes software developed by the University of
18 1.1 cgd * California, Berkeley and its contributors.
19 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
20 1.1 cgd * may be used to endorse or promote products derived from this software
21 1.1 cgd * without specific prior written permission.
22 1.1 cgd *
23 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 cgd * SUCH DAMAGE.
34 1.1 cgd *
35 1.18 thorpej * @(#)in_proto.c 8.2 (Berkeley) 2/9/95
36 1.1 cgd */
37 1.19 scottr
38 1.19 scottr #include "opt_mrouting.h"
39 1.22 jonathan #include "opt_eon.h" /* ISO CLNL over IP */
40 1.22 jonathan #include "opt_iso.h" /* ISO TP tunneled over IP */
41 1.23 jonathan #include "opt_ns.h" /* NSIP: XNS tunneled over IP */
42 1.1 cgd
43 1.5 mycroft #include <sys/param.h>
44 1.5 mycroft #include <sys/socket.h>
45 1.5 mycroft #include <sys/protosw.h>
46 1.5 mycroft #include <sys/domain.h>
47 1.5 mycroft #include <sys/mbuf.h>
48 1.1 cgd
49 1.8 mycroft #include <net/if.h>
50 1.8 mycroft #include <net/radix.h>
51 1.8 mycroft #include <net/route.h>
52 1.8 mycroft
53 1.5 mycroft #include <netinet/in.h>
54 1.5 mycroft #include <netinet/in_systm.h>
55 1.8 mycroft #include <netinet/ip.h>
56 1.8 mycroft #include <netinet/ip_var.h>
57 1.8 mycroft #include <netinet/ip_icmp.h>
58 1.8 mycroft #include <netinet/in_pcb.h>
59 1.8 mycroft #include <netinet/igmp_var.h>
60 1.8 mycroft #include <netinet/tcp.h>
61 1.8 mycroft #include <netinet/tcp_fsm.h>
62 1.8 mycroft #include <netinet/tcp_seq.h>
63 1.8 mycroft #include <netinet/tcp_timer.h>
64 1.8 mycroft #include <netinet/tcp_var.h>
65 1.8 mycroft #include <netinet/tcpip.h>
66 1.8 mycroft #include <netinet/tcp_debug.h>
67 1.8 mycroft #include <netinet/udp.h>
68 1.8 mycroft #include <netinet/udp_var.h>
69 1.1 cgd /*
70 1.1 cgd * TCP/IP protocol family: IP, ICMP, UDP, TCP.
71 1.1 cgd */
72 1.1 cgd
73 1.1 cgd #ifdef NSIP
74 1.13 christos #include <netns/ns_var.h>
75 1.13 christos #include <netns/idp_var.h>
76 1.11 mycroft #endif /* NSIP */
77 1.1 cgd
78 1.1 cgd #ifdef TPIP
79 1.13 christos #include <netiso/tp_param.h>
80 1.13 christos #include <netiso/tp_var.h>
81 1.11 mycroft #endif /* TPIP */
82 1.1 cgd
83 1.1 cgd #ifdef EON
84 1.13 christos #include <netiso/eonvar.h>
85 1.8 mycroft #endif /* EON */
86 1.1 cgd
87 1.11 mycroft #ifdef MROUTING
88 1.14 christos #include <netinet/ip_mroute.h>
89 1.11 mycroft #endif /* MROUTING */
90 1.11 mycroft
91 1.1 cgd extern struct domain inetdomain;
92 1.1 cgd
93 1.1 cgd struct protosw inetsw[] = {
94 1.1 cgd { 0, &inetdomain, 0, 0,
95 1.1 cgd 0, ip_output, 0, 0,
96 1.1 cgd 0,
97 1.8 mycroft ip_init, 0, ip_slowtimo, ip_drain, ip_sysctl
98 1.1 cgd },
99 1.1 cgd { SOCK_DGRAM, &inetdomain, IPPROTO_UDP, PR_ATOMIC|PR_ADDR,
100 1.1 cgd udp_input, 0, udp_ctlinput, ip_ctloutput,
101 1.1 cgd udp_usrreq,
102 1.8 mycroft udp_init, 0, 0, 0, udp_sysctl
103 1.1 cgd },
104 1.1 cgd { SOCK_STREAM, &inetdomain, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD,
105 1.1 cgd tcp_input, 0, tcp_ctlinput, tcp_ctloutput,
106 1.1 cgd tcp_usrreq,
107 1.12 thorpej tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain, tcp_sysctl
108 1.1 cgd },
109 1.1 cgd { SOCK_RAW, &inetdomain, IPPROTO_RAW, PR_ATOMIC|PR_ADDR,
110 1.1 cgd rip_input, rip_output, 0, rip_ctloutput,
111 1.1 cgd rip_usrreq,
112 1.1 cgd 0, 0, 0, 0,
113 1.1 cgd },
114 1.1 cgd { SOCK_RAW, &inetdomain, IPPROTO_ICMP, PR_ATOMIC|PR_ADDR,
115 1.1 cgd icmp_input, rip_output, 0, rip_ctloutput,
116 1.1 cgd rip_usrreq,
117 1.8 mycroft 0, 0, 0, 0, icmp_sysctl
118 1.8 mycroft },
119 1.11 mycroft #ifdef MROUTING
120 1.11 mycroft { SOCK_RAW, &inetdomain, IPPROTO_IPIP, PR_ATOMIC|PR_ADDR,
121 1.11 mycroft ipip_input, rip_output, 0, rip_ctloutput,
122 1.11 mycroft rip_usrreq, /* XXX */
123 1.11 mycroft 0, 0, 0, 0,
124 1.11 mycroft },
125 1.11 mycroft #endif /* MROUTING */
126 1.8 mycroft { SOCK_RAW, &inetdomain, IPPROTO_IGMP, PR_ATOMIC|PR_ADDR,
127 1.8 mycroft igmp_input, rip_output, 0, rip_ctloutput,
128 1.8 mycroft rip_usrreq,
129 1.10 mycroft igmp_init, igmp_fasttimo, igmp_slowtimo, 0,
130 1.1 cgd },
131 1.1 cgd #ifdef TPIP
132 1.1 cgd { SOCK_SEQPACKET,&inetdomain, IPPROTO_TP, PR_CONNREQUIRED|PR_WANTRCVD,
133 1.8 mycroft tpip_input, 0, tpip_ctlinput, tp_ctloutput,
134 1.1 cgd tp_usrreq,
135 1.1 cgd tp_init, 0, tp_slowtimo, tp_drain,
136 1.1 cgd },
137 1.11 mycroft #endif /* TPIP */
138 1.1 cgd /* EON (ISO CLNL over IP) */
139 1.1 cgd #ifdef EON
140 1.1 cgd { SOCK_RAW, &inetdomain, IPPROTO_EON, 0,
141 1.1 cgd eoninput, 0, eonctlinput, 0,
142 1.1 cgd 0,
143 1.1 cgd eonprotoinit, 0, 0, 0,
144 1.4 hpeyerl },
145 1.11 mycroft #endif /* EON */
146 1.1 cgd #ifdef NSIP
147 1.1 cgd { SOCK_RAW, &inetdomain, IPPROTO_IDP, PR_ATOMIC|PR_ADDR,
148 1.16 christos idpip_input, NULL, nsip_ctlinput, 0,
149 1.1 cgd rip_usrreq,
150 1.1 cgd 0, 0, 0, 0,
151 1.1 cgd },
152 1.11 mycroft #endif /* NSIP */
153 1.11 mycroft /* raw wildcard */
154 1.1 cgd { SOCK_RAW, &inetdomain, 0, PR_ATOMIC|PR_ADDR,
155 1.1 cgd rip_input, rip_output, 0, rip_ctloutput,
156 1.1 cgd rip_usrreq,
157 1.8 mycroft rip_init, 0, 0, 0,
158 1.1 cgd },
159 1.1 cgd };
160 1.1 cgd
161 1.1 cgd struct domain inetdomain =
162 1.8 mycroft { AF_INET, "internet", 0, 0, 0,
163 1.8 mycroft inetsw, &inetsw[sizeof(inetsw)/sizeof(inetsw[0])], 0,
164 1.8 mycroft rn_inithead, 32, sizeof(struct sockaddr_in) };
165 1.1 cgd
166 1.8 mycroft #ifdef notyet /* XXXX */
167 1.8 mycroft #include "imp.h"
168 1.1 cgd #if NIMP > 0
169 1.1 cgd extern struct domain impdomain;
170 1.8 mycroft int rimp_output(), hostslowtimo();
171 1.1 cgd
172 1.1 cgd struct protosw impsw[] = {
173 1.1 cgd { SOCK_RAW, &impdomain, 0, PR_ATOMIC|PR_ADDR,
174 1.1 cgd 0, rimp_output, 0, 0,
175 1.1 cgd rip_usrreq,
176 1.1 cgd 0, 0, hostslowtimo, 0,
177 1.1 cgd },
178 1.1 cgd };
179 1.1 cgd
180 1.1 cgd struct domain impdomain =
181 1.1 cgd { AF_IMPLINK, "imp", 0, 0, 0,
182 1.1 cgd impsw, &impsw[sizeof (impsw)/sizeof(impsw[0])] };
183 1.1 cgd #endif
184 1.1 cgd
185 1.8 mycroft #include "hy.h"
186 1.8 mycroft #if NHY > 0
187 1.8 mycroft /*
188 1.8 mycroft * HYPERchannel protocol family: raw interface.
189 1.8 mycroft */
190 1.8 mycroft int rhy_output();
191 1.8 mycroft extern struct domain hydomain;
192 1.8 mycroft
193 1.8 mycroft struct protosw hysw[] = {
194 1.8 mycroft { SOCK_RAW, &hydomain, 0, PR_ATOMIC|PR_ADDR,
195 1.8 mycroft 0, rhy_output, 0, 0,
196 1.8 mycroft rip_usrreq,
197 1.8 mycroft 0, 0, 0, 0,
198 1.8 mycroft },
199 1.8 mycroft };
200 1.8 mycroft
201 1.8 mycroft struct domain hydomain =
202 1.8 mycroft { AF_HYLINK, "hy", 0, 0, 0, hysw, &hysw[sizeof (hysw)/sizeof(hysw[0])] };
203 1.8 mycroft #endif
204 1.8 mycroft #endif
205 1.17 thorpej
206 1.17 thorpej
207 1.17 thorpej #define TCP_SYN_HASH_SIZE 293
208 1.17 thorpej #define TCP_SYN_BUCKET_SIZE 35
209 1.17 thorpej
210 1.17 thorpej int tcp_syn_cache_size = TCP_SYN_HASH_SIZE;
211 1.17 thorpej int tcp_syn_cache_limit = TCP_SYN_HASH_SIZE*TCP_SYN_BUCKET_SIZE;
212 1.17 thorpej int tcp_syn_bucket_limit = 3*TCP_SYN_BUCKET_SIZE;
213 1.17 thorpej struct syn_cache_head tcp_syn_cache[TCP_SYN_HASH_SIZE];
214 1.17 thorpej int tcp_syn_cache_interval = 8; /* runs timer every 4 seconds */
215 1.17 thorpej int tcp_syn_cache_timeo = TCPTV_KEEP_INIT;
216