Example #1
0
int
auth_unix_cred_to_xdr(struct authunix_parms *au, char *dest, size_t len,
                      struct iovec *iov)
{
    XDR xdr;
    int ret = -1;

    GF_VALIDATE_OR_GOTO("rpc", au, out);
    GF_VALIDATE_OR_GOTO("rpc", dest, out);
    GF_VALIDATE_OR_GOTO("rpc", iov, out);

    xdrmem_create(&xdr, dest, len, XDR_DECODE);

    if (!xdr_authunix_parms(&xdr, au)) {
        gf_log("rpc", GF_LOG_WARNING, "failed to decode authunix parms");
        goto out;
    }

    iov->iov_base = dest;
    iov->iov_len = xdr_encoded_length(xdr);

    ret = 0;
out:
    return ret;
}
Example #2
0
int
rpc_request_to_xdr(struct rpc_msg *request, char *dest, size_t len,
                   struct iovec *dst)
{
    XDR xdr;
    int ret = -1;

    GF_VALIDATE_OR_GOTO("rpc", dest, out);
    GF_VALIDATE_OR_GOTO("rpc", request, out);
    GF_VALIDATE_OR_GOTO("rpc", dst, out);

    xdrmem_create(&xdr, dest, len, XDR_ENCODE);
    if (!xdr_callmsg(&xdr, request)) {
        gf_log("rpc", GF_LOG_WARNING, "failed to encode call msg");
        goto out;
    }

    dst->iov_base = dest;
    dst->iov_len = xdr_encoded_length(xdr);

    ret = 0;

out:
    return ret;
}
Example #3
0
ssize_t
xdr_serialize_generic(struct iovec outmsg, void *res, xdrproc_t proc)
{
    ssize_t ret = -1;
    XDR xdr;

    if ((!outmsg.iov_base) || (!res) || (!proc))
        return -1;

    xdrmem_create(&xdr, outmsg.iov_base, (unsigned int)outmsg.iov_len,
                  XDR_ENCODE);

    if (!PROC(&xdr, res)) {
        ret = -1;
        goto ret;
    }

    ret = xdr_encoded_length(xdr);

ret:
    return ret;
}
Example #4
0
ssize_t
xdr_serialize_generic (struct iovec outmsg, void *res, xdrproc_t proc)
{
        ssize_t ret = -1;
        XDR     xdr;

        if ((!outmsg.iov_base) || (!res) || (!proc))
                return -1;

        xdrmem_create (&xdr, outmsg.iov_base, (unsigned int)outmsg.iov_len,
                       XDR_ENCODE);

        if (!proc (&xdr, res)) {
                gf_log_callingfn ("xdr", GF_LOG_WARNING,
                                  "XDR encoding failed");
                ret = -1;
                goto ret;
        }

        ret = xdr_encoded_length (xdr);

ret:
        return ret;
}