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