+/* Structure for tracking a single incoming TCP connection for RPCs. For now,
+ * used for NFS only. */
+typedef struct {
+ GIOChannel *channel;
+
+ /* The reassembled message, thus far. */
+ GString *msgbuf;
+
+ /* Remaining number of bytes in this message fragment; 0 if we next expect
+ * another fragment header. */
+ uint32_t frag_len;
+
+ /* If frag_len is zero: the number of bytes of the fragment header that
+ * have been read so far. */
+ int frag_hdr_bytes;
+
+ /* Mutex protecting send operations on the socket (to ensure that replies
+ * are not accidentally interleaved). */
+ GMutex *send_lock;
+
+ /* Is this a UDP connection? */
+ gboolean udp_transport;
+
+ /* For UDP connections only, the address of the sender. */
+ struct sockaddr_in peer;
+
+ /* For UDP only, a buffer for accumulating the full contents of a message
+ * before it is sent */
+ GString *sendbuf;
+} RPCConnection;
+
+/* Linked list of cleanup functions to call when a request is completed. */
+struct cleanup_list {
+ void (*func)(void *arg);
+ void *arg;
+ struct cleanup_list *next;
+};
+
+/* Used to track a single outstanding RPC request. Not all of the fields are
+ * initially filled in, but more are filled in as the request is processed. */
+typedef struct {
+ /* The corresponding connection on which the request was made. */
+ RPCConnection *connection;
+
+ /* Timining information for generating statistics about response times. */
+ int64_t time_start;
+
+ /* Transaction ID of the request, in host byte order. */
+ uint32_t xid;
+
+ /* Raw XDR arguments for the call, including headers (everything except the
+ * fragment headers). Also, the offset to the actual arguments (number of
+ * bytes making up the headers). */
+ GString *raw_args;
+ size_t raw_args_header_bytes;
+
+ /* Decoded header information. */
+ int req_proc;
+
+ /* The XDR-decoded argument of the call, and the procedure to use for
+ * freeing these arguments. The actual freeing is done automatically when
+ * the response is sent. */
+ void *args;
+ xdrproc_t xdr_args_free;
+
+ /* Procedure to be used for encoding the eventual return value into XDR. */
+ xdrproc_t xdr_result;
+
+ /* Functions to be called when the response is sent to clean up any
+ * resources. */
+ struct cleanup_list *cleanup;
+} RPCRequest;
+
+extern void async_rpc_send_reply(RPCRequest *req, void *result);
+