Ejemplo n.º 1
0
void register_server(int client_id)
{
	register SVCXPRT *transp;

	pmap_unset (CALLBACK_SEMAPHORE, V1 + client_id);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, CALLBACK_SEMAPHORE, V1 + client_id, callback_semaphore_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (CALLBACK_SEMAPHORE, V1, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, CALLBACK_SEMAPHORE, V1 + client_id, callback_semaphore_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (CALLBACK_SEMAPHORE, V1, tcp).");
		exit(1);
	}

	//svc_run ();
	//fprintf (stderr, "%s", "svc_run returned");
	//exit (1);
}
Ejemplo n.º 2
0
int
main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (WHATSUPPROG, WHATSUPVERS);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, WHATSUPPROG, WHATSUPVERS, whatsupprog_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (WHATSUPPROG, WHATSUPVERS, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, WHATSUPPROG, WHATSUPVERS, whatsupprog_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (WHATSUPPROG, WHATSUPVERS, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 3
0
int
main(int argc, char **argv)
{
	register SVCXPRT *transp;

	signal(SIGCHLD, sigchld);

	(void) pmap_unset(SCSI_PROG, SCSI_VERS);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf(stderr, "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, SCSI_PROG, SCSI_VERS, scsi_prog_1, IPPROTO_UDP)) {
		fprintf(stderr, "unable to register (SCSI_PROG, SCSI_VERS, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf(stderr, "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, SCSI_PROG, SCSI_VERS, scsi_prog_1, IPPROTO_TCP)) {
		fprintf(stderr, "unable to register (SCSI_PROG, SCSI_VERS, tcp).");
		exit(1);
	}

	svc_run();
	fprintf(stderr, "svc_run returned");
	exit(1);
	/* NOTREACHED */
}
Ejemplo n.º 4
0
int
main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (COOKIE_JAR, COOKIE_JAR_VERSION);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, COOKIE_JAR, COOKIE_JAR_VERSION, cookie_jar_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (COOKIE_JAR, COOKIE_JAR_VERSION, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, COOKIE_JAR, COOKIE_JAR_VERSION, cookie_jar_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (COOKIE_JAR, COOKIE_JAR_VERSION, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 5
0
main()
{
	SVCXPRT *transp;

	(void)pmap_unset(KUNDENPROG, KUNDENVERS);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		(void)fprintf(stderr, "cannot create udp service.\n");
		exit(1);
	}
	if (!svc_register(transp, KUNDENPROG, KUNDENVERS, kundenprog_1, IPPROTO_UDP)) {
		(void)fprintf(stderr, "unable to register (KUNDENPROG, KUNDENVERS, udp).\n");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		(void)fprintf(stderr, "cannot create tcp service.\n");
		exit(1);
	}
	if (!svc_register(transp, KUNDENPROG, KUNDENVERS, kundenprog_1, IPPROTO_TCP)) {
		(void)fprintf(stderr, "unable to register (KUNDENPROG, KUNDENVERS, tcp).\n");
		exit(1);
	}
	svc_run();
	(void)fprintf(stderr, "svc_run returned\n");
	exit(1);
}
Ejemplo n.º 6
0
main()
{
	SVCXPRT *transp;

	pw_serv_init();
	(void)pmap_unset(payments, paymentsver);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		(void)fprintf(stderr, "cannot create udp service.\n");
		exit(1);
	}
		(void)fprintf(stdout, "Created udp service.\n");
	udp_master = transp;
	if (!svc_register(transp, payments, paymentsver, payments_1, IPPROTO_UDP)) {
		(void)fprintf(stderr, "unable to register (payments, paymentsver, udp).\n");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		(void)fprintf(stderr, "cannot create tcp service.\n");
		exit(1);
	}
		(void)fprintf(stdout, "Created tcp service.\n");
	tcp_master = transp;
	if (!svc_register(transp, payments, paymentsver, payments_1, IPPROTO_TCP)) {
		(void)fprintf(stderr, "unable to register (payments, paymentsver, tcp).\n");
		exit(1);
	}
	pw_serv_mainloop(tcp_master, udp_master, 0, 1);
	(void)fprintf(stderr, "svc_run returned\n");
	exit(1);
}
Ejemplo n.º 7
0
int
main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (ARRAYSUM_CALC, ARRAYSUM_CALC_1);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, ARRAYSUM_CALC, ARRAYSUM_CALC_1, arraysum_calc_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (ARRAYSUM_CALC, ARRAYSUM_CALC_1, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, ARRAYSUM_CALC, ARRAYSUM_CALC_1, arraysum_calc_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (ARRAYSUM_CALC, ARRAYSUM_CALC_1, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 8
0
int daVarServSet(int prog, int version)
{
   
  if(prog==0) prog = DAVARSVR;
  if(version==0) version = DAVARVERS;
  (void) pmap_unset(prog,version);
  last_program = prog;
  last_version = version;
  
  udp_transp = (SVCXPRT *) svcudp_create(RPC_ANYSOCK);
  if (udp_transp == NULL) {
    fprintf(stderr, "cannot create udp service.");
    exit(1);
  }
  if (!svc_register(udp_transp, prog, version, davarsvr_1, IPPROTO_UDP)) {
    fprintf(stderr, "unable to register (%d, %d), udp).\n",prog,version);
    exit(1);
  }
  
  tcp_transp = (SVCXPRT *) svctcp_create(RPC_ANYSOCK, 0, 0);
  if (tcp_transp == NULL) {
    fprintf(stderr, "cannot create tcp service.\n");
    exit(1);
  }
  if (!svc_register(tcp_transp, prog, version, davarsvr_1, IPPROTO_TCP)) {
    fprintf(stderr, "unable to register (%d, %d), tcp).\n",prog,version);
    exit(1);
  }
  
}
Ejemplo n.º 9
0
void *
rpc2_server()
{
	register SVCXPRT *transp;

	pmap_unset (RPC2_RPC_PROG, RPC2_RPC_VERS1);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, RPC2_RPC_PROG, RPC2_RPC_VERS1, rpc2_rpc_prog_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (RPC2_RPC_PROG, RPC2_RPC_VERS1, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, RPC2_RPC_PROG, RPC2_RPC_VERS1, rpc2_rpc_prog_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (RPC2_RPC_PROG, RPC2_RPC_VERS1, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 10
0
int
main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (NAMENODE, NN);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, NAMENODE, NN, namenode_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (NAMENODE, NN, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, NAMENODE, NN, namenode_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (NAMENODE, NN, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 11
0
int
main (int argc, char **argv)
{


    thread_opts_t opts;
    opts.udp_port = 51234;
    opts.tcp_port = 51234;
    opts.sock = create_mcast_sock(NULL, opts.udp_port);

    pthread_t mcast_thread, tcp_thread;
    pthread_create(&mcast_thread, NULL, start_mcast_thread, &opts);
    pthread_create(&tcp_thread, NULL, start_tcp_thread, &opts);


	register SVCXPRT *transp;

	pmap_unset (OCL_PROG, OCL_VERS);

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, OCL_PROG, OCL_VERS, ocl_prog_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (OCL_PROG, OCL_VERS, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 12
0
void
yp_init(struct env *x_env)
{
	struct yp_data	*yp;

	if ((yp = calloc(1, sizeof(*yp))) == NULL)
		fatal(NULL);
	TAILQ_INIT(&yp->yd_events);

	env = x_env;
	env->sc_yp = yp;
	
	(void)pmap_unset(YPPROG, YPVERS);

	if ((yp->yp_trans_udp = svcudp_create(RPC_ANYSOCK)) == NULL)
		fatal("cannot create udp service");
	if ((yp->yp_trans_tcp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL)
		fatal("cannot create tcp service");

	if (!svc_register(yp->yp_trans_udp, YPPROG, YPVERS,
	    yp_dispatch, IPPROTO_UDP)) {
		fatal("unable to register (YPPROG, YPVERS, udp)");
	}
	if (!svc_register(yp->yp_trans_tcp, YPPROG, YPVERS,
	    yp_dispatch, IPPROTO_TCP)) {
		fatal("unable to register (YPPROG, YPVERS, tcp)");
	}
}
Ejemplo n.º 13
0
int
main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (DISPLAY_PRG, DISPLAY_VER);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, DISPLAY_PRG, DISPLAY_VER, display_prg_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (DISPLAY_PRG, DISPLAY_VER, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, DISPLAY_PRG, DISPLAY_VER, display_prg_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (DISPLAY_PRG, DISPLAY_VER, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 14
0
int main(void)
{
	//Program parameters : argc[1] : HostName or Host IP
	//                                         argc[2] : Server Program Number
	//                                         other arguments depend on test case

	int test_status = 1;	//Default test result set to FAILED
	int sock = 600;
	SVCXPRT *svcr = NULL;

	//create a server
	sock = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_TCP);
	svcr = svctcp_create(sock, 0, 0);

	test_status = (svcr != NULL) ? 0 : 1;

	//clean up
	svc_destroy(svcr);

	//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.º 15
0
int
main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (TELL_ME_DAY1, TELL_ME_DAY_VERSION1);
	pmap_unset (TELL_ME_DAY2, TELL_ME_DAY_VERSION2);
	pmap_unset (TELL_ME_DAY3, TELL_ME_DAY_VERSION3);
	pmap_unset (TELL_ME_DAY4, TELL_ME_DAY_VERSION4);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, TELL_ME_DAY1, TELL_ME_DAY_VERSION1, tell_me_day1_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (TELL_ME_DAY1, TELL_ME_DAY_VERSION1, udp).");
		exit(1);
	}
	if (!svc_register(transp, TELL_ME_DAY2, TELL_ME_DAY_VERSION2, tell_me_day2_2, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (TELL_ME_DAY2, TELL_ME_DAY_VERSION2, udp).");
		exit(1);
	}
	if (!svc_register(transp, TELL_ME_DAY3, TELL_ME_DAY_VERSION3, tell_me_day3_3, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (TELL_ME_DAY3, TELL_ME_DAY_VERSION3, udp).");
		exit(1);
	}
	if (!svc_register(transp, TELL_ME_DAY4, TELL_ME_DAY_VERSION4, tell_me_day4_4, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (TELL_ME_DAY4, TELL_ME_DAY_VERSION4, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, TELL_ME_DAY1, TELL_ME_DAY_VERSION1, tell_me_day1_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (TELL_ME_DAY1, TELL_ME_DAY_VERSION1, tcp).");
		exit(1);
	}
	if (!svc_register(transp, TELL_ME_DAY2, TELL_ME_DAY_VERSION2, tell_me_day2_2, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (TELL_ME_DAY2, TELL_ME_DAY_VERSION2, tcp).");
		exit(1);
	}
	if (!svc_register(transp, TELL_ME_DAY3, TELL_ME_DAY_VERSION3, tell_me_day3_3, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (TELL_ME_DAY3, TELL_ME_DAY_VERSION3, tcp).");
		exit(1);
	}
	if (!svc_register(transp, TELL_ME_DAY4, TELL_ME_DAY_VERSION4, tell_me_day4_4, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (TELL_ME_DAY4, TELL_ME_DAY_VERSION4, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 16
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];
	int sock = 600;
	SVCXPRT *svcr = NULL;

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

	sock = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_TCP);

	//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
		svcr = svctcp_create(sock, paramList[i].bufsnd, paramList[i].bufrec);

		//Check result
		if (svcr == 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.º 17
0
main()
{
   int			 ival;
   sigset_t		 qmask;
   struct sigaction	 sigchld_vec;
   SVCXPRT        	*transp;

   sigemptyset( &qmask );
   sigchld_vec.sa_handler = (void *) sigchld_irpt;
   sigchld_vec.sa_mask    = qmask;
   sigchld_vec.sa_flags   = 0;
   ival = sigaction( SIGCHLD, &sigchld_vec, 0 );
   if (ival < 0) {
	perror( "sigaction failed for SIGCHLD" );
	exit( 10 );
   }


   /*
    * Unregister our server before registering it again.  This makes sure we
    * clear out any old versions
    */

   (void) pmap_unset(ACQINFOPROG, ACQINFOVERS);

   /* Create a TCP socket for the server */
   transp = svctcp_create(RPC_ANYSOCK, 0, 0);
   if (transp == NULL)
   {
      (void) fprintf(stderr, "cannot create tcp service.\n");
      exit(1);
   }

   /*
    * Register the server with the portmapper so that clients can find out
    * what our port number is
    */
   if (!svc_register(transp, ACQINFOPROG, ACQINFOVERS, acqinfoprog_2, IPPROTO_TCP))
   {
      (void) fprintf(stderr, "unable to register (ACQINFOPROG, ACQINFOVERS, tcp).\n");
      exit(1);
   }

   /*
    * The portmapper table now has a program number, version, and protocol,
    * associated with a port number for our server. Now go to sleep until a
    * request comes in for this server.
    */

   svc_run();
   (void) fprintf(stderr, "svc_run returned\n");
   exit(1);
}
Ejemplo n.º 18
0
int
main (int argc, char **argv)
{  
try {

   if(argc<2) {
      throw GenericError("Faltan parametros para torre_de_control_svc: ./torre_de_control_svc config_file_abs_path");
   }
    
   std::string wkdir = ApiConfiguracion::get_torre_wkdir(argv[1]);
   crear_archivos_lck_torre(wkdir.c_str());

   torre_de_control = new TorreDeControlSvc(wkdir.c_str());
   api_torre = new ApiTorreDeControlSvc(wkdir.c_str(), argv[1]);

	register SVCXPRT *transp;

	pmap_unset (TORREDECONTROLPROG, TORREDECONTROLVERS);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, TORREDECONTROLPROG, TORREDECONTROLVERS, torredecontrolprog_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (TORREDECONTROLPROG, TORREDECONTROLVERS, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, TORREDECONTROLPROG, TORREDECONTROLVERS, torredecontrolprog_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (TORREDECONTROLPROG, TORREDECONTROLVERS, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
   return(0);
	// exit (1);
	/* NOTREACHED */

 } catch (const std::exception &e) {
	Log::crit("%s", e.what());
}
catch (...) {
	Log::crit("Critical error. Unknow exception at the end of the 'main' function.");
}

}
Ejemplo n.º 19
0
int main(void)
{
	SVCXPRT *xprt;
	xprt = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (xprt == NULL)
		errx(2, "svctcp_create\n");
	pmap_unset(RUSERSPROG, RUSERSVERS);
	if (!svc_register(xprt, RUSERSPROG, RUSERSVERS, dispatch, IPPROTO_TCP))
		errx(1, "svc_register\n");
	svc_run();
	return 0;
}
Ejemplo n.º 20
0
int
main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (DEVICE_ASYNC, DEVICE_ASYNC_VERSION);
	pmap_unset (DEVICE_CORE, DEVICE_CORE_VERSION);
	pmap_unset (DEVICE_INTR, DEVICE_INTR_VERSION);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, udp).");
		exit(1);
	}
	if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, udp).");
		exit(1);
	}
	if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (DEVICE_INTR, DEVICE_INTR_VERSION, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, tcp).");
		exit(1);
	}
	if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, tcp).");
		exit(1);
	}
	if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (DEVICE_INTR, DEVICE_INTR_VERSION, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 21
0
static void on_start() {
    int sock;
    int one = 1;
    DEBUG_FUNCTION;

    sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

    setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof (int));
    setsockopt(sock, SOL_TCP, TCP_DEFER_ACCEPT, (char *) &one, sizeof (int));
    setsockopt(sock, SOL_TCP, TCP_NODELAY, (char *) &one, sizeof (int));

    // SET NONBLOCK
    int value = 1;
    int oldflags = fcntl(sock, F_GETFL, 0);
    /* If reading the flags failed, return error indication now. */
    if (oldflags < 0) {
        return;
    }
    /* Set just the flag we want to set. */
    if (value != 0) {
        oldflags |= O_NONBLOCK;
    } else {
        oldflags &= ~O_NONBLOCK;
    }
    /* Store modified flag word in the descriptor. */
    fcntl(sock, F_SETFL, oldflags);

    if ((storaged_svc =
            svctcp_create(sock, ROZOFS_RPC_BUFFER_SIZE,
            ROZOFS_RPC_BUFFER_SIZE)) == NULL) {
        fatal("can't create service.");
        return;
    }

    pmap_unset(STORAGE_PROGRAM, STORAGE_VERSION); // in case !

    if (!svc_register
            (storaged_svc, STORAGE_PROGRAM, STORAGE_VERSION, storage_program_1,
            IPPROTO_TCP)) {
        fatal("can't register service : %s", strerror(errno));
        return;
    }

    info("running.");
    svc_run();
}
Ejemplo n.º 22
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//					   argc[2] : Server Program Number
	//					   argc[3] : Number of testes function calls
	//					   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 sock = 600;
	SVCXPRT *svcr = NULL;
    int nbCall = atoi(argc[3]);
	int nbOk = 0;
	int i;

	//create a server
	sock = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_TCP);
	for (i = 0; i < nbCall; i++)
	{
		svcr = svctcp_create(sock, 0, 0);
		if (svcr != NULL)
			nbOk++;
	}

	//If we are here, macro call was successful
	if (run_mode == 1)
	{
		printf("Aimed : %d\n", nbCall);
		printf("Got : %d\n", nbOk);
	}

	test_status = (nbOk == nbCall) ? 0 : 1;

	//clean up
	svc_destroy(svcr);

	//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.º 23
0
void *
nsm_thread (void *argv)
{
	register SVCXPRT *transp;
        int ret = 0;

        ret = pmap_unset (NLMCBK_PROGRAM, NLMCBK_V1);
        if (ret == 0) {
                gf_msg (GF_NLM, GF_LOG_ERROR, 0, NFS_MSG_PMAP_UNSET_FAIL,
                        "pmap_unset failed");
                return NULL;
        }
        transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		gf_msg (GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_UDP_SERV_FAIL,
                        "cannot create udp service.");
                return NULL;
	}
	if (!svc_register(transp, NLMCBK_PROGRAM, NLMCBK_V1, nlmcbk_program_0, IPPROTO_UDP)) {
		gf_msg (GF_NLM, GF_LOG_ERROR, 0, NFS_MSG_REG_NLMCBK_FAIL,
                        "unable to register (NLMCBK_PROGRAM, "
                        "NLMCBK_V0, udp).");
                return NULL;
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		gf_msg (GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_TCP_SERV_FAIL,
                        "cannot create tcp service.");
                return NULL;
	}
	if (!svc_register(transp, NLMCBK_PROGRAM, NLMCBK_V1, nlmcbk_program_0, IPPROTO_TCP)) {
		gf_msg (GF_NLM, GF_LOG_ERROR, 0, NFS_MSG_REG_NLMCBK_FAIL,
                        "unable to register (NLMCBK_PROGRAM, "
                        "NLMCBK_V0, tcp).");
                return NULL;
	}

	svc_run ();
	gf_msg (GF_NLM, GF_LOG_ERROR, 0, NFS_MSG_SVC_RUN_RETURNED,
                "svc_run returned");
        return NULL;
	/* NOTREACHED */
}
Ejemplo n.º 24
0
int main() {
	srand(time(NULL));
	int i;

	// RPC

	SVCXPRT *transp;

	// initialize map
	M_init(&map, 100, 85, PERCENTAGE, OBS_SIZE);

	// initialize populations
	for(i=0; i < NB_POP; i++) {
		pop_tab[i] = Population_new();
		Population_init(pop_tab[i], &map);
		pop_tab[i]->id = i + 1;
		pop_status[i] = 1;
	}


	Population_sort(pop_tab[0]);
	best_dna = pop_tab[0]->dna_tab[0];
	printf("Best DNA of first population: %f\n", pop_tab[0]->dna_tab[0].score);


	// initialize RPC

	pmap_unset(MWAP, MWAP_V1);

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, MWAP, MWAP_V1, dispatch, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (MWAP, MWAP_V1, tcp).");
		exit(1);
	}

	svc_run();
	return 0;
}
Ejemplo n.º 25
0
int
main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (PART3, PART3_V1);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, PART3, PART3_V1, part3_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (PART3, PART3_V1, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, PART3, PART3_V1, part3_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (PART3, PART3_V1, tcp).");
		exit(1);
	}

	if (argc == 1) {
		printf("Using default username and password.");
	} else if (argc == 3) {
		set_custom_userpass(argv[1], argv[2]);
		printf("Setting new username and password.");
	} else { //invalid number of args
		printf("Invalid number of args. Please enter 0 or 2 args. Exiting.");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 26
0
/*************************************************************************
**									**
**  main() - The main server routine.  This was generated by rpcgen.	**
**  It was cut out of the rpcgen'ed code because there needs to be	**
**  initialization done inside of main.					**
**									**
*************************************************************************/
main()
{
    register SVCXPRT *transp;

    (void) pmap_unset(BILLBOARD_PROG, BILLBOARD_VERS);

    transp = svcudp_create(RPC_ANYSOCK);
    if (transp == NULL) {
        fprintf(stderr, "cannot create udp service.");
        exit(1);
    }
    if (!svc_register(transp, BILLBOARD_PROG, BILLBOARD_VERS, billboard_prog_1, IPPROTO_UDP)) {
        fprintf(stderr, "unable to register (BILLBOARD_PROG, BILLBOARD_VERS, udp).");
        exit(1);
    }

    transp = svctcp_create(RPC_ANYSOCK, 0, 0);
    if (transp == NULL) {
        fprintf(stderr, "cannot create tcp service.");
        exit(1);
    }
    if (!svc_register(transp, BILLBOARD_PROG, BILLBOARD_VERS, billboard_prog_1, IPPROTO_TCP)) {
        fprintf(stderr, "unable to register (BILLBOARD_PROG, BILLBOARD_VERS, tcp).");
        exit(1);
    }

    /*
    **  Initialize the server.  Read all of the data structures and
    **  create the files that do not exist.
    */
    if ( bb_server_init() != BB_SUCCESS )
    {
        fprintf( stderr, "ABORTING: Unable to init server database.\n");
        return BB_FAILURE;
    }

    svc_run();
    fprintf(stderr, "svc_run returned");
    exit(1);
    /* NOTREACHED */
}
Ejemplo n.º 27
0
int
main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (ADDERPROG, ADDERVERS);
	pmap_unset (SQRTPROG, SQRTVER);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create udp service.");
		exit(1);
	}
	if (!svc_register(transp, ADDERPROG, ADDERVERS, adderprog_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (ADDERPROG, ADDERVERS, udp).");
		exit(1);
	}
	if (!svc_register(transp, SQRTPROG, SQRTVER, sqrtprog_1, IPPROTO_UDP)) {
		fprintf (stderr, "%s", "unable to register (SQRTPROG, SQRTVER, udp).");
		exit(1);
	}

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, ADDERPROG, ADDERVERS, adderprog_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (ADDERPROG, ADDERVERS, tcp).");
		exit(1);
	}
	if (!svc_register(transp, SQRTPROG, SQRTVER, sqrtprog_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (SQRTPROG, SQRTVER, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}
Ejemplo n.º 28
0
//****************************************//
//***           Main Function          ***//
//****************************************//
int main(int argn, char *argc[])
{
	//Server parameter is : argc[1] : Server Program Number
	//					    others arguments depend on server program
	int run_mode = 1;
	int progNum = atoi(argc[1]);
	SVCXPRT *transpTCP = NULL;
	SVCXPRT *transpUDP = NULL;
	//char *simplePing();

	//Initialization
	pmap_unset(progNum, VERSNUM);
	svc_unregister(progNum, VERSNUM);

    //registerrpc(progNum, VERSNUM, PROCSIMPLEPING,
    //    		simplePing, xdr_int, xdr_int);
    transpTCP = svctcp_create(RPC_ANYSOCK, 1000, 1000);
    transpUDP = svcudp_create(RPC_ANYSOCK);

    if (run_mode)
    {
    	printf ("SVC TCP : %d\n", transpTCP);
    	printf ("SVC UDP : %d\n", transpUDP);
    }

	if (!svc_register(transpTCP, progNum, VERSNUM, (void *)rcp_service, IPPROTO_TCP))
	{
    	fprintf(stderr, "svc_register: error (TCP)\n");
    }

    if (!svc_register(transpUDP, progNum, VERSNUM, (void *)rcp_service, IPPROTO_UDP))
	{
    	fprintf(stderr, "svc_register: error (UDP)\n");
    }

    svc_run();
    fprintf(stderr, "Error: svc_run returned!\n");
    exit(1);
}
Ejemplo n.º 29
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]);
	SVCXPRT *svcr = NULL;

	//Initialisation
	pmap_unset(progNum, VERSNUM);
	//create a server
	svcr = svctcp_create(RPC_ANYSOCK, 0, 0);

	svc_register(svcr, progNum, VERSNUM, dispatch, IPPROTO_TCP);

	if (run_mode) {
		printf("SVC : %p\n", svcr);
	}
	//call routine
	svc_unregister(progNum, VERSNUM);

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

	//clean up
	svc_destroy(svcr);

	//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.º 30
0
int
void __dbsrv_main (int argc, char **argv)
{
	register SVCXPRT *transp;

	pmap_unset (DB_SERVERPROG, DB_SERVERVERS);

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, DB_SERVERPROG, DB_SERVERVERS, db_serverprog_1, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (DB_SERVERPROG, DB_SERVERVERS, tcp).");
		exit(1);
	}

	svc_run ();
	fprintf (stderr, "%s", "svc_run returned");
	exit (1);
	/* NOTREACHED */
}