home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / protosw.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  9.8 KB  |  244 lines

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