reverse sense of pid/pgrp for fcntl, SIOCSPGRP (pgrp is negative)
[unix-history] / usr / src / sys / sys / protosw.h
CommitLineData
1142e2e9 1/* protosw.h 6.4 85/03/07 */
0df80259
BJ
2
3/*
4 * Protocol switch table.
5 *
6 * Each protocol has a handle initializing one of these structures,
7 * which is used for protocol-protocol and system-protocol communication.
8 *
541352f0 9 * A protocol is called through the pr_init entry before any other.
10d6a919 10 * Thereafter it is called every 200ms through the pr_fasttimo entry and
541352f0
BJ
11 * every 500ms through the pr_slowtimo for timer based actions.
12 * The system will call the pr_drain entry if it is low on space and
13 * this should throw away any non-critical data.
14 *
0df80259
BJ
15 * Protocols pass data between themselves as chains of mbufs using
16 * the pr_input and pr_output hooks. Pr_input passes data up (towards
541352f0
BJ
17 * UNIX) and pr_output passes it down (towards the imps); control
18 * information passes up and down on pr_ctlinput and pr_ctloutput.
19 * The protocol is responsible for the space occupied by any the
20 * arguments to these entries and must dispose it.
0df80259 21 *
541352f0
BJ
22 * The userreq routine interfaces protocols to the system and is
23 * described below.
0df80259
BJ
24 */
25struct protosw {
26 short pr_type; /* socket type used for */
fde4dc17 27 struct domain *pr_domain; /* domain protocol a member of */
0df80259 28 short pr_protocol; /* protocol number */
541352f0
BJ
29 short pr_flags; /* see below */
30/* protocol-protocol hooks */
0df80259
BJ
31 int (*pr_input)(); /* input to protocol (from below) */
32 int (*pr_output)(); /* output to protocol (from above) */
541352f0
BJ
33 int (*pr_ctlinput)(); /* control input (from below) */
34 int (*pr_ctloutput)(); /* control output (from above) */
1cae93a2 35/* user-protocol hook */
541352f0 36 int (*pr_usrreq)(); /* user request: see list below */
541352f0
BJ
37/* utility hooks */
38 int (*pr_init)(); /* initialization hook */
10d6a919 39 int (*pr_fasttimo)(); /* fast timeout (200ms) */
114cd253 40 int (*pr_slowtimo)(); /* slow timeout (500ms) */
0df80259 41 int (*pr_drain)(); /* flush any excess space possible */
0df80259
BJ
42};
43
114cd253 44#define PR_SLOWHZ 2 /* 2 slow timeouts per second */
10d6a919 45#define PR_FASTHZ 5 /* 5 fast timeouts per second */
0fa05083 46
0df80259
BJ
47/*
48 * Values for pr_flags
49 */
50#define PR_ATOMIC 0x01 /* exchange atomic messages only */
51#define PR_ADDR 0x02 /* addresses given with messages */
52/* in the current implementation, PR_ADDR needs PR_ATOMIC to work */
541352f0
BJ
53#define PR_CONNREQUIRED 0x04 /* connection required by protocol */
54#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
d6d65f4d 55#define PR_RIGHTS 0x10 /* passes capabilities */
0df80259
BJ
56
57/*
58 * The arguments to usrreq are:
dc44a5d7 59 * (*protosw[].pr_usrreq)(up, req, m, nam, opt);
0df80259 60 * where up is a (struct socket *), req is one of these requests,
dc44a5d7
BJ
61 * m is a optional mbuf chain containing a message,
62 * nam is an optional mbuf chain containing an address,
63 * and opt is a pointer to a socketopt structure or nil.
64 * The protocol is responsible for disposal of the mbuf chain m,
65 * the caller is responsible for any space held by nam and opt.
66 * A non-zero return from usrreq gives an
0df80259
BJ
67 * UNIX error number which should be passed to higher level software.
68 */
541352f0
BJ
69#define PRU_ATTACH 0 /* attach protocol to up */
70#define PRU_DETACH 1 /* detach protocol from up */
dc44a5d7
BJ
71#define PRU_BIND 2 /* bind socket to address */
72#define PRU_LISTEN 3 /* listen for connection */
73#define PRU_CONNECT 4 /* establish connection to peer */
74#define PRU_ACCEPT 5 /* accept connection from peer */
75#define PRU_DISCONNECT 6 /* disconnect from peer */
76#define PRU_SHUTDOWN 7 /* won't send any more data */
77#define PRU_RCVD 8 /* have taken data; more room now */
78#define PRU_SEND 9 /* send this data */
79#define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */
80#define PRU_CONTROL 11 /* control operations on protocol */
81#define PRU_SENSE 12 /* return status into m */
82#define PRU_RCVOOB 13 /* retrieve out of band data */
83#define PRU_SENDOOB 14 /* send out of band data */
84#define PRU_SOCKADDR 15 /* fetch socket's address */
a7343092
SL
85#define PRU_PEERADDR 16 /* fetch peer's address */
86#define PRU_CONNECT2 17 /* connect two sockets */
541352f0 87/* begin for protocols internal use */
a7343092
SL
88#define PRU_FASTTIMO 18 /* 200ms timeout */
89#define PRU_SLOWTIMO 19 /* 500ms timeout */
90#define PRU_PROTORCV 20 /* receive from below */
91#define PRU_PROTOSEND 21 /* send to below */
0df80259 92
a7343092 93#define PRU_NREQ 21
541352f0
BJ
94
95#ifdef PRUREQUESTS
96char *prurequests[] = {
dc44a5d7
BJ
97 "ATTACH", "DETACH", "BIND", "LISTEN",
98 "CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN",
99 "RCVD", "SEND", "ABORT", "CONTROL",
100 "SENSE", "RCVOOB", "SENDOOB", "SOCKADDR",
a7343092
SL
101 "PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO",
102 "PROTORCV", "PROTOSEND",
541352f0
BJ
103};
104#endif
105
0649e349
SL
106/*
107 * The arguments to the ctlinput routine are
108 * (*protosw[].pr_ctlinput)(cmd, arg);
109 * where cmd is one of the commands below, and arg is
110 * an optional argument (caddr_t).
111 *
112 * N.B. The IMP code, in particular, pressumes the values
113 * of some of the commands; change with extreme care.
af0b24db
SL
114 * TODO:
115 * spread out codes so new ICMP codes can be
116 * accomodated more easily
0649e349
SL
117 */
118#define PRC_IFDOWN 0 /* interface transition */
119#define PRC_ROUTEDEAD 1 /* select new route if possible */
120#define PRC_QUENCH 4 /* some said to slow down */
af0b24db 121#define PRC_MSGSIZE 5 /* message size forced drop */
0649e349
SL
122#define PRC_HOSTDEAD 6 /* normally from IMP */
123#define PRC_HOSTUNREACH 7 /* ditto */
124#define PRC_UNREACH_NET 8 /* no route to network */
125#define PRC_UNREACH_HOST 9 /* no route to host */
126#define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */
127#define PRC_UNREACH_PORT 11 /* bad port # */
efd6b0d0
KM
128#define PRC_UNREACH_NEEDFRAG 12 /* IP_DF caused drop */
129#define PRC_UNREACH_SRCFAIL 13 /* source route failed */
130#define PRC_REDIRECT_NET 14 /* net routing redirect */
131#define PRC_REDIRECT_HOST 15 /* host routing redirect */
132#define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */
133#define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */
134#define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */
135#define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */
136#define PRC_PARAMPROB 20 /* header incorrect */
0649e349 137
efd6b0d0 138#define PRC_NCMDS 21
0649e349
SL
139
140#ifdef PRCREQUESTS
141char *prcrequests[] = {
efd6b0d0
KM
142 "IFDOWN", "ROUTEDEAD", "#2", "#3",
143 "QUENCH", "MSGSIZE", "HOSTDEAD", "HOSTUNREACH",
144 "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
145 "FRAG-UNREACH", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
146 "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
147 "PARAMPROB"
0649e349
SL
148};
149#endif
150
1142e2e9
MK
151/*
152 * The arguments to ctloutput are:
153 * (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
154 * req is one of the actions listed below, so is a (struct socket *),
155 * level is an indication of which protocol layer the option is intended.
156 * optname is a protocol dependent socket option request,
157 * optval is a pointer to a mbuf-chain pointer, for value-return results.
158 * The protocol is responsible for disposal of the mbuf chain *optval
159 * if supplied,
160 * the caller is responsible for any space held by *optval, when returned.
161 * A non-zero return from usrreq gives an
162 * UNIX error number which should be passed to higher level software.
163 */
164#define PRCO_GETOPT 0
165#define PRCO_SETOPT 1
166
167#define PRCO_NCMDS 2
168
169#ifdef PRCOREQUESTS
170char *prcorequests[] = {
171 "GETOPT", "SETOPT",
172};
173#endif
174
0df80259 175#ifdef KERNEL
541352f0 176extern struct protosw *pffindproto(), *pffindtype();
0df80259 177#endif