"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/rpc/rpc-lib/src/xdr-rpc.h" (16 Sep 2020, 3304 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "xdr-rpc.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2   Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
    3   This file is part of GlusterFS.
    4 
    5   This file is licensed to you under your choice of the GNU Lesser
    6   General Public License, version 3 or any later version (LGPLv3 or
    7   later), or the GNU General Public License, version 2 (GPLv2), in all
    8   cases as published by the Free Software Foundation.
    9 */
   10 
   11 #ifndef _XDR_RPC_H_
   12 #define _XDR_RPC_H_
   13 
   14 #ifndef GF_SOLARIS_HOST_OS
   15 #include <rpc/rpc.h>
   16 #endif
   17 
   18 #ifdef GF_SOLARIS_HOST_OS
   19 #include <rpc/auth.h>
   20 #include <rpc/auth_sys.h>
   21 #endif
   22 
   23 #include <arpa/inet.h>
   24 #include <rpc/xdr.h>
   25 #include <sys/uio.h>
   26 
   27 #include "xdr-common.h"
   28 
   29 typedef enum {
   30     AUTH_GLUSTERFS = 5,
   31     AUTH_GLUSTERFS_v2 = 390039, /* using a number from  'unused' range,
   32                                    from the list available in RFC5531 */
   33     AUTH_GLUSTERFS_v3 = 390040, /* this too is unused */
   34 } gf_rpc_authtype_t;
   35 
   36 /* Converts a given network buffer from its XDR format to a structure
   37  * that contains everything an RPC call needs to work.
   38  */
   39 extern int
   40 xdr_to_rpc_call(char *msgbuf, size_t len, struct rpc_msg *call,
   41                 struct iovec *payload, char *credbytes, char *verfbytes);
   42 
   43 extern int
   44 rpc_fill_empty_reply(struct rpc_msg *reply, uint32_t xid);
   45 
   46 extern int
   47 rpc_fill_denied_reply(struct rpc_msg *reply, int rjstat, int auth_err);
   48 
   49 extern int
   50 rpc_fill_accepted_reply(struct rpc_msg *reply, int arstat, int proglow,
   51                         int proghigh, int verf, int len, char *vdata);
   52 extern int
   53 rpc_reply_to_xdr(struct rpc_msg *reply, char *dest, size_t len,
   54                  struct iovec *dst);
   55 
   56 extern int
   57 xdr_to_auth_unix_cred(char *msgbuf, int msglen, struct authunix_parms *au,
   58                       char *machname, gid_t *gids);
   59 /* Macros that simplify accessing the members of an RPC call structure. */
   60 #define rpc_call_xid(call) ((call)->rm_xid)
   61 #define rpc_call_direction(call) ((call)->rm_direction)
   62 #define rpc_call_rpcvers(call) ((call)->ru.RM_cmb.cb_rpcvers)
   63 #define rpc_call_program(call) ((call)->ru.RM_cmb.cb_prog)
   64 #define rpc_call_progver(call) ((call)->ru.RM_cmb.cb_vers)
   65 #define rpc_call_progproc(call) ((call)->ru.RM_cmb.cb_proc)
   66 #define rpc_opaque_auth_flavour(oa) ((oa)->oa_flavor)
   67 #define rpc_opaque_auth_len(oa) ((oa)->oa_length)
   68 
   69 #define rpc_call_cred_flavour(call)                                            \
   70     (rpc_opaque_auth_flavour((&(call)->ru.RM_cmb.cb_cred)))
   71 #define rpc_call_cred_len(call)                                                \
   72     (rpc_opaque_auth_len((&(call)->ru.RM_cmb.cb_cred)))
   73 
   74 #define rpc_call_verf_flavour(call)                                            \
   75     (rpc_opaque_auth_flavour((&(call)->ru.RM_cmb.cb_verf)))
   76 #define rpc_call_verf_len(call)                                                \
   77     (rpc_opaque_auth_len((&(call)->ru.RM_cmb.cb_verf)))
   78 
   79 #if defined(GF_DARWIN_HOST_OS) || !defined(HAVE_RPC_RPC_H)
   80 #define GF_PRI_RPC_XID PRIu32
   81 #define GF_PRI_RPC_VERSION PRIu32
   82 #define GF_PRI_RPC_PROG_ID PRIu32
   83 #define GF_PRI_RPC_PROG_VERS PRIu32
   84 #define GF_PRI_RPC_PROC PRIu32
   85 #define GF_PRI_RPC_PROC_VERSION PRIu32
   86 #else
   87 #define GF_PRI_RPC_XID PRIu64
   88 #define GF_PRI_RPC_VERSION PRIu64
   89 #define GF_PRI_RPC_PROG_ID PRIu64
   90 #define GF_PRI_RPC_PROG_VERS PRIu64
   91 #define GF_PRI_RPC_PROC PRIu64
   92 #define GF_PRI_RPC_PROC_VERSION PRIu64
   93 #endif
   94 
   95 #endif