xref: /titanic_44/usr/src/uts/common/sys/protosw.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1991 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
32*7c478bd9Sstevel@tonic-gate  * The Regents of the University of California
33*7c478bd9Sstevel@tonic-gate  * All Rights Reserved
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
36*7c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
37*7c478bd9Sstevel@tonic-gate  * contributors.
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifndef _SYS_PROTOSW_H
41*7c478bd9Sstevel@tonic-gate #define	_SYS_PROTOSW_H
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
46*7c478bd9Sstevel@tonic-gate extern "C" {
47*7c478bd9Sstevel@tonic-gate #endif
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate /*
50*7c478bd9Sstevel@tonic-gate  * Protocol switch table.
51*7c478bd9Sstevel@tonic-gate  *
52*7c478bd9Sstevel@tonic-gate  * Each protocol has a handle initializing one of these structures,
53*7c478bd9Sstevel@tonic-gate  * which is used for protocol-protocol and system-protocol communication.
54*7c478bd9Sstevel@tonic-gate  *
55*7c478bd9Sstevel@tonic-gate  * A protocol is called through the pr_init entry before any other.
56*7c478bd9Sstevel@tonic-gate  * Thereafter it is called every 200ms through the pr_fasttimo entry and
57*7c478bd9Sstevel@tonic-gate  * every 500ms through the pr_slowtimo for timer based actions.
58*7c478bd9Sstevel@tonic-gate  * The system will call the pr_drain entry if it is low on space and
59*7c478bd9Sstevel@tonic-gate  * this should throw away any non-critical data.
60*7c478bd9Sstevel@tonic-gate  *
61*7c478bd9Sstevel@tonic-gate  * Protocols pass data between themselves as chains of mbufs using
62*7c478bd9Sstevel@tonic-gate  * the pr_input and pr_output hooks.  Pr_input passes data up (towards
63*7c478bd9Sstevel@tonic-gate  * UNIX) and pr_output passes it down (towards the imps); control
64*7c478bd9Sstevel@tonic-gate  * information passes up and down on pr_ctlinput and pr_ctloutput.
65*7c478bd9Sstevel@tonic-gate  * The protocol is responsible for the space occupied by any the
66*7c478bd9Sstevel@tonic-gate  * arguments to these entries and must dispose it.
67*7c478bd9Sstevel@tonic-gate  *
68*7c478bd9Sstevel@tonic-gate  * The userreq routine interfaces protocols to the system and is
69*7c478bd9Sstevel@tonic-gate  * described below.
70*7c478bd9Sstevel@tonic-gate  */
71*7c478bd9Sstevel@tonic-gate struct protosw {
72*7c478bd9Sstevel@tonic-gate 	short	pr_type;		/* socket type used for */
73*7c478bd9Sstevel@tonic-gate 	struct	domain *pr_domain;	/* domain protocol a member of */
74*7c478bd9Sstevel@tonic-gate 	short	pr_protocol;		/* protocol number */
75*7c478bd9Sstevel@tonic-gate 	short	pr_flags;		/* see below */
76*7c478bd9Sstevel@tonic-gate /* protocol-protocol hooks */
77*7c478bd9Sstevel@tonic-gate 	int	(*pr_input)();		/* input to protocol (from below) */
78*7c478bd9Sstevel@tonic-gate 	int	(*pr_output)();		/* output to protocol (from above) */
79*7c478bd9Sstevel@tonic-gate 	int	(*pr_ctlinput)();	/* control input (from below) */
80*7c478bd9Sstevel@tonic-gate 	int	(*pr_ctloutput)();	/* control output (from above) */
81*7c478bd9Sstevel@tonic-gate /* user-protocol hook */
82*7c478bd9Sstevel@tonic-gate 	int	(*pr_usrreq)();		/* user request: see list below */
83*7c478bd9Sstevel@tonic-gate /* utility hooks */
84*7c478bd9Sstevel@tonic-gate 	int	(*pr_init)();		/* initialization hook */
85*7c478bd9Sstevel@tonic-gate 	int	(*pr_fasttimo)();	/* fast timeout (200ms) */
86*7c478bd9Sstevel@tonic-gate 	int	(*pr_slowtimo)();	/* slow timeout (500ms) */
87*7c478bd9Sstevel@tonic-gate 	int	(*pr_drain)();		/* flush any excess space possible */
88*7c478bd9Sstevel@tonic-gate };
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate #define	PR_SLOWHZ	2		/* 2 slow timeouts per second */
91*7c478bd9Sstevel@tonic-gate #define	PR_FASTHZ	5		/* 5 fast timeouts per second */
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /*
94*7c478bd9Sstevel@tonic-gate  * Values for pr_flags
95*7c478bd9Sstevel@tonic-gate  */
96*7c478bd9Sstevel@tonic-gate #define	PR_ATOMIC	0x01		/* exchange atomic messages only */
97*7c478bd9Sstevel@tonic-gate #define	PR_ADDR		0x02		/* addresses given with messages */
98*7c478bd9Sstevel@tonic-gate /* in the current implementation, PR_ADDR needs PR_ATOMIC to work */
99*7c478bd9Sstevel@tonic-gate #define	PR_CONNREQUIRED	0x04		/* connection required by protocol */
100*7c478bd9Sstevel@tonic-gate #define	PR_WANTRCVD	0x08		/* want PRU_RCVD calls */
101*7c478bd9Sstevel@tonic-gate #define	PR_RIGHTS	0x10		/* passes capabilities */
102*7c478bd9Sstevel@tonic-gate #define	PR_OOB_ADDR	0x20		/* addresses given with OOB data */
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate /*
105*7c478bd9Sstevel@tonic-gate  * The arguments to usrreq are:
106*7c478bd9Sstevel@tonic-gate  *	(*protosw[].pr_usrreq)(up, req, m, nam, opt);
107*7c478bd9Sstevel@tonic-gate  * where up is a (struct socket *), req is one of these requests,
108*7c478bd9Sstevel@tonic-gate  * m is a optional mbuf chain containing a message,
109*7c478bd9Sstevel@tonic-gate  * nam is an optional mbuf chain containing an address,
110*7c478bd9Sstevel@tonic-gate  * and opt is a pointer to a socketopt structure or nil.
111*7c478bd9Sstevel@tonic-gate  * The protocol is responsible for disposal of the mbuf chain m,
112*7c478bd9Sstevel@tonic-gate  * the caller is responsible for any space held by nam and opt.
113*7c478bd9Sstevel@tonic-gate  * A non-zero return from usrreq gives an
114*7c478bd9Sstevel@tonic-gate  * UNIX error number which should be passed to higher level software.
115*7c478bd9Sstevel@tonic-gate  */
116*7c478bd9Sstevel@tonic-gate #define	PRU_ATTACH		0	/* attach protocol to up */
117*7c478bd9Sstevel@tonic-gate #define	PRU_DETACH		1	/* detach protocol from up */
118*7c478bd9Sstevel@tonic-gate #define	PRU_BIND		2	/* bind socket to address */
119*7c478bd9Sstevel@tonic-gate #define	PRU_LISTEN		3	/* listen for connection */
120*7c478bd9Sstevel@tonic-gate #define	PRU_CONNECT		4	/* establish connection to peer */
121*7c478bd9Sstevel@tonic-gate #define	PRU_ACCEPT		5	/* accept connection from peer */
122*7c478bd9Sstevel@tonic-gate #define	PRU_DISCONNECT		6	/* disconnect from peer */
123*7c478bd9Sstevel@tonic-gate #define	PRU_SHUTDOWN		7	/* won't send any more data */
124*7c478bd9Sstevel@tonic-gate #define	PRU_RCVD		8	/* have taken data; more room now */
125*7c478bd9Sstevel@tonic-gate #define	PRU_SEND		9	/* send this data */
126*7c478bd9Sstevel@tonic-gate #define	PRU_ABORT		10	/* abort (fast DISCONNECT, DETATCH) */
127*7c478bd9Sstevel@tonic-gate #define	PRU_CONTROL		11	/* control operations on protocol */
128*7c478bd9Sstevel@tonic-gate #define	PRU_SENSE		12	/* return status into m */
129*7c478bd9Sstevel@tonic-gate #define	PRU_RCVOOB		13	/* retrieve out of band data */
130*7c478bd9Sstevel@tonic-gate #define	PRU_SENDOOB		14	/* send out of band data */
131*7c478bd9Sstevel@tonic-gate #define	PRU_SOCKADDR		15	/* fetch socket's address */
132*7c478bd9Sstevel@tonic-gate #define	PRU_PEERADDR		16	/* fetch peer's address */
133*7c478bd9Sstevel@tonic-gate #define	PRU_CONNECT2		17	/* connect two sockets */
134*7c478bd9Sstevel@tonic-gate /* begin for protocols internal use */
135*7c478bd9Sstevel@tonic-gate #define	PRU_FASTTIMO		18	/* 200ms timeout */
136*7c478bd9Sstevel@tonic-gate #define	PRU_SLOWTIMO		19	/* 500ms timeout */
137*7c478bd9Sstevel@tonic-gate #define	PRU_PROTORCV		20	/* receive from below */
138*7c478bd9Sstevel@tonic-gate #define	PRU_PROTOSEND		21	/* send to below */
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate #define	PRU_NREQ		21
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate #ifdef PRUREQUESTS
143*7c478bd9Sstevel@tonic-gate char *prurequests[] = {
144*7c478bd9Sstevel@tonic-gate 	"ATTACH",	"DETACH",	"BIND",		"LISTEN",
145*7c478bd9Sstevel@tonic-gate 	"CONNECT",	"ACCEPT",	"DISCONNECT",	"SHUTDOWN",
146*7c478bd9Sstevel@tonic-gate 	"RCVD",		"SEND",		"ABORT",	"CONTROL",
147*7c478bd9Sstevel@tonic-gate 	"SENSE",	"RCVOOB",	"SENDOOB",	"SOCKADDR",
148*7c478bd9Sstevel@tonic-gate 	"PEERADDR",	"CONNECT2",	"FASTTIMO",	"SLOWTIMO",
149*7c478bd9Sstevel@tonic-gate 	"PROTORCV",	"PROTOSEND",
150*7c478bd9Sstevel@tonic-gate };
151*7c478bd9Sstevel@tonic-gate #endif
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate /*
154*7c478bd9Sstevel@tonic-gate  * The arguments to the ctlinput routine are
155*7c478bd9Sstevel@tonic-gate  *	(*protosw[].pr_ctlinput)(cmd, arg);
156*7c478bd9Sstevel@tonic-gate  * where cmd is one of the commands below, and arg is
157*7c478bd9Sstevel@tonic-gate  * an optional argument (caddr_t).
158*7c478bd9Sstevel@tonic-gate  *
159*7c478bd9Sstevel@tonic-gate  * N.B. The IMP code, in particular, pressumes the values
160*7c478bd9Sstevel@tonic-gate  *	of some of the commands; change with extreme care.
161*7c478bd9Sstevel@tonic-gate  * TODO:
162*7c478bd9Sstevel@tonic-gate  *	spread out codes so new ICMP codes can be
163*7c478bd9Sstevel@tonic-gate  *	accomodated more easily
164*7c478bd9Sstevel@tonic-gate  */
165*7c478bd9Sstevel@tonic-gate #define	PRC_IFDOWN		0	/* interface transition */
166*7c478bd9Sstevel@tonic-gate #define	PRC_ROUTEDEAD		1	/* select new route if possible */
167*7c478bd9Sstevel@tonic-gate #define	PRC_QUENCH		4	/* some said to slow down */
168*7c478bd9Sstevel@tonic-gate #define	PRC_MSGSIZE		5	/* message size forced drop */
169*7c478bd9Sstevel@tonic-gate #define	PRC_HOSTDEAD		6	/* normally from IMP */
170*7c478bd9Sstevel@tonic-gate #define	PRC_HOSTUNREACH		7	/* ditto */
171*7c478bd9Sstevel@tonic-gate #define	PRC_UNREACH_NET		8	/* no route to network */
172*7c478bd9Sstevel@tonic-gate #define	PRC_UNREACH_HOST	9	/* no route to host */
173*7c478bd9Sstevel@tonic-gate #define	PRC_UNREACH_PROTOCOL	10	/* dst says bad protocol */
174*7c478bd9Sstevel@tonic-gate #define	PRC_UNREACH_PORT	11	/* bad port # */
175*7c478bd9Sstevel@tonic-gate #define	PRC_UNREACH_NEEDFRAG	12	/* IP_DF caused drop */
176*7c478bd9Sstevel@tonic-gate #define	PRC_UNREACH_SRCFAIL	13	/* source route failed */
177*7c478bd9Sstevel@tonic-gate #define	PRC_REDIRECT_NET	14	/* net routing redirect */
178*7c478bd9Sstevel@tonic-gate #define	PRC_REDIRECT_HOST	15	/* host routing redirect */
179*7c478bd9Sstevel@tonic-gate #define	PRC_REDIRECT_TOSNET	16	/* redirect for type of service & net */
180*7c478bd9Sstevel@tonic-gate #define	PRC_REDIRECT_TOSHOST	17	/* redirect for tos & host */
181*7c478bd9Sstevel@tonic-gate #define	PRC_TIMXCEED_INTRANS	18	/* packet lifetime expired in transit */
182*7c478bd9Sstevel@tonic-gate #define	PRC_TIMXCEED_REASS	19	/* lifetime expired on reass q */
183*7c478bd9Sstevel@tonic-gate #define	PRC_PARAMPROB		20	/* header incorrect */
184*7c478bd9Sstevel@tonic-gate #define	PRC_GWDOWN		21	/* gateway down */
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate #define	PRC_NCMDS		22
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate #ifdef PRCREQUESTS
189*7c478bd9Sstevel@tonic-gate char	*prcrequests[] = {
190*7c478bd9Sstevel@tonic-gate 	"IFDOWN", "ROUTEDEAD", "#2", "#3",
191*7c478bd9Sstevel@tonic-gate 	"QUENCH", "MSGSIZE", "HOSTDEAD", "HOSTUNREACH",
192*7c478bd9Sstevel@tonic-gate 	"NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
193*7c478bd9Sstevel@tonic-gate 	"FRAG-UNREACH", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
194*7c478bd9Sstevel@tonic-gate 	"TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
195*7c478bd9Sstevel@tonic-gate 	"PARAMPROB"
196*7c478bd9Sstevel@tonic-gate };
197*7c478bd9Sstevel@tonic-gate #endif
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate /*
200*7c478bd9Sstevel@tonic-gate  * The arguments to ctloutput are:
201*7c478bd9Sstevel@tonic-gate  *	(*protosw[].pr_ctloutput)(req, so, level, optname, optval);
202*7c478bd9Sstevel@tonic-gate  * req is one of the actions listed below, so is a (struct socket *),
203*7c478bd9Sstevel@tonic-gate  * level is an indication of which protocol layer the option is intended.
204*7c478bd9Sstevel@tonic-gate  * optname is a protocol dependent socket option request,
205*7c478bd9Sstevel@tonic-gate  * optval is a pointer to a mbuf-chain pointer, for value-return results.
206*7c478bd9Sstevel@tonic-gate  * The protocol is responsible for disposal of the mbuf chain *optval
207*7c478bd9Sstevel@tonic-gate  * if supplied,
208*7c478bd9Sstevel@tonic-gate  * the caller is responsible for any space held by *optval, when returned.
209*7c478bd9Sstevel@tonic-gate  * A non-zero return from usrreq gives an
210*7c478bd9Sstevel@tonic-gate  * UNIX error number which should be passed to higher level software.
211*7c478bd9Sstevel@tonic-gate  */
212*7c478bd9Sstevel@tonic-gate #define	PRCO_GETOPT	0
213*7c478bd9Sstevel@tonic-gate #define	PRCO_SETOPT	1
214*7c478bd9Sstevel@tonic-gate 
215*7c478bd9Sstevel@tonic-gate #define	PRCO_NCMDS	2
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate #ifdef PRCOREQUESTS
218*7c478bd9Sstevel@tonic-gate char	*prcorequests[] = {
219*7c478bd9Sstevel@tonic-gate 	"GETOPT", "SETOPT",
220*7c478bd9Sstevel@tonic-gate };
221*7c478bd9Sstevel@tonic-gate #endif
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
224*7c478bd9Sstevel@tonic-gate extern	struct protosw *pffindproto(), *pffindtype();
225*7c478bd9Sstevel@tonic-gate #endif
226*7c478bd9Sstevel@tonic-gate 
227*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
228*7c478bd9Sstevel@tonic-gate }
229*7c478bd9Sstevel@tonic-gate #endif
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_PROTOSW_H */
232