当前位置: 首页>>代码示例>>C++>>正文


C++ xdrmem_create函数代码示例

本文整理汇总了C++中xdrmem_create函数的典型用法代码示例。如果您正苦于以下问题:C++ xdrmem_create函数的具体用法?C++ xdrmem_create怎么用?C++ xdrmem_create使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xdrmem_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: xdr_to_mountpath

/* Decode the mount path from the network message in inmsg
 * into the memory referenced by outpath.iov_base.
 * The size allocated for outpath.iov_base is outpath.iov_len.
 * The size of the path extracted from the message is returned.
 */
ssize_t
xdr_to_mountpath (struct iovec outpath, struct iovec inmsg)
{
    XDR     xdr;
    ssize_t ret = -1;
    char    *mntpath = NULL;

    if ((!outpath.iov_base) || (!inmsg.iov_base))
        return -1;

    xdrmem_create (&xdr, inmsg.iov_base, (unsigned int)inmsg.iov_len,
                   XDR_DECODE);

    mntpath = outpath.iov_base;
    if (!xdr_dirpath (&xdr, (dirpath *)&mntpath)) {
        ret = -1;
        goto ret;
    }

    ret = xdr_decoded_length (xdr);

ret:
    return ret;
}
开发者ID:lkzhd,项目名称:glusterfs-annotation,代码行数:29,代码来源:msg-nfs3.c

示例2: gvir_sandbox_rpcpacket_encode_payload_raw

gboolean gvir_sandbox_rpcpacket_encode_payload_raw(GVirSandboxRPCPacket *msg,
                                                   const char *data,
                                                   gsize len,
                                                   GError **error)
{
    XDR xdr;
    unsigned int msglen;

    if ((msg->bufferLength - msg->bufferOffset) < len) {
        g_set_error(error, 0, 0,
                    "Raw data too long to send (%zu bytes needed, %zu bytes available)",
                    len, (msg->bufferLength - msg->bufferOffset));
        return FALSE;
    }

    memcpy(msg->buffer + msg->bufferOffset, data, len);
    msg->bufferOffset += len;

    /* Re-encode the length word. */
    xdrmem_create(&xdr, msg->buffer, GVIR_SANDBOX_PROTOCOL_LEN_MAX, XDR_ENCODE);
    msglen = msg->bufferOffset;
    if (!xdr_u_int(&xdr, &msglen)) {
        g_set_error(error, 0, 0,
                    "%s", "Unable to encode message length");
        goto error;
    }
    xdr_destroy(&xdr);

    msg->bufferLength = msg->bufferOffset;
    msg->bufferOffset = 0;
    return TRUE;

error:
    xdr_destroy(&xdr);
    return FALSE;
}
开发者ID:aristeu,项目名称:libvirt-sandbox,代码行数:36,代码来源:libvirt-sandbox-rpcpacket.c

示例3: gvir_sandbox_rpcpacket_encode_payload_empty

gboolean gvir_sandbox_rpcpacket_encode_payload_empty(GVirSandboxRPCPacket *msg,
                                                     GError **error)
{
    XDR xdr;
    unsigned int msglen;

    /* Re-encode the length word. */
    xdrmem_create(&xdr, msg->buffer, GVIR_SANDBOX_PROTOCOL_LEN_MAX, XDR_ENCODE);
    msglen = msg->bufferOffset;
    if (!xdr_u_int(&xdr, &msglen)) {
        g_set_error(error, 0, 0,
                    "%s", "Unable to encode message length");
        goto error;
    }
    xdr_destroy(&xdr);

    msg->bufferLength = msg->bufferOffset;
    msg->bufferOffset = 0;
    return TRUE;

error:
    xdr_destroy(&xdr);
    return FALSE;
}
开发者ID:aristeu,项目名称:libvirt-sandbox,代码行数:24,代码来源:libvirt-sandbox-rpcpacket.c

示例4: xdr_to_RMDIR3args

RMDIR3args * 
xdr_to_RMDIR3args(char *msg, int len)
{
	RMDIR3args *args = NULL;
	XDR xdr;

	if(msg == NULL)
		return NULL;

	args = (RMDIR3args *)mem_alloc(sizeof(RMDIR3args));
	if(args == NULL)
		return NULL;
	
	xdrmem_create(&xdr, msg, len, XDR_DECODE);
	
	args->object.dir.data.data_val = NULL;
	args->object.name = NULL;
	if(!xdr_RMDIR3args(&xdr, args)) {
		mem_free(args, sizeof(RMDIR3args));
		return NULL;
	}

	return args;
}
开发者ID:shehjart,项目名称:unfsclient,代码行数:24,代码来源:nfs3.c

示例5: xdr_to_MKNOD3args

MKNOD3args * 
xdr_to_MKNOD3args(char *msg, int len)
{
	MKNOD3args *args = NULL;
	XDR xdr;

	if(msg == NULL)
		return NULL;

	args = (MKNOD3args *)mem_alloc(sizeof(MKNOD3args));
	if(args == NULL)
		return NULL;
	
	xdrmem_create(&xdr, msg, len, XDR_DECODE);
	
	args->where.dir.data.data_val = NULL;
	args->where.name = NULL;
	if(!xdr_MKNOD3args(&xdr, args)) {
		mem_free(args, sizeof(MKNOD3args));
		return NULL;
	}

	return args;
}
开发者ID:shehjart,项目名称:unfsclient,代码行数:24,代码来源:nfs3.c

示例6: virNetMessageDecodeNumFDs

int virNetMessageDecodeNumFDs(virNetMessagePtr msg)
{
    XDR xdr;
    unsigned int numFDs;
    int ret = -1;
    size_t i;

    xdrmem_create(&xdr, msg->buffer + msg->bufferOffset,
                  msg->bufferLength - msg->bufferOffset, XDR_DECODE);
    if (!xdr_u_int(&xdr, &numFDs)) {
        virReportError(VIR_ERR_RPC, "%s", _("Unable to decode number of FDs"));
        goto cleanup;
    }
    msg->bufferOffset += xdr_getpos(&xdr);

    if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) {
        virReportError(VIR_ERR_RPC,
                       _("Received too many FDs %d, expected %d maximum"),
                       numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX);
        goto cleanup;
    }

    msg->nfds = numFDs;
    if (VIR_ALLOC_N(msg->fds, msg->nfds) < 0)
        goto cleanup;
    for (i = 0; i < msg->nfds; i++)
        msg->fds[i] = -1;

    VIR_DEBUG("Got %zu FDs from peer", msg->nfds);

    ret = 0;

 cleanup:
    xdr_destroy(&xdr);
    return ret;
}
开发者ID:aruiz,项目名称:libvirt,代码行数:36,代码来源:virnetmessage.c

示例7: rpc_reply_to_xdr

int
rpc_reply_to_xdr(struct rpc_msg *reply, char *dest, size_t len,
                 struct iovec *dst)
{
    XDR xdr;
    int ret = -1;

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

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

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

    ret = 0;
out:
    return ret;
}
开发者ID:gluster,项目名称:glusterfs,代码行数:24,代码来源:xdr-rpc.c

示例8: XdrUtil_Deserialize

Bool
XdrUtil_Deserialize(const void *data,  // IN
                    size_t dataLen,    // IN
                    void *xdrProc,     // IN
                    void *dest)        // IN
{
   Bool ret;
   xdrproc_t proc = xdrProc;
   XDR xdrs;

   ASSERT(data != NULL);
   ASSERT(xdrProc != NULL);
   ASSERT(dest != NULL);

   xdrmem_create(&xdrs, (char *) data, dataLen, XDR_DECODE);
   ret = (Bool) proc(&xdrs, dest, 0);
   xdr_destroy(&xdrs);

   if (!ret) {
      VMX_XDR_FREE(proc, dest);
   }

   return ret;
}
开发者ID:AlissonGiron,项目名称:open-vm-tools,代码行数:24,代码来源:xdrutil.c

示例9: authnone_create

AUTH *
authnone_create(void)
{
	struct authnone_private *ap = authnone_private;
	XDR xdr_stream;
	XDR *xdrs;

	if (ap == 0) {
		ap = &authnone_local;
		authnone_private = ap;
	}
	if (!ap->mcnt) {
		ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
		ap->no_client.ah_ops = authnone_ops();
		xdrs = &xdr_stream;
		xdrmem_create(xdrs, ap->marshalled_client,
			(uint_t)MAX_MARSHEL_SIZE, XDR_ENCODE);
		(void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
		(void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
		ap->mcnt = XDR_GETPOS(xdrs);
		XDR_DESTROY(xdrs);
	}
	return (&ap->no_client);
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:24,代码来源:auth_none.c

示例10: rgetpidCompletionHandler_

int
rgetpidCompletionHandler_(struct lsRequest *request)
{
    struct resPid pidReply;
    XDR xdrs;
    int rc;


    rc = resRC2LSErr_(request->rc);
    if (rc != 0)
	return(-1);

    xdrmem_create(&xdrs, request->replyBuf, sizeof(struct resPid), XDR_DECODE);
    if (! xdr_resGetpid(&xdrs, &pidReply, NULL)) {
	lserrno = LSE_BAD_XDR;
	xdr_destroy(&xdrs);
	return(-1);
    }

    *((int *)request->extra) = pidReply.pid;
    xdr_destroy(&xdrs);
    return(0);

}
开发者ID:FSchumacher,项目名称:openlava,代码行数:24,代码来源:lib.rtask.c

示例11: function


//.........这里部分代码省略.........
        TX_STATS(ROZOFS_TX_NO_CTX_ERROR);
        errno = ENOMEM;
        goto error;
    }

    /*
    ** allocate an xmit buffer
    */
    xmit_buf = ruc_buf_getBuffer(ROZOFS_TX_LARGE_TX_POOL);
    if (xmit_buf == NULL)
    {
        /*
        ** something rotten here, we exit we an error
        ** without activating the FSM
        */
        TX_STATS(ROZOFS_TX_NO_BUFFER_ERROR);
        errno = ENOMEM;
        goto error;
    }
    /*
    ** store the reference of the xmit buffer in the transaction context: might be useful
    ** in case we want to remove it from a transmit list of the underlying network stacks
    */
    rozofs_tx_save_xmitBuf(rozofs_tx_ctx_p,xmit_buf);
    /*
    ** get the pointer to the payload of the buffer
    */
    header_size_p  = (uint32_t*) ruc_buf_getPayload(xmit_buf);
    arg_p = (uint8_t*)(header_size_p+1);
    /*
    ** create the xdr_mem structure for encoding the message
    */
    bufsize = ruc_buf_getMaxPayloadLen(xmit_buf);
    xdrmem_create(&xdrs,(char*)arg_p,bufsize,XDR_ENCODE);
    /*
    ** fill in the rpc header
    */
    call_msg.rm_direction = CALL;
    /*
    ** allocate a xid for the transaction
    */
    call_msg.rm_xid             = rozofs_tx_alloc_xid(rozofs_tx_ctx_p);
    call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
    /* XXX: prog and vers have been long historically :-( */
    call_msg.rm_call.cb_prog = (uint32_t)prog;
    call_msg.rm_call.cb_vers = (uint32_t)vers;
    if (! xdr_callhdr(&xdrs, &call_msg))
    {
        /*
        ** THIS MUST NOT HAPPEN
        */
        TX_STATS(ROZOFS_TX_ENCODING_ERROR);
        errno = EPROTO;
        goto error;
    }
    /*
    ** insert the procedure number, NULL credential and verifier
    */
    XDR_PUTINT32(&xdrs, (int32_t *)&opcode);
    XDR_PUTINT32(&xdrs, (int32_t *)&null_val);
    XDR_PUTINT32(&xdrs, (int32_t *)&null_val);
    XDR_PUTINT32(&xdrs, (int32_t *)&null_val);
    XDR_PUTINT32(&xdrs, (int32_t *)&null_val);

    /*
    ** ok now call the procedure to encode the message
开发者ID:dcasier,项目名称:rozofs,代码行数:67,代码来源:expgw_rpc_generic.c

示例12: svc_dg_ncreate

SVCXPRT *
svc_dg_ncreate(int fd, u_int sendsize, u_int recvsize)
{
    SVCXPRT *xprt;
    struct svc_dg_data *su = NULL;
    struct __rpc_sockinfo si;
    struct sockaddr_storage ss;
    socklen_t slen;
    uint32_t oflags;

    if (!__rpc_fd2sockinfo(fd, &si)) {
        __warnx(TIRPC_DEBUG_FLAG_SVC_DG,
                svc_dg_str, svc_dg_err1);
        return (NULL);
    }
    /*
     * Find the receive and the send size
     */
    sendsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsize);
    recvsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsize);
    if ((sendsize == 0) || (recvsize == 0)) {
        __warnx(TIRPC_DEBUG_FLAG_SVC_DG,
                svc_dg_str, svc_dg_err2);
        return (NULL);
    }

    xprt = mem_alloc(sizeof (SVCXPRT));
    if (xprt == NULL)
        goto freedata;
    memset(xprt, 0, sizeof (SVCXPRT));

    /* Init SVCXPRT locks, etc */
    mutex_init(&xprt->xp_lock, NULL);
    mutex_init(&xprt->xp_auth_lock, NULL);

    su = mem_alloc(sizeof (*su));
    if (su == NULL)
        goto freedata;
    su->su_iosz = ((MAX(sendsize, recvsize) + 3) / 4) * 4;
    if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL)
        goto freedata;
    xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz,
                  XDR_DECODE);

    su->su_cache = NULL;
    xprt->xp_flags = SVC_XPRT_FLAG_NONE;
    xprt->xp_refcnt = 1;
    xprt->xp_fd = fd;
    xprt->xp_p2 = su;
    svc_dg_ops(xprt);
    xprt->xp_rtaddr.maxlen = sizeof (struct sockaddr_storage);

    slen = sizeof ss;
    if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) < 0)
        goto freedata;

    __rpc_set_netbuf(&xprt->xp_ltaddr, &ss, slen);

    switch (ss.ss_family) {
    case AF_INET:
        xprt->xp_port = ntohs(((struct sockaddr_in *) &ss)->sin_port);
        break;
#ifdef INET6
    case AF_INET6:
        xprt->xp_port = ntohs(((struct sockaddr_in6 *) &ss)->sin6_port);
        break;
#endif
    case AF_LOCAL:
        /* no port */
        break;
    default:
        break;
    }

    /* Enable reception of IP*_PKTINFO control msgs */
    svc_dg_enable_pktinfo(fd, &si);

    /* Make reachable */
    xprt->xp_p5 = rpc_dplx_lookup_rec(xprt->xp_fd,
                                      RPC_DPLX_FLAG_NONE, &oflags); /* ref+1 */
    svc_rqst_init_xprt(xprt);

    /* Conditional xprt_register */
    if (! (__svc_params->flags & SVC_FLAG_NOREG_XPRTS))
        xprt_register(xprt);

    return (xprt);
freedata:
    __warnx(TIRPC_DEBUG_FLAG_SVC_DG,
            svc_dg_str, __no_mem_str);
    if (xprt) {
        if (su)
            (void) mem_free(su, sizeof (*su));
        svc_rqst_finalize_xprt(xprt, SVC_RQST_FLAG_NONE);
        (void) mem_free(xprt, sizeof (SVCXPRT));
    }
    return (NULL);
}
开发者ID:vganapathi,项目名称:ntirpc,代码行数:98,代码来源:svc_dg.c

示例13: clnt_vc_create


//.........这里部分代码省略.........
			mutex_unlock(&clnt_fd_lock);
			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
			goto err;
		} else {
			int i;

			for (i = 0; i < dtbsize; i++)
				cond_init(&vc_cv[i], 0, (void *) 0);
		}
	} else
		assert(vc_cv != (cond_t *) NULL);

	/*
	 * XXX - fvdl connecting while holding a mutex?
	 */
	slen = sizeof ss;
	if (_getpeername(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) {
		if (errno != ENOTCONN) {
			rpc_createerr.cf_stat = RPC_SYSTEMERROR;
			rpc_createerr.cf_error.re_errno = errno;
			mutex_unlock(&clnt_fd_lock);
			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
			goto err;
		}
		if (_connect(fd, (struct sockaddr *)raddr->buf, raddr->len) < 0){
			rpc_createerr.cf_stat = RPC_SYSTEMERROR;
			rpc_createerr.cf_error.re_errno = errno;
			mutex_unlock(&clnt_fd_lock);
			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
			goto err;
		}
	}
	mutex_unlock(&clnt_fd_lock);
	thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
	if (!__rpc_fd2sockinfo(fd, &si))
		goto err;

	ct->ct_closeit = FALSE;

	/*
	 * Set up private data struct
	 */
	ct->ct_fd = fd;
	ct->ct_wait.tv_usec = 0;
	ct->ct_waitset = FALSE;
	ct->ct_addr.buf = malloc(raddr->maxlen);
	if (ct->ct_addr.buf == NULL)
		goto err;
	memcpy(ct->ct_addr.buf, raddr->buf, raddr->len);
	ct->ct_addr.len = raddr->len;
	ct->ct_addr.maxlen = raddr->maxlen;

	/*
	 * Initialize call message
	 */
	(void)gettimeofday(&now, NULL);
	call_msg.rm_xid = ((u_int32_t)++disrupt) ^ __RPC_GETXID(&now);
	call_msg.rm_direction = CALL;
	call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
	call_msg.rm_call.cb_prog = (u_int32_t)prog;
	call_msg.rm_call.cb_vers = (u_int32_t)vers;

	/*
	 * pre-serialize the static part of the call msg and stash it away
	 */
	xdrmem_create(&(ct->ct_xdrs), ct->ct_u.ct_mcallc, MCALL_MSG_SIZE,
	    XDR_ENCODE);
	if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
		if (ct->ct_closeit) {
			(void)_close(fd);
		}
		goto err;
	}
	ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs));
	XDR_DESTROY(&(ct->ct_xdrs));
	assert(ct->ct_mpos + sizeof(uint32_t) <= MCALL_MSG_SIZE);

	/*
	 * Create a client handle which uses xdrrec for serialization
	 * and authnone for authentication.
	 */
	cl->cl_ops = clnt_vc_ops();
	cl->cl_private = ct;
	cl->cl_auth = authnone_create();
	sendsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsz);
	recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz);
	xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz,
	    cl->cl_private, read_vc, write_vc);
	return (cl);

err:
	if (ct) {
		if (ct->ct_addr.len)
			mem_free(ct->ct_addr.buf, ct->ct_addr.len);
		mem_free(ct, sizeof (struct ct_data));
	}
	if (cl)
		mem_free(cl, sizeof (CLIENT));
	return ((CLIENT *)NULL);
}
开发者ID:ngkaho1234,项目名称:freebsd,代码行数:101,代码来源:clnt_vc.c

示例14: clnt_dg_create

/*
 * Connection less client creation returns with client handle parameters.
 * Default options are set, which the user can change using clnt_control().
 * fd should be open and bound.
 * NB: The rpch->cl_auth is initialized to null authentication.
 * 	Caller may wish to set this something more useful.
 *
 * sendsz and recvsz are the maximum allowable packet sizes that can be
 * sent and received. Normally they are the same, but they can be
 * changed to improve the program efficiency and buffer allocation.
 * If they are 0, use the transport default.
 *
 * If svcaddr is NULL, returns NULL.
 */
CLIENT *
clnt_dg_create(const int fd, struct netbuf *svcaddr, const rpcprog_t program,
	const rpcvers_t version, const uint_t sendsz, const uint_t recvsz)
{
	CLIENT *cl = NULL;		/* client handle */
	struct cu_data *cu = NULL;	/* private data */
	struct t_unitdata *tr_data;
	struct t_info tinfo;
	struct timeval now;
	struct rpc_msg call_msg;
	uint_t ssz;
	uint_t rsz;

	sig_mutex_lock(&dgtbl_lock);
	if ((dgtbl == NULL) && ((dgtbl = rpc_fd_init()) == NULL)) {
		sig_mutex_unlock(&dgtbl_lock);
		goto err1;
	}
	sig_mutex_unlock(&dgtbl_lock);

	if (svcaddr == NULL) {
		rpc_createerr.cf_stat = RPC_UNKNOWNADDR;
		return (NULL);
	}
	if (t_getinfo(fd, &tinfo) == -1) {
		rpc_createerr.cf_stat = RPC_TLIERROR;
		rpc_createerr.cf_error.re_errno = 0;
		rpc_createerr.cf_error.re_terrno = t_errno;
		return (NULL);
	}
	/*
	 * Setup to rcv datagram error, we ignore any errors returned from
	 * __rpc_tli_set_options() as SO_DGRAM_ERRIND is only relevant to
	 * udp/udp6 transports and this point in the code we only know that
	 * we are using a connection less transport.
	 */
	if (tinfo.servtype == T_CLTS)
		(void) __rpc_tli_set_options(fd, SOL_SOCKET, SO_DGRAM_ERRIND,
		    1);
	/*
	 * Find the receive and the send size
	 */
	ssz = __rpc_get_t_size((int)sendsz, tinfo.tsdu);
	rsz = __rpc_get_t_size((int)recvsz, tinfo.tsdu);
	if ((ssz == 0) || (rsz == 0)) {
		rpc_createerr.cf_stat = RPC_TLIERROR; /* XXX */
		rpc_createerr.cf_error.re_errno = 0;
		rpc_createerr.cf_error.re_terrno = 0;
		return (NULL);
	}

	if ((cl = malloc(sizeof (CLIENT))) == NULL)
		goto err1;
	/*
	 * Should be multiple of 4 for XDR.
	 */
	ssz = ((ssz + 3) / 4) * 4;
	rsz = ((rsz + 3) / 4) * 4;
	cu = malloc(sizeof (*cu) + ssz + rsz);
	if (cu == NULL)
		goto err1;
	if ((cu->cu_raddr.buf = malloc(svcaddr->len)) == NULL)
		goto err1;
	(void) memcpy(cu->cu_raddr.buf, svcaddr->buf, (size_t)svcaddr->len);
	cu->cu_raddr.len = cu->cu_raddr.maxlen = svcaddr->len;
	cu->cu_outbuf_start = &cu->cu_inbuf[rsz];
	/* Other values can also be set through clnt_control() */
	cu->cu_wait.tv_sec = 15;	/* heuristically chosen */
	cu->cu_wait.tv_usec = 0;
	cu->cu_total.tv_sec = -1;
	cu->cu_total.tv_usec = -1;
	cu->cu_sendsz = ssz;
	cu->cu_recvsz = rsz;
	(void) gettimeofday(&now, NULL);
	call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec;
	call_msg.rm_call.cb_prog = program;
	call_msg.rm_call.cb_vers = version;
	xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, ssz, XDR_ENCODE);
	if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) {
		rpc_createerr.cf_stat = RPC_CANTENCODEARGS;  /* XXX */
		rpc_createerr.cf_error.re_errno = 0;
		rpc_createerr.cf_error.re_terrno = 0;
		goto err2;
	}
	cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
	XDR_DESTROY(&(cu->cu_outxdrs));
//.........这里部分代码省略.........
开发者ID:bahamas10,项目名称:openzfs,代码行数:101,代码来源:clnt_dg.c

示例15: svcbyz_auth_unix

enum auth_stat
svcbyz_auth_unix(struct svc_req *rqst, struct rpc_msg *msg) {
  register enum auth_stat stat;
  XDR xdrs;
  register struct authunix_parms *aup;
  register int *buf;
  struct area {
    struct authunix_parms area_aup;
    char area_machname[MAX_MACHINE_NAME+1];
    unsigned int area_gids[NGRPS]; // JC: changed to unsigned
  } *area;
  u_int auth_len;
  int str_len, gid_len;
  register int i;

  area = (struct area *) rqst->rq_clntcred;
  aup = &area->area_aup;
  aup->aup_machname = area->area_machname;
  aup->aup_gids = area->area_gids;
  auth_len = (unsigned int)msg->rm_call.cb_cred.oa_length;
  xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE);
  buf = XDR_INLINE(&xdrs, auth_len);
  if (buf != NULL) {
    aup->aup_time = IXDR_GET_LONG(buf);
    str_len = IXDR_GET_U_LONG(buf);
    if (str_len > MAX_MACHINE_NAME) {
      stat = AUTH_BADCRED;
      goto done;
    }
    bcopy((caddr_t)buf, aup->aup_machname, (u_int)str_len);
    aup->aup_machname[str_len] = 0;
    str_len = RNDUP(str_len);
    buf += str_len / sizeof(int);
    aup->aup_uid = IXDR_GET_LONG(buf);
    aup->aup_gid = IXDR_GET_LONG(buf);
    gid_len = IXDR_GET_U_LONG(buf);
    if (gid_len > NGRPS) {
      stat = AUTH_BADCRED;
      goto done;
    }
    aup->aup_len = gid_len;
    for (i = 0; i < gid_len; i++) {
      aup->aup_gids[i] = IXDR_GET_LONG(buf);
    }
    /*
     * five is the smallest unix credentials structure -
     * timestamp, hostname len (0), uid, gid, and gids len (0).
     */
    if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) {
      (void) printf("bad auth_len gid %d str %d auth %d\n",
		    gid_len, str_len, auth_len);
      stat = AUTH_BADCRED;
      goto done;
    }
  } else if (! xdr_authunix_parms(&xdrs, aup)) {
    xdrs.x_op = XDR_FREE;
    (void)xdr_authunix_parms(&xdrs, aup);
    stat = AUTH_BADCRED;
    goto done;
  }
  rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL;
  rqst->rq_xprt->xp_verf.oa_length = 0;
  stat = AUTH_OK;
done:
  XDR_DESTROY(&xdrs);
  return (stat);
}
开发者ID:vonwenm,项目名称:pbft,代码行数:67,代码来源:svc.c


注:本文中的xdrmem_create函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。