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