home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / UNIX3862.ZIP / U386-06.ZIP / U386-6.TD0 / usr / include / sys / comm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-26  |  7.1 KB  |  246 lines

  1. /*    Copyright (c) 1984, 1986, 1987, 1988 AT&T    */
  2. /*      All Rights Reserved      */
  3.  
  4. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  5. /*    The copyright notice above does not evidence any       */
  6. /*    actual or intended publication of such source code.    */
  7.  
  8.  
  9. #ident    "@(#)head.sys:comm.h    1.3"
  10.  
  11. #undef NOFILE
  12. #define NOFILE     v.v_nofiles
  13.  
  14. /*  parameters of this implementation  */
  15.  
  16. #define MINPKSIZE    64        /* minimum ethernet packet size */
  17. #define    MAXNIBUF    (1024 + 64 * 2)    /*  size of the rcvq buffers    */
  18. #define    MSGBUFSIZE    MAXNIBUF    /*  the same as above        */
  19. #define DFRPORT        2        /*  default rcv port for machine*/
  20. #define    PCOMM        PZERO        /*  priority of sleeping comm    */
  21. #define    NADDRLEN    6        /*  length of network address    */
  22. #define    RCVQEMP        -3        /*  receive queue empty        */
  23. #define NSQSIZE        10        /*  normal rcvd queue length    */
  24. #define SIGQSIZE    65535        /*  signal rcvd queue length    */
  25.  
  26.  
  27. #define    DU_UP    1    /* on network */
  28. #define    DU_DOWN    0    /* not on network */
  29. #define DU_INTER 2    /* RFS in an intermediate state */
  30.  
  31. #ifndef    TRUE
  32. #define    TRUE    1
  33. #define    FALSE    0
  34. #endif
  35.  
  36. #ifndef SUCCESS
  37. #define SUCCESS    1
  38. #define    FAILURE    0    
  39. #endif
  40.  
  41. #ifndef NULL
  42. #define NULL    0
  43. #endif
  44.  
  45.  
  46. #define ROUND(X) ((X+3)&~3)    /*  round to full word  */
  47. /* convert rcvd to an index */
  48. #define    rdtoinx(x)    (x - rcvd)
  49. /* convert index to a rcvd */
  50. #define    inxtord(x)    (&rcvd[x])
  51. /* is a receive queue empty? */
  52. #define rcvdemp(RD) (RD->rd_rcvdq.qc_head == NULL)
  53.  
  54. /*  The network address is a NADDRLEN bytes long.
  55.  */
  56.  
  57. typedef    struct  naddr  {
  58.     ushort    length;
  59.     char    address[NADDRLEN];
  60. }    naddr_t;
  61.  
  62.  
  63. typedef    int    csect_t;
  64. #define    csect()        spl6()
  65. #define    ecsect(s)    splx(s)
  66. /*
  67.  *  buffer queue control structure
  68.  */
  69.  
  70. struct    bqctrl_st {
  71.     struct    msgb *qc_head;        /* head pointer */
  72.     struct    msgb *qc_tail;        /* tail pointer */
  73. };
  74.  
  75.  
  76. /*   receive descriptor structure
  77.  */
  78.  
  79. typedef struct rcvd  {
  80.     char    rd_stat;
  81.     char    rd_qtype;        /*  unix - GENERAL or SPECIFIC    */
  82.     union    {
  83.     struct    inode *rd_inodep;    /*  unix - pointer to inode    */
  84.     struct    file  *rd_filep;    /*  unix - pointer to file table*/
  85.     }  r1;
  86.     ushort    rd_act_cnt;        /*  unix - active server count    */
  87.     ushort    rd_max_serv;        /*  unix - maximum # servers    */
  88.     struct    rcvd *rd_next;        /*  unix - pointer to next rcvd    */
  89.     ushort    rd_qsize;        /*  recv queue size        */
  90.     ushort    rd_qcnt;        /*  how many msg queued        */
  91.     ushort    rd_refcnt;        /*  how many remote send desc    */
  92.     ushort    rd_connid;        /*  connection id         */
  93.     struct    bqctrl_st rd_rcvdq;    /*  receive descriptor queue    */
  94.     struct    rd_user *rd_user_list;    /* one for each time RD is a gift */
  95.     struct    sndd *rd_sdnack;    /* send desc list for NACK */
  96.     sema_t    rd_qslp;        /*  recv desc queue sleep sema    */
  97.     time_t    rd_mtime;        /*  last write time - for cache    */
  98. }    *rcvd_t;
  99.  
  100. #define rd_inode    r1.rd_inodep
  101. #define    rd_file        r1.rd_filep
  102.  
  103. /* rd_stat */
  104. #define    RDUSED        0x1
  105. #define    RDUNUSED    0x2
  106. #define    RDLINKDOWN    0x4
  107. #define RDWANT        0x10
  108.  
  109. /* rd_qtype */
  110. #define    GENERAL        0x1
  111. #define SPECIFIC    0x2
  112. #define RDTEXT        0x40
  113.  
  114.  
  115.  
  116. /*  A send descriptor contains information to identify the destination
  117.  *  of messages sent on this descriptor.
  118.  *  It contains a pointer to the stream queue, which has a virtual circuit 
  119.  *  setup to the remote side.
  120.  *  The index tells the other side
  121.  *  which receive descriptor queue to put messages in.  
  122.  *  sd_refcnt is the refrence count of how many duplication of this
  123.  *  send descriptor due to fork on the local machine.
  124.  *  sd_mntindx is an index into the remote side's srmount table so that
  125.  *  counts can be kept properly for umount.
  126.  */
  127.  
  128. typedef struct sndd  {
  129.     char    sd_stat;
  130.     ushort    sd_refcnt;    /* how many duplication on local due to fork */
  131.     index_t    sd_sindex;    /* index for the remote recv descriptor */
  132.     ushort    sd_connid;    /* connect id for the remote recv descriptor*/
  133.     index_t    sd_mntindx;    /* index to the remote srmount table */
  134.     ushort    sd_copycnt;    /* how many copyout on this sd */
  135.     struct    proc *sd_srvproc;    /* points to proc of dedicated server */
  136.     struct    queue *sd_queue;    /* points to stream head queue     */
  137.     struct    sndd *sd_next;
  138.     int    sd_temp;        /* used for temp sd related oper */
  139.     ushort    sd_mode;
  140.     long    sd_fhandle;    /* file handle for client caching */
  141.     off_t    sd_offset;    /* for client caching */
  142.     uint    sd_count;    /* for client caching */
  143. }    *sndd_t;
  144.  
  145. #define    SDUSED        0x1
  146. #define    SDUNUSED    0x2
  147. #define    SDLINKDOWN    0x4
  148. #define SDSERVE        0x8
  149. #define SDWANT        0x10
  150. #define SDCACHE        0x20    /* remote file is cacheable */
  151. #define SDMNDLCK    0x40    /* remote file mandatory lock set 
  152.                  * (not updated if someone turns off mandatory
  153.                  * locked with chmod on remote file before
  154.                  * last file close) */
  155.  
  156. extern    struct    sndd    sndd[];
  157.  
  158.  
  159.  
  160. /*
  161.  * default size of receive queues.
  162.  *    mount points will receive more
  163.  *    simultaneous traffic than files.
  164.  */
  165. #define    MOUNT_QSIZE    10
  166. #define    FILE_QSIZE     5
  167.  
  168. extern    struct    rcvd    rcvd[];
  169. /*
  170.  *    Every time the refcnt of an RD is bumped, an rd_user
  171.  *    structure is allocated to keep track of who it was
  172.  *    bumped for and why.  This is the only way we have
  173.  *    enough information to clean up after a crash.
  174.  */
  175.  
  176. struct rd_user {
  177.     struct    rd_user *ru_next;    /* next user */
  178.     struct    queue *ru_queue;    /* which stream queue */
  179.     index_t    ru_srmntindx;        /* which srmount entry */
  180.     ushort ru_fcount;
  181.     ushort ru_icount;
  182.     ushort ru_frcnt;
  183.     ushort ru_fwcnt;
  184.     ushort ru_stat;            /* rd_user struct status */
  185.     ushort ru_cflag;        /* cache flag */
  186.     ushort ru_cwcnt;        /* cache writer count */
  187. };
  188.  
  189. extern struct rd_user rd_user[];
  190.  
  191. /*  status flags     */
  192. #define    RU_FREE        0x1        /* rd_user structure is on free list */
  193. #define    RU_USED        0x2        /* structure is in use */
  194.  
  195. /*    cache flags     */
  196. #define CACHE_OFF    0x1        /* no remote cache */
  197. #define CACHE_ENABLE    0x2        /* remote cache is on */
  198. #define CACHE_DISABLE    0x4        /* cache is disabled */
  199. #define CACHE_REENABLE    0x8        /* cache can be re-enabled */
  200. #define CACHE_WRITE    0x10        /* remote machine has done a write */
  201.  
  202.  
  203.  
  204. /*  
  205.  *   The message structure is the header to every message.
  206.  */
  207.  
  208. struct    message  {
  209.     long    m_cmd;        /*  not used                 */
  210.     long    m_stat;        /*  see stat values below          */
  211.     long    m_dest;        /*  destination index to which this goes*/
  212.     long    m_connid;    /*  connection id            */
  213.     long    m_gindex;    /*  gift index                */
  214.     long    m_gconnid;    /*  gift connection id            */
  215.     long    m_size;        /*  size of this message        */
  216.     long    m_queue;    /*  queue message came in on         */
  217. };
  218.  
  219. #define    PTOMSG(x)    (((struct message *)x) + 1)
  220.  
  221. /*  status values  */
  222. #define GIFT    0x8        /*  are address & index real?    */
  223. #define SIGNAL    0x10        /*set for signal messages*/
  224. #define VER1    0x20        /*set for NACKABLE messages*/
  225.  
  226. /*  parameters of the implementation  */
  227.  
  228. extern    int    nrcvd;         /*  number of receive descriptors*/
  229. extern    int    nsndd;        /*  number of send descriptors    */
  230. extern    int    nrduser;    /*  number of rd_user entries    */
  231. extern  int    maxserve;
  232. extern  int    minserve;
  233.  
  234. /*  subroutines available from the communications interface  */
  235.  
  236. extern    sndd_t    cr_sndd ();    /*  create a send descriptor        */
  237. extern        del_sndd ();    /*  delete a send descriptor        */
  238. extern    rcvd_t    cr_rcvd ();    /*  create a receive descriptor        */
  239. extern        del_rcvd ();    /*  delete a receive descriptor        */
  240. extern        sndmsg ();    /*  send a message            */
  241. extern    struct    msgb *alocbuf();/*  allocate a buffer to send later    */
  242. extern        freesbuf ();    /*  free a send buffer (didn't send)    */
  243. extern        dequeue ();    /*  dequeue a message from a rcv desc    */
  244. extern        freerbuf ();    /*  free a received message buffer    */
  245.  
  246.