2 * rx.h,v 1.7 1995/04/11 06:07:07 assar Exp
9 #include <sys/socket.h>
10 #include <netinet/in.h>
17 /* XXX - This should be moved somewhere else and replaced with XDR */
19 typedef u_long unsigned32
;
20 typedef u_short unsigned16
;
22 /* Security garbage */
24 typedef struct rx_securityClass
{
27 typedef struct rx_connection rx_connection
;
29 typedef struct rx_call rx_call
;
31 typedef struct rx_service rx_service
;
33 #define RX_MAXDATA 1444 /* XXX - ??? */
36 typedef struct rx_wirepacket
{
38 char data
[RX_MAXDATA
];
42 * There are two different types of acks.
43 * soft ack means that the packet has been receieved at the other end,
44 * but the sender should not throw away the packet yet. The receiver
45 * can still drop the packet or not give it to the application.
46 * The point of the soft acks is mainly flow-control.
48 * A hard ack means that the packet has been acknowledged by the
49 * application. Then the packet can be thrown away.
57 typedef struct rx_packet
{
61 rx_packet_flags flags
;
65 /* every call - i.e. RPC transaction */
68 enum { SENDING
, RECEIVING
} mode
;
69 u_long callno
; /* Call # of this connection */
70 u_long seqno
; /* Seq # for packets */
71 int channelid
; /* What channel are we using? */
73 List
*recvpackets
; /* List of received packets */
75 List
*ooopackets
; /* Packets rec'd out-of-order */
77 rx_packet
*thispacket
; /* This packet, sending or receiving */
78 char *ptr
; /* Here we should write data */
79 unsigned nleft
; /* How much data there is left */
80 pthread_mutex_t mutex
; /* Synchronisation */
84 /* This represents the on-going communication, i.e. a connection */
87 RX_CONN_SERVER
, /* This is a server */
88 RX_CONN_CLIENT
/* The other side is a server */
93 struct rx_connection
{
94 time_t epoch
; /* Time when this connection started */
95 u_long connid
; /* Connection ID. How? */
96 struct sockaddr_in peer
; /* The one we're talking to */
97 u_long serialno
; /* Next serial number to use */
98 u_long callno
[MAXCALLS
]; /* Next call number to use */
99 rx_call
*calls
[MAXCALLS
]; /* The on-going calls */
100 u_char secindex
; /* Security index */
101 u_short serviceid
; /* Service ID */
102 rx_connection_type type
; /* Type of connection C-S or S-C */
103 u_long maxnoacked
; /* Max packet sent and soft-acked */
104 List
*packets
; /* Not yet acked sent packets */
105 u_long window
; /* Size of the window */
106 pthread_cond_t condsend
; /* Conditional variable for sending */
107 pthread_mutex_t mutexsend
; /* Mutex for above */
108 pthread_cond_t condrecv
;
109 pthread_mutex_t mutexrecv
;
110 rx_service
*service
; /* Service if server, else NULL */
116 * Here we keep the packets that have been sent but not yet
117 * hard-acked. When a packet has been soft-acked we set a flag in the
118 * packet_flags and stop the resend-timer.
125 int (*serviceproc
)(rx_call
*);
131 int rx_Init (int port
);
133 rx_connection
*rx_NewConnection (struct in_addr host
, u_short port
,
135 rx_securityClass
*sec
,
138 void rx_DestroyConnection (rx_connection
*);
140 rx_call
*rx_NewCall (rx_connection
*);
142 int rx_EndCall (rx_call
*, int);
144 rx_service
*rx_NewService(u_short port
, u_short serviceid
,
145 char *servicename
, rx_securityClass
**so
,
146 int nso
, int (*serviceproc
)(rx_call
*));
148 int rx_Write (rx_call
*, void *, int);
149 int rx_Read (rx_call
*, void *, int);
150 int rx_FlushWrite (rx_call
*call
);
162 /* header of a RPC packet */
163 /* We should use XDR on this too. */
176 /* For flags in header */
179 HF_CLIENT_INITIATED
= 1,
186 #define CALL_MASK (MAXCALLS-1)
187 #define CONNID_MASK (~(MAXCALLS-1))
189 typedef struct rx_header
{
191 unsigned32 connid
; /* And channel ID */
193 unsigned32 seqno
; /* Call-based number */
194 unsigned32 serialno
; /* Unique number */
199 unsigned16 reserved
; /* ??? verifier? */
200 unsigned16 serviceid
;
201 /* This should be the other way around according to everything but */
210 RX_ACK_REQUESTED
= 1,
211 RX_ACK_DUPLICATE
= 2,
212 RX_ACK_OUT_OF_SEQUENCE
= 3,
213 RX_ACK_EXEEDS_WINDOW
= 4,
216 RX_ACK_PING_RESPONSE
= 7,
221 RX_ACK_TYPE_NACK
= 0,
225 #define RXMAXACKS 255
227 typedef struct rx_ack_packet
{
228 unsigned16 bufferspace
;
230 unsigned32 firstpacket
; /* First packet in acks below */
231 unsigned32 prevpacket
;
232 unsigned32 serial
; /* Packet that prompted this one */
233 u_char reason
; /* rx_ack_reason */
234 u_char nacks
; /* # of acks */
235 u_char acks
[RXMAXACKS
]; /* acks (rx_ack_type) */