struct iobuf * quotad_serialize_reply (rpcsvc_request_t *req, void *arg, struct iovec *outmsg, xdrproc_t xdrproc) { struct iobuf *iob = NULL; ssize_t retlen = 0; ssize_t xdr_size = 0; GF_VALIDATE_OR_GOTO ("server", req, ret); /* First, get the io buffer into which the reply in arg will * be serialized. */ if (arg && xdrproc) { xdr_size = xdr_sizeof (xdrproc, arg); iob = iobuf_get2 (req->svc->ctx->iobuf_pool, xdr_size); if (!iob) { gf_log_callingfn (THIS->name, GF_LOG_ERROR, "Failed to get iobuf"); goto ret; }; iobuf_to_iovec (iob, outmsg); /* Use the given serializer to translate the give C structure in arg * to XDR format which will be written into the buffer in outmsg. */ /* retlen is used to received the error since size_t is unsigned and we * need -1 for error notification during encoding. */ retlen = xdr_serialize_generic (*outmsg, arg, xdrproc); if (retlen == -1) { /* Failed to Encode 'GlusterFS' msg in RPC is not exactly failure of RPC return values.. client should get notified about this, so there are no missing frames */ gf_log_callingfn ("", GF_LOG_ERROR, "Failed to encode message"); req->rpc_err = GARBAGE_ARGS; retlen = 0; } } outmsg->iov_len = retlen; ret: if (retlen == -1) { iobuf_unref (iob); iob = NULL; } return iob; }
int lic_submit_request(void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc) { int ret = -1; struct iovec iov = {0}; struct iobuf *iobuf = NULL; ssize_t xdr_size = 0; if (req) { xdr_size = xdr_sizeof(xdrproc, req); iobuf = iobuf_get2(THIS->ctx->iobuf_pool, xdr_size); if (!iobuf) { goto out; }; iov.iov_base = iobuf->ptr; iov.iov_len = iobuf_size (iobuf); /* Create the xdr payload */ ret = xdr_serialize_generic (iov, req, xdrproc); if (ret == -1) goto out; iov.iov_len = ret; } lic_await_connected(60); /* Send the msg */ ret = rpc_clnt_submit (g_rpc, prog, procnum, cbkfn, &iov, 1, NULL, 0, NULL, frame, NULL, 0, NULL, 0, NULL); ret = 0; out: if (iobuf) iobuf_unref (iobuf); return ret; }
ssize_t xdr_serialize_getattr3res (struct iovec outmsg, getattr3res *res) { return xdr_serialize_generic (outmsg, (void *)res, (xdrproc_t)xdr_getattr3res); }
ssize_t xdr_serialize_mountstat3 (struct iovec outmsg, mountstat3 *m) { return xdr_serialize_generic (outmsg, (void *)m, (xdrproc_t)xdr_mountstat3); }
ssize_t xdr_serialize_mountlist (struct iovec outmsg, mountlist *ml) { return xdr_serialize_generic (outmsg, (void *)ml, (xdrproc_t)xdr_mountlist); }
ssize_t xdr_serialize_mountbody (struct iovec outmsg, mountbody *mb) { return xdr_serialize_generic (outmsg, (void *)mb, (xdrproc_t)xdr_mountbody); }
ssize_t xdr_serialize_setaclreply (struct iovec inmsg, setaclreply *res) { return xdr_serialize_generic (inmsg, (void *) res, (xdrproc_t)xdr_setaclreply); }
/* Translate the mountres3 structure in res into XDR format into memory * referenced by outmsg.iov_base. * Returns the number of bytes used in encoding into XDR format. */ ssize_t xdr_serialize_mountres3 (struct iovec outmsg, mountres3 *res) { return xdr_serialize_generic (outmsg, (void *)res, (xdrproc_t)xdr_mountres3); }
ssize_t xdr_serialize_nlm4_testargs (struct iovec outmsg, nlm4_testargs *args) { return xdr_serialize_generic (outmsg, (void*)args, (xdrproc_t)xdr_nlm4_testargs); }
ssize_t xdr_serialize_nlm4_shareres (struct iovec outmsg, nlm4_shareres *res) { return xdr_serialize_generic (outmsg, (void *)res, (xdrproc_t)xdr_nlm4_shareres); }
ssize_t xdr_serialize_nfsstat3 (struct iovec outmsg, nfsstat3 *s) { return xdr_serialize_generic (outmsg, (void *)s, (xdrproc_t)xdr_nfsstat3); }
ssize_t xdr_serialize_pathconf3res (struct iovec outmsg, pathconf3res *res) { return xdr_serialize_generic (outmsg, (void *)res, (xdrproc_t)xdr_pathconf3res); }
ssize_t xdr_serialize_readdirp3res (struct iovec outmsg, readdirp3res *res) { return xdr_serialize_generic (outmsg, (void *)res, (xdrproc_t)xdr_readdirp3res); }
ssize_t xdr_serialize_link3res (struct iovec outmsg, link3res *li) { return xdr_serialize_generic (outmsg, (void *)li, (xdrproc_t)xdr_link3res); }
ssize_t xdr_from_dump_req (struct iovec outmsg, void *rsp) { return xdr_serialize_generic (outmsg, (void *)rsp, (xdrproc_t)xdr_gf_dump_req); }
int rpc_clnt_mgmt_pmap_signout (glusterfs_ctx_t *ctx, char *brickname) { int ret = 0; pmap_signout_req req = {0, }; call_frame_t *frame = NULL; cmd_args_t *cmd_args = NULL; char brick_name[PATH_MAX] = {0,}; struct iovec iov = {0, }; struct iobuf *iobuf = NULL; struct iobref *iobref = NULL; ssize_t xdr_size = 0; frame = create_frame (THIS, ctx->pool); cmd_args = &ctx->cmd_args; if (!cmd_args->brick_port && (!cmd_args->brick_name || !brickname)) { gf_log ("fsd-mgmt", GF_LOG_DEBUG, "portmapper signout arguments not given"); goto out; } if (cmd_args->volfile_server_transport && !strcmp(cmd_args->volfile_server_transport, "rdma")) { snprintf (brick_name, sizeof(brick_name), "%s.rdma", cmd_args->brick_name); req.brick = brick_name; } else { if (brickname) req.brick = brickname; else req.brick = cmd_args->brick_name; } req.port = cmd_args->brick_port; req.rdma_port = cmd_args->brick_port2; /* mgmt_submit_request is not available in libglusterfs. * Need to serialize and submit manually. */ iobref = iobref_new (); if (!iobref) { goto out; } xdr_size = xdr_sizeof ((xdrproc_t)xdr_pmap_signout_req, &req); iobuf = iobuf_get2 (ctx->iobuf_pool, xdr_size); if (!iobuf) { goto out; }; iobref_add (iobref, iobuf); iov.iov_base = iobuf->ptr; iov.iov_len = iobuf_pagesize (iobuf); /* Create the xdr payload */ ret = xdr_serialize_generic (iov, &req, (xdrproc_t)xdr_pmap_signout_req); if (ret == -1) { gf_log (THIS->name, GF_LOG_WARNING, "failed to create XDR payload"); goto out; } iov.iov_len = ret; ret = rpc_clnt_submit (ctx->mgmt, &clnt_pmap_signout_prog, GF_PMAP_SIGNOUT, mgmt_pmap_signout_cbk, &iov, 1, NULL, 0, iobref, frame, NULL, 0, NULL, 0, NULL); out: if (iobref) iobref_unref (iobref); if (iobuf) iobuf_unref (iobuf); return ret; }