1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// include/sys/protosw.h
|
4 |
|
|
//
|
5 |
|
|
//
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
9 |
|
|
//
|
10 |
|
|
// -------------------------------------------
|
11 |
|
|
//
|
12 |
|
|
// Portions of this software may have been derived from OpenBSD or other sources,
|
13 |
|
|
// and are covered by the appropriate copyright disclaimers included herein.
|
14 |
|
|
//
|
15 |
|
|
// -------------------------------------------
|
16 |
|
|
//
|
17 |
|
|
//####BSDCOPYRIGHTEND####
|
18 |
|
|
//==========================================================================
|
19 |
|
|
//#####DESCRIPTIONBEGIN####
|
20 |
|
|
//
|
21 |
|
|
// Author(s): gthomas
|
22 |
|
|
// Contributors: gthomas
|
23 |
|
|
// Date: 2000-01-10
|
24 |
|
|
// Purpose:
|
25 |
|
|
// Description:
|
26 |
|
|
//
|
27 |
|
|
//
|
28 |
|
|
//####DESCRIPTIONEND####
|
29 |
|
|
//
|
30 |
|
|
//==========================================================================
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/* $OpenBSD: protosw.h,v 1.3 1996/04/21 22:31:54 deraadt Exp $ */
|
34 |
|
|
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
|
35 |
|
|
|
36 |
|
|
/*-
|
37 |
|
|
* Copyright (c) 1982, 1986, 1993
|
38 |
|
|
* The Regents of the University of California. All rights reserved.
|
39 |
|
|
*
|
40 |
|
|
* Redistribution and use in source and binary forms, with or without
|
41 |
|
|
* modification, are permitted provided that the following conditions
|
42 |
|
|
* are met:
|
43 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
44 |
|
|
* notice, this list of conditions and the following disclaimer.
|
45 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
46 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
47 |
|
|
* documentation and/or other materials provided with the distribution.
|
48 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
49 |
|
|
* must display the following acknowledgement:
|
50 |
|
|
* This product includes software developed by the University of
|
51 |
|
|
* California, Berkeley and its contributors.
|
52 |
|
|
* 4. Neither the name of the University nor the names of its contributors
|
53 |
|
|
* may be used to endorse or promote products derived from this software
|
54 |
|
|
* without specific prior written permission.
|
55 |
|
|
*
|
56 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
57 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
58 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
59 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
60 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
61 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
62 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
63 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
64 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
65 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
66 |
|
|
* SUCH DAMAGE.
|
67 |
|
|
*
|
68 |
|
|
* @(#)protosw.h 8.1 (Berkeley) 6/2/93
|
69 |
|
|
*/
|
70 |
|
|
|
71 |
|
|
#ifndef _SYS_PROTOSW_H_
|
72 |
|
|
#define _SYS_PROTOSW_H_
|
73 |
|
|
|
74 |
|
|
/*
|
75 |
|
|
* Protocol switch table.
|
76 |
|
|
*
|
77 |
|
|
* Each protocol has a handle initializing one of these structures,
|
78 |
|
|
* which is used for protocol-protocol and system-protocol communication.
|
79 |
|
|
*
|
80 |
|
|
* A protocol is called through the pr_init entry before any other.
|
81 |
|
|
* Thereafter it is called every 200ms through the pr_fasttimo entry and
|
82 |
|
|
* every 500ms through the pr_slowtimo for timer based actions.
|
83 |
|
|
* The system will call the pr_drain entry if it is low on space and
|
84 |
|
|
* this should throw away any non-critical data.
|
85 |
|
|
*
|
86 |
|
|
* Protocols pass data between themselves as chains of mbufs using
|
87 |
|
|
* the pr_input and pr_output hooks. Pr_input passes data up (towards
|
88 |
|
|
* UNIX) and pr_output passes it down (towards the imps); control
|
89 |
|
|
* information passes up and down on pr_ctlinput and pr_ctloutput.
|
90 |
|
|
* The protocol is responsible for the space occupied by any the
|
91 |
|
|
* arguments to these entries and must dispose it.
|
92 |
|
|
*
|
93 |
|
|
* The userreq routine interfaces protocols to the system and is
|
94 |
|
|
* described below.
|
95 |
|
|
*/
|
96 |
|
|
|
97 |
|
|
struct mbuf;
|
98 |
|
|
struct sockaddr;
|
99 |
|
|
struct socket;
|
100 |
|
|
struct domain;
|
101 |
|
|
|
102 |
|
|
struct protosw {
|
103 |
|
|
short pr_type; /* socket type used for */
|
104 |
|
|
struct domain *pr_domain; /* domain protocol a member of */
|
105 |
|
|
short pr_protocol; /* protocol number */
|
106 |
|
|
short pr_flags; /* see below */
|
107 |
|
|
|
108 |
|
|
/* protocol-protocol hooks */
|
109 |
|
|
void (*pr_input) /* input to protocol (from below) */
|
110 |
|
|
__P((struct mbuf *, ...));
|
111 |
|
|
int (*pr_output) /* output to protocol (from above) */
|
112 |
|
|
__P((struct mbuf *, ...));
|
113 |
|
|
void *(*pr_ctlinput) /* control input (from below) */
|
114 |
|
|
__P((int, struct sockaddr *, void *));
|
115 |
|
|
int (*pr_ctloutput) /* control output (from above) */
|
116 |
|
|
__P((int, struct socket *, int, int, struct mbuf **));
|
117 |
|
|
|
118 |
|
|
/* user-protocol hook */
|
119 |
|
|
int (*pr_usrreq) /* user request: see list below */
|
120 |
|
|
__P((struct socket *, int, struct mbuf *,
|
121 |
|
|
struct mbuf *, struct mbuf *));
|
122 |
|
|
|
123 |
|
|
/* utility hooks */
|
124 |
|
|
void (*pr_init) /* initialization hook */
|
125 |
|
|
__P((void));
|
126 |
|
|
|
127 |
|
|
void (*pr_fasttimo) /* fast timeout (200ms) */
|
128 |
|
|
__P((void));
|
129 |
|
|
void (*pr_slowtimo) /* slow timeout (500ms) */
|
130 |
|
|
__P((void));
|
131 |
|
|
void (*pr_drain) /* flush any excess space possible */
|
132 |
|
|
__P((void));
|
133 |
|
|
int (*pr_sysctl) /* sysctl for protocol */
|
134 |
|
|
__P((int *, u_int, void *, size_t *, void *, size_t));
|
135 |
|
|
};
|
136 |
|
|
|
137 |
|
|
#define PR_SLOWHZ 2 /* 2 slow timeouts per second */
|
138 |
|
|
#define PR_FASTHZ 5 /* 5 fast timeouts per second */
|
139 |
|
|
|
140 |
|
|
/*
|
141 |
|
|
* Values for pr_flags.
|
142 |
|
|
* PR_ADDR requires PR_ATOMIC;
|
143 |
|
|
* PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
|
144 |
|
|
*/
|
145 |
|
|
#define PR_ATOMIC 0x01 /* exchange atomic messages only */
|
146 |
|
|
#define PR_ADDR 0x02 /* addresses given with messages */
|
147 |
|
|
#define PR_CONNREQUIRED 0x04 /* connection required by protocol */
|
148 |
|
|
#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
|
149 |
|
|
#define PR_RIGHTS 0x10 /* passes capabilities */
|
150 |
|
|
|
151 |
|
|
/*
|
152 |
|
|
* The arguments to usrreq are:
|
153 |
|
|
* (*protosw[].pr_usrreq)(up, req, m, nam, opt);
|
154 |
|
|
* where up is a (struct socket *), req is one of these requests,
|
155 |
|
|
* m is a optional mbuf chain containing a message,
|
156 |
|
|
* nam is an optional mbuf chain containing an address,
|
157 |
|
|
* and opt is a pointer to a socketopt structure or nil.
|
158 |
|
|
* The protocol is responsible for disposal of the mbuf chain m,
|
159 |
|
|
* the caller is responsible for any space held by nam and opt.
|
160 |
|
|
* A non-zero return from usrreq gives an
|
161 |
|
|
* UNIX error number which should be passed to higher level software.
|
162 |
|
|
*/
|
163 |
|
|
#define PRU_ATTACH 0 /* attach protocol to up */
|
164 |
|
|
#define PRU_DETACH 1 /* detach protocol from up */
|
165 |
|
|
#define PRU_BIND 2 /* bind socket to address */
|
166 |
|
|
#define PRU_LISTEN 3 /* listen for connection */
|
167 |
|
|
#define PRU_CONNECT 4 /* establish connection to peer */
|
168 |
|
|
#define PRU_ACCEPT 5 /* accept connection from peer */
|
169 |
|
|
#define PRU_DISCONNECT 6 /* disconnect from peer */
|
170 |
|
|
#define PRU_SHUTDOWN 7 /* won't send any more data */
|
171 |
|
|
#define PRU_RCVD 8 /* have taken data; more room now */
|
172 |
|
|
#define PRU_SEND 9 /* send this data */
|
173 |
|
|
#define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */
|
174 |
|
|
#define PRU_CONTROL 11 /* control operations on protocol */
|
175 |
|
|
#define PRU_SENSE 12 /* return status into m */
|
176 |
|
|
#define PRU_RCVOOB 13 /* retrieve out of band data */
|
177 |
|
|
#define PRU_SENDOOB 14 /* send out of band data */
|
178 |
|
|
#define PRU_SOCKADDR 15 /* fetch socket's address */
|
179 |
|
|
#define PRU_PEERADDR 16 /* fetch peer's address */
|
180 |
|
|
#define PRU_CONNECT2 17 /* connect two sockets */
|
181 |
|
|
/* begin for protocols internal use */
|
182 |
|
|
#define PRU_FASTTIMO 18 /* 200ms timeout */
|
183 |
|
|
#define PRU_SLOWTIMO 19 /* 500ms timeout */
|
184 |
|
|
#define PRU_PROTORCV 20 /* receive from below */
|
185 |
|
|
#define PRU_PROTOSEND 21 /* send to below */
|
186 |
|
|
|
187 |
|
|
#define PRU_NREQ 21
|
188 |
|
|
|
189 |
|
|
#ifdef PRUREQUESTS
|
190 |
|
|
char *prurequests[] = {
|
191 |
|
|
"ATTACH", "DETACH", "BIND", "LISTEN",
|
192 |
|
|
"CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN",
|
193 |
|
|
"RCVD", "SEND", "ABORT", "CONTROL",
|
194 |
|
|
"SENSE", "RCVOOB", "SENDOOB", "SOCKADDR",
|
195 |
|
|
"PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO",
|
196 |
|
|
"PROTORCV", "PROTOSEND",
|
197 |
|
|
};
|
198 |
|
|
#endif
|
199 |
|
|
|
200 |
|
|
/*
|
201 |
|
|
* The arguments to the ctlinput routine are
|
202 |
|
|
* (*protosw[].pr_ctlinput)(cmd, sa, arg);
|
203 |
|
|
* where cmd is one of the commands below, sa is a pointer to a sockaddr,
|
204 |
|
|
* and arg is an optional caddr_t argument used within a protocol family.
|
205 |
|
|
*/
|
206 |
|
|
#define PRC_IFDOWN 0 /* interface transition */
|
207 |
|
|
#define PRC_ROUTEDEAD 1 /* select new route if possible ??? */
|
208 |
|
|
#define PRC_QUENCH2 3 /* DEC congestion bit says slow down */
|
209 |
|
|
#define PRC_QUENCH 4 /* some one said to slow down */
|
210 |
|
|
#define PRC_MSGSIZE 5 /* message size forced drop */
|
211 |
|
|
#define PRC_HOSTDEAD 6 /* host appears to be down */
|
212 |
|
|
#define PRC_HOSTUNREACH 7 /* deprecated (use PRC_UNREACH_HOST) */
|
213 |
|
|
#define PRC_UNREACH_NET 8 /* no route to network */
|
214 |
|
|
#define PRC_UNREACH_HOST 9 /* no route to host */
|
215 |
|
|
#define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */
|
216 |
|
|
#define PRC_UNREACH_PORT 11 /* bad port # */
|
217 |
|
|
/* was PRC_UNREACH_NEEDFRAG 12 (use PRC_MSGSIZE) */
|
218 |
|
|
#define PRC_UNREACH_SRCFAIL 13 /* source route failed */
|
219 |
|
|
#define PRC_REDIRECT_NET 14 /* net routing redirect */
|
220 |
|
|
#define PRC_REDIRECT_HOST 15 /* host routing redirect */
|
221 |
|
|
#define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */
|
222 |
|
|
#define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */
|
223 |
|
|
#define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */
|
224 |
|
|
#define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */
|
225 |
|
|
#define PRC_PARAMPROB 20 /* header incorrect */
|
226 |
|
|
|
227 |
|
|
#define PRC_NCMDS 21
|
228 |
|
|
|
229 |
|
|
#define PRC_IS_REDIRECT(cmd) \
|
230 |
|
|
((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)
|
231 |
|
|
|
232 |
|
|
#ifdef PRCREQUESTS
|
233 |
|
|
char *prcrequests[] = {
|
234 |
|
|
"IFDOWN", "ROUTEDEAD", "#2", "DEC-BIT-QUENCH2",
|
235 |
|
|
"QUENCH", "MSGSIZE", "HOSTDEAD", "#7",
|
236 |
|
|
"NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
|
237 |
|
|
"#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
|
238 |
|
|
"TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
|
239 |
|
|
"PARAMPROB"
|
240 |
|
|
};
|
241 |
|
|
#endif
|
242 |
|
|
|
243 |
|
|
/*
|
244 |
|
|
* The arguments to ctloutput are:
|
245 |
|
|
* (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
|
246 |
|
|
* req is one of the actions listed below, so is a (struct socket *),
|
247 |
|
|
* level is an indication of which protocol layer the option is intended.
|
248 |
|
|
* optname is a protocol dependent socket option request,
|
249 |
|
|
* optval is a pointer to a mbuf-chain pointer, for value-return results.
|
250 |
|
|
* The protocol is responsible for disposal of the mbuf chain *optval
|
251 |
|
|
* if supplied,
|
252 |
|
|
* the caller is responsible for any space held by *optval, when returned.
|
253 |
|
|
* A non-zero return from usrreq gives an
|
254 |
|
|
* UNIX error number which should be passed to higher level software.
|
255 |
|
|
*/
|
256 |
|
|
#define PRCO_GETOPT 0
|
257 |
|
|
#define PRCO_SETOPT 1
|
258 |
|
|
|
259 |
|
|
#define PRCO_NCMDS 2
|
260 |
|
|
|
261 |
|
|
#ifdef PRCOREQUESTS
|
262 |
|
|
char *prcorequests[] = {
|
263 |
|
|
"GETOPT", "SETOPT",
|
264 |
|
|
};
|
265 |
|
|
#endif
|
266 |
|
|
|
267 |
|
|
#ifdef _KERNEL
|
268 |
|
|
struct sockaddr;
|
269 |
|
|
struct protosw *pffindproto __P((int, int, int));
|
270 |
|
|
struct protosw *pffindtype __P((int, int));
|
271 |
|
|
void pfctlinput __P((int, struct sockaddr *));
|
272 |
|
|
#endif
|
273 |
|
|
|
274 |
|
|
#endif // _SYS_PROTOSW_H_
|