protosw.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:10k
源码类别:

VxWorks

开发平台:

C/C++

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