2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1982, 1986, 1993
30 * The Regents of the University of California. All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * @(#)in_proto.c 8.2 (Berkeley) 2/9/95
63 #include <sys/param.h>
64 #include <sys/kernel.h>
65 #include <sys/socket.h>
66 #include <sys/domain.h>
67 #include <sys/protosw.h>
68 #include <sys/queue.h>
69 #include <sys/sysctl.h>
73 #include <net/route.h>
75 #include <netinet/in.h>
76 #include <netinet/in_systm.h>
77 #include <netinet/ip.h>
78 #include <netinet/ip_var.h>
79 #include <netinet/ip_icmp.h>
80 #include <netinet/igmp_var.h>
81 #include <netinet/tcp.h>
82 #include <netinet/tcp_timer.h>
83 #include <netinet/tcp_var.h>
84 #include <netinet/tcpip.h>
85 #include <netinet/udp.h>
86 #include <netinet/udp_var.h>
87 #include <netinet/ip_encap.h>
88 #include <netinet/ip_divert.h>
92 * TCP/IP protocol family: IP, ICMP, UDP, TCP.
96 #include <netinet6/ipsec.h>
97 #include <netinet6/ah.h>
99 #include <netinet6/esp.h>
101 #include <netinet6/ipcomp.h>
105 #include <netipx/ipx_ip.h>
108 extern struct domain inetdomain
;
109 static struct pr_usrreqs nousrreqs
;
110 extern struct pr_usrreqs icmp_dgram_usrreqs
;
111 extern int icmp_dgram_ctloutput(struct socket
*, struct sockopt
*);
114 struct protosw inetsw
[] = {
115 { 0, &inetdomain
, 0, 0,
118 ip_init
, 0, ip_slowtimo
, ip_drain
,
121 0, 0, 0, { 0, 0 }, 0, { 0 }
123 { SOCK_DGRAM
, &inetdomain
, IPPROTO_UDP
, PR_ATOMIC
|PR_ADDR
|PR_PROTOLOCK
|PR_PCBLOCK
,
124 udp_input
, 0, udp_ctlinput
, ip_ctloutput
,
126 udp_init
, 0, udp_slowtimo
, 0,
129 udp_lock
, udp_unlock
, udp_getlock
, { 0, 0 }, 0, { 0 }
131 { SOCK_STREAM
, &inetdomain
, IPPROTO_TCP
,
132 PR_CONNREQUIRED
|PR_IMPLOPCL
|PR_WANTRCVD
|PR_PCBLOCK
|PR_PROTOLOCK
|PR_DISPOSE
,
133 tcp_input
, 0, tcp_ctlinput
, tcp_ctloutput
,
135 tcp_init
, tcp_fasttimo
, tcp_slowtimo
, tcp_drain
,
138 tcp_lock
, tcp_unlock
, tcp_getlock
, { 0, 0 }, 0, { 0 }
140 { SOCK_RAW
, &inetdomain
, IPPROTO_RAW
, PR_ATOMIC
|PR_ADDR
,
141 rip_input
, 0, rip_ctlinput
, rip_ctloutput
,
146 0, rip_unlock
, 0, { 0, 0 }, 0, { 0 }
148 { SOCK_RAW
, &inetdomain
, IPPROTO_ICMP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
149 icmp_input
, 0, 0, rip_ctloutput
,
154 0, rip_unlock
, 0, { 0, 0 }, 0, { 0 }
156 { SOCK_DGRAM
, &inetdomain
, IPPROTO_ICMP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
157 icmp_input
, 0, 0, icmp_dgram_ctloutput
,
162 0, rip_unlock
, 0, { 0, 0 }, 0, { 0 }
164 { SOCK_RAW
, &inetdomain
, IPPROTO_IGMP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
165 igmp_input
, 0, 0, rip_ctloutput
,
167 igmp_init
, igmp_fasttimo
, igmp_slowtimo
, 0,
170 0, rip_unlock
, 0, { 0, 0 }, 0, { 0 }
172 { SOCK_RAW
, &inetdomain
, IPPROTO_RSVP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
173 rsvp_input
, 0, 0, rip_ctloutput
,
178 0, rip_unlock
, 0, { 0, 0 }, 0, { 0 }
181 { SOCK_RAW
, &inetdomain
, IPPROTO_AH
, PR_ATOMIC
|PR_ADDR
|PR_PROTOLOCK
,
187 0, 0, 0, { 0, 0 }, 0, { 0 }
190 { SOCK_RAW
, &inetdomain
, IPPROTO_ESP
, PR_ATOMIC
|PR_ADDR
|PR_PROTOLOCK
,
196 0, 0, 0, { 0, 0 }, 0, { 0 }
199 { SOCK_RAW
, &inetdomain
, IPPROTO_IPCOMP
, PR_ATOMIC
|PR_ADDR
|PR_PROTOLOCK
,
200 ipcomp4_input
, 0, 0, 0,
205 0, 0, 0, { 0, 0 }, 0, { 0 }
208 { SOCK_RAW
, &inetdomain
, IPPROTO_IPV4
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
209 encap4_input
, 0, 0, rip_ctloutput
,
214 0, 0, 0, { 0, 0 }, 0, { 0 }
217 { SOCK_RAW
, &inetdomain
, IPPROTO_IPV6
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
218 encap4_input
, 0, 0, rip_ctloutput
,
223 0, 0, 0, { 0, 0 }, 0, { 0 }
227 { SOCK_RAW
, &inetdomain
, IPPROTO_DIVERT
, PR_ATOMIC
|PR_ADDR
|PR_PCBLOCK
,
228 div_input
, 0, 0, ip_ctloutput
,
233 div_lock
, div_unlock
, div_getlock
, { 0, 0 }, 0, { 0 }
237 { SOCK_RAW
, &inetdomain
, IPPROTO_IDP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
238 ipxip_input
, 0, ipxip_ctlinput
, 0,
243 0, 0, 0, { 0, 0 }, 0, { 0 }
247 { SOCK_RAW
, &inetdomain
, IPPROTO_IDP
, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
248 idpip_input
, 0, nsip_ctlinput
, 0,
253 0, 0, 0, { 0, 0 }, 0, { 0 }
257 { SOCK_RAW
, &inetdomain
, 0, PR_ATOMIC
|PR_ADDR
|PR_LASTHDR
,
258 rip_input
, 0, 0, rip_ctloutput
,
263 0, rip_unlock
, 0, { 0, 0 }, 0, { 0 }
267 extern int in_inithead(void **, int);
269 int in_proto_count
= (sizeof (inetsw
) / sizeof (struct protosw
));
271 extern void in_dinit(void);
272 /* A routing init function, and a header size */
273 struct domain inetdomain
=
283 sizeof(struct sockaddr_in
),
284 sizeof(struct tcpiphdr
),
293 SYSCTL_NODE(_net
, PF_INET
, inet
, CTLFLAG_RW
, 0,
296 SYSCTL_NODE(_net_inet
, IPPROTO_IP
, ip
, CTLFLAG_RW
, 0, "IP");
297 SYSCTL_NODE(_net_inet
, IPPROTO_ICMP
, icmp
, CTLFLAG_RW
, 0, "ICMP");
298 SYSCTL_NODE(_net_inet
, IPPROTO_UDP
, udp
, CTLFLAG_RW
, 0, "UDP");
299 SYSCTL_NODE(_net_inet
, IPPROTO_TCP
, tcp
, CTLFLAG_RW
, 0, "TCP");
300 SYSCTL_NODE(_net_inet
, IPPROTO_IGMP
, igmp
, CTLFLAG_RW
, 0, "IGMP");
302 SYSCTL_NODE(_net_inet
, IPPROTO_AH
, ipsec
, CTLFLAG_RW
, 0, "IPSEC");
304 SYSCTL_NODE(_net_inet
, IPPROTO_RAW
, raw
, CTLFLAG_RW
, 0, "RAW");
306 SYSCTL_NODE(_net_inet
, IPPROTO_DIVERT
, div
, CTLFLAG_RW
, 0, "DIVERT");