BSD 4_4 release
[unix-history] / usr / include / rpc / clnt.h
index 46df55e..8c002a1 100644 (file)
@@ -1,3 +1,4 @@
+/* @(#)clnt.h  2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -26,7 +27,6 @@
  * 2550 Garcia Avenue
  * Mountain View, California  94043
  */
  * 2550 Garcia Avenue
  * Mountain View, California  94043
  */
-/*      @(#)clnt.h 1.3 85/03/20 SMI      */
 
 /*
  * clnt.h - Client side remote procedure call interface.
 
 /*
  * clnt.h - Client side remote procedure call interface.
@@ -34,6 +34,9 @@
  * Copyright (C) 1984, Sun Microsystems, Inc.
  */
 
  * Copyright (C) 1984, Sun Microsystems, Inc.
  */
 
+#ifndef _CLNT_
+#define _CLNT_
+
 /*
  * Rpc calls return an enum clnt_stat.  This should be looked at more,
  * since each implementation is required to live with this (implementation
 /*
  * Rpc calls return an enum clnt_stat.  This should be looked at more,
  * since each implementation is required to live with this (implementation
@@ -61,9 +64,10 @@ enum clnt_stat {
        RPC_SYSTEMERROR=12,             /* generic "other problem" */
 
        /*
        RPC_SYSTEMERROR=12,             /* generic "other problem" */
 
        /*
-        * callrpc errors
+        * callrpc & clnt_create errors
         */
        RPC_UNKNOWNHOST=13,             /* unknown host name */
         */
        RPC_UNKNOWNHOST=13,             /* unknown host name */
+       RPC_UNKNOWNPROTO=17,            /* unkown protocol */
 
        /*
         * _ create errors
 
        /*
         * _ create errors
@@ -114,6 +118,7 @@ typedef struct {
                void            (*cl_geterr)(); /* get specific error code */
                bool_t          (*cl_freeres)(); /* frees results */
                void            (*cl_destroy)();/* destroy this structure */
                void            (*cl_geterr)(); /* get specific error code */
                bool_t          (*cl_freeres)(); /* frees results */
                void            (*cl_destroy)();/* destroy this structure */
+               bool_t          (*cl_control)();/* the ioctl() of rpc */
        } *cl_ops;
        caddr_t                 cl_private;     /* private stuff */
 } CLIENT;
        } *cl_ops;
        caddr_t                 cl_private;     /* private stuff */
 } CLIENT;
@@ -135,7 +140,7 @@ typedef struct {
  *     caddr_t argsp;
  *     xdrproc_t xres;
  *     caddr_t resp;
  *     caddr_t argsp;
  *     xdrproc_t xres;
  *     caddr_t resp;
- *     struct timeval  timeout;
+ *     struct timeval timeout;
  */
 #define        CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)     \
        ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
  */
 #define        CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)     \
        ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
@@ -169,6 +174,28 @@ typedef struct {
 #define        CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
 #define        clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
 
 #define        CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
 #define        clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
 
+/*
+ * bool_t
+ * CLNT_CONTROL(cl, request, info)
+ *      CLIENT *cl;
+ *      u_int request;
+ *      char *info;
+ */
+#define        CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
+#define        clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
+
+/*
+ * control operations that apply to both udp and tcp transports
+ */
+#define CLSET_TIMEOUT       1   /* set timeout (timeval) */
+#define CLGET_TIMEOUT       2   /* get timeout (timeval) */
+#define CLGET_SERVER_ADDR   3   /* get server's address (sockaddr) */
+/*
+ * udp only control operations
+ */
+#define CLSET_RETRY_TIMEOUT 4   /* set retry timeout (timeval) */
+#define CLGET_RETRY_TIMEOUT 5   /* get retry timeout (timeval) */
+
 /*
  * void
  * CLNT_DESTROY(rh);
 /*
  * void
  * CLNT_DESTROY(rh);
@@ -210,18 +237,20 @@ typedef struct {
  */
 extern CLIENT *clntraw_create();
 
  */
 extern CLIENT *clntraw_create();
 
+
 /*
 /*
- * UDP based rpc.
- * CLIENT *
- * clntudp_create(raddr, program, version, wait, sockp)
- *     struct sockaddr_in *raddr;
- *     u_long program;
- *     u_long version;
- *     struct timeval wait;
- *     int *sockp;
+ * Generic client creation routine. Supported protocols are "udp" and "tcp"
  */
  */
-extern CLIENT *clntudp_create();
-#define UDPMSGSIZE 8800
+extern CLIENT *
+clnt_create(/*host, prog, vers, prot*/); /*
+       char *host;     -- hostname
+       u_long prog;    -- program number
+       u_long vers;    -- version number
+       char *prot;     -- protocol
+*/
+
+
+
 
 /*
  * TCP based rpc
 
 /*
  * TCP based rpc
@@ -236,6 +265,46 @@ extern CLIENT *clntudp_create();
  */
 extern CLIENT *clnttcp_create();
 
  */
 extern CLIENT *clnttcp_create();
 
+/*
+ * UDP based rpc.
+ * CLIENT *
+ * clntudp_create(raddr, program, version, wait, sockp)
+ *     struct sockaddr_in *raddr;
+ *     u_long program;
+ *     u_long version;
+ *     struct timeval wait;
+ *     int *sockp;
+ *
+ * Same as above, but you specify max packet sizes.
+ * CLIENT *
+ * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
+ *     struct sockaddr_in *raddr;
+ *     u_long program;
+ *     u_long version;
+ *     struct timeval wait;
+ *     int *sockp;
+ *     u_int sendsz;
+ *     u_int recvsz;
+ */
+extern CLIENT *clntudp_create();
+extern CLIENT *clntudp_bufcreate();
+
+/*
+ * Print why creation failed
+ */
+void clnt_pcreateerror(/* char *msg */);       /* stderr */
+char *clnt_spcreateerror(/* char *msg */);     /* string */
+
+/*
+ * Like clnt_perror(), but is more verbose in its output
+ */ 
+void clnt_perrno(/* enum clnt_stat num */);    /* stderr */
+
+/*
+ * Print an English error message, given the client error code
+ */
+void clnt_perror(/* CLIENT *clnt, char *msg */);       /* stderr */
+char *clnt_sperror(/* CLIENT *clnt, char *msg */);     /* string */
 
 /* 
  * If a creation fails, the following allows the user to figure out why.
 
 /* 
  * If a creation fails, the following allows the user to figure out why.
@@ -247,3 +316,16 @@ struct rpc_createerr {
 
 extern struct rpc_createerr rpc_createerr;
 
 
 extern struct rpc_createerr rpc_createerr;
 
+
+
+/*
+ * Copy error message to buffer.
+ */
+char *clnt_sperrno(/* enum clnt_stat num */);  /* string */
+
+
+
+#define UDPMSGSIZE     8800    /* rpc imposed limit on udp msg size */
+#define RPCSMALLMSGSIZE        400     /* a more reasonable packet size */
+
+#endif /*!_CLNT_*/