Commit | Line | Data |
---|---|---|
c94ae9b7 | 1 | /* uipc_proto.c 4.19 82/03/28 */ |
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 | 19 | int piusrreq(); |
d0e67d5f | 20 | |
d0e67d5f BJ |
21 | /* |
22 | * TCP/IP protocol family: IP, ICMP, UDP, TCP. | |
23 | */ | |
0ef33f87 | 24 | int ip_output(); |
cc15ab5d | 25 | int ip_init(),ip_slowtimo(),ip_drain(); |
b454c3ea | 26 | int icmp_input(),icmp_ctlinput(); |
cc15ab5d BJ |
27 | int icmp_drain(); |
28 | int udp_input(),udp_ctlinput(); | |
b454c3ea | 29 | int udp_usrreq(); |
cc15ab5d BJ |
30 | int udp_init(); |
31 | int tcp_input(),tcp_ctlinput(); | |
b454c3ea | 32 | int tcp_usrreq(); |
cc15ab5d | 33 | int tcp_init(),tcp_fasttimo(),tcp_slowtimo(),tcp_drain(); |
c94ae9b7 | 34 | int rip_input(),rip_output(); |
d0e67d5f | 35 | |
8f4851aa BJ |
36 | /* |
37 | * IMP protocol family: raw interface | |
38 | */ | |
39 | #include "imp.h" | |
40 | #if NIMP > 0 | |
c94ae9b7 | 41 | int rimp_output(); |
6b1458f3 BJ |
42 | #endif |
43 | ||
44 | /* | |
45 | * PUP-I protocol family: raw interface | |
46 | */ | |
47 | #include "pup.h" | |
48 | #if NPUP > 0 | |
c94ae9b7 | 49 | int rpup_output(); |
8f4851aa BJ |
50 | #endif |
51 | ||
52 | /* | |
53 | * Sundries. | |
54 | */ | |
55 | int raw_init(),raw_usrreq(),raw_input(); | |
56 | ||
d0e67d5f | 57 | struct protosw protosw[] = { |
5b3fa994 | 58 | { SOCK_STREAM, PF_UNIX, 0, PR_CONNREQUIRED, |
07d8f161 | 59 | 0, 0, 0, 0, |
5b3fa994 | 60 | piusrreq, |
07d8f161 | 61 | 0, 0, 0, 0, |
cc15ab5d | 62 | }, |
5b3fa994 | 63 | { SOCK_DGRAM, PF_UNIX, 0, PR_ATOMIC|PR_ADDR, |
07d8f161 | 64 | 0, 0, 0, 0, |
5b3fa994 | 65 | piusrreq, |
07d8f161 | 66 | 0, 0, 0, 0, |
cc15ab5d | 67 | }, |
5b3fa994 | 68 | { SOCK_RDM, PF_UNIX, 0, PR_ATOMIC|PR_ADDR, |
cc15ab5d | 69 | 0, 0, 0, 0, |
5b3fa994 | 70 | piusrreq, |
cc15ab5d BJ |
71 | 0, 0, 0, 0, |
72 | }, | |
5b3fa994 | 73 | { SOCK_RAW, PF_UNIX, 0, PR_ATOMIC|PR_ADDR, |
cc15ab5d | 74 | 0, 0, 0, 0, |
5b3fa994 | 75 | piusrreq, |
cc15ab5d BJ |
76 | 0, 0, 0, 0, |
77 | }, | |
d0e67d5f | 78 | { 0, 0, 0, 0, |
0ef33f87 | 79 | 0, ip_output, 0, 0, |
5b3fa994 | 80 | 0, |
cc15ab5d BJ |
81 | ip_init, 0, ip_slowtimo, ip_drain, |
82 | }, | |
d0e67d5f | 83 | { 0, 0, IPPROTO_ICMP, 0, |
b454c3ea | 84 | icmp_input, 0, icmp_ctlinput, 0, |
5b3fa994 | 85 | 0, |
cc15ab5d BJ |
86 | 0, 0, 0, icmp_drain, |
87 | }, | |
07d8f161 | 88 | { SOCK_DGRAM, PF_INET, IPPROTO_UDP, PR_ATOMIC|PR_ADDR, |
cc15ab5d | 89 | udp_input, 0, udp_ctlinput, 0, |
5b3fa994 | 90 | udp_usrreq, |
cc15ab5d BJ |
91 | udp_init, 0, 0, 0, |
92 | }, | |
687794cc | 93 | { SOCK_STREAM, PF_INET, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD, |
cc15ab5d | 94 | tcp_input, 0, tcp_ctlinput, 0, |
5b3fa994 | 95 | tcp_usrreq, |
cc15ab5d BJ |
96 | tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain, |
97 | }, | |
8f4851aa BJ |
98 | { 0, 0, 0, 0, |
99 | raw_input, 0, 0, 0, | |
100 | raw_usrreq, | |
101 | raw_init, 0, 0, 0, | |
102 | }, | |
7859593f | 103 | { SOCK_RAW, PF_INET, IPPROTO_RAW, PR_ATOMIC|PR_ADDR, |
c94ae9b7 SL |
104 | rip_input, rip_output, 0, 0, |
105 | raw_usrreq, | |
8f4851aa BJ |
106 | 0, 0, 0, 0, |
107 | } | |
108 | #if NIMP > 0 | |
109 | , | |
110 | { SOCK_RAW, PF_IMPLINK, 0, PR_ATOMIC|PR_ADDR, | |
c94ae9b7 SL |
111 | 0, rimp_output, 0, 0, |
112 | raw_usrreq, | |
6b1458f3 BJ |
113 | 0, 0, 0, 0, |
114 | } | |
115 | #endif | |
116 | #if NPUP > 0 | |
117 | , | |
118 | { SOCK_RAW, PF_PUP, 0, PR_ATOMIC|PR_ADDR, | |
c94ae9b7 | 119 | 0, rpup_output, 0, 0, |
a907fb30 | 120 | raw_usrreq, |
8f4851aa | 121 | 0, 0, 0, 0, |
cc15ab5d | 122 | } |
8f4851aa | 123 | #endif |
d0e67d5f | 124 | }; |
cc15ab5d BJ |
125 | |
126 | #define NPROTOSW (sizeof(protosw) / sizeof(protosw[0])) | |
127 | ||
128 | struct protosw *protoswLAST = &protosw[NPROTOSW-1]; | |
d0e67d5f BJ |
129 | |
130 | /* | |
131 | * Operations on protocol table and protocol families. | |
132 | */ | |
133 | ||
cc15ab5d BJ |
134 | /* |
135 | * Initialize all protocols. | |
136 | */ | |
137 | pfinit() | |
138 | { | |
139 | register struct protosw *pr; | |
140 | ||
2b4b57cd | 141 | COUNT(PFINIT); |
cc15ab5d BJ |
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 | 151 | struct protosw * |
cc15ab5d | 152 | pffindtype(family, type) |
d0e67d5f BJ |
153 | int family, type; |
154 | { | |
155 | register struct protosw *pr; | |
156 | ||
2b4b57cd | 157 | COUNT(PFFINDTYPE); |
d0e67d5f BJ |
158 | if (family == 0) |
159 | return (0); | |
687794cc | 160 | for (pr = protosw; pr <= protoswLAST; pr++) |
d0e67d5f BJ |
161 | if (pr->pr_family == family && pr->pr_type == type) |
162 | return (pr); | |
163 | return (0); | |
164 | } | |
165 | ||
166 | /* | |
167 | * Find a specified protocol in a specified protocol family. | |
168 | */ | |
07d8f161 | 169 | struct protosw * |
cc15ab5d | 170 | pffindproto(family, protocol) |
07d8f161 | 171 | int family, protocol; |
d0e67d5f BJ |
172 | { |
173 | register struct protosw *pr; | |
174 | ||
2b4b57cd | 175 | COUNT(PFFINDPROTO); |
d0e67d5f BJ |
176 | if (family == 0) |
177 | return (0); | |
687794cc | 178 | for (pr = protosw; pr <= protoswLAST; pr++) |
07d8f161 | 179 | if (pr->pr_family == family && pr->pr_protocol == protocol) |
d0e67d5f BJ |
180 | return (pr); |
181 | return (0); | |
182 | } | |
72857acf BJ |
183 | |
184 | /* | |
185 | * Slow timeout on all protocols. | |
186 | */ | |
187 | pfslowtimo() | |
188 | { | |
189 | register struct protosw *pr; | |
190 | ||
191 | COUNT(PFSLOWTIMO); | |
192 | for (pr = protoswLAST; pr >= protosw; pr--) | |
193 | if (pr->pr_slowtimo) | |
194 | (*pr->pr_slowtimo)(); | |
195 | } | |
196 | ||
197 | pffasttimo() | |
198 | { | |
199 | register struct protosw *pr; | |
200 | ||
201 | COUNT(PFSLOWTIMO); | |
202 | for (pr = protoswLAST; pr >= protosw; pr--) | |
bdf22b53 BJ |
203 | if (pr->pr_fasttimo) |
204 | (*pr->pr_fasttimo)(); | |
72857acf | 205 | } |