Commit | Line | Data |
---|---|---|
07d8f161 BJ |
1 | /* uipc_proto.c 4.2 81/11/08 */ |
2 | ||
d0e67d5f | 3 | #include "../h/param.h" |
07d8f161 BJ |
4 | #include "../h/socket.h" |
5 | #include "../h/protocol.h" | |
6 | #include "../h/protosw.h" | |
7 | #include "../h/mbuf.h" | |
8 | #include "../net/inet.h" | |
9 | ||
d0e67d5f BJ |
10 | /* should include a header file giving desired protocols */ |
11 | #define NTCP 1 | |
12 | ||
13 | /* | |
14 | * Protocol configuration table and routines to search it. | |
15 | */ | |
16 | ||
17 | /* | |
18 | * Generic (local or not yet specified) protocol. | |
19 | */ | |
20 | int gen_usrreq(); | |
21 | ||
22 | #if NTCP > 0 | |
23 | /* | |
24 | * TCP/IP protocol family: IP, ICMP, UDP, TCP. | |
25 | */ | |
07d8f161 BJ |
26 | int ip_init(),ip_input(),ip_output(),ip_advise(),ip_slowtimo(),ip_drain(); |
27 | int icmp_input(),icmp_drain(); | |
d0e67d5f | 28 | int udp_input(),udp_advise(),udp_usrreq(),udp_sense(); |
07d8f161 BJ |
29 | int tcp_init(),tcp_input(),tcp_advise(),tcp_fasttimo(),tcp_slowtimo(), |
30 | tcp_usrreq(),tcp_drain(),tcp_sense(); | |
31 | int ri_input(),ri_advise(),ri_usrreq(),ri_sense(); | |
d0e67d5f BJ |
32 | #endif |
33 | ||
34 | #if NPUP > 0 | |
35 | /* | |
36 | * Pup protocols: PUP, BSP. | |
37 | */ | |
38 | int pup1_input(),pup1_output(),pup1_advise(),pup1_slowtimo(), | |
39 | pup1_drain(),pup1_usrreq(),pup1_sense(); | |
40 | int bsp_input(),bsp_advise(),bsp_fasttimo(),bsp_slowtimo(), | |
41 | bsp_drain(),bsp_usrreq(),bsp_sense(); | |
42 | int rawpup_input(),rawpup_usrreq(),rawpup_sense(); | |
43 | #endif | |
44 | ||
45 | #if NCHAOS > 0 | |
46 | /* | |
47 | * Chaosnet protocols. | |
48 | */ | |
49 | /* ... */ | |
50 | #endif | |
51 | ||
52 | #if NOISCP > 0 | |
53 | /* | |
54 | * Office information system communcation protocols. | |
55 | */ | |
56 | /* ... */ | |
57 | #endif | |
58 | ||
59 | #if NNBS > 0 | |
60 | /* | |
61 | * NBS protocols. | |
62 | */ | |
63 | /* ... */ | |
64 | #endif | |
65 | ||
66 | #if NECMA > 0 | |
67 | /* | |
68 | * ECMA protocols. | |
69 | */ | |
70 | /* ... */ | |
71 | #endif | |
72 | ||
73 | #if NDATAKIT > 0 | |
74 | /* | |
75 | * Datakit protocols. | |
76 | */ | |
77 | /* ... */ | |
78 | #endif | |
79 | ||
80 | struct protosw protosw[] = { | |
81 | { SOCK_STREAM, PF_GENERIC, 0, 0, | |
07d8f161 | 82 | 0, 0, 0, 0, |
d0e67d5f BJ |
83 | 0, 0, 0, gen_usrreq, 0, |
84 | 0 }, | |
07d8f161 BJ |
85 | { SOCK_DGRAM, PF_GENERIC, 0, PR_ATOMIC|PR_ADDR, |
86 | 0, 0, 0, 0, | |
d0e67d5f BJ |
87 | 0, 0, 0, gen_usrreq, 0, |
88 | 0 }, | |
07d8f161 BJ |
89 | { SOCK_RDM, PF_GENERIC, 0, PR_ATOMIC|PR_ADDR, |
90 | 0, 0, 0, 0, | |
d0e67d5f BJ |
91 | 0, 0, 0, gen_usrreq, 0, |
92 | 0 }, | |
07d8f161 BJ |
93 | { SOCK_RAW, PF_GENERIC, 0, PR_ATOMIC|PR_ADDR, |
94 | 0, 0, 0, 0, | |
d0e67d5f | 95 | 0, 0, 0, gen_usrreq, 0, |
07d8f161 | 96 | 0 }, |
d0e67d5f BJ |
97 | #if NTCP > 0 |
98 | { 0, 0, 0, 0, | |
07d8f161 | 99 | ip_init, ip_input, ip_output, 0, |
d0e67d5f BJ |
100 | 0, ip_slowtimo, ip_drain, 0, 0, |
101 | 0 }, | |
102 | { 0, 0, IPPROTO_ICMP, 0, | |
07d8f161 | 103 | 0, icmp_input, 0, 0, |
d0e67d5f BJ |
104 | 0, 0, icmp_drain, 0, 0, |
105 | 0 }, | |
07d8f161 BJ |
106 | { SOCK_DGRAM, PF_INET, IPPROTO_UDP, PR_ATOMIC|PR_ADDR, |
107 | 0, udp_input, 0, udp_advise, | |
d0e67d5f BJ |
108 | 0, 0, 0, udp_usrreq, udp_sense, |
109 | MLEN }, | |
110 | { SOCK_STREAM, PF_INET, IPPROTO_TCP, 0, | |
07d8f161 | 111 | tcp_init, tcp_input, 0, tcp_advise, |
d0e67d5f BJ |
112 | tcp_fasttimo, tcp_slowtimo, tcp_drain, tcp_usrreq, tcp_sense, |
113 | MLEN }, | |
07d8f161 BJ |
114 | { SOCK_RAW, PF_INET, IPPROTO_RAW, PR_ATOMIC|PR_ADDR, |
115 | 0, ri_input, 0, ri_advise, | |
116 | 0, 0, 0, ri_usrreq, ri_sense, | |
d0e67d5f BJ |
117 | MLEN }, |
118 | #endif | |
119 | #if NPUP > 0 | |
07d8f161 BJ |
120 | { SOCK_DGRAM, PF_PUP, 0, PR_ATOMIC|PR_ADDR, |
121 | pup_init, pup_input, pup_output, pup_advise, | |
d0e67d5f BJ |
122 | 0, pup_slowtimo, pup_drain, pup_usrreq, pup_sense, |
123 | MLEN }, | |
124 | { SOCK_STREAM, PF_PUP1, PUPPROTO_BSP, 0, | |
07d8f161 | 125 | bsp_init, bsp_input, 0, bsp_advise, |
d0e67d5f BJ |
126 | bsp_fasttimo, bsp_slowtimo, bsp_drain, bsp_usrreq, bsp_sense, |
127 | MLEN }, | |
07d8f161 BJ |
128 | { SOCK_RAW, PF_PUP1, PUPPROTO_RAW, PR_ATOMIC|PR_ADDR, |
129 | rp_init, rp_input, 0, rp_advise, | |
d0e67d5f BJ |
130 | rp_fasttimo, rp_slowtimo, rp_drain, rp_usrreq, rp_sense, |
131 | MLEN }, | |
132 | #endif | |
133 | #if NCHAOS > 0 | |
134 | /* ... */ | |
135 | #endif | |
136 | #if NOISCP > 0 | |
137 | /* ... */ | |
138 | #endif | |
139 | #if NNBS > 0 | |
140 | /* ... */ | |
141 | #endif | |
142 | #if NECMA > 0 | |
143 | /* ... */ | |
144 | #endif | |
145 | #if NDATAKIT > 0 | |
146 | /* ... */ | |
147 | #endif | |
148 | }; | |
149 | #define protoswEND &protosw[sizeof (protosw)/sizeof (protosw[0])] | |
150 | ||
151 | /* | |
152 | * Operations on protocol table and protocol families. | |
153 | */ | |
154 | ||
155 | /* | |
156 | * Find a standard protocol in a protocol family | |
157 | * of a specific type. | |
158 | */ | |
07d8f161 BJ |
159 | struct protosw * |
160 | pf_findtype(family, type) | |
d0e67d5f BJ |
161 | int family, type; |
162 | { | |
163 | register struct protosw *pr; | |
164 | ||
165 | if (family == 0) | |
166 | return (0); | |
167 | for (pr = protosw; pr < protoswEND; pr++) | |
168 | if (pr->pr_family == family && pr->pr_type == type) | |
169 | return (pr); | |
170 | return (0); | |
171 | } | |
172 | ||
173 | /* | |
174 | * Find a specified protocol in a specified protocol family. | |
175 | */ | |
07d8f161 BJ |
176 | struct protosw * |
177 | pf_findproto(family, protocol) | |
178 | int family, protocol; | |
d0e67d5f BJ |
179 | { |
180 | register struct protosw *pr; | |
181 | ||
182 | if (family == 0) | |
183 | return (0); | |
184 | for (pr = protosw; pr < protoswEND; pr++) | |
07d8f161 | 185 | if (pr->pr_family == family && pr->pr_protocol == protocol) |
d0e67d5f BJ |
186 | return (pr); |
187 | return (0); | |
188 | } | |
07d8f161 BJ |
189 | |
190 | prinit() | |
191 | { | |
192 | ||
193 | } |