hook for ps driver and untimeout stuff for lucas drivers
[unix-history] / usr / src / sys / kern / uipc_proto.c
CommitLineData
4a2ddbf1 1/* uipc_proto.c 4.22 82/06/20 */
07d8f161 2
d0e67d5f 3#include "../h/param.h"
07d8f161 4#include "../h/socket.h"
07d8f161
BJ
5#include "../h/protosw.h"
6#include "../h/mbuf.h"
0ef33f87
BJ
7#include "../net/in.h"
8#include "../net/in_systm.h"
07d8f161 9
d0e67d5f
BJ
10/*
11 * Protocol configuration table and routines to search it.
cc15ab5d
BJ
12 *
13 * SHOULD INCLUDE A HEADER FILE GIVING DESIRED PROTOCOLS
d0e67d5f
BJ
14 */
15
16/*
cc15ab5d 17 * Local protocol handler.
d0e67d5f 18 */
2b4b57cd 19int piusrreq();
d0e67d5f 20
d0e67d5f
BJ
21/*
22 * TCP/IP protocol family: IP, ICMP, UDP, TCP.
23 */
0ef33f87 24int ip_output();
cc15ab5d 25int ip_init(),ip_slowtimo(),ip_drain();
0649e349 26int icmp_input();
cc15ab5d 27int udp_input(),udp_ctlinput();
b454c3ea 28int udp_usrreq();
cc15ab5d
BJ
29int udp_init();
30int tcp_input(),tcp_ctlinput();
b454c3ea 31int tcp_usrreq();
cc15ab5d 32int tcp_init(),tcp_fasttimo(),tcp_slowtimo(),tcp_drain();
c94ae9b7 33int rip_input(),rip_output();
d0e67d5f 34
8f4851aa 35/*
1d7d0c6d
SL
36 * IMP protocol family: raw interface.
37 * Using the raw interface entry to get the timer routine
38 * in is a kludge.
8f4851aa
BJ
39 */
40#include "imp.h"
41#if NIMP > 0
1d7d0c6d 42int rimp_output(), hostslowtimo();
6b1458f3
BJ
43#endif
44
45/*
46 * PUP-I protocol family: raw interface
47 */
48#include "pup.h"
49#if NPUP > 0
c94ae9b7 50int rpup_output();
8f4851aa
BJ
51#endif
52
53/*
54 * Sundries.
55*/
0649e349 56int raw_init(),raw_usrreq(),raw_input(),raw_ctlinput();
8f4851aa 57
d0e67d5f 58struct protosw protosw[] = {
5b3fa994 59{ SOCK_STREAM, PF_UNIX, 0, PR_CONNREQUIRED,
07d8f161 60 0, 0, 0, 0,
5b3fa994 61 piusrreq,
07d8f161 62 0, 0, 0, 0,
cc15ab5d 63},
5b3fa994 64{ SOCK_DGRAM, PF_UNIX, 0, PR_ATOMIC|PR_ADDR,
07d8f161 65 0, 0, 0, 0,
5b3fa994 66 piusrreq,
07d8f161 67 0, 0, 0, 0,
cc15ab5d 68},
5b3fa994 69{ SOCK_RDM, PF_UNIX, 0, PR_ATOMIC|PR_ADDR,
cc15ab5d 70 0, 0, 0, 0,
5b3fa994 71 piusrreq,
cc15ab5d
BJ
72 0, 0, 0, 0,
73},
5b3fa994 74{ SOCK_RAW, PF_UNIX, 0, PR_ATOMIC|PR_ADDR,
cc15ab5d 75 0, 0, 0, 0,
5b3fa994 76 piusrreq,
cc15ab5d
BJ
77 0, 0, 0, 0,
78},
d0e67d5f 79{ 0, 0, 0, 0,
0ef33f87 80 0, ip_output, 0, 0,
5b3fa994 81 0,
cc15ab5d
BJ
82 ip_init, 0, ip_slowtimo, ip_drain,
83},
0649e349
SL
84{ 0, PF_INET, IPPROTO_ICMP, 0,
85 icmp_input, 0, 0, 0,
5b3fa994 86 0,
0649e349 87 0, 0, 0, 0,
cc15ab5d 88},
07d8f161 89{ SOCK_DGRAM, PF_INET, IPPROTO_UDP, PR_ATOMIC|PR_ADDR,
cc15ab5d 90 udp_input, 0, udp_ctlinput, 0,
5b3fa994 91 udp_usrreq,
cc15ab5d
BJ
92 udp_init, 0, 0, 0,
93},
687794cc 94{ SOCK_STREAM, PF_INET, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD,
cc15ab5d 95 tcp_input, 0, tcp_ctlinput, 0,
5b3fa994 96 tcp_usrreq,
cc15ab5d
BJ
97 tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain,
98},
8f4851aa 99{ 0, 0, 0, 0,
0649e349 100 raw_input, 0, raw_ctlinput, 0,
8f4851aa
BJ
101 raw_usrreq,
102 raw_init, 0, 0, 0,
103},
7859593f 104{ SOCK_RAW, PF_INET, IPPROTO_RAW, PR_ATOMIC|PR_ADDR,
0649e349 105 rip_input, rip_output, 0, 0,
c94ae9b7 106 raw_usrreq,
8f4851aa
BJ
107 0, 0, 0, 0,
108}
109#if NIMP > 0
110,
111{ SOCK_RAW, PF_IMPLINK, 0, PR_ATOMIC|PR_ADDR,
c94ae9b7
SL
112 0, rimp_output, 0, 0,
113 raw_usrreq,
1d7d0c6d 114 0, 0, hostslowtimo, 0,
6b1458f3
BJ
115}
116#endif
117#if NPUP > 0
118,
119{ SOCK_RAW, PF_PUP, 0, PR_ATOMIC|PR_ADDR,
c94ae9b7 120 0, rpup_output, 0, 0,
a907fb30 121 raw_usrreq,
8f4851aa 122 0, 0, 0, 0,
cc15ab5d 123}
8f4851aa 124#endif
d0e67d5f 125};
cc15ab5d
BJ
126
127#define NPROTOSW (sizeof(protosw) / sizeof(protosw[0]))
128
129struct protosw *protoswLAST = &protosw[NPROTOSW-1];
d0e67d5f
BJ
130
131/*
132 * Operations on protocol table and protocol families.
133 */
134
cc15ab5d
BJ
135/*
136 * Initialize all protocols.
137 */
138pfinit()
139{
140 register struct protosw *pr;
141
142 for (pr = protoswLAST; pr >= protosw; pr--)
143 if (pr->pr_init)
144 (*pr->pr_init)();
145}
146
d0e67d5f
BJ
147/*
148 * Find a standard protocol in a protocol family
149 * of a specific type.
150 */
07d8f161 151struct protosw *
cc15ab5d 152pffindtype(family, type)
d0e67d5f
BJ
153 int family, type;
154{
155 register struct protosw *pr;
156
157 if (family == 0)
158 return (0);
687794cc 159 for (pr = protosw; pr <= protoswLAST; pr++)
d0e67d5f
BJ
160 if (pr->pr_family == family && pr->pr_type == type)
161 return (pr);
162 return (0);
163}
164
165/*
166 * Find a specified protocol in a specified protocol family.
167 */
07d8f161 168struct protosw *
cc15ab5d 169pffindproto(family, protocol)
07d8f161 170 int family, protocol;
d0e67d5f
BJ
171{
172 register struct protosw *pr;
173
174 if (family == 0)
175 return (0);
687794cc 176 for (pr = protosw; pr <= protoswLAST; pr++)
07d8f161 177 if (pr->pr_family == family && pr->pr_protocol == protocol)
d0e67d5f
BJ
178 return (pr);
179 return (0);
180}
72857acf 181
0649e349
SL
182pfctlinput(cmd, arg)
183 int cmd;
184 caddr_t arg;
185{
186 register struct protosw *pr;
0649e349
SL
187
188 for (pr = protosw; pr <= protoswLAST; pr++)
189 if (pr->pr_ctlinput)
190 (*pr->pr_ctlinput)(cmd, arg);
191}
192
72857acf
BJ
193/*
194 * Slow timeout on all protocols.
195 */
196pfslowtimo()
197{
198 register struct protosw *pr;
199
72857acf
BJ
200 for (pr = protoswLAST; pr >= protosw; pr--)
201 if (pr->pr_slowtimo)
202 (*pr->pr_slowtimo)();
203}
204
205pffasttimo()
206{
207 register struct protosw *pr;
208
72857acf 209 for (pr = protoswLAST; pr >= protosw; pr--)
bdf22b53
BJ
210 if (pr->pr_fasttimo)
211 (*pr->pr_fasttimo)();
72857acf 212}