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