The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/rpc/rpcclnt.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $FreeBSD: releng/6.0/sys/rpc/rpcclnt.h 139825 2005-01-07 02:29:27Z imp $ */
    2 /*      $OpenBSD: nfsmount.h,v 1.11 2002/03/14 01:27:13 millert Exp $   */
    3 /*      $NetBSD: nfsmount.h,v 1.10 1996/02/18 11:54:03 fvdl Exp $       */
    4 
    5 /*-
    6  * copyright (c) 2003
    7  * the regents of the university of michigan
    8  * all rights reserved
    9  * 
   10  * permission is granted to use, copy, create derivative works and redistribute
   11  * this software and such derivative works for any purpose, so long as the name
   12  * of the university of michigan is not used in any advertising or publicity
   13  * pertaining to the use or distribution of this software without specific,
   14  * written prior authorization.  if the above copyright notice or any other
   15  * identification of the university of michigan is included in any copy of any
   16  * portion of this software, then the disclaimer below must also be included.
   17  * 
   18  * this software is provided as is, without representation from the university
   19  * of michigan as to its fitness for any purpose, and without warranty by the
   20  * university of michigan of any kind, either express or implied, including
   21  * without limitation the implied warranties of merchantability and fitness for
   22  * a particular purpose. the regents of the university of michigan shall not be
   23  * liable for any damages, including special, indirect, incidental, or
   24  * consequential damages, with respect to any claim arising out of or in
   25  * connection with the use of the software, even if it has been or is hereafter
   26  * advised of the possibility of such damages.
   27  */
   28 
   29 /*-
   30  * Copyright (c) 1989, 1993
   31  *      The Regents of the University of California.  All rights reserved.
   32  *
   33  * This code is derived from software contributed to Berkeley by
   34  * Rick Macklem at The University of Guelph.
   35  *
   36  * Redistribution and use in source and binary forms, with or without
   37  * modification, are permitted provided that the following conditions
   38  * are met:
   39  * 1. Redistributions of source code must retain the above copyright
   40  *    notice, this list of conditions and the following disclaimer.
   41  * 2. Redistributions in binary form must reproduce the above copyright
   42  *    notice, this list of conditions and the following disclaimer in the
   43  *    documentation and/or other materials provided with the distribution.
   44  * 4. Neither the name of the University nor the names of its contributors
   45  *    may be used to endorse or promote products derived from this software
   46  *    without specific prior written permission.
   47  *
   48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   58  * SUCH DAMAGE.
   59  *
   60  *      @(#)nfsmount.h  8.3 (Berkeley) 3/30/95
   61  */
   62 
   63 
   64 #ifndef _RPCCLNT_H_
   65 #define _RPCCLNT_H_
   66 
   67 #include <sys/types.h>
   68 #include <sys/malloc.h>
   69 #include <sys/lock.h>
   70 #include <sys/mutex.h>
   71 
   72 #ifdef __OpenBSD__
   73         #define RPC_EXEC_CTX struct proc *
   74 #else
   75         #define RPC_EXEC_CTX struct thread *
   76 #endif
   77 
   78 
   79 #ifdef RPCCLNT_DEBUG
   80 #define RPCDEBUG(args...) do{   \
   81         if(rpcdebugon != 0){    \
   82                 printf("%s(): ", __func__);\
   83                 printf(args);   \
   84                 printf("\n");   \
   85         }}while(0)
   86 #else
   87 #define RPCDEBUG(args...)
   88 #endif
   89 
   90 /* from nfs/nfs.h */
   91 #define RPC_TICKINTVL     10
   92 
   93 
   94 /* from nfs/nfsproto.h */
   95 #define RPC_MAXDATA     32768
   96 #define RPC_MAXPKTHDR   404
   97 #define RPC_MAXPACKET   (RPC_MAXPKTHDR + RPC_MAXDATA)
   98 
   99 #define RPCX_UNSIGNED   4
  100 
  101 /* defines for rpcclnt's rc_flags
  102    XXX these flags came from the NFSMNT_* flags in OpenBSD's sys/mount.h */
  103 #define RPCCLNT_SOFT            0x001 /* soft mount (hard is details) */
  104 #define RPCCLNT_INT             0x002 /* allow interrupts on hard mounts */
  105 #define RPCCLNT_NOCONN          0x004 /* dont connect the socket (udp) */
  106 #define RPCCLNT_DUMBTIMR        0x010
  107 
  108 #define RPCCLNT_SNDLOCK         0x100
  109 #define RPCCLNT_WANTSND         0x200
  110 #define RPCCLNT_RCVLOCK         0x400
  111 #define RPCCLNT_WANTRCV         0x800
  112 
  113 
  114 /* Flag values for r_flags */
  115 #define R_TIMING        0x01            /* timing request (in mntp) */
  116 #define R_SENT          0x02            /* request has been sent */
  117 #define R_SOFTTERM      0x04            /* soft mnt, too many retries */
  118 #define R_INTR          0x08            /* intr mnt, signal pending */
  119 #define R_SOCKERR       0x10            /* Fatal error on socket */
  120 #define R_TPRINTFMSG    0x20            /* Did a tprintf msg. */
  121 #define R_MUSTRESEND    0x40            /* Must resend request */
  122 #define R_GETONEREP     0x80            /* Probe for one reply only */
  123 
  124 
  125 #define RPC_HZ          (hz / rpcclnt_ticks) /* Ticks/sec */
  126 #define RPC_TIMEO       (1 * RPC_HZ)    /* Default timeout = 1 second */
  127 
  128 #define RPC_MAXREXMIT   100             /* Stop counting after this many */
  129 
  130 
  131 #define RPCIGNORE_SOERROR(s, e) \
  132                 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
  133                 ((s) & PR_CONNREQUIRED) == 0)
  134 
  135 #define RPCINT_SIGMASK  (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
  136                          sigmask(SIGHUP)|sigmask(SIGQUIT))
  137 
  138 #define RPCMADV(m, s)   (m)->m_data += (s)
  139 
  140 #define RPCAUTH_ROOTCREDS NULL
  141 
  142 #define RPCCLNTINT_SIGMASK(set)             \
  143   (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
  144          SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
  145          SIGISMEMBER(set, SIGQUIT))
  146 
  147 
  148 #define fxdr_unsigned(t, v) ((t)ntohl((int32_t)(v)))
  149 #define txdr_unsigned(v)  (htonl((int32_t)(v)))
  150 
  151 
  152 /* global rpcstats 
  153  * XXX should be per rpcclnt */
  154 struct rpcstats {
  155         int     rpcretries;
  156         int rpcrequests;
  157         int rpctimeouts;
  158         int rpcunexpected;
  159         int rpcinvalid;
  160 };
  161 
  162 struct rpc_program {
  163         u_int32_t prog_id;
  164         u_int32_t prog_version;
  165         char * prog_name;
  166 };
  167 
  168 struct rpc_auth {
  169         unsigned int auth_type;
  170 };
  171 
  172 struct rpctask {
  173         TAILQ_ENTRY(rpctask) r_chain;
  174         struct mbuf     *r_mreq;
  175         struct mbuf     *r_mrep;
  176         struct mbuf     *r_md;
  177         caddr_t         r_dpos;
  178 
  179         struct rpcclnt  *r_rpcclnt;
  180 
  181         u_int32_t       r_xid;
  182         int             r_flags;        /* flags on request, see below */
  183         int             r_retry;        /* max retransmission count */
  184         int             r_rexmit;       /* current retrans count */
  185         int             r_timer;        /* tick counter on reply */
  186         int             r_procnum;      /* NFS procedure number */
  187         int             r_rtt;          /* RTT for rpc */
  188         RPC_EXEC_CTX    r_td;
  189 };
  190 
  191 struct rpc_reply {
  192         struct {
  193                 u_int32_t type;
  194                 u_int32_t status;
  195 
  196                 /* used only when reply == RPC_MSGDENIED and
  197                  * status == RPC_AUTHERR */
  198                 u_int32_t autherr;
  199 
  200                 /* rpc mismatch info if reply == RPC_MSGDENIED and
  201                 * status == RPC_MISMATCH */
  202                 struct {
  203                         u_int32_t low;
  204                         u_int32_t high;
  205                 } mismatch_info;
  206         } stat;
  207 
  208         /* head of the mbuf chain */
  209         struct mbuf * mrep;
  210 
  211         /* mbuf and position of the verification opaque data
  212          * note that this is only valid when stat.reply == RPC_MSGACCEPTED */
  213         u_int32_t verf_type;
  214         u_int32_t verf_size;
  215         struct mbuf * verf_md;
  216         caddr_t verf_dpos;
  217 
  218         /* mbuf and postion of the result of the rpc request */
  219         struct mbuf * result_md;
  220         caddr_t result_dpos;
  221 };
  222 
  223 
  224 /*
  225  * RPC Client connection context.
  226  * One allocated on every NFS mount.
  227  * Holds RPC specific information for mount.
  228  */
  229 /* XXX: please note that all pointer type variables are just set (not copied),
  230  *      so it is up to the user to free these values */
  231 struct  rpcclnt {
  232         int     rc_flag;                /* For RPCCLNT_* flags  */
  233 
  234         int     rc_wsize;               /* Max size of the request data */
  235         int     rc_rsize;               /* Max size of the response data */
  236         struct  sockaddr *rc_name;              
  237         struct  socket *rc_so;          /* Rpc socket */
  238         int     rc_sotype;              /* Type of socket */
  239         int     rc_soproto;             /* and protocol */
  240         int     rc_soflags;             /* pr_flags for socket protocol */
  241 
  242         int     rc_timeo;               /* Init timer for NFSMNT_DUMBTIMR */
  243         int     rc_retry;               /* Max retries */
  244         int     rc_srtt[4];             /* Timers for rpcs */
  245         int     rc_sdrtt[4];
  246         int     rc_sent;                /* Request send count */
  247         int     rc_cwnd;                /* Request send window */
  248         int     rc_timeouts;            /* Request timeouts */
  249 
  250 /* XXX: this is not being set!!!! */
  251         int     rc_deadthresh;          /* Threshold of timeouts-->dead server*/
  252 
  253 
  254         /* authentication: */
  255         /* currently can be RPCAUTH_NULL, RPCAUTH_KERBV4, RPCAUTH_UNIX */
  256         /* should be kept in XDR form */
  257         int     rc_authtype;            /* Authenticator type */
  258 
  259 
  260 #if 0
  261         /* RPCAUTH_KERB4 */
  262         int     rc_authlen;             /* and length */
  263         char    *rc_authstr;            /* Authenticator string */
  264         int     rc_verflen;
  265         char    *rc_verfstr;            /* and the verifier */
  266 #endif
  267 
  268         /* RPCAUTH_UNIX*/
  269         struct rpc_auth * rc_auth;      /* authentication */
  270 
  271 #if 0
  272         /* stored in XDR form (network byte order) */
  273         unsigned int rc_progid;         /* program id */
  274         unsigned int rc_progvers;       /* program version */
  275 
  276         /* name of server for log messages */
  277         const char *rc_servername;      /* for printing error messages */
  278 #else 
  279         struct rpc_program * rc_prog;
  280 #endif
  281 
  282         /* XXX: this should be removed */
  283         int rc_proctlen;                /* if == 0 then rc_proct == NULL */
  284         int * rc_proct;
  285 };
  286 
  287 #ifdef __OpenBSD__
  288 extern struct pool rpcreply_pool;
  289 extern struct pool rpcclnt_pool;
  290 #else 
  291 /* MALLOC_DECLARE(M_RPC); */
  292 #endif
  293 extern int rpcdebugon;
  294 
  295 
  296 #ifdef __OpenBSD__
  297 #define rpcclnt_get(X)  \
  298         do {    \
  299         (X) = pool_get(&rpcclnt_pool, PR_WAITOK);       \
  300         bzero((X), sizeof(struct rpcclnt));     \
  301         }while(0)
  302 
  303 #define rpcclnt_put(X)  \
  304         do {    \
  305         if ((X) != NULL){       \
  306                 pool_put(&rpcclnt_pool, (X));   \
  307         }}while(0)
  308 
  309 #else /* !__OpenBSD__ */
  310 
  311 /* usage count for module (un)loading */
  312 extern unsigned int rpcclnt_usage;
  313 extern struct mtx rpcclnt_usage_mutex;
  314 
  315 void rpcclnt_create(struct rpcclnt ** rpc);
  316 void rpcclnt_destroy(struct rpcclnt * rpc);
  317 
  318 #define rpcclnt_get(X) rpcclnt_create(&(X))
  319 #define rpcclnt_put(X) rpcclnt_destroy(X)
  320 
  321 #ifdef RPCCLNT_TEST
  322 struct rpcclnt_test_args {
  323         int nothing;
  324 };
  325 int rpcclnt_test(struct thread *, struct rpcclnt_test_args *);
  326 
  327 #define RPC_RETURN(X) do { RPCDEBUG("returning %d", X); return X; }while(0)
  328 #endif /* RPCCLNT_TEST */
  329 
  330 #endif /* !__OpenBSD__ */
  331 
  332 void rpcclnt_init(void);
  333 void rpcclnt_uninit(void);
  334 #if 0
  335 int rpcclnt_setup(struct rpcclnt *, int, struct sockaddr *, int, int, int, int, const char *, int, int);
  336 #endif
  337 
  338 int rpcclnt_setup(struct rpcclnt *, struct rpc_program *, struct sockaddr *, int, int, struct rpc_auth *, int, int, int);
  339 
  340 
  341 int rpcclnt_connect(struct rpcclnt *, RPC_EXEC_CTX td);
  342 int rpcclnt_reconnect(struct rpctask *, RPC_EXEC_CTX td);
  343 void rpcclnt_disconnect(struct rpcclnt *);
  344 void rpcclnt_safedisconnect(struct rpcclnt *);
  345 
  346 void rpcclnt_setauth(struct rpcclnt *, u_int32_t,  u_int32_t, char *, u_int32_t, char *, struct ucred *);
  347 int rpcclnt_request(struct rpcclnt *, struct mbuf *, int, RPC_EXEC_CTX, struct ucred *, struct rpc_reply *);
  348 int rpcclnt_err(struct rpc_reply *);
  349 
  350 int rpcclnt_cancelreqs(struct rpcclnt *);
  351 int rpcclnt_sigintr(struct rpcclnt *, struct rpctask *, RPC_EXEC_CTX);
  352 
  353 
  354 #endif /* _RPCCLNT_H_ */

Cache object: 8783b9a46572365c5350fa7f5b08d296


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.