home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / sys / h / protosw < prev    next >
Encoding:
Text File  |  1995-01-11  |  7.5 KB  |  201 lines

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