[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet/in_proto.c

Version: -  FREEBSD  -  FREEBSD7  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  OPENSOLARIS  -  minix-3-1-1  -  TRUSTEDBSD-SEBSD  -  FREEBSD-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  excerpts  -  bigexcerpts 

  1 /*-
  2  * Copyright (c) 1982, 1986, 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
  9  *    notice, this list of conditions and the following disclaimer.
 10  * 2. Redistributions in binary form must reproduce the above copyright
 11  *    notice, this list of conditions and the following disclaimer in the
 12  *    documentation and/or other materials provided with the distribution.
 13  * 4. Neither the name of the University nor the names of its contributors
 14  *    may be used to endorse or promote products derived from this software
 15  *    without specific prior written permission.
 16  *
 17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 27  * SUCH DAMAGE.
 28  *
 29  *      @(#)in_proto.c  8.2 (Berkeley) 2/9/95
 30  */
 31 
 32 #include <sys/cdefs.h>
 33 __FBSDID("$FreeBSD: src/sys/netinet/in_proto.c,v 1.89 2008/11/19 09:39:34 zec Exp $");
 34 
 35 #include "opt_ipx.h"
 36 #include "opt_mrouting.h"
 37 #include "opt_ipsec.h"
 38 #include "opt_inet6.h"
 39 #include "opt_pf.h"
 40 #include "opt_carp.h"
 41 #include "opt_sctp.h"
 42 #include "opt_mpath.h"
 43 
 44 #include <sys/param.h>
 45 #include <sys/systm.h>
 46 #include <sys/kernel.h>
 47 #include <sys/socket.h>
 48 #include <sys/domain.h>
 49 #include <sys/protosw.h>
 50 #include <sys/queue.h>
 51 #include <sys/sysctl.h>
 52 
 53 #include <net/if.h>
 54 #include <net/route.h>
 55 #ifdef RADIX_MPATH
 56 #include <net/radix_mpath.h>
 57 #endif
 58 
 59 #include <netinet/in.h>
 60 #include <netinet/in_systm.h>
 61 #include <netinet/ip.h>
 62 #include <netinet/ip_var.h>
 63 #include <netinet/ip_icmp.h>
 64 #include <netinet/igmp_var.h>
 65 #include <netinet/tcp.h>
 66 #include <netinet/tcp_timer.h>
 67 #include <netinet/tcp_var.h>
 68 #include <netinet/udp.h>
 69 #include <netinet/udp_var.h>
 70 #include <netinet/ip_encap.h>
 71 
 72 /*
 73  * TCP/IP protocol family: IP, ICMP, UDP, TCP.
 74  */
 75 
 76 static struct pr_usrreqs nousrreqs;
 77 
 78 #ifdef IPSEC
 79 #include <netipsec/ipsec.h>
 80 #endif /* IPSEC */
 81 
 82 #ifdef SCTP
 83 #include <netinet/in_pcb.h>
 84 #include <netinet/sctp_pcb.h>
 85 #include <netinet/sctp.h>
 86 #include <netinet/sctp_var.h>
 87 #endif /* SCTP */
 88 
 89 #ifdef DEV_PFSYNC
 90 #include <net/pfvar.h>
 91 #include <net/if_pfsync.h>
 92 #endif
 93 
 94 #ifdef DEV_CARP
 95 #include <netinet/ip_carp.h>
 96 #endif
 97 
 98 extern  struct domain inetdomain;
 99 
100 /* Spacer for loadable protocols. */
101 #define IPPROTOSPACER                           \
102 {                                               \
103         .pr_domain =            &inetdomain,    \
104         .pr_protocol =          PROTO_SPACER,   \
105         .pr_usrreqs =           &nousrreqs      \
106 }
107 
108 struct protosw inetsw[] = {
109 {
110         .pr_type =              0,
111         .pr_domain =            &inetdomain,
112         .pr_protocol =          IPPROTO_IP,
113         .pr_init =              ip_init,
114         .pr_slowtimo =          ip_slowtimo,
115         .pr_drain =             ip_drain,
116         .pr_usrreqs =           &nousrreqs
117 },
118 {
119         .pr_type =              SOCK_DGRAM,
120         .pr_domain =            &inetdomain,
121         .pr_protocol =          IPPROTO_UDP,
122         .pr_flags =             PR_ATOMIC|PR_ADDR,
123         .pr_input =             udp_input,
124         .pr_ctlinput =          udp_ctlinput,
125         .pr_ctloutput =         ip_ctloutput,
126         .pr_init =              udp_init,
127         .pr_usrreqs =           &udp_usrreqs
128 },
129 {
130         .pr_type =              SOCK_STREAM,
131         .pr_domain =            &inetdomain,
132         .pr_protocol =          IPPROTO_TCP,
133         .pr_flags =             PR_CONNREQUIRED|PR_IMPLOPCL|PR_WANTRCVD,
134         .pr_input =             tcp_input,
135         .pr_ctlinput =          tcp_ctlinput,
136         .pr_ctloutput =         tcp_ctloutput,
137         .pr_init =              tcp_init,
138         .pr_slowtimo =          tcp_slowtimo,
139         .pr_drain =             tcp_drain,
140         .pr_usrreqs =           &tcp_usrreqs
141 },
142 #ifdef SCTP
143 { 
144         .pr_type =      SOCK_DGRAM,
145         .pr_domain =    &inetdomain,
146         .pr_protocol =  IPPROTO_SCTP,
147         .pr_flags =     PR_WANTRCVD,
148         .pr_input =     sctp_input,
149         .pr_ctlinput =  sctp_ctlinput,  
150         .pr_ctloutput = sctp_ctloutput,
151         .pr_init =      sctp_init,      
152         .pr_drain =     sctp_drain,
153         .pr_usrreqs =   &sctp_usrreqs
154 },
155 {
156         .pr_type =      SOCK_SEQPACKET,
157         .pr_domain =    &inetdomain,
158         .pr_protocol =  IPPROTO_SCTP,
159         .pr_flags =     PR_WANTRCVD,
160         .pr_input =     sctp_input,
161         .pr_ctlinput =  sctp_ctlinput,  
162         .pr_ctloutput = sctp_ctloutput,
163         .pr_drain =     sctp_drain,
164         .pr_usrreqs =   &sctp_usrreqs
165 },
166 
167 { 
168         .pr_type =      SOCK_STREAM,
169         .pr_domain =    &inetdomain,
170         .pr_protocol =  IPPROTO_SCTP,
171         .pr_flags =     PR_WANTRCVD,
172         .pr_input =     sctp_input,
173         .pr_ctlinput =  sctp_ctlinput,  
174         .pr_ctloutput = sctp_ctloutput,
175         .pr_drain =     sctp_drain,
176         .pr_usrreqs =   &sctp_usrreqs
177 },
178 #endif /* SCTP */
179 {
180         .pr_type =              SOCK_RAW,
181         .pr_domain =            &inetdomain,
182         .pr_protocol =          IPPROTO_RAW,
183         .pr_flags =             PR_ATOMIC|PR_ADDR,
184         .pr_input =             rip_input,
185         .pr_ctlinput =          rip_ctlinput,
186         .pr_ctloutput =         rip_ctloutput,
187         .pr_usrreqs =           &rip_usrreqs
188 },
189 {
190         .pr_type =              SOCK_RAW,
191         .pr_domain =            &inetdomain,
192         .pr_protocol =          IPPROTO_ICMP,
193         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
194         .pr_input =             icmp_input,
195         .pr_ctloutput =         rip_ctloutput,
196         .pr_init =              icmp_init,
197         .pr_usrreqs =           &rip_usrreqs
198 },
199 {
200         .pr_type =              SOCK_RAW,
201         .pr_domain =            &inetdomain,
202         .pr_protocol =          IPPROTO_IGMP,
203         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
204         .pr_input =             igmp_input,
205         .pr_ctloutput =         rip_ctloutput,
206         .pr_init =              igmp_init,
207         .pr_fasttimo =          igmp_fasttimo,
208         .pr_slowtimo =          igmp_slowtimo,
209         .pr_usrreqs =           &rip_usrreqs
210 },
211 {
212         .pr_type =              SOCK_RAW,
213         .pr_domain =            &inetdomain,
214         .pr_protocol =          IPPROTO_RSVP,
215         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
216         .pr_input =             rsvp_input,
217         .pr_ctloutput =         rip_ctloutput,
218         .pr_usrreqs =           &rip_usrreqs
219 },
220 #ifdef IPSEC
221 {
222         .pr_type =              SOCK_RAW,
223         .pr_domain =            &inetdomain,
224         .pr_protocol =          IPPROTO_AH,
225         .pr_flags =             PR_ATOMIC|PR_ADDR,
226         .pr_input =             ah4_input,
227         .pr_ctlinput =          ah4_ctlinput,
228         .pr_usrreqs =           &nousrreqs
229 },
230 {
231         .pr_type =              SOCK_RAW,
232         .pr_domain =            &inetdomain,
233         .pr_protocol =          IPPROTO_ESP,
234         .pr_flags =             PR_ATOMIC|PR_ADDR,
235         .pr_input =             esp4_input,
236         .pr_ctlinput =          esp4_ctlinput,
237         .pr_usrreqs =           &nousrreqs
238 },
239 {
240         .pr_type =              SOCK_RAW,
241         .pr_domain =            &inetdomain,
242         .pr_protocol =          IPPROTO_IPCOMP,
243         .pr_flags =             PR_ATOMIC|PR_ADDR,
244         .pr_input =             ipcomp4_input,
245         .pr_usrreqs =           &nousrreqs
246 },
247 #endif /* IPSEC */
248 {
249         .pr_type =              SOCK_RAW,
250         .pr_domain =            &inetdomain,
251         .pr_protocol =          IPPROTO_IPV4,
252         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
253         .pr_input =             encap4_input,
254         .pr_ctloutput =         rip_ctloutput,
255         .pr_init =              encap_init,
256         .pr_usrreqs =           &rip_usrreqs
257 },
258 {
259         .pr_type =              SOCK_RAW,
260         .pr_domain =            &inetdomain,
261         .pr_protocol =          IPPROTO_MOBILE,
262         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
263         .pr_input =             encap4_input,
264         .pr_ctloutput =         rip_ctloutput,
265         .pr_init =              encap_init,
266         .pr_usrreqs =           &rip_usrreqs
267 },
268 {
269         .pr_type =              SOCK_RAW,
270         .pr_domain =            &inetdomain,
271         .pr_protocol =          IPPROTO_ETHERIP,
272         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
273         .pr_input =             encap4_input,
274         .pr_ctloutput =         rip_ctloutput,
275         .pr_init =              encap_init,
276         .pr_usrreqs =           &rip_usrreqs
277 },
278 {
279         .pr_type =              SOCK_RAW,
280         .pr_domain =            &inetdomain,
281         .pr_protocol =          IPPROTO_GRE,
282         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
283         .pr_input =             encap4_input,
284         .pr_ctloutput =         rip_ctloutput,
285         .pr_init =              encap_init,
286         .pr_usrreqs =           &rip_usrreqs
287 },
288 # ifdef INET6
289 {
290         .pr_type =              SOCK_RAW,
291         .pr_domain =            &inetdomain,
292         .pr_protocol =          IPPROTO_IPV6,
293         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
294         .pr_input =             encap4_input,
295         .pr_ctloutput =         rip_ctloutput,
296         .pr_init =              encap_init,
297         .pr_usrreqs =           &rip_usrreqs
298 },
299 #endif
300 {
301         .pr_type =              SOCK_RAW,
302         .pr_domain =            &inetdomain,
303         .pr_protocol =          IPPROTO_PIM,
304         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
305         .pr_input =             encap4_input,
306         .pr_ctloutput =         rip_ctloutput,
307         .pr_usrreqs =           &rip_usrreqs
308 },
309 #ifdef DEV_PFSYNC
310 {
311         .pr_type =              SOCK_RAW,
312         .pr_domain =            &inetdomain,
313         .pr_protocol =          IPPROTO_PFSYNC,
314         .pr_flags =             PR_ATOMIC|PR_ADDR,
315         .pr_input =             pfsync_input,
316         .pr_ctloutput =         rip_ctloutput,
317         .pr_usrreqs =           &rip_usrreqs
318 },
319 #endif  /* DEV_PFSYNC */
320 #ifdef DEV_CARP
321 {
322         .pr_type =              SOCK_RAW,
323         .pr_domain =            &inetdomain,
324         .pr_protocol =          IPPROTO_CARP,
325         .pr_flags =             PR_ATOMIC|PR_ADDR,
326         .pr_input =             carp_input,
327         .pr_output =            (pr_output_t*)rip_output,
328         .pr_ctloutput =         rip_ctloutput,
329         .pr_usrreqs =           &rip_usrreqs
330 },
331 #endif /* DEV_CARP */
332 /* Spacer n-times for loadable protocols. */
333 IPPROTOSPACER,
334 IPPROTOSPACER,
335 IPPROTOSPACER,
336 IPPROTOSPACER,
337 IPPROTOSPACER,
338 IPPROTOSPACER,
339 IPPROTOSPACER,
340 IPPROTOSPACER,
341 /* raw wildcard */
342 {
343         .pr_type =              SOCK_RAW,
344         .pr_domain =            &inetdomain,
345         .pr_flags =             PR_ATOMIC|PR_ADDR,
346         .pr_input =             rip_input,
347         .pr_ctloutput =         rip_ctloutput,
348         .pr_init =              rip_init,
349         .pr_usrreqs =           &rip_usrreqs
350 },
351 };
352 
353 extern int in_inithead(void **, int);
354 
355 struct domain inetdomain = {
356         .dom_family =           AF_INET,
357         .dom_name =             "internet",
358         .dom_protosw =          inetsw,
359         .dom_protoswNPROTOSW =  &inetsw[sizeof(inetsw)/sizeof(inetsw[0])],
360 #ifdef RADIX_MPATH
361         .dom_rtattach =         rn4_mpath_inithead,
362 #else
363         .dom_rtattach =         in_inithead,
364 #endif
365         .dom_rtoffset =         32,
366         .dom_maxrtkey =         sizeof(struct sockaddr_in)
367 };
368 
369 DOMAIN_SET(inet);
370 
371 SYSCTL_NODE(_net,      PF_INET,         inet,   CTLFLAG_RW, 0,
372         "Internet Family");
373 
374 SYSCTL_NODE(_net_inet, IPPROTO_IP,      ip,     CTLFLAG_RW, 0,  "IP");
375 SYSCTL_NODE(_net_inet, IPPROTO_ICMP,    icmp,   CTLFLAG_RW, 0,  "ICMP");
376 SYSCTL_NODE(_net_inet, IPPROTO_UDP,     udp,    CTLFLAG_RW, 0,  "UDP");
377 SYSCTL_NODE(_net_inet, IPPROTO_TCP,     tcp,    CTLFLAG_RW, 0,  "TCP");
378 #ifdef SCTP
379 SYSCTL_NODE(_net_inet, IPPROTO_SCTP,    sctp,   CTLFLAG_RW, 0,  "SCTP");
380 #endif
381 SYSCTL_NODE(_net_inet, IPPROTO_IGMP,    igmp,   CTLFLAG_RW, 0,  "IGMP");
382 #ifdef IPSEC
383 /* XXX no protocol # to use, pick something "reserved" */
384 SYSCTL_NODE(_net_inet, 253,             ipsec,  CTLFLAG_RW, 0,  "IPSEC");
385 SYSCTL_NODE(_net_inet, IPPROTO_AH,      ah,     CTLFLAG_RW, 0,  "AH");
386 SYSCTL_NODE(_net_inet, IPPROTO_ESP,     esp,    CTLFLAG_RW, 0,  "ESP");
387 SYSCTL_NODE(_net_inet, IPPROTO_IPCOMP,  ipcomp, CTLFLAG_RW, 0,  "IPCOMP");
388 SYSCTL_NODE(_net_inet, IPPROTO_IPIP,    ipip,   CTLFLAG_RW, 0,  "IPIP");
389 #endif /* IPSEC */
390 SYSCTL_NODE(_net_inet, IPPROTO_RAW,     raw,    CTLFLAG_RW, 0,  "RAW");
391 #ifdef DEV_PFSYNC
392 SYSCTL_NODE(_net_inet, IPPROTO_PFSYNC,  pfsync, CTLFLAG_RW, 0,  "PFSYNC");
393 #endif
394 #ifdef DEV_CARP
395 SYSCTL_NODE(_net_inet, IPPROTO_CARP,    carp,   CTLFLAG_RW, 0,  "CARP");
396 #endif
397 

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.