xref: /f-stack/tools/compat/include/sys/protosw.h (revision 1eaf0ac3)
1*1eaf0ac3Slogwang /*-
2*1eaf0ac3Slogwang  * Copyright (c) 1982, 1986, 1993
3*1eaf0ac3Slogwang  *	The Regents of the University of California.  All rights reserved.
4*1eaf0ac3Slogwang  *
5*1eaf0ac3Slogwang  * Redistribution and use in source and binary forms, with or without
6*1eaf0ac3Slogwang  * modification, are permitted provided that the following conditions
7*1eaf0ac3Slogwang  * are met:
8*1eaf0ac3Slogwang  * 1. Redistributions of source code must retain the above copyright
9*1eaf0ac3Slogwang  *    notice, this list of conditions and the following disclaimer.
10*1eaf0ac3Slogwang  * 2. Redistributions in binary form must reproduce the above copyright
11*1eaf0ac3Slogwang  *    notice, this list of conditions and the following disclaimer in the
12*1eaf0ac3Slogwang  *    documentation and/or other materials provided with the distribution.
13*1eaf0ac3Slogwang  * 4. Neither the name of the University nor the names of its contributors
14*1eaf0ac3Slogwang  *    may be used to endorse or promote products derived from this software
15*1eaf0ac3Slogwang  *    without specific prior written permission.
16*1eaf0ac3Slogwang  *
17*1eaf0ac3Slogwang  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18*1eaf0ac3Slogwang  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*1eaf0ac3Slogwang  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*1eaf0ac3Slogwang  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21*1eaf0ac3Slogwang  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*1eaf0ac3Slogwang  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*1eaf0ac3Slogwang  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*1eaf0ac3Slogwang  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*1eaf0ac3Slogwang  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*1eaf0ac3Slogwang  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*1eaf0ac3Slogwang  * SUCH DAMAGE.
28*1eaf0ac3Slogwang  *
29*1eaf0ac3Slogwang  *	@(#)protosw.h	8.1 (Berkeley) 6/2/93
30*1eaf0ac3Slogwang  * $FreeBSD$
31*1eaf0ac3Slogwang  */
32*1eaf0ac3Slogwang 
33*1eaf0ac3Slogwang #ifndef _SYS_PROTOSW_H_
34*1eaf0ac3Slogwang #define _SYS_PROTOSW_H_
35*1eaf0ac3Slogwang 
36*1eaf0ac3Slogwang /* Forward declare these structures referenced from prototypes below. */
37*1eaf0ac3Slogwang struct kaiocb;
38*1eaf0ac3Slogwang struct mbuf;
39*1eaf0ac3Slogwang struct thread;
40*1eaf0ac3Slogwang struct sockaddr;
41*1eaf0ac3Slogwang struct socket;
42*1eaf0ac3Slogwang struct sockopt;
43*1eaf0ac3Slogwang 
44*1eaf0ac3Slogwang /*#ifdef _KERNEL*/
45*1eaf0ac3Slogwang /*
46*1eaf0ac3Slogwang  * Protocol switch table.
47*1eaf0ac3Slogwang  *
48*1eaf0ac3Slogwang  * Each protocol has a handle initializing one of these structures,
49*1eaf0ac3Slogwang  * which is used for protocol-protocol and system-protocol communication.
50*1eaf0ac3Slogwang  *
51*1eaf0ac3Slogwang  * A protocol is called through the pr_init entry before any other.
52*1eaf0ac3Slogwang  * Thereafter it is called every 200ms through the pr_fasttimo entry and
53*1eaf0ac3Slogwang  * every 500ms through the pr_slowtimo for timer based actions.
54*1eaf0ac3Slogwang  * The system will call the pr_drain entry if it is low on space and
55*1eaf0ac3Slogwang  * this should throw away any non-critical data.
56*1eaf0ac3Slogwang  *
57*1eaf0ac3Slogwang  * Protocols pass data between themselves as chains of mbufs using
58*1eaf0ac3Slogwang  * the pr_input and pr_output hooks.  Pr_input passes data up (towards
59*1eaf0ac3Slogwang  * the users) and pr_output passes it down (towards the interfaces); control
60*1eaf0ac3Slogwang  * information passes up and down on pr_ctlinput and pr_ctloutput.
61*1eaf0ac3Slogwang  * The protocol is responsible for the space occupied by any the
62*1eaf0ac3Slogwang  * arguments to these entries and must dispose it.
63*1eaf0ac3Slogwang  *
64*1eaf0ac3Slogwang  * In retrospect, it would be a lot nicer to use an interface
65*1eaf0ac3Slogwang  * similar to the vnode VOP interface.
66*1eaf0ac3Slogwang  */
67*1eaf0ac3Slogwang /* USE THESE FOR YOUR PROTOTYPES ! */
68*1eaf0ac3Slogwang typedef int	pr_input_t (struct mbuf **, int*, int);
69*1eaf0ac3Slogwang typedef int	pr_output_t (struct mbuf *, struct socket *, ...);
70*1eaf0ac3Slogwang typedef void	pr_ctlinput_t (int, struct sockaddr *, void *);
71*1eaf0ac3Slogwang typedef int	pr_ctloutput_t (struct socket *, struct sockopt *);
72*1eaf0ac3Slogwang typedef	void	pr_init_t (void);
73*1eaf0ac3Slogwang typedef	void	pr_fasttimo_t (void);
74*1eaf0ac3Slogwang typedef	void	pr_slowtimo_t (void);
75*1eaf0ac3Slogwang typedef	void	pr_drain_t (void);
76*1eaf0ac3Slogwang 
77*1eaf0ac3Slogwang struct protosw {
78*1eaf0ac3Slogwang 	short	pr_type;		/* socket type used for */
79*1eaf0ac3Slogwang 	struct	domain *pr_domain;	/* domain protocol a member of */
80*1eaf0ac3Slogwang 	short	pr_protocol;		/* protocol number */
81*1eaf0ac3Slogwang 	short	pr_flags;		/* see below */
82*1eaf0ac3Slogwang /* protocol-protocol hooks */
83*1eaf0ac3Slogwang 	pr_input_t *pr_input;		/* input to protocol (from below) */
84*1eaf0ac3Slogwang 	pr_output_t *pr_output;		/* output to protocol (from above) */
85*1eaf0ac3Slogwang 	pr_ctlinput_t *pr_ctlinput;	/* control input (from below) */
86*1eaf0ac3Slogwang 	pr_ctloutput_t *pr_ctloutput;	/* control output (from above) */
87*1eaf0ac3Slogwang /* utility hooks */
88*1eaf0ac3Slogwang 	pr_init_t *pr_init;
89*1eaf0ac3Slogwang 	pr_fasttimo_t *pr_fasttimo;	/* fast timeout (200ms) */
90*1eaf0ac3Slogwang 	pr_slowtimo_t *pr_slowtimo;	/* slow timeout (500ms) */
91*1eaf0ac3Slogwang 	pr_drain_t *pr_drain;		/* flush any excess space possible */
92*1eaf0ac3Slogwang 
93*1eaf0ac3Slogwang 	struct	pr_usrreqs *pr_usrreqs;	/* user-protocol hook */
94*1eaf0ac3Slogwang };
95*1eaf0ac3Slogwang /*#endif*/
96*1eaf0ac3Slogwang 
97*1eaf0ac3Slogwang #define	PR_SLOWHZ	2		/* 2 slow timeouts per second */
98*1eaf0ac3Slogwang #define	PR_FASTHZ	5		/* 5 fast timeouts per second */
99*1eaf0ac3Slogwang 
100*1eaf0ac3Slogwang /*
101*1eaf0ac3Slogwang  * This number should be defined again within each protocol family to avoid
102*1eaf0ac3Slogwang  * confusion.
103*1eaf0ac3Slogwang  */
104*1eaf0ac3Slogwang #define	PROTO_SPACER	32767		/* spacer for loadable protocols */
105*1eaf0ac3Slogwang 
106*1eaf0ac3Slogwang /*
107*1eaf0ac3Slogwang  * Values for pr_flags.
108*1eaf0ac3Slogwang  * PR_ADDR requires PR_ATOMIC;
109*1eaf0ac3Slogwang  * PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
110*1eaf0ac3Slogwang  * PR_IMPLOPCL means that the protocol allows sendto without prior connect,
111*1eaf0ac3Slogwang  *	and the protocol understands the MSG_EOF flag.  The first property is
112*1eaf0ac3Slogwang  *	is only relevant if PR_CONNREQUIRED is set (otherwise sendto is allowed
113*1eaf0ac3Slogwang  *	anyhow).
114*1eaf0ac3Slogwang  */
115*1eaf0ac3Slogwang #define	PR_ATOMIC	0x01		/* exchange atomic messages only */
116*1eaf0ac3Slogwang #define	PR_ADDR		0x02		/* addresses given with messages */
117*1eaf0ac3Slogwang #define	PR_CONNREQUIRED	0x04		/* connection required by protocol */
118*1eaf0ac3Slogwang #define	PR_WANTRCVD	0x08		/* want PRU_RCVD calls */
119*1eaf0ac3Slogwang #define	PR_RIGHTS	0x10		/* passes capabilities */
120*1eaf0ac3Slogwang #define PR_IMPLOPCL	0x20		/* implied open/close */
121*1eaf0ac3Slogwang #define	PR_LASTHDR	0x40		/* enforce ipsec policy; last header */
122*1eaf0ac3Slogwang 
123*1eaf0ac3Slogwang /*
124*1eaf0ac3Slogwang  * In earlier BSD network stacks, a single pr_usrreq() function pointer was
125*1eaf0ac3Slogwang  * invoked with an operation number indicating what operation was desired.
126*1eaf0ac3Slogwang  * We now provide individual function pointers which protocols can implement,
127*1eaf0ac3Slogwang  * which offers a number of benefits (such as type checking for arguments).
128*1eaf0ac3Slogwang  * These older constants are still present in order to support TCP debugging.
129*1eaf0ac3Slogwang  */
130*1eaf0ac3Slogwang #define	PRU_ATTACH		0	/* attach protocol to up */
131*1eaf0ac3Slogwang #define	PRU_DETACH		1	/* detach protocol from up */
132*1eaf0ac3Slogwang #define	PRU_BIND		2	/* bind socket to address */
133*1eaf0ac3Slogwang #define	PRU_LISTEN		3	/* listen for connection */
134*1eaf0ac3Slogwang #define	PRU_CONNECT		4	/* establish connection to peer */
135*1eaf0ac3Slogwang #define	PRU_ACCEPT		5	/* accept connection from peer */
136*1eaf0ac3Slogwang #define	PRU_DISCONNECT		6	/* disconnect from peer */
137*1eaf0ac3Slogwang #define	PRU_SHUTDOWN		7	/* won't send any more data */
138*1eaf0ac3Slogwang #define	PRU_RCVD		8	/* have taken data; more room now */
139*1eaf0ac3Slogwang #define	PRU_SEND		9	/* send this data */
140*1eaf0ac3Slogwang #define	PRU_ABORT		10	/* abort (fast DISCONNECT, DETATCH) */
141*1eaf0ac3Slogwang #define	PRU_CONTROL		11	/* control operations on protocol */
142*1eaf0ac3Slogwang #define	PRU_SENSE		12	/* return status into m */
143*1eaf0ac3Slogwang #define	PRU_RCVOOB		13	/* retrieve out of band data */
144*1eaf0ac3Slogwang #define	PRU_SENDOOB		14	/* send out of band data */
145*1eaf0ac3Slogwang #define	PRU_SOCKADDR		15	/* fetch socket's address */
146*1eaf0ac3Slogwang #define	PRU_PEERADDR		16	/* fetch peer's address */
147*1eaf0ac3Slogwang #define	PRU_CONNECT2		17	/* connect two sockets */
148*1eaf0ac3Slogwang /* begin for protocols internal use */
149*1eaf0ac3Slogwang #define	PRU_FASTTIMO		18	/* 200ms timeout */
150*1eaf0ac3Slogwang #define	PRU_SLOWTIMO		19	/* 500ms timeout */
151*1eaf0ac3Slogwang #define	PRU_PROTORCV		20	/* receive from below */
152*1eaf0ac3Slogwang #define	PRU_PROTOSEND		21	/* send to below */
153*1eaf0ac3Slogwang /* end for protocol's internal use */
154*1eaf0ac3Slogwang #define PRU_SEND_EOF		22	/* send and close */
155*1eaf0ac3Slogwang #define	PRU_SOSETLABEL		23	/* MAC label change */
156*1eaf0ac3Slogwang #define	PRU_CLOSE		24	/* socket close */
157*1eaf0ac3Slogwang #define	PRU_FLUSH		25	/* flush the socket */
158*1eaf0ac3Slogwang #define	PRU_NREQ		25
159*1eaf0ac3Slogwang 
160*1eaf0ac3Slogwang #ifdef PRUREQUESTS
161*1eaf0ac3Slogwang const char *prurequests[] = {
162*1eaf0ac3Slogwang 	"ATTACH",	"DETACH",	"BIND",		"LISTEN",
163*1eaf0ac3Slogwang 	"CONNECT",	"ACCEPT",	"DISCONNECT",	"SHUTDOWN",
164*1eaf0ac3Slogwang 	"RCVD",		"SEND",		"ABORT",	"CONTROL",
165*1eaf0ac3Slogwang 	"SENSE",	"RCVOOB",	"SENDOOB",	"SOCKADDR",
166*1eaf0ac3Slogwang 	"PEERADDR",	"CONNECT2",	"FASTTIMO",	"SLOWTIMO",
167*1eaf0ac3Slogwang 	"PROTORCV",	"PROTOSEND",	"SEND_EOF",	"SOSETLABEL",
168*1eaf0ac3Slogwang 	"CLOSE",	"FLUSH",
169*1eaf0ac3Slogwang };
170*1eaf0ac3Slogwang #endif
171*1eaf0ac3Slogwang 
172*1eaf0ac3Slogwang #ifdef	_KERNEL			/* users shouldn't see this decl */
173*1eaf0ac3Slogwang 
174*1eaf0ac3Slogwang struct ifnet;
175*1eaf0ac3Slogwang struct stat;
176*1eaf0ac3Slogwang struct ucred;
177*1eaf0ac3Slogwang struct uio;
178*1eaf0ac3Slogwang 
179*1eaf0ac3Slogwang /*
180*1eaf0ac3Slogwang  * If the ordering here looks odd, that's because it's alphabetical.  These
181*1eaf0ac3Slogwang  * should eventually be merged back into struct protosw.
182*1eaf0ac3Slogwang  *
183*1eaf0ac3Slogwang  * Some fields initialized to defaults if they are NULL.
184*1eaf0ac3Slogwang  * See uipc_domain.c:net_init_domain()
185*1eaf0ac3Slogwang  */
186*1eaf0ac3Slogwang struct pr_usrreqs {
187*1eaf0ac3Slogwang 	void	(*pru_abort)(struct socket *so);
188*1eaf0ac3Slogwang 	int	(*pru_accept)(struct socket *so, struct sockaddr **nam);
189*1eaf0ac3Slogwang 	int	(*pru_attach)(struct socket *so, int proto, struct thread *td);
190*1eaf0ac3Slogwang 	int	(*pru_bind)(struct socket *so, struct sockaddr *nam,
191*1eaf0ac3Slogwang 		    struct thread *td);
192*1eaf0ac3Slogwang 	int	(*pru_connect)(struct socket *so, struct sockaddr *nam,
193*1eaf0ac3Slogwang 		    struct thread *td);
194*1eaf0ac3Slogwang 	int	(*pru_connect2)(struct socket *so1, struct socket *so2);
195*1eaf0ac3Slogwang 	int	(*pru_control)(struct socket *so, u_long cmd, caddr_t data,
196*1eaf0ac3Slogwang 		    struct ifnet *ifp, struct thread *td);
197*1eaf0ac3Slogwang 	void	(*pru_detach)(struct socket *so);
198*1eaf0ac3Slogwang 	int	(*pru_disconnect)(struct socket *so);
199*1eaf0ac3Slogwang 	int	(*pru_listen)(struct socket *so, int backlog,
200*1eaf0ac3Slogwang 		    struct thread *td);
201*1eaf0ac3Slogwang 	int	(*pru_peeraddr)(struct socket *so, struct sockaddr **nam);
202*1eaf0ac3Slogwang 	int	(*pru_rcvd)(struct socket *so, int flags);
203*1eaf0ac3Slogwang 	int	(*pru_rcvoob)(struct socket *so, struct mbuf *m, int flags);
204*1eaf0ac3Slogwang 	int	(*pru_send)(struct socket *so, int flags, struct mbuf *m,
205*1eaf0ac3Slogwang 		    struct sockaddr *addr, struct mbuf *control,
206*1eaf0ac3Slogwang 		    struct thread *td);
207*1eaf0ac3Slogwang #define	PRUS_OOB	0x1
208*1eaf0ac3Slogwang #define	PRUS_EOF	0x2
209*1eaf0ac3Slogwang #define	PRUS_MORETOCOME	0x4
210*1eaf0ac3Slogwang #define	PRUS_NOTREADY	0x8
211*1eaf0ac3Slogwang 	int	(*pru_ready)(struct socket *so, struct mbuf *m, int count);
212*1eaf0ac3Slogwang 	int	(*pru_sense)(struct socket *so, struct stat *sb);
213*1eaf0ac3Slogwang 	int	(*pru_shutdown)(struct socket *so);
214*1eaf0ac3Slogwang 	int	(*pru_flush)(struct socket *so, int direction);
215*1eaf0ac3Slogwang 	int	(*pru_sockaddr)(struct socket *so, struct sockaddr **nam);
216*1eaf0ac3Slogwang 	int	(*pru_sosend)(struct socket *so, struct sockaddr *addr,
217*1eaf0ac3Slogwang 		    struct uio *uio, struct mbuf *top, struct mbuf *control,
218*1eaf0ac3Slogwang 		    int flags, struct thread *td);
219*1eaf0ac3Slogwang 	int	(*pru_soreceive)(struct socket *so, struct sockaddr **paddr,
220*1eaf0ac3Slogwang 		    struct uio *uio, struct mbuf **mp0, struct mbuf **controlp,
221*1eaf0ac3Slogwang 		    int *flagsp);
222*1eaf0ac3Slogwang 	int	(*pru_sopoll)(struct socket *so, int events,
223*1eaf0ac3Slogwang 		    struct ucred *cred, struct thread *td);
224*1eaf0ac3Slogwang 	void	(*pru_sosetlabel)(struct socket *so);
225*1eaf0ac3Slogwang 	void	(*pru_close)(struct socket *so);
226*1eaf0ac3Slogwang 	int	(*pru_bindat)(int fd, struct socket *so, struct sockaddr *nam,
227*1eaf0ac3Slogwang 		    struct thread *td);
228*1eaf0ac3Slogwang 	int	(*pru_connectat)(int fd, struct socket *so,
229*1eaf0ac3Slogwang 		    struct sockaddr *nam, struct thread *td);
230*1eaf0ac3Slogwang 	int	(*pru_aio_queue)(struct socket *so, struct kaiocb *job);
231*1eaf0ac3Slogwang };
232*1eaf0ac3Slogwang 
233*1eaf0ac3Slogwang /*
234*1eaf0ac3Slogwang  * All nonvoid pru_*() functions below return EOPNOTSUPP.
235*1eaf0ac3Slogwang  */
236*1eaf0ac3Slogwang int	pru_accept_notsupp(struct socket *so, struct sockaddr **nam);
237*1eaf0ac3Slogwang int	pru_aio_queue_notsupp(struct socket *so, struct kaiocb *job);
238*1eaf0ac3Slogwang int	pru_attach_notsupp(struct socket *so, int proto, struct thread *td);
239*1eaf0ac3Slogwang int	pru_bind_notsupp(struct socket *so, struct sockaddr *nam,
240*1eaf0ac3Slogwang 	    struct thread *td);
241*1eaf0ac3Slogwang int	pru_bindat_notsupp(int fd, struct socket *so, struct sockaddr *nam,
242*1eaf0ac3Slogwang 	    struct thread *td);
243*1eaf0ac3Slogwang int	pru_connect_notsupp(struct socket *so, struct sockaddr *nam,
244*1eaf0ac3Slogwang 	    struct thread *td);
245*1eaf0ac3Slogwang int	pru_connectat_notsupp(int fd, struct socket *so, struct sockaddr *nam,
246*1eaf0ac3Slogwang 	    struct thread *td);
247*1eaf0ac3Slogwang int	pru_connect2_notsupp(struct socket *so1, struct socket *so2);
248*1eaf0ac3Slogwang int	pru_control_notsupp(struct socket *so, u_long cmd, caddr_t data,
249*1eaf0ac3Slogwang 	    struct ifnet *ifp, struct thread *td);
250*1eaf0ac3Slogwang int	pru_disconnect_notsupp(struct socket *so);
251*1eaf0ac3Slogwang int	pru_listen_notsupp(struct socket *so, int backlog, struct thread *td);
252*1eaf0ac3Slogwang int	pru_peeraddr_notsupp(struct socket *so, struct sockaddr **nam);
253*1eaf0ac3Slogwang int	pru_rcvd_notsupp(struct socket *so, int flags);
254*1eaf0ac3Slogwang int	pru_rcvoob_notsupp(struct socket *so, struct mbuf *m, int flags);
255*1eaf0ac3Slogwang int	pru_send_notsupp(struct socket *so, int flags, struct mbuf *m,
256*1eaf0ac3Slogwang 	    struct sockaddr *addr, struct mbuf *control, struct thread *td);
257*1eaf0ac3Slogwang int	pru_ready_notsupp(struct socket *so, struct mbuf *m, int count);
258*1eaf0ac3Slogwang int	pru_sense_null(struct socket *so, struct stat *sb);
259*1eaf0ac3Slogwang int	pru_shutdown_notsupp(struct socket *so);
260*1eaf0ac3Slogwang int	pru_sockaddr_notsupp(struct socket *so, struct sockaddr **nam);
261*1eaf0ac3Slogwang int	pru_sosend_notsupp(struct socket *so, struct sockaddr *addr,
262*1eaf0ac3Slogwang 	    struct uio *uio, struct mbuf *top, struct mbuf *control, int flags,
263*1eaf0ac3Slogwang 	    struct thread *td);
264*1eaf0ac3Slogwang int	pru_soreceive_notsupp(struct socket *so, struct sockaddr **paddr,
265*1eaf0ac3Slogwang 	    struct uio *uio, struct mbuf **mp0, struct mbuf **controlp,
266*1eaf0ac3Slogwang 	    int *flagsp);
267*1eaf0ac3Slogwang int	pru_sopoll_notsupp(struct socket *so, int events, struct ucred *cred,
268*1eaf0ac3Slogwang 	    struct thread *td);
269*1eaf0ac3Slogwang 
270*1eaf0ac3Slogwang #endif /* _KERNEL */
271*1eaf0ac3Slogwang 
272*1eaf0ac3Slogwang /*
273*1eaf0ac3Slogwang  * The arguments to the ctlinput routine are
274*1eaf0ac3Slogwang  *	(*protosw[].pr_ctlinput)(cmd, sa, arg);
275*1eaf0ac3Slogwang  * where cmd is one of the commands below, sa is a pointer to a sockaddr,
276*1eaf0ac3Slogwang  * and arg is a `void *' argument used within a protocol family.
277*1eaf0ac3Slogwang  */
278*1eaf0ac3Slogwang #define	PRC_IFDOWN		0	/* interface transition */
279*1eaf0ac3Slogwang #define	PRC_ROUTEDEAD		1	/* select new route if possible ??? */
280*1eaf0ac3Slogwang #define	PRC_IFUP		2	/* interface has come back up */
281*1eaf0ac3Slogwang /* was	PRC_QUENCH2		3	DEC congestion bit says slow down */
282*1eaf0ac3Slogwang /* was	PRC_QUENCH		4	Deprecated by RFC 6633 */
283*1eaf0ac3Slogwang #define	PRC_MSGSIZE		5	/* message size forced drop */
284*1eaf0ac3Slogwang #define	PRC_HOSTDEAD		6	/* host appears to be down */
285*1eaf0ac3Slogwang #define	PRC_HOSTUNREACH		7	/* deprecated (use PRC_UNREACH_HOST) */
286*1eaf0ac3Slogwang #define	PRC_UNREACH_NET		8	/* no route to network */
287*1eaf0ac3Slogwang #define	PRC_UNREACH_HOST	9	/* no route to host */
288*1eaf0ac3Slogwang #define	PRC_UNREACH_PROTOCOL	10	/* dst says bad protocol */
289*1eaf0ac3Slogwang #define	PRC_UNREACH_PORT	11	/* bad port # */
290*1eaf0ac3Slogwang /* was	PRC_UNREACH_NEEDFRAG	12	   (use PRC_MSGSIZE) */
291*1eaf0ac3Slogwang #define	PRC_UNREACH_SRCFAIL	13	/* source route failed */
292*1eaf0ac3Slogwang #define	PRC_REDIRECT_NET	14	/* net routing redirect */
293*1eaf0ac3Slogwang #define	PRC_REDIRECT_HOST	15	/* host routing redirect */
294*1eaf0ac3Slogwang #define	PRC_REDIRECT_TOSNET	16	/* redirect for type of service & net */
295*1eaf0ac3Slogwang #define	PRC_REDIRECT_TOSHOST	17	/* redirect for tos & host */
296*1eaf0ac3Slogwang #define	PRC_TIMXCEED_INTRANS	18	/* packet lifetime expired in transit */
297*1eaf0ac3Slogwang #define	PRC_TIMXCEED_REASS	19	/* lifetime expired on reass q */
298*1eaf0ac3Slogwang #define	PRC_PARAMPROB		20	/* header incorrect */
299*1eaf0ac3Slogwang #define	PRC_UNREACH_ADMIN_PROHIB	21	/* packet administrativly prohibited */
300*1eaf0ac3Slogwang 
301*1eaf0ac3Slogwang #define	PRC_NCMDS		22
302*1eaf0ac3Slogwang 
303*1eaf0ac3Slogwang #define	PRC_IS_REDIRECT(cmd)	\
304*1eaf0ac3Slogwang 	((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)
305*1eaf0ac3Slogwang 
306*1eaf0ac3Slogwang #ifdef PRCREQUESTS
307*1eaf0ac3Slogwang char	*prcrequests[] = {
308*1eaf0ac3Slogwang 	"IFDOWN", "ROUTEDEAD", "IFUP", "DEC-BIT-QUENCH2",
309*1eaf0ac3Slogwang 	"QUENCH", "MSGSIZE", "HOSTDEAD", "#7",
310*1eaf0ac3Slogwang 	"NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
311*1eaf0ac3Slogwang 	"#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
312*1eaf0ac3Slogwang 	"TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
313*1eaf0ac3Slogwang 	"PARAMPROB", "ADMIN-UNREACH"
314*1eaf0ac3Slogwang };
315*1eaf0ac3Slogwang #endif
316*1eaf0ac3Slogwang 
317*1eaf0ac3Slogwang /*
318*1eaf0ac3Slogwang  * The arguments to ctloutput are:
319*1eaf0ac3Slogwang  *	(*protosw[].pr_ctloutput)(req, so, level, optname, optval, p);
320*1eaf0ac3Slogwang  * req is one of the actions listed below, so is a (struct socket *),
321*1eaf0ac3Slogwang  * level is an indication of which protocol layer the option is intended.
322*1eaf0ac3Slogwang  * optname is a protocol dependent socket option request,
323*1eaf0ac3Slogwang  * optval is a pointer to a mbuf-chain pointer, for value-return results.
324*1eaf0ac3Slogwang  * The protocol is responsible for disposal of the mbuf chain *optval
325*1eaf0ac3Slogwang  * if supplied,
326*1eaf0ac3Slogwang  * the caller is responsible for any space held by *optval, when returned.
327*1eaf0ac3Slogwang  * A non-zero return from ctloutput gives an
328*1eaf0ac3Slogwang  * UNIX error number which should be passed to higher level software.
329*1eaf0ac3Slogwang  */
330*1eaf0ac3Slogwang #define	PRCO_GETOPT	0
331*1eaf0ac3Slogwang #define	PRCO_SETOPT	1
332*1eaf0ac3Slogwang 
333*1eaf0ac3Slogwang #define	PRCO_NCMDS	2
334*1eaf0ac3Slogwang 
335*1eaf0ac3Slogwang #ifdef PRCOREQUESTS
336*1eaf0ac3Slogwang char	*prcorequests[] = {
337*1eaf0ac3Slogwang 	"GETOPT", "SETOPT",
338*1eaf0ac3Slogwang };
339*1eaf0ac3Slogwang #endif
340*1eaf0ac3Slogwang 
341*1eaf0ac3Slogwang #ifdef _KERNEL
342*1eaf0ac3Slogwang void	pfctlinput(int, struct sockaddr *);
343*1eaf0ac3Slogwang void	pfctlinput2(int, struct sockaddr *, void *);
344*1eaf0ac3Slogwang struct domain *pffinddomain(int family);
345*1eaf0ac3Slogwang struct protosw *pffindproto(int family, int protocol, int type);
346*1eaf0ac3Slogwang struct protosw *pffindtype(int family, int type);
347*1eaf0ac3Slogwang int	pf_proto_register(int family, struct protosw *npr);
348*1eaf0ac3Slogwang int	pf_proto_unregister(int family, int protocol, int type);
349*1eaf0ac3Slogwang #endif
350*1eaf0ac3Slogwang 
351*1eaf0ac3Slogwang #endif
352