Beispiel #1
0
/**
 * Gets FSID and PID by path and cuts path to relative path for FS
 *  @param path Path to file
 *  @param parent If FS of parent directory of file is needed
 *  @return FSID
 */
static struct fslist_item *fsbypath(char *path,int parent) {
  if (path==NULL || path[0]==0) return NULL;
  struct fslist_item *fs = mp_match(path,parent);
  if (fs==NULL) {
    fs = malloc(sizeof(struct fslist_item));
    char *mountpoint = strdup(path);
    fs->id = rpc_call("vfs_getfsid",RPC_FLAG_RETPARAMS,path,parent);
    if (fs->id<0) {
      free(mountpoint);
      errno = -fs->id;
      return NULL;
    }
    fs->pid = rpc_call("vfs_getpid",0,fs->id);
    if (fs->pid<0) {
      errno = -fs->pid;
      return NULL;
    }
    mountpoint[strlen(mountpoint)-strlen(path)] = 0;
    fs->mountpoint = path_parse(mountpoint);
    fs->mountpoint_str = path_output(fs->mountpoint,NULL);
    free(mountpoint);
    llist_push(fslist,fs);
  }

  return fs;
}
/*
 * Bare-bones access to getattr: this is for nfs_read_super.
 */
static int
nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
		  struct nfs_fsinfo *info)
{
	struct nfs_fattr *fattr = info->fattr;
	struct nfs2_fsstat fsinfo;
	int status;

	dprintk("%s: call getattr\n", __FUNCTION__);
	fattr->valid = 0;
	status = rpc_call(server->client_sys, NFSPROC_GETATTR, fhandle, fattr, 0);
	dprintk("%s: reply getattr %d\n", __FUNCTION__, status);
	if (status)
		return status;
	dprintk("%s: call statfs\n", __FUNCTION__);
	status = rpc_call(server->client_sys, NFSPROC_STATFS, fhandle, &fsinfo, 0);
	dprintk("%s: reply statfs %d\n", __FUNCTION__, status);
	if (status)
		return status;
	info->rtmax  = NFS_MAXDATA;
	info->rtpref = fsinfo.tsize;
	info->rtmult = fsinfo.bsize;
	info->wtmax  = NFS_MAXDATA;
	info->wtpref = fsinfo.tsize;
	info->wtmult = fsinfo.bsize;
	info->dtpref = fsinfo.tsize;
	info->maxfilesize = 0x7FFFFFFF;
	info->lease_time = 0;
	return 0;
}
Beispiel #3
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//                                         argc[2] : Server Program Number
	//                                         other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 1;	//Default test result set to FAILED
	int progNum = atoi(argc[2]);
	char nettype[16] = "visible";
	int sndVar = 0;
	int recVar = -1;
	struct timeval total_timeout;
	enum clnt_stat rslt;
	CLIENT *clnt = NULL;

	if (run_mode == 1) {
		printf("Server : %s\n", argc[1]);
		printf("Server # %d\n", progNum);
		printf("Net : %s\n", nettype);
	}
	//Initialisation
	total_timeout.tv_sec = 1;
	total_timeout.tv_usec = 1;
	/**/ clnt = clnt_create(argc[1], progNum, VERSNUM, nettype);

	//Multiple test case
	rslt = rpc_call(argc[1], progNum, VERSNUM, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, nettype);
	clnt_perror(clnt, "Success");

	rslt = rpc_call(argc[1], 1, VERSNUM, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, nettype);
	clnt_perror(clnt, "Wrong Prog");

	rslt = rpc_call(argc[1], progNum, 10, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, nettype);
	clnt_perror(clnt, "Wrong Vers");

	rslt = rpc_call(argc[1], progNum, VERSNUM, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, "wrong");
	clnt_perror(clnt, "Wrong Proto");

	//If we are here, test has passed
	test_status = 0;

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}
YAAMP_JOB_TEMPLATE *coind_create_template_memorypool(YAAMP_COIND *coind)
{
	json_value *json = rpc_call(&coind->rpc, "getmemorypool");
	if(!json || json->type == json_null)
	{
		coind_error(coind, "getmemorypool");
		return NULL;
	}

	json_value *json_result = json_get_object(json, "result");
	if(!json_result || json_result->type == json_null)
	{
		coind_error(coind, "getmemorypool");
		json_value_free(json);

		return NULL;
	}

	YAAMP_JOB_TEMPLATE *templ = new YAAMP_JOB_TEMPLATE;
	memset(templ, 0, sizeof(YAAMP_JOB_TEMPLATE));

	templ->created = time(NULL);
	templ->value = json_get_int(json_result, "coinbasevalue");
//	templ->height = json_get_int(json_result, "height");
	sprintf(templ->version, "%08x", (unsigned int)json_get_int(json_result, "version"));
	sprintf(templ->ntime, "%08x", (unsigned int)json_get_int(json_result, "time"));
	strcpy(templ->nbits, json_get_string(json_result, "bits"));
	strcpy(templ->prevhash_hex, json_get_string(json_result, "previousblockhash"));

	json_value_free(json);

	json = rpc_call(&coind->rpc, "getinfo", "[]");
	if(!json || json->type == json_null)
	{
		coind_error(coind, "coind_getinfo");
		return NULL;
	}

	json_result = json_get_object(json, "result");
	if(!json_result || json_result->type == json_null)
	{
		coind_error(coind, "coind_getinfo");
		json_value_free(json);

		return NULL;
	}

	templ->height = json_get_int(json_result, "blocks")+1;
	json_value_free(json);

	if(coind->isaux)
		coind_getauxblock(coind);

	coind->usememorypool = true;
	return templ;
}
Beispiel #5
0
int
main(int argc, char **argv)
{
	enum clnt_stat stat;
	char *hostname;
	nlm4_notify notify;

	if (argc != 2) {
		fprintf(stderr, "Usage: clear_locks <hostname>\n");
		exit(1);
	}
	hostname = argv[1];

	if (geteuid() != 0) {
		fprintf(stderr, "clear_locks: must be root\n");
		exit(1);
	}

	notify.name = hostname;
	notify.state = 0;
	stat = rpc_call("localhost", NLM_PROG, NLM_VERS4, NLM4_FREE_ALL,
	    (xdrproc_t) xdr_nlm4_notify, (void *) &notify,
	    (xdrproc_t) xdr_void, NULL, NULL);

	if (stat != RPC_SUCCESS) {
		clnt_perrno(stat);
		exit(1);
	}
	fprintf(stderr, "clear_locks: cleared locks for hostname %s\n",
	    hostname);

	return (0);
}
Beispiel #6
0
static int8_t rpc_rcmd(node_id_t node, char *cmd)
{
    int8_t rc = NRK_OK;
    uint8_t reply_len = sizeof(reply_buf);
    uint8_t req_len = 0;

    LOG("remote cmd to "); LOGP("%u: ", node);
    LOGP("%s\r\n", cmd);

    req_len += strlen(cmd) + 1; /* include null byte */

    rc = rpc_call(&rcmd_endpoint.client, node,
                  PORT_RPC_SERVER_RCMD, RPC_RCMD, &rcmd_rpc_time_out,
                  (uint8_t *)cmd_buf, req_len, reply_buf, &reply_len);
    if (rc != NRK_OK) {
        LOG("WARN: rcmd rpc failed\r\n");
        return rc;
    }

#if 0 /* TODO: make cmds return a code */
    if (reply_len != RPC_RCMD_REPLY_LEN) {
        LOG("WARN: rcmd reply of unexpected length\r\n");
        return NRK_ERROR;
    }

    rc = reply_buf[RPC_RCMD_REPLY_RC_OFFSET];
    LOG("rpc rcmd rc: "); LOGP("%d\r\n", rc);
#endif

    return NRK_OK;
}
Beispiel #7
0
static int rpc_call_result(rpc_t *rpc, rpc_request_t *req)
{
	LOG_ENTRY;
	int rc = -1;

	if (!rpc) {
		RPC_ERROR("rpc is NULL");
		goto fail;
	}

	if (!req) {
		RPC_ERROR("request is NULL");
		goto fail;
	}

	rc = rpc_call(rpc, req);
	if (rc < 0) {
		RPC_ERROR("rpc_call failed %d", rc);
		goto fail;
	}
	RPC_DEBUG("%s: rpc_call done", __func__);

	size_t idx = 0;
	RPC_UNPACK(req->reply.buffer, idx, rc);
fail:
	LOG_EXIT;
	return rc;
}
Beispiel #8
0
unsigned int
map_getport(mapping_t* pmap)
{
    int port;
    struct pbuf *pbuf;
    struct pbuf *ret;
    debug("Getting port\n");
    pmap->port = 0;
    
    /* add the xid */
    pbuf = initbuf(PMAP_NUMBER, PMAP_VERSION, PMAPPROC_GETPORT);
    
    /* pack up the map struct */
    addtobuf(pbuf, (char*) pmap, sizeof(mapping_t));
    
    /* make the call */
    ret = rpc_call(pbuf, PMAP_PORT);

    assert(ret != NULL);
    
    /* now we can extract the port */
    getfrombuf(ret, (char*) &port, sizeof(port));
    
    pmap->port = port;
    
    debug("Got port %d\n", port);

    return 0;
}
Beispiel #9
0
unsigned int
mnt_mount(char *dir, struct cookie *pfh)
{
    struct pbuf *pbuf, *ret;
    int status;

    pbuf = initbuf(MNT_NUMBER, MNT_VERSION, MNTPROC_MNT);

    addstring(pbuf, dir);
    
    ret = rpc_call(pbuf, mount_port);

	 if (ret == 0) {
		 debug( "mount call failed :(\n" );
		 return 1;
	 }

    /* now we do some stuff :) */
    getfrombuf(ret, (char*) &status, sizeof(status));

	 if (status != 0) {
		 debug( "Could not mount %s, %d!\n", dir, status );
		 return 1;
	 }

	 debug("All seems good for mount: %s!\n", dir);

    getfrombuf(ret, (char*) pfh, sizeof(struct cookie));

    return 0;
}
Beispiel #10
0
/*
 * Bare-bones access to getattr: this is for nfs_read_super.
 */
static int
nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
		   struct nfs_fsinfo *info)
{
	int	status;

	dprintk("%s: call  fsinfo\n", __FUNCTION__);
	info->fattr->valid = 0;
	status = rpc_call(server->client_sys, NFS3PROC_FSINFO, fhandle, info, 0);
	dprintk("%s: reply fsinfo: %d\n", __FUNCTION__, status);
	if (!(info->fattr->valid & NFS_ATTR_FATTR)) {
		status = rpc_call(server->client_sys, NFS3PROC_GETATTR, fhandle, info->fattr, 0);
		dprintk("%s: reply getattr: %d\n", __FUNCTION__, status);
	}
	return status;
}
Beispiel #11
0
static void ril_ni_message(uint8_t *msg, size_t len) {
	LOG_ENTRY;
	
	if (!msg || !len) {
		RPC_ERROR("%s: msg is NULL", __func__);
		goto fail;
	}

	struct rpc_request_t req = {
		.header = {
			.code = RIL_NI_MSG,
		}
	};
	
	char *buf = req.header.buffer;
	size_t idx = 0;

	memset(req.header.buffer, 0, RPC_PAYLOAD_MAX);
	RPC_PACK(buf, idx, len);
	RPC_PACK_RAW(buf, idx, msg, len);
	req.header.buffer[RPC_PAYLOAD_MAX - 1] = '\0';

	rpc_call(gps_rpc, &req);
fail:
	LOG_EXIT;
}
Beispiel #12
0
static int8_t rpc_ping(node_id_t node, uint8_t token)
{
    int8_t rc = NRK_OK;
    uint8_t reply_token;
    uint8_t reply_len = sizeof(reply_buf);
    uint8_t req_len = 0;

    LOG("call ping rpc\r\n");

    req_buf[RPC_PING_REQ_TOKEN_OFFSET] = token;
    req_len += RPC_PING_REQ_TOKEN_LEN;

    rc = rpc_call(&rping_endpoint.client, node,
                  PORT_RPC_SERVER_PING, RPC_PING, &ping_time_out,
                  req_buf, req_len, reply_buf, &reply_len);
    if (rc != NRK_OK) {
        LOG("WARN: ping rpc failed\r\n");
        return rc;
    }
    if (reply_len != RPC_PING_REPLY_LEN) {
        LOG("WARN: ping reply of unexpected length\r\n");
        return NRK_ERROR;
    }

    reply_token = reply_buf[RPC_PING_REPLY_TOKEN_OFFSET];
    if (reply_token != token) {
        LOG("WARN: unexpected token in ping reply\r\n");
        return NRK_ERROR;
    }

    return rc;
}
Beispiel #13
0
int rpc_peer_call(struct rpc *r, uint32_t uuid, uint32_t cmd_id,
            const void *in_arg, size_t in_len,
            void *out_arg, size_t out_len)
{
    r->send_pkt.header.uuid_dst = uuid;
    return rpc_call(r, cmd_id, in_arg, in_len, out_arg, out_len);
}
Beispiel #14
0
static int8_t rpc_heading(node_id_t node, int16_t *heading)
{
    int8_t rc = NRK_OK;
    uint8_t reply_len = sizeof(reply_buf);
    uint8_t req_len = 0;

    rc = rpc_call(&compass_endpoint.client, node, PORT_RPC_SERVER_COMPASS, RPC_HEADING,
                  &compass_rpc_time_out, req_buf, req_len, reply_buf, &reply_len);
    if (rc != NRK_OK) {
        LOG("WARN: heading rpc failed\r\n");
        return rc;
    }

    if (reply_len != RPC_HEADING_REPLY_LEN) {
        LOG("WARN: heading reply of unexpected length\r\n");
        return NRK_ERROR;
    }

    *heading = reply_buf[RPC_HEADING_REPLY_HEADING_OFFSET + 1];
    *heading <<= 8;
    *heading |= reply_buf[RPC_HEADING_REPLY_HEADING_OFFSET];

    memcpy(mag_uT, reply_buf + RPC_HEADING_REPLY_MAG_OFFSET, sizeof(mag_uT));

    return NRK_OK;
}
Beispiel #15
0
bool coind_submitgetauxblock(YAAMP_COIND *coind, const char *hash, const char *block)
{
	int paramlen = strlen(block);

	char *params = (char *)malloc(paramlen+1024);
	if(!params) return false;

	sprintf(params, "[\"%s\",\"%s\"]", hash, block);
	json_value *json = rpc_call(&coind->rpc, "getauxblock", params);

	free(params);
	if(!json) return false;

	json_value *json_error = json_get_object(json, "error");
	if(json_error && json_error->type != json_null)
	{
		const char *p = json_get_string(json_error, "message");
		if(p) stratumlog("ERROR %s %s\n", coind->name, p);

	//	job_reset();
		json_value_free(json);

		return false;
	}

	json_value *json_result = json_get_object(json, "result");
	bool b = json_result && json_result->type == json_boolean && json_result->u.boolean;

	json_value_free(json);
	return b;
}
void *my_thread_process(void *arg)
{
	int i;
	struct datas vars;
	static double result = 0;

	if (run_mode == 1) {
		fprintf(stderr, "Thread %d\n", atoi(arg));
	}

	vars.a = getRand();
	vars.b = getRand();
	vars.c = getRand();

	resTbl[atoi(arg)].locRes = vars.a + (vars.b * vars.c);

	rpc_call(hostname, progNum, VERSNUM, CALCTHREADPROC, (xdrproc_t) xdr_datas, (char *)&vars,	// xdr_in
		 (xdrproc_t) xdr_double, (char *)&resTbl[atoi(arg)].svcRes,	// xdr_out
		 nettype);

	thread_array_result[atoi(arg)] =
	    (resTbl[atoi(arg)].svcRes == resTbl[atoi(arg)].locRes) ? 0 : 1;

	if (run_mode == 1) {
		fprintf(stderr, "Thread #%d calc : %lf, received : %lf\n",
			atoi(arg), resTbl[atoi(arg)].locRes,
			resTbl[atoi(arg)].svcRes);
	}

	pthread_exit(0);
}
Beispiel #17
0
static void ril_set_ref_location(const AGpsRefLocation *agps_reflocation,
	size_t sz_struct)
{
	LOG_ENTRY;

	if (!agps_reflocation || !sz_struct) {
		RPC_ERROR("%s: agps_reflocation is NULL", __func__);
		goto fail;
	}

	struct rpc_request_t req = {
		.header = {
			.code = RIL_SET_REF_LOC,
		}
	};
	
	char *buf = req.header.buffer;
	size_t idx = 0;

	memset(req.header.buffer, 0, RPC_PAYLOAD_MAX);
	RPC_PACK(buf, idx, sz_struct);
	RPC_PACK_RAW(buf, idx, agps_reflocation, sz_struct);

	rpc_call(gps_rpc, &req);
fail:
	LOG_EXIT;
}
Beispiel #18
0
static int
nfs3_proc_mknod(struct inode *dir, struct qstr *name, struct iattr *sattr,
		dev_t rdev, struct nfs_fh *fh, struct nfs_fattr *fattr)
{
	struct nfs_fattr	dir_attr;
	struct nfs3_mknodargs	arg = { NFS_FH(dir), name->name, name->len, 0,
					sattr, rdev };
	struct nfs3_diropres	res = { &dir_attr, fh, fattr };
	int			status;

	switch (sattr->ia_mode & S_IFMT) {
	case S_IFBLK:	arg.type = NF3BLK;  break;
	case S_IFCHR:	arg.type = NF3CHR;  break;
	case S_IFIFO:	arg.type = NF3FIFO; break;
	case S_IFSOCK:	arg.type = NF3SOCK; break;
	default:	return -EINVAL;
	}

	dprintk("NFS call  mknod %s %x\n", name->name, rdev);
	dir_attr.valid = 0;
	fattr->valid = 0;
	status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKNOD, &arg, &res, 0);
	nfs_refresh_inode(dir, &dir_attr);
	dprintk("NFS reply mknod: %d\n", status);
	return status;
}
Beispiel #19
0
static int _nfs_unlink(nfs_fs *nfs, nfs_vnode *dir, const char *name, stream_type type)
{
	int err;
	uint8 argbuf[NFS_DIROPARGS_MAXLEN];
	nfs_diropargs args;
	size_t arglen;
	nfs_status res;
	int proc;

	/* start building the args */
	args.dir = &dir->nfs_handle;
	args.name.name = name;
	arglen = nfs_pack_diropargs(argbuf, &args);

	switch (type) {
		case STREAM_TYPE_FILE:
			proc = NFSPROC_REMOVE;
			break;
		case STREAM_TYPE_DIR:
			proc = NFSPROC_RMDIR;
			break;
		default:
			panic("_nfs_unlink asked to remove file type it doesn't understand\n");
	}

	err = rpc_call(&nfs->rpc, NFSPROG, NFSVERS, proc, argbuf, arglen, &res, sizeof(res));
	if (err < 0)
		return err;

	return nfs_status_to_error(ntohl(res));
}
Beispiel #20
0
static void ril_set_set_id(AGpsSetIDType type, const char *setid) {
	LOG_ENTRY;
	
	if (!setid) {
		RPC_ERROR("%s: setid is NULL", __func__);
		goto fail;
	}

	struct rpc_request_t req = {
		.header = {
			.code = RIL_SET_SET_ID,
		}
	};
	
	char *buf = req.header.buffer;
	size_t idx = 0;

	memset(req.header.buffer, 0, RPC_PAYLOAD_MAX);
	RPC_PACK(buf, idx, type);
	RPC_PACK_S(buf, idx, setid);
	req.header.buffer[RPC_PAYLOAD_MAX - 1] = '\0';

	rpc_call(gps_rpc, &req);
fail:
	LOG_EXIT;
}
Beispiel #21
0
static int
nfs3_proc_access(struct inode *inode, int mode, int ruid)
{
	struct nfs_fattr	fattr;
	struct nfs3_accessargs	arg = { NFS_FH(inode), 0 };
	struct nfs3_accessres	res = { &fattr, 0 };
	int	status, flags;

	dprintk("NFS call  access\n");
	fattr.valid = 0;

	if (mode & MAY_READ)
		arg.access |= NFS3_ACCESS_READ;
	if (S_ISDIR(inode->i_mode)) {
		if (mode & MAY_WRITE)
			arg.access |= NFS3_ACCESS_MODIFY | NFS3_ACCESS_EXTEND | NFS3_ACCESS_DELETE;
		if (mode & MAY_EXEC)
			arg.access |= NFS3_ACCESS_LOOKUP;
	} else {
		if (mode & MAY_WRITE)
			arg.access |= NFS3_ACCESS_MODIFY | NFS3_ACCESS_EXTEND;
		if (mode & MAY_EXEC)
			arg.access |= NFS3_ACCESS_EXECUTE;
	}
	flags = (ruid) ? RPC_CALL_REALUID : 0;
	status = rpc_call(NFS_CLIENT(inode), NFS3PROC_ACCESS, &arg, &res, flags);
	nfs_refresh_inode(inode, &fattr);
	dprintk("NFS reply access\n");

	if (status == 0 && (arg.access & res.access) != arg.access)
		status = -EACCES;
	return status;
}
Beispiel #22
0
static int nfs_mount_fs(nfs_fs *nfs, const char *server_path)
{
	uint8 sendbuf[256];
	char buf[128];
	nfs_mountargs args;
	size_t arglen;
	int err;

	rpc_set_port(&nfs->rpc, nfs->mount_port);

	args.dirpath = server_path;
	arglen = nfs_pack_mountargs(sendbuf, &args);

	err = rpc_call(&nfs->rpc, MOUNTPROG, MOUNTVERS, MOUNTPROC_MNT, sendbuf, arglen, buf, sizeof(buf));
	if(err < 0)
		return err;

#if NFS_TRACE
	TRACE("nfs_mount_fs: have root fhandle: ");
	dump_fhandle((const nfs_fhandle *)&buf[4]);
	TRACE("\n");
#endif
	// we should have the root handle now
	memcpy(&nfs->root_vnode->nfs_handle, &buf[4], sizeof(nfs->root_vnode->nfs_handle));

	// set the rpc port to the nfs server
	rpc_set_port(&nfs->rpc, nfs->nfs_port);

	return 0;
}
Beispiel #23
0
bool coind_validate_address(YAAMP_COIND *coind)
{
    if(!coind->wallet[0]) return false;

    char params[YAAMP_SMALLBUFSIZE];
    sprintf(params, "[\"%s\"]", coind->wallet);

    json_value *json = rpc_call(&coind->rpc, "validateaddress", params);
    if(!json) return false;

    json_value *json_result = json_get_object(json, "result");
    if(!json_result)
    {
        json_value_free(json);
        return false;
    }

    bool isvalid = json_get_bool(json_result, "isvalid");
    if(!isvalid) stratumlog("%s wallet %s is not valid.\n", coind->name, coind->wallet);

    bool ismine = json_get_bool(json_result, "ismine");
    if(!ismine) stratumlog("%s wallet %s is not mine.\n", coind->name, coind->wallet);

    const char *p = json_get_string(json_result, "pubkey");
    if(p) strcpy(coind->pubkey, p);

    json_value_free(json);
    base58_decode(coind->wallet, coind->script_pubkey);

    return isvalid && ismine;
}
/*
 * Common procedure for SM_MON/SM_UNMON calls
 */
static int
nsm_mon_unmon(struct nlm_host *host, u32 proc, struct nsm_res *res)
{
	struct rpc_clnt	*clnt;
	int		status;
	struct nsm_args	args;

	clnt = nsm_create();
	if (IS_ERR(clnt)) {
		status = PTR_ERR(clnt);
		goto out;
	}

	args.addr = host->h_addr.sin_addr.s_addr;
	args.proto= (host->h_proto<<1) | host->h_server;
	args.prog = NLM_PROGRAM;
	args.vers = host->h_version;
	args.proc = NLMPROC_NSM_NOTIFY;
	memset(res, 0, sizeof(*res));

	status = rpc_call(clnt, proc, &args, res, 0);
	if (status < 0)
		printk(KERN_DEBUG "nsm_mon_unmon: rpc failed, status=%d\n",
			status);
	else
		status = 0;
 out:
	return status;
}
Beispiel #25
0
unsigned int
mnt_get_export_list(void)
{
    struct pbuf *pbuf;
    struct pbuf *ret;
    char str[100];

    int opt;

    pbuf = initbuf(MNT_NUMBER, MNT_VERSION, MNTPROC_EXPORT);

    ret = rpc_call(pbuf, mount_port);

    while (getfrombuf(ret, (char*) &opt, sizeof(opt)), opt) {

	debug( "NFS Export...\n" );

	getstring(ret, str, 100);

	debug( "* Export name is %s\n", (char*) &str );

	/* now to extract more stuff... */
	while (getfrombuf(ret, (char*) &opt, sizeof(opt)), opt) {
	    getstring(ret, str, 100 );
	    debug("* Group %s\n", (char*) str);
	}
    }

    return 0;
}
void *my_thread_process(void *arg)
{
	enum clnt_stat rslt;
	int sndVar = atoi(arg);
	int recVar;
	int i;

	if (run_mode == 1) {
		fprintf(stderr, "Thread %d\n", atoi(arg));
		fprintf(stderr, "%s\n", nettype);
		fprintf(stderr, "%s\n", hostname);
		fprintf(stderr, "Value sent : %d\n", sndVar);
	}

	for (i = 0; i < callNb; i++) {
		rslt = rpc_call(hostname, progNum + atoi(arg), VERSNUM, PROCNUM, (xdrproc_t) xdr_int, (char *)&sndVar,	// xdr_in
				(xdrproc_t) xdr_int, (char *)&recVar,	// xdr_out
				nettype);
		/**/
		    //printf("Value received : %d\n", recVar);
		    thread_array_result[atoi(arg)] =
		    thread_array_result[atoi(arg)] + (rslt == RPC_SUCCESS);
	}

	pthread_exit(0);
}
Beispiel #27
0
void coind_getauxblock(YAAMP_COIND *coind)
{
	if(!coind->isaux) return;

	json_value *json = rpc_call(&coind->rpc, "getauxblock", "[]");
	if(!json)
	{
		coind_error(coind, "coind_getauxblock");
		return;
	}

	json_value *json_result = json_get_object(json, "result");
	if(!json_result)
	{
		coind_error(coind, "coind_getauxblock");
		return;
	}

//	coind->aux.height = coind->height+1;
	coind->aux.chainid = json_get_int(json_result, "chainid");

	const char *p = json_get_string(json_result, "target");
	if(p) strcpy(coind->aux.target, p);

	p = json_get_string(json_result, "hash");
	if(p) strcpy(coind->aux.hash, p);

//	if(strcmp(coind->symbol, "UNO") == 0)
//	{
//		string_be1(coind->aux.target);
//		string_be1(coind->aux.hash);
//	}

	json_value_free(json);
}
Beispiel #28
0
int rpc_peer_post_msg(struct rpc *r, void *buf, size_t len)
{
    rpc_call(r, RPC_PEER_POST_MSG, buf, len, NULL, 0);
    //printf("func_id = %x\n", RPC_PEER_POST_MSG);
    //dump_packet(&r->packet);
    return 0;
}
Beispiel #29
0
/*
 * For connectionless "udp" transport. Obsoleted by rpc_call().
 */
int
callrpc(char *host, int prognum, int versnum, int procnum,
	xdrproc_t inproc, char *in, xdrproc_t outproc, char *out)
{
	return (int)rpc_call(host, (rpcprog_t)prognum, (rpcvers_t)versnum,
	    (rpcproc_t)procnum, inproc, in, outproc, out, "udp");
}
Beispiel #30
0
/*
 * For connectionless "udp" transport. Obsoleted by rpc_call().
 */
int
callrpc(char *host, rpcprog_t prognum, rpcvers_t versnum, rpcproc_t procnum,
	xdrproc_t inproc, char *in, xdrproc_t outproc, char *out)
{
	return ((int)rpc_call(host, prognum, versnum, procnum, inproc,
				in, outproc, out, "udp"));
}