2 * Copyright (C) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
3 * Helsinki University of Technology, Finland.
5 * Copyright (C) 2005 Neil Cafferkey
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24 * Copyright (c) 1982, 1986 The Regents of the University of California.
25 * All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgement:
37 * This product includes software developed by the University of
38 * California, Berkeley and its contributors.
39 * 4. Neither the name of the University nor the names of its contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * @(#)protosw.h 7.8 (Berkeley) 4/28/91
61 #include <sys/cdefs.h>
64 * Protocol switch table.
66 * Each protocol has a handle initializing one of these structures,
67 * which is used for protocol-protocol and system-protocol communication.
69 * A protocol is called through the pr_init entry before any other.
70 * Thereafter it is called every 200ms through the pr_fasttimo entry and
71 * every 500ms through the pr_slowtimo for timer based actions.
72 * The system will call the pr_drain entry if it is low on space and
73 * this should throw away any non-critical data.
75 * Protocols pass data between themselves as chains of mbufs using
76 * the pr_input and pr_output hooks. Pr_input passes data up (towards
77 * UNIX) and pr_output passes it down (towards the imps); control
78 * information passes up and down on pr_ctlinput and pr_ctloutput.
79 * The protocol is responsible for the space occupied by any the
80 * arguments to these entries and must dispose it.
82 * The userreq routine interfaces protocols to the system and is
91 short pr_type
; /* socket type used for */
92 struct domain
*pr_domain
; /* domain protocol a member of */
93 short pr_protocol
; /* protocol number */
94 short pr_flags
; /* see below */
95 /* protocol-protocol hooks */
96 void (*pr_input
)(void *args
, ...); /* input to protocol (from below) */
97 int (*pr_output
)(void *args
, ...); /* output to protocol (from above) */
98 void (*pr_ctlinput
)(int cmd
, /* control input (from below) */
99 struct sockaddr
*sa
, void *arg
);
100 int (*pr_ctloutput
)(int req
, /* control output (from above) */
101 struct socket
*so
, int level
, int optname
,
102 struct mbuf
**optval
);
103 /* user-protocol hook */
104 int (*pr_usrreq
)(struct socket
*,/* user request: see list below */
105 int req
, struct mbuf
*m
, struct mbuf
*nam
,
106 struct mbuf
*control
);
108 void (*pr_init
)(void); /* initialization hook */
109 void (*pr_fasttimo
)(void); /* fast timeout (200ms) */
110 void (*pr_slowtimo
)(void); /* slow timeout (500ms) */
111 void (*pr_drain
)(void); /* flush any excess space possible */
114 #define PR_SLOWHZ 2 /* 2 slow timeouts per second */
115 #define PR_FASTHZ 5 /* 5 fast timeouts per second */
118 * Values for pr_flags.
119 * PR_ADDR requires PR_ATOMIC;
120 * PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
122 #define PR_ATOMIC 0x01 /* exchange atomic messages only */
123 #define PR_ADDR 0x02 /* addresses given with messages */
124 #define PR_CONNREQUIRED 0x04 /* connection required by protocol */
125 #define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
126 #define PR_RIGHTS 0x10 /* passes capabilities */
127 #define PR_IMPLOPCL 0x20 /* implied open/close */
130 * The arguments to usrreq are:
131 * (*protosw[].pr_usrreq)(up, req, m, nam, opt);
132 * where up is a (struct socket *), req is one of these requests,
133 * m is a optional mbuf chain containing a message,
134 * nam is an optional mbuf chain containing an address,
135 * and opt is a pointer to a socketopt structure or nil.
136 * The protocol is responsible for disposal of the mbuf chain m,
137 * the caller is responsible for any space held by nam and opt.
138 * A non-zero return from usrreq gives an
139 * UNIX error number which should be passed to higher level software.
141 #define PRU_ATTACH 0 /* attach protocol to up */
142 #define PRU_DETACH 1 /* detach protocol from up */
143 #define PRU_BIND 2 /* bind socket to address */
144 #define PRU_LISTEN 3 /* listen for connection */
145 #define PRU_CONNECT 4 /* establish connection to peer */
146 #define PRU_ACCEPT 5 /* accept connection from peer */
147 #define PRU_DISCONNECT 6 /* disconnect from peer */
148 #define PRU_SHUTDOWN 7 /* won't send any more data */
149 #define PRU_RCVD 8 /* have taken data; more room now */
150 #define PRU_SEND 9 /* send this data */
151 #define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */
152 #define PRU_CONTROL 11 /* control operations on protocol */
153 #define PRU_SENSE 12 /* return status into m */
154 #define PRU_RCVOOB 13 /* retrieve out of band data */
155 #define PRU_SENDOOB 14 /* send out of band data */
156 #define PRU_SOCKADDR 15 /* fetch socket's address */
157 #define PRU_PEERADDR 16 /* fetch peer's address */
158 #define PRU_CONNECT2 17 /* connect two sockets */
159 /* begin for protocols internal use */
160 #define PRU_FASTTIMO 18 /* 200ms timeout */
161 #define PRU_SLOWTIMO 19 /* 500ms timeout */
162 #define PRU_PROTORCV 20 /* receive from below */
163 #define PRU_PROTOSEND 21 /* send to below */
164 #define PRU_SEND_EOF 22 /* send and close */
169 * moved prurequests array definition to netinet/tcp_debug.c
172 extern char *prurequests
[];
176 * The arguments to the ctlinput routine are
177 * (*protosw[].pr_ctlinput)(cmd, sa, arg);
178 * where cmd is one of the commands below, sa is a pointer to a sockaddr,
179 * and arg is an optional caddr_t argument used within a protocol family.
181 #define PRC_IFDOWN 0 /* interface transition */
182 #define PRC_ROUTEDEAD 1 /* select new route if possible ??? */
183 #define PRC_QUENCH2 3 /* DEC congestion bit says slow down */
184 #define PRC_QUENCH 4 /* some one said to slow down */
185 #define PRC_MSGSIZE 5 /* message size forced drop */
186 #define PRC_HOSTDEAD 6 /* host appears to be down */
187 #define PRC_HOSTUNREACH 7 /* deprecated (use PRC_UNREACH_HOST) */
188 #define PRC_UNREACH_NET 8 /* no route to network */
189 #define PRC_UNREACH_HOST 9 /* no route to host */
190 #define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */
191 #define PRC_UNREACH_PORT 11 /* bad port # */
192 /* was PRC_UNREACH_NEEDFRAG 12 (use PRC_MSGSIZE) */
193 #define PRC_UNREACH_SRCFAIL 13 /* source route failed */
194 #define PRC_REDIRECT_NET 14 /* net routing redirect */
195 #define PRC_REDIRECT_HOST 15 /* host routing redirect */
196 #define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */
197 #define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */
198 #define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */
199 #define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */
200 #define PRC_PARAMPROB 20 /* header incorrect */
204 #define PRC_IS_REDIRECT(cmd) \
205 ((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)
207 #ifndef AMITCP /* this would define storage in header, ugly */
209 char *prcrequests
[] = {
210 "IFDOWN", "ROUTEDEAD", "#2", "DEC-BIT-QUENCH2",
211 "QUENCH", "MSGSIZE", "HOSTDEAD", "#7",
212 "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
213 "#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
214 "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
221 * The arguments to ctloutput are:
222 * (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
223 * req is one of the actions listed below, so is a (struct socket *),
224 * level is an indication of which protocol layer the option is intended.
225 * optname is a protocol dependent socket option request,
226 * optval is a pointer to a mbuf-chain pointer, for value-return results.
227 * The protocol is responsible for disposal of the mbuf chain *optval
229 * the caller is responsible for any space held by *optval, when returned.
230 * A non-zero return from usrreq gives an
231 * UNIX error number which should be passed to higher level software.
233 #define PRCO_GETOPT 0
234 #define PRCO_SETOPT 1
238 #ifndef AMITCP /* this would define storage in header, ugly */
240 char *prcorequests
[] = {
246 extern struct protosw
*pffindproto(), *pffindtype();
250 #endif /* !SYS_PROTOSW_H */