Ejemplo n.º 1
0
/*
 * Adds a socket to the list for servicing by nfscbds.
 */
int
nfscbd_addsock(struct file *fp)
{
	int siz;
	struct socket *so;
	int error;
	SVCXPRT *xprt;

	so = fp->f_data;

	siz = sb_max_adj;
	error = soreserve(so, siz, siz);
	if (error)
		return (error);

	/*
	 * Steal the socket from userland so that it doesn't close
	 * unexpectedly.
	 */
	if (so->so_type == SOCK_DGRAM)
		xprt = svc_dg_create(nfscbd_pool, so, 0, 0);
	else
		xprt = svc_vc_create(nfscbd_pool, so, 0, 0);
	if (xprt) {
		fp->f_ops = &badfileops;
		fp->f_data = NULL;
		svc_reg(xprt, NFS_CALLBCKPROG, NFSV4_CBVERS, nfscb_program,
		    NULL);
		SVC_RELEASE(xprt);
	}

	return (0);
}
Ejemplo n.º 2
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 = 0; //Default test result set to PASS
	int progNum = atoi(argc[2]);
	int i;
	params paramList[NBCASE];
	SVCXPRT *transp = NULL;

    //Test arguments initialization
	paramList[0].bufsnd = 0;
	paramList[0].bufrec = 0;
	paramList[1].bufsnd = 0;
	paramList[1].bufrec = 2147483647;
	paramList[2].bufsnd = 2147483647;
	paramList[2].bufrec = 0;
	paramList[3].bufsnd = 2147483647;
	paramList[3].bufrec = 2147483647;

	//Call tested function using all tests cases
	for (i = 0; i < NBCASE; i++)
	{
		//Debug mode prints
		if (run_mode == 1)
		{
			printf("Test using values : %d ", paramList[i].bufsnd);
			printf("%d", paramList[i].bufrec);
			printf("\n");
		}

		//Call function
		transp = svc_dg_create(RPC_ANYFD, paramList[i].bufsnd, paramList[i].bufrec);

		//Check result
		if (transp == NULL)
		{
			//test has failed
			test_status = 1;
			break;
		}
	}

	//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;
}
Ejemplo n.º 3
0
/*
 * Adds a socket to the list for servicing by nfsds.
 */
int
nfsrvd_addsock(struct file *fp)
{
	int siz;
	struct socket *so;
	int error = 0;
	SVCXPRT *xprt;
	static u_int64_t sockref = 0;

	so = fp->f_data;

	siz = sb_max_adj;
	error = soreserve(so, siz, siz);
	if (error)
		goto out;

	/*
	 * Steal the socket from userland so that it doesn't close
	 * unexpectedly.
	 */
	if (so->so_type == SOCK_DGRAM)
		xprt = svc_dg_create(nfsrvd_pool, so, 0, 0);
	else
		xprt = svc_vc_create(nfsrvd_pool, so, 0, 0);
	if (xprt) {
		fp->f_ops = &badfileops;
		fp->f_data = NULL;
		xprt->xp_sockref = ++sockref;
		if (nfs_minvers == NFS_VER2)
			svc_reg(xprt, NFS_PROG, NFS_VER2, nfssvc_program,
			    NULL);
		if (nfs_minvers <= NFS_VER3 && nfs_maxvers >= NFS_VER3)
			svc_reg(xprt, NFS_PROG, NFS_VER3, nfssvc_program,
			    NULL);
		if (nfs_maxvers >= NFS_VER4)
			svc_reg(xprt, NFS_PROG, NFS_VER4, nfssvc_program,
			    NULL);
		if (so->so_type == SOCK_STREAM)
			svc_loss_reg(xprt, nfssvc_loss);
		SVC_RELEASE(xprt);
	}

out:
	NFSEXITCODE(error);
	return (error);
}
Ejemplo n.º 4
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
	SVCXPRT *transp = NULL;

	transp = svc_dg_create(RPC_ANYFD, 0, 0);
	/**/ test_status = ((SVCXPRT *) transp != NULL) ? 0 : 1;

	//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;
}
Ejemplo n.º 5
0
int main(void)
{
	int test_status = 1;
	SVCXPRT *transp = NULL;
	int sock;

	sock = bound_socket(AF_INET, SOCK_DGRAM);
	if (sock < 0) {
		perror("bound_socket() failed");
		return 1;
	}

	transp = svc_dg_create(sock, 0, 0);
	test_status = ((SVCXPRT *) transp != NULL) ? 0 : 1;

	if (transp != NULL)
		svc_destroy(transp);

	close(sock);

	printf("%d\n", test_status);

	return test_status;
}