home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / sys / ticlts.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  7.6 KB  |  250 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/ticlts.h.sl 1.1 4.0 12/08/90 61620 AT&T-USL"
  11. /*
  12.  *    ticlts provider-dependent info
  13.  *    (provider-independent applications must not include this header file)
  14.  */
  15.  
  16. /*
  17.  *    unitdata error codes (see t_rcvuderr())
  18.  */
  19. #define TCL_BADADDR        1        /* bad addr specification */
  20. #define TCL_BADOPT        2        /* bad option specification */
  21. #define TCL_NOPEER        3        /* dest addr is unbound */
  22. #define TCL_PEERBADSTATE    4        /* peer in wrong state */
  23.  
  24. /*
  25.  *    options (flattened linked-list of flattened C-structures)
  26.  */
  27. #define TCL_OPT_NOHDR        0        /* invalid nexthdr offset (end of list) */
  28.  
  29. #define TCL_OPT_NOOP        1        /* no-op opt -- default */
  30. #define TCL_OPT_SETID        2        /* set ident */
  31. #define TCL_OPT_GETID        3        /* get ident */
  32. #define TCL_OPT_UID        4        /* uid info */
  33. #define TCL_OPT_GID        5        /* gid info */
  34. #define TCL_OPT_RUID        6        /* ruid info */
  35. #define TCL_OPT_RGID        7        /* rgid info */
  36.  
  37. #define TCL_IDFLG_UID        0x1        /* uid flag */
  38. #define TCL_IDFLG_GID        0x2        /* gid flag */
  39. #define TCL_IDFLG_RUID        0x4        /* ruid flag */
  40. #define TCL_IDFLG_RGID        0x8        /* rgid flag */
  41.  
  42. /* header for maintaining list of opts; one for each opt in list;
  43.    offsets are measured from beginning of options buffer;
  44.    headers must occur in increasing order, to avoid loops */
  45. struct tcl_opt_hdr {
  46.     long            hdr_thisopt_off;    /* offset to current opt */
  47.     long            hdr_nexthdr_off;    /* offset to next hdr */
  48. };
  49.  
  50. /* no-op opt -- the default */
  51. struct tcl_opt_noop {
  52.     long            noop_type;    /* TCL_OPT_NOOP; must be first */
  53. };
  54.  
  55. /* set ident opt -- subsequent t_rcvudata()'s
  56.    (i.e., T_UNITDATA_IND) will contain peer's ident info */
  57. struct tcl_opt_setid {
  58.     long            setid_type;    /* TCL_OPT_SETID; must be first */
  59.     long            setid_flg;    /* which id opts to set */
  60. };
  61.  
  62. /* get ident opt */
  63. struct tcl_opt_getid {
  64.     long            getid_type;    /* TCL_OPT_GETID; must be first */
  65.     long            getid_flg;    /* which id opts are set */
  66. };
  67.  
  68. /* uid info opt */
  69. struct tcl_opt_uid {
  70.     long            uid_type;    /* TCL_OPT_UID; must be first */
  71.     uid_t            uid_val;    /* effective user id */
  72. };
  73.  
  74. /* gid info opt */
  75. struct tcl_opt_gid {
  76.     long            gid_type;    /* TCL_OPT_GID; must be first */
  77.     gid_t            gid_val;    /* effective group id */
  78. };
  79.  
  80. /* ruid info opt */
  81. struct tcl_opt_ruid {
  82.     long            ruid_type;    /* TCL_OPT_RUID; must be first */
  83.     uid_t            ruid_val;    /* real user id */
  84. };
  85.  
  86. /* rgid info opt */
  87. struct tcl_opt_rgid {
  88.     long            rgid_type;    /* TCL_OPT_RGID; must be first */
  89.     gid_t            rgid_val;    /* real group id */
  90. };
  91.  
  92. /* union of all the opts */
  93. union tcl_opt {
  94.     long            opt_type;    /* opt type; must be first */
  95.     struct tcl_opt_noop    opt_noop;    /* noop opt */
  96.     struct tcl_opt_setid    opt_setid;    /* set ident opt */
  97.     struct tcl_opt_getid    opt_getid;    /* get ident opt */
  98.     struct tcl_opt_uid    opt_uid;    /* uid info opt */
  99.     struct tcl_opt_gid    opt_gid;    /* gid info opt */
  100.     struct tcl_opt_ruid    opt_ruid;    /* ruid info opt */
  101.     struct tcl_opt_rgid    opt_rgid;    /* rgid info opt */
  102. };
  103.  
  104. /******************************************************************************/
  105.  
  106. #ifdef _KERNEL
  107.  
  108. /*
  109.  *    transport endpoint structure
  110.  */
  111. struct tcl_endpt {
  112.     struct tcl_endpt    *te_folist;    /* forw ptr, list of open endpts */
  113.     struct tcl_endpt    *te_bolist;    /* back ptr, list of open endpts */
  114.     queue_t            *te_rq;        /* stream read queue */
  115.     queue_t            *te_backwq;    /* back q on WR side for flow cntl */
  116.     struct tcl_addr        *te_addr;    /* address bound to this endpt */
  117.     minor_t            te_min;        /* minor number */
  118.     char            te_state;    /* state of interface */
  119.     char            te_flg;        /* internal flags */
  120.     long            te_idflg;    /* ident flags */
  121.     uid_t            te_uid;        /* uid */
  122.     gid_t            te_gid;        /* gid */
  123.     uid_t            te_ruid;    /* ruid */
  124.     gid_t            te_rgid;    /* rgid */
  125. };
  126. typedef struct tcl_endpt    tcl_endpt_t;
  127.  
  128. /*
  129.  *    transport addr structure
  130.  */
  131. struct tcl_addr {
  132.     struct tcl_addr        *ta_falist;    /* forw ptr, list of bound addrs */
  133.     struct tcl_addr        *ta_balist;    /* back ptr, list of bound addrs */
  134.     struct tcl_endpt    *ta_blist;    /* list (<= 1) of endpts bound to this addr */
  135.     unsigned short        ta_ahash;    /* addr hash bucket */
  136.     long            ta_alen;    /* length of abuf */
  137.     char            *ta_abuf;    /* the addr itself */
  138. };
  139. typedef struct tcl_addr        tcl_addr_t;
  140.  
  141. /* M_CTL types.
  142.  */
  143. #define        TCL_IOCTL    ('T'<<8)
  144. #define        TCL_LINK    (TCL_IOCTL|101)
  145. #define        TCL_UNLINK    (TCL_IOCTL|102)
  146.  
  147. /* Socket link M_CTL structure.
  148.  */
  149. struct tcl_sictl {
  150.     long    type;
  151.     long    ADDR_offset;
  152.     long    ADDR_len;
  153. };
  154.  
  155. /*
  156.  *    registered id
  157.  */
  158. #define TCL_ID            10001
  159.  
  160. /*
  161.  *    macro to change state
  162.  *    NEXTSTATE(event, current state)
  163.  */
  164. #define NEXTSTATE(X,Y)        ti_statetbl[X][Y]    /* should be standardized */
  165. #define NR             127    /* unreachable state */    /* should be standardized */
  166.  
  167. /*
  168.  *    basic constants
  169.  */
  170. #define TCL_NENDPT        (OMAXMIN+1)
  171. #define TCL_SERVTYPE        T_CLTS
  172. #define TCL_TIDUSZ        (4*1024)        /* max packet size */
  173. #define TCL_DEFAULTADDRSZ    4            /* default addr sz */
  174. /* can't make the following 2 sizes -1 (unlimited), because of bug in TLI/TPI specs:
  175.    unlimited data can be sent but cannot received in a well-specified way
  176.    (receiver doesn't know how big to make buffer, and T_MORE flag can't be used) */
  177. #define TCL_ADDRSZ        (256-24)        /* 24 = sizeof(struct T_bind_req) + 8
  178.                                   = sizeof(struct T_bind_ack) + 8
  179.                                   = sizeof(struct T_unitdata_req) + 4
  180.                                   = sizeof(struct T_uderror_ind) */
  181. #define TCL_OPTSZ        (TCL_TIDUSZ-24)        /* 24 = sizeof(struct T_optmgmt_req) + 8
  182.                                   = sizeof(struct T_optmgmt_ack) + 8
  183.                                   = sizeof(struct T_unitdata_req) + 4
  184.                                   = sizeof(struct T_uderror_ind) */
  185. #define TCL_CDATASZ        -2            /* connectionless */
  186. #define TCL_DDATASZ        -2            /* connectionless */
  187. #define TCL_TSDUSZ        TCL_TIDUSZ        /* connectionless */
  188. #define TCL_ETSDUSZ        -2            /* connectionless */
  189. #define TCL_MINPSZ        0
  190. #define TCL_MAXPSZ        TCL_TIDUSZ
  191. #define TCL_LOWAT        (TCL_TIDUSZ/4)
  192. #define TCL_HIWAT        (4*TCL_TIDUSZ)
  193.  
  194. /*
  195.  *    te_flg
  196.  */
  197. #define TCL_ZOMBIE        0x1            /* fatal error on endpoint */
  198.  
  199. /*
  200.  *    pass/fail indicators
  201.  */
  202. #define TCL_PASS        0
  203. #define TCL_FAIL        (!TCL_PASS)
  204. #define TCL_REALOPT        0x01            /* for tcl_ckopt() */
  205. #define TCL_NOOPOPT        0x02            /* for tcl_ckopt() */
  206. #define TCL_BADFORMAT        0x04            /* for tcl_ckopt() */
  207. #define TCL_BADTYPE        0x08            /* for tcl_ckopt() */
  208. #define TCL_BADVALUE        0x10            /* for tcl_ckopt() */
  209. #define UNIX_PASS        0            /* should be standardized */
  210. #define UNIX_FAIL        (!UNIX_PASS)        /* should be standardized */
  211.  
  212. /*
  213.  *    internal defines
  214.  */
  215. #define TCL_BIND        1
  216. #define TCL_DEST        2
  217. #define TCL_OPEN        3
  218. #define TCL_IDFLG_ALL        (TCL_IDFLG_UID | TCL_IDFLG_GID | TCL_IDFLG_RUID | TCL_IDFLG_RGID)
  219. #define TCL_MHASH        5
  220. #define TCL_NMHASH        (1 << TCL_MHASH)    /* num of hash buckets in open endpt table */
  221. #define TCL_MMASK        (TCL_NMHASH - 1)
  222. #define TCL_AHASH        5            /* must be <= NBBY*sizeof(tcl_addr.ta_ahash) */
  223. #define TCL_NAHASH        (1 << TCL_AHASH)    /* num of hash buckets in bound addr table */
  224. #define TCL_AMASK        (TCL_NAHASH - 1)
  225.  
  226. /*
  227.  *    some useful macros
  228.  */
  229. #define tcl_min(TE)        ((TE)->te_min)
  230. #define tcl_mkmhash(TE)        ((unsigned)(tcl_min(TE)) & TCL_MMASK)
  231. #define tcl_mhash(TE)        tcl_mkmhash(TE)
  232. #define tcl_alen(TA)        ((TA)->ta_alen)
  233. #define tcl_abuf(TA)        ((TA)->ta_abuf)
  234. #define tcl_mkahash(TA)        ((unsigned)(tcl_sumbytes(tcl_abuf(TA),tcl_alen(TA)) & TCL_AMASK))
  235. #define tcl_ahash(TA)        ((unsigned)(TA)->ta_ahash)
  236. #define tcl_eqabuf(TA,TB)    ((tcl_alen(TA) == tcl_alen(TB)) \
  237.                  && tcl_bequal(tcl_abuf(TA),tcl_abuf(TB),tcl_alen(TA)))
  238.  
  239. /*
  240.  *    STRLOG tracing levels:
  241.  *
  242.  *    0 = urgent
  243.  *    1 = fatal
  244.  *    2 = errack, uderr
  245.  *    3 = interesting stuff
  246.  *    4 = chit-chat
  247.  */
  248.  
  249. #endif /* _KERNEL */
  250.