mask-loopback-address-allow-loopback-interfaces-to-be-advertised-20041110
[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 #ifndef _RX_STREAM_
14 #define _RX_STREAM_
15 #ifdef  KERNEL
16 #include "rx/rx.h"
17 #else                           /* KERNEL */
18 #include <sys/types.h>
19 #include <sys/uio.h>
20 #include "rx.h"
21 #endif                          /* KERNEL */
22 /* Write descriptor */
23     struct rx_stream_wd {
24     char *freePtr;              /* Pointer to bytes in first packet */
25     int nFree;                  /* Number of bytes free in first packet */
26     struct rx_call *call;       /* The call this stream is attached to */
27     struct rx_queue wq;         /* Currently allocated packets for this stream */
28     int packetSize;             /* Data size used in each packet */
29 };
30
31 /* Read descriptor */
32 struct rx_stream_rd {
33     struct rx_packet *packet;   /* The current packet */
34     char *nextByte;             /* Pointer to bytes in current packet */
35     int nLeft;                  /* Number of bytes free in current packet */
36     struct rx_call *call;       /* The call this stream is attached to */
37     struct rx_queue rq;         /* Currently allocated packets for this stream */
38     struct rx_queue freeTheseQ; /* These packets should be freed on the next operation */
39 };
40
41 /* Composite stream descriptor */
42 struct rx_stream {
43     union {
44         struct rx_stream_rd rd;
45         struct rx_stream_wd wd;
46     } sd;
47 };
48
49 /* Externals */
50 void rx_stream_InitWrite();
51 void rx_stream_InitRead();
52 void rx_stream_FinishWrite();
53 void rx_stream_FinishRead();
54 int rx_stream_Read();
55 int rx_stream_Write();
56 int rx_stream_AllocIov();
57
58 /* Write nbytes of data to the write stream.  Returns the number of bytes written */
59 /* If it returns 0, the call status should be checked with rx_Error. */
60 #define rx_stream_Write(iod, buf, nbytes)                               \
61     (iod)->sd.wd.nFree > (nbytes) ?                                     \
62         (buf) && memcpy((iod)->sd.wd.freePtr, (buf), (nbytes)),         \
63         (iod)->sd.wd.nFree -= (nbytes),                                 \
64         (iod)->sd.wd.freePtr += (nbytes), (nbytes)                      \
65       : rx_stream_WriteProc((iod), (buf), (nbytes))
66
67
68 /* Read nbytes of data from the read stream.  Returns the number of bytes read */
69 /* If it returns less than requested, the call status should be checked with rx_Error */
70 #define rx_stream_Read(iod, buf, nbytes)                                        \
71     (iod)->sd.rd.nLeft > (nbytes) ?                                             \
72     memcpy((buf), (iod)->sd.rd.nextByte, (nbytes)),                             \
73     (iod)->sd.rd.nLeft -= (nbytes), (iod)->sd.rd.nextByte += (nbytes), (nbytes) \
74    : rx_stream_ReadProc((iod), (buf), (nbytes))
75
76 #endif /* _RX_STREAM_    End of rx_stream.h */