home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / sys / ticots.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  9.0 KB  |  268 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. #ident    "@(#)/usr/include/sys/ticots.h.sl 1.1 4.0 12/08/90 39691 AT&T-USL"
  11. /*
  12.  *    ticots provider-dependent info
  13.  *    (provider-independent applications must not include this header file)
  14.  */
  15.  
  16. /*
  17.  *    disconnect reason codes     (see t_rcvdis())
  18.  */
  19. #define TCO_NOPEER         ECONNREFUSED    /* no listener on dest addr */
  20. #define TCO_PEERNOROOMONQ    ECONNREFUSED    /* peer has no room on incoming queue */
  21. #define TCO_PEERBADSTATE    ECONNREFUSED    /* peer in wrong state */
  22. #define TCO_PEERINITIATED     ECONNRESET    /* peer-initiated disconnect */
  23. #define TCO_PROVIDERINITIATED     ECONNABORTED    /* provider-initiated disconnect */
  24.  
  25. /*
  26.  *    options (flattened linked-list of flattened C-structures)
  27.  */
  28. #define TCO_OPT_NOHDR        0        /* invalid nexthdr offset (end of list) */
  29.  
  30. #define TCO_OPT_NOOP        1        /* no-op opt -- default */
  31. #define TCO_OPT_SETID        2        /* set ident */
  32. #define TCO_OPT_GETID        3        /* get ident */
  33. #define TCO_OPT_UID        4        /* uid info */
  34. #define TCO_OPT_GID        5        /* gid info */
  35. #define TCO_OPT_RUID        6        /* ruid info */
  36. #define TCO_OPT_RGID        7        /* rgid info */
  37.  
  38. #define TCO_IDFLG_UID        0x1        /* uid flag */
  39. #define TCO_IDFLG_GID        0x2        /* gid flag */
  40. #define TCO_IDFLG_RUID        0x4        /* ruid flag */
  41. #define TCO_IDFLG_RGID        0x8        /* rgid flag */
  42.  
  43. /* header for maintaining list of opts; one for each opt in list;
  44.    offsets are measured from beginning of options buffer;
  45.    headers must occur in increasing order, to avoid loops */
  46. struct tco_opt_hdr {
  47.     long            hdr_thisopt_off;    /* offset to current opt */
  48.     long            hdr_nexthdr_off;    /* offset to next hdr */
  49. };
  50.  
  51. /* no-op opt -- the default */
  52. struct tco_opt_noop {
  53.     long            noop_type;    /* TCO_OPT_NOOP; must be first */
  54. };
  55.  
  56. /* set ident opt -- subsequent t_rcvudata()'s
  57.    (i.e., T_UNITDATA_IND) will contain peer's ident info */
  58. struct tco_opt_setid {
  59.     long            setid_type;    /* TCO_OPT_SETID; must be first */
  60.     long            setid_flg;    /* which id opts to set */
  61. };
  62.  
  63. /* get ident opt */
  64. struct tco_opt_getid {
  65.     long            getid_type;    /* TCO_OPT_GETID; must be first */
  66.     long            getid_flg;    /* which id opts are set */
  67. };
  68.  
  69. /* uid info opt */
  70. struct tco_opt_uid {
  71.     long            uid_type;    /* TCO_OPT_UID; must be first */
  72.     uid_t            uid_val;    /* effective user id */
  73. };
  74.  
  75. /* gid info opt */
  76. struct tco_opt_gid {
  77.     long            gid_type;    /* TCO_OPT_GID; must be first */
  78.     gid_t            gid_val;    /* effective group id */
  79. };
  80.  
  81. /* ruid info opt */
  82. struct tco_opt_ruid {
  83.     long            ruid_type;    /* TCO_OPT_RUID; must be first */
  84.     uid_t            ruid_val;    /* real user id */
  85. };
  86.  
  87. /* rgid info opt */
  88. struct tco_opt_rgid {
  89.     long            rgid_type;    /* TCO_OPT_RGID; must be first */
  90.     gid_t            rgid_val;    /* real group id */
  91. };
  92.  
  93. /* union of all the opts */
  94. union tco_opt {
  95.     long            opt_type;    /* opt type; must be first */
  96.     struct tco_opt_noop    opt_noop;    /* noop opt */
  97.     struct tco_opt_setid    opt_setid;    /* set ident opt */
  98.     struct tco_opt_getid    opt_getid;    /* get ident opt */
  99.     struct tco_opt_uid    opt_uid;    /* uid info opt */
  100.     struct tco_opt_gid    opt_gid;    /* gid info opt */
  101.     struct tco_opt_ruid    opt_ruid;    /* ruid info opt */
  102.     struct tco_opt_rgid    opt_rgid;    /* rgid info opt */
  103. };
  104.  
  105. /******************************************************************************/
  106.  
  107. #ifdef _KERNEL
  108.  
  109. /*
  110.  *    transport endpoint structure
  111.  */
  112. struct tco_endpt {
  113.     struct tco_endpt    *te_folist;    /* forw ptr, list of open endpts */
  114.     struct tco_endpt    *te_bolist;    /* back ptr, list of open endpts */
  115.     struct tco_endpt    *te_frqlist;    /* forw ptr, te_rq list */
  116.     struct tco_endpt    *te_brqlist;    /* back ptr, te_rq list */
  117.     struct tco_endpt    *te_fblist;    /* forw ptr, list of endpts bound to addr */
  118.     struct tco_endpt    *te_bblist;    /* back ptr, list of endpts bound to addr */
  119.     queue_t            *te_rq;        /* stream read queue */
  120.     struct tco_addr        *te_addr;    /* addr bound to this endpt */
  121.     minor_t            te_min;        /* minor number */
  122.     unsigned short        te_rqhash;    /* te_rq hash bucket */
  123.     char             te_state;    /* state of interface */
  124.     char            te_flg;        /* internal flags */
  125.     long            te_idflg;    /* ident flags */
  126.     unsigned char        te_qlen;    /* max incoming connect reqs pending */
  127.     unsigned char        te_nicon;    /* num of incoming connect reqs pending */
  128. #define TCO_MAXQLEN        8        /* must be <= (1 << (NBBY*sizeof(te_nicon))) */
  129.     struct tco_endpt    *te_icon[TCO_MAXQLEN];    /* incoming connect requests pending */
  130.     struct tco_endpt    *te_ocon;    /* outgoing connect request pending */
  131.     struct tco_endpt    *te_con;    /* connected endpt */
  132.     uid_t            te_uid;        /* uid */
  133.     gid_t            te_gid;        /* gid */
  134.     uid_t            te_ruid;    /* ruid */
  135.     gid_t            te_rgid;    /* rgid */
  136. };
  137. typedef struct tco_endpt    tco_endpt_t;
  138.  
  139. /*
  140.  *    transport addr structure
  141.  */
  142. struct tco_addr {
  143.     struct tco_addr        *ta_falist;    /* forw ptr, list of bound addrs */
  144.     struct tco_addr        *ta_balist;    /* back ptr, list of bound addrs */
  145.     struct tco_endpt    *ta_hblist;    /* head ptr, list of endpts bound to this addr */
  146.     struct tco_endpt    *ta_tblist;    /* tail ptr, list of endpts bound to this addr */
  147.     unsigned short         ta_ahash;    /* addr hash bucket */
  148.     long            ta_alen;    /* length of abuf */
  149.     char            *ta_abuf;    /* the addr itself */
  150. };
  151. typedef struct tco_addr        tco_addr_t;
  152.  
  153. /*
  154.  *    registered id
  155.  */
  156. #ifdef TICOTS
  157. #define TCO_ID            10002
  158. #endif
  159. #ifdef TICOTSORD
  160. #define    TCO_ID            10003
  161. #endif
  162.  
  163. /*
  164.  *    macro to change state
  165.  *    NEXTSTATE(event,current state)
  166.  */
  167. #define NEXTSTATE(X,Y)        ti_statetbl[X][Y]    /* should be standardized */
  168. #define NR             127    /* unreachable state */    /* should be standardized */
  169.  
  170. /*
  171.  *    basic constants
  172.  */
  173. #define TCO_NENDPT        (OMAXMIN+1)
  174. #ifdef TICOTS
  175. #define TCO_SERVTYPE        T_COTS
  176. #endif
  177. #ifdef TICOTSORD
  178. #define TCO_SERVTYPE        T_COTS_ORD
  179. #endif
  180. #define TCO_TIDUSZ        (4*1024)        /* max packet size */
  181. #define TCO_DEFAULTADDRSZ    4            /* default addr sz */
  182. /* can't make the following 4 sizes -1 (unlimited), because of bug in TLI/TPI specs:
  183.    unlimited data can be sent but cannot received in a well-specified way
  184.    (receiver doesn't know how big to make buffer, and T_MORE flag can't be used) */
  185. #define TCO_ADDRSZ        (256-16)        /* 16 = sizeof(struct T_bind_req)
  186.                                   = sizeof(struct T_bind_ack) */
  187. #define TCO_OPTSZ        (TCO_TIDUSZ-16)        /* 16 = sizeof(struct T_optmgmt_req)
  188.                                   = sizeof(struct T_optmgmt_ack) */
  189. #define TCO_CDATASZ        (TCO_TIDUSZ-24)        /* 24 = sizeof(struct T_conn_req) + 4
  190.                                   = sizeof(struct T_conn_ind)
  191.                                   = sizeof(struct T_conn_res) + 4
  192.                                   = sizeof(struct T_conn_con) + 4 */
  193. #define TCO_DDATASZ        (TCO_TIDUSZ-12)        /* 8 = sizeof(struct T_discon_req) + 4
  194.                                  = sizeof(struct T_discon_ind) */
  195. #define TCO_TSDUSZ        -1            /* unlimited */
  196. #define TCO_ETSDUSZ        -1            /* unlimited */
  197. #define TCO_MINPSZ        0
  198. #define TCO_MAXPSZ        TCO_TIDUSZ
  199. #define TCO_LOWAT        (TCO_TIDUSZ/4)
  200. #define TCO_HIWAT        (4*TCO_TIDUSZ)
  201.  
  202. /*
  203.  *    te_flg
  204.  */
  205. #define TCO_ZOMBIE        0x1            /* fatal error on endpoint */
  206.  
  207. /*
  208.  *    pass/fail indicators
  209.  */
  210. #define TCO_PASS        0
  211. #define TCO_FAIL        (!TCO_PASS)
  212. #define TCO_REALOPT        0x01            /* for tco_ckopt() */
  213. #define TCO_NOOPOPT        0x02            /* for tco_ckopt() */
  214. #define TCO_BADFORMAT        0x04            /* for tco_ckopt() */
  215. #define TCO_BADTYPE        0x08            /* for tco_ckopt() */
  216. #define TCO_BADVALUE        0x10            /* for tco_ckopt() */
  217. #define UNIX_PASS        0            /* should be standardized */
  218. #define UNIX_FAIL        (!UNIX_PASS)        /* should be standardized */
  219. #define BADSEQNUM        ((long)(-1))        /* should be standardized */
  220.  
  221. /*
  222.  *    internal defines
  223.  */
  224. #define TCO_BIND        1
  225. #define TCO_CONN        2
  226. #define TCO_OPEN        3
  227. #define TCO_RQ            4
  228. #define TCO_IDFLG_ALL        (TCO_IDFLG_UID | TCO_IDFLG_GID | TCO_IDFLG_RUID | TCO_IDFLG_RGID)
  229. #define TCO_MHASH        5
  230. #define TCO_NMHASH        (1 << TCO_MHASH)    /* num of hash buckets in open endpt table */
  231. #define TCO_MMASK        (TCO_NMHASH - 1)
  232. #define TCO_RQHASH        5            /* must be <= NBBY*sizeof(te_rqhash) */
  233. #define TCO_NRQHASH        (1 << TCO_RQHASH)    /* num of hash buckets in te_rq table */
  234. #define TCO_RQMASK        (TCO_NRQHASH - 1)
  235. /* following magic number and shift factor for fibonacci hash function */
  236. #define TCO_RQMAGIC        0x9ce14b36
  237. #define TCO_RQSHIFT        (NBBY*sizeof(int) - TCO_RQHASH)
  238. #define TCO_AHASH        5            /* must be <= NBBY*sizeof(ta_ahash) */
  239. #define TCO_NAHASH        (1 << TCO_AHASH)    /* num of hash buckets in bound addr table */
  240. #define TCO_AMASK        (TCO_NAHASH - 1)
  241.  
  242. /*
  243.  *    some useful macros
  244.  */
  245. #define tco_min(TE)        ((TE)->te_min)
  246. #define tco_mkmhash(TE)        ((unsigned)(tco_min(TE)) & TCO_MMASK)
  247. #define tco_mhash(TE)        tco_mkmhash(TE)
  248. #define tco_mkrqhash(TE)    (((((unsigned)((TE)->te_rq))*TCO_RQMAGIC) >> TCO_RQSHIFT) & TCO_RQMASK)
  249. #define tco_rqhash(TE)        ((unsigned)(TE)->te_rqhash)
  250. #define tco_alen(TA)        ((TA)->ta_alen)
  251. #define tco_abuf(TA)        ((TA)->ta_abuf)
  252. #define tco_ahash(TA)        ((unsigned)(TA)->ta_ahash)
  253. #define tco_mkahash(TA)        ((unsigned)(tco_sumbytes(tco_abuf(TA),tco_alen(TA)) & TCO_AMASK))
  254. #define tco_eqabuf(TA,TB)    ((tco_alen(TA) == tco_alen(TB)) \
  255.                  && tco_bequal(tco_abuf(TA),tco_abuf(TB),tco_alen(TA)))
  256.  
  257. /*
  258.  *    STRLOG tracing levels:
  259.  *
  260.  *    0 = urgent
  261.  *    1 = fatal
  262.  *    2 = errack
  263.  *    3 = interesting stuff
  264.  *    4 = chit-chat
  265.  */
  266.  
  267. #endif /* _KERNEL */
  268.