home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / protosw.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  8.1 KB  |  218 lines

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