rx-keep-track-of-resent-packets-20010406
[openafs.git] / src / rx / rx_stream.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* rx_stream.h:  the stream I/O layer for RX */
11
12 This file is now obsolete.
13
14
15
16 #ifndef _RX_STREAM_
17 #define _RX_STREAM_
18
19 #ifdef  KERNEL
20 #include "../rx/rx.h"
21 #else /* KERNEL */
22 #include <sys/types.h>
23 #include <sys/uio.h>
24 #include "rx.h"
25 #endif /* KERNEL */
26
27 /* Write descriptor */
28 struct rx_stream_wd {
29     char *freePtr;              /* Pointer to bytes in first packet */
30     int nFree;                  /* Number of bytes free in first packet */
31     struct rx_call *call;       /* The call this stream is attached to */
32     struct rx_queue wq;         /* Currently allocated packets for this stream */
33     int packetSize;             /* Data size used in each packet */
34 };
35
36 /* Read descriptor */
37 struct rx_stream_rd {
38     struct rx_packet *packet;   /* The current packet */
39     char *nextByte;             /* Pointer to bytes in current packet */
40     int nLeft;                  /* Number of bytes free in current packet */
41     struct rx_call *call;       /* The call this stream is attached to */
42     struct rx_queue rq;         /* Currently allocated packets for this stream */
43     struct rx_queue freeTheseQ; /* These packets should be freed on the next operation */
44 };
45
46 /* Composite stream descriptor */
47 struct rx_stream {
48     union {
49         struct rx_stream_rd rd;
50         struct rx_stream_wd wd;
51     } sd;
52 };
53
54 /* Externals */
55 void rx_stream_InitWrite();
56 void rx_stream_InitRead();
57 void rx_stream_FinishWrite();
58 void rx_stream_FinishRead();
59 int rx_stream_Read();
60 int rx_stream_Write();
61 int rx_stream_AllocIov();
62
63 /* Write nbytes of data to the write stream.  Returns the number of bytes written */
64 /* If it returns 0, the call status should be checked with rx_Error. */
65 #define rx_stream_Write(iod, buf, nbytes)                               \
66     (iod)->sd.wd.nFree > (nbytes) ?                                     \
67         (buf) && bcopy((buf), (iod)->sd.wd.freePtr, (nbytes)),          \
68         (iod)->sd.wd.nFree -= (nbytes),                                 \
69         (iod)->sd.wd.freePtr += (nbytes), (nbytes)                      \
70       : rx_stream_WriteProc((iod), (buf), (nbytes))
71
72
73 /* Read nbytes of data from the read stream.  Returns the number of bytes read */
74 /* If it returns less than requested, the call status should be checked with rx_Error */
75 #define rx_stream_Read(iod, buf, nbytes)                                        \
76     (iod)->sd.rd.nLeft > (nbytes) ?                                             \
77     bcopy((iod)->sd.rd.nextByte, (buf), (nbytes)),                              \
78     (iod)->sd.rd.nLeft -= (nbytes), (iod)->sd.rd.nextByte += (nbytes), (nbytes) \
79    : rx_stream_ReadProc((iod), (buf), (nbytes))
80
81 #endif /* _RX_STREAM_    End of rx_stream.h */