2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1982, 1986, 1993
27 * The Regents of the University of California. All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. All advertising materials mentioning features or use of this software
38 * must display the following acknowledgement:
39 * This product includes software developed by the University of
40 * California, Berkeley and its contributors.
41 * 4. Neither the name of the University nor the names of its contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
45 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * @(#)in_proto.c 8.2 (Berkeley) 2/9/95
60 #include <sys/param.h>
61 #include <sys/kernel.h>
62 #include <sys/socket.h>
63 #include <sys/domain.h>
64 #include <sys/protosw.h>
65 #include <sys/queue.h>
66 #include <sys/sysctl.h>
69 #include <net/route.h>
71 #include <netinet/in.h>
72 #include <netinet/in_systm.h>
73 #include <netinet/ip.h>
74 #include <netinet/ip_var.h>
75 #include <netinet/ip_icmp.h>
76 #include <netinet/igmp_var.h>
77 #include <netinet/tcp.h>
78 #include <netinet/tcp_timer.h>
79 #include <netinet/tcp_var.h>
80 #include <netinet/tcpip.h>
81 #include <netinet/udp.h>
82 #include <netinet/udp_var.h>
83 #include <netinet/ip_encap.h>
87 * TCP/IP protocol family: IP, ICMP, UDP, TCP.
91 #include <netinet6/ipsec.h>
92 #include <netinet6/ah.h>
94 #include <netinet6/esp.h>
96 #include <netinet6/ipcomp.h>
100 #include <netipx/ipx_ip.h>
103 extern struct domain inetdomain
;
104 static struct pr_usrreqs nousrreqs
;
105 extern struct pr_usrreqs icmp_dgram_usrreqs
;
106 extern int icmp_dgram_ctloutput(struct socket
*, struct sockopt
*);
108 struct protosw inetsw
[] = {
109 { 0, &inetdomain
, 0, 0,
112 ip_init
, 0, ip_slowtimo
, ip_drain
,
115 { SOCK_DGRAM
, &inetdomain
, IPPROTO_UDP
, PR_ATOMIC
|PR_ADDR
,
116 udp_input
, 0, udp_ctlinput
, ip_ctloutput
,
121 { SOCK_STREAM
, &inetdomain
, IPPROTO_TCP
,
122 PR_CONNREQUIRED
|PR_IMPLOPCL
|PR_WANTRCVD
,
123 tcp_input
, 0, tcp_ctlinput
, tcp_ctloutput
,
125 tcp_init
, tcp_fasttimo
, tcp_slowtimo
, tcp_drain
,
128 { SOCK_RAW
, &inetdomain
, IPPROTO_RAW
, PR_ATOMIC
|PR_ADDR
,
129 rip_input
, 0, rip_ctlinput
, rip_ctloutput
,
134 { SOCK_RAW
, &inetdomain
, IPPROTO_ICMP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
135 icmp_input
, 0, 0, rip_ctloutput
,
140 { SOCK_DGRAM
, &inetdomain
, IPPROTO_ICMP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
141 icmp_input
, 0, 0, icmp_dgram_ctloutput
,
144 0, &icmp_dgram_usrreqs
146 { SOCK_RAW
, &inetdomain
, IPPROTO_IGMP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
147 igmp_input
, 0, 0, rip_ctloutput
,
149 igmp_init
, igmp_fasttimo
, igmp_slowtimo
, 0,
152 { SOCK_RAW
, &inetdomain
, IPPROTO_RSVP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
153 rsvp_input
, 0, 0, rip_ctloutput
,
159 { SOCK_RAW
, &inetdomain
, IPPROTO_AH
, PR_ATOMIC
|PR_ADDR
,
166 { SOCK_RAW
, &inetdomain
, IPPROTO_ESP
, PR_ATOMIC
|PR_ADDR
,
173 { SOCK_RAW
, &inetdomain
, IPPROTO_IPCOMP
, PR_ATOMIC
|PR_ADDR
,
174 ipcomp4_input
, 0, 0, 0,
180 { SOCK_RAW
, &inetdomain
, IPPROTO_IPV4
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
181 encap4_input
, 0, 0, rip_ctloutput
,
187 { SOCK_RAW
, &inetdomain
, IPPROTO_IPV6
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
188 encap4_input
, 0, 0, rip_ctloutput
,
195 { SOCK_RAW
, &inetdomain
, IPPROTO_DIVERT
, PR_ATOMIC
|PR_ADDR
,
196 div_input
, 0, 0, ip_ctloutput
,
203 { SOCK_RAW
, &inetdomain
, IPPROTO_IDP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
204 ipxip_input
, 0, ipxip_ctlinput
, 0,
211 { SOCK_RAW
, &inetdomain
, IPPROTO_IDP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
212 idpip_input
, 0, nsip_ctlinput
, 0,
219 { SOCK_RAW
, &inetdomain
, 0, PR_ATOMIC
|PR_ADDR
,
220 rip_input
, 0, 0, rip_ctloutput
,
227 extern int in_inithead
__P((void **, int));
229 int in_proto_count
= (sizeof (inetsw
) / sizeof (struct protosw
));
231 extern void in_dinit(void);
232 /* A routing init function, and a header size */
233 struct domain inetdomain
=
234 { AF_INET
, "internet", in_dinit
, 0, 0,
236 in_inithead
, 32, sizeof(struct sockaddr_in
),
237 sizeof(struct tcpiphdr
), 0
242 SYSCTL_NODE(_net
, PF_INET
, inet
, CTLFLAG_RW
, 0,
245 SYSCTL_NODE(_net_inet
, IPPROTO_IP
, ip
, CTLFLAG_RW
, 0, "IP");
246 SYSCTL_NODE(_net_inet
, IPPROTO_ICMP
, icmp
, CTLFLAG_RW
, 0, "ICMP");
247 SYSCTL_NODE(_net_inet
, IPPROTO_UDP
, udp
, CTLFLAG_RW
, 0, "UDP");
248 SYSCTL_NODE(_net_inet
, IPPROTO_TCP
, tcp
, CTLFLAG_RW
, 0, "TCP");
249 SYSCTL_NODE(_net_inet
, IPPROTO_IGMP
, igmp
, CTLFLAG_RW
, 0, "IGMP");
251 SYSCTL_NODE(_net_inet
, IPPROTO_AH
, ipsec
, CTLFLAG_RW
, 0, "IPSEC");
253 SYSCTL_NODE(_net_inet
, IPPROTO_RAW
, raw
, CTLFLAG_RW
, 0, "RAW");
255 SYSCTL_NODE(_net_inet
, IPPROTO_DIVERT
, div
, CTLFLAG_RW
, 0, "DIVERT");