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[])
{
	SVCXPRT *transp;
        int sock = 0;
        int proto = 0;
	struct sockaddr_in from;
	int fromlen;

        if (argc == 2)
                closedown = atoi(argv[1]);
        if (closedown <= 0)
                closedown = 20;

        /*
         * See if inetd started us
         */
	fromlen = sizeof(from);
        if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
                from_inetd = 0;
                sock = RPC_ANYSOCK;
                proto = IPPROTO_UDP;
        }

        if (!from_inetd) {
                daemon(0, 0);

                (void)pmap_unset(RSTATPROG, RSTATVERS_TIME);
                (void)pmap_unset(RSTATPROG, RSTATVERS_SWTCH);
                (void)pmap_unset(RSTATPROG, RSTATVERS_ORIG);

		(void) signal(SIGINT, cleanup);
		(void) signal(SIGTERM, cleanup);
		(void) signal(SIGHUP, cleanup);
        }

        openlog("rpc.rstatd", LOG_CONS|LOG_PID, LOG_DAEMON);

	transp = svcudp_create(sock);
	if (transp == NULL) {
		syslog(LOG_ERR, "cannot create udp service");
		exit(1);
	}
	if (!svc_register(transp, RSTATPROG, RSTATVERS_TIME, rstat_service, proto)) {
		syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_TIME, %s)", proto?"udp":"(inetd)");
		exit(1);
	}
	if (!svc_register(transp, RSTATPROG, RSTATVERS_SWTCH, rstat_service, proto)) {
		syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_SWTCH, %s)", proto?"udp":"(inetd)");
		exit(1);
	}
	if (!svc_register(transp, RSTATPROG, RSTATVERS_ORIG, rstat_service, proto)) {
		syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_ORIG, %s)", proto?"udp":"(inetd)");
		exit(1);
	}

        svc_run();
	syslog(LOG_ERR, "svc_run returned");
	exit(1);
}
Ejemplo n.º 3
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.º 4
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.º 5
0
/*
 * Create the nfs service for amd
 */
int
create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp))
{

  *soNFSp = socket(AF_INET, SOCK_DGRAM, 0);

  if (*soNFSp < 0 || bind_resv_port(*soNFSp, nfs_portp) < 0) {
    plog(XLOG_FATAL, "Can't create privileged nfs port (socket)");
    if (*soNFSp >= 0)
      close(*soNFSp);
    return 1;
  }
  if ((*nfs_xprtp = svcudp_create(*soNFSp)) == NULL) {
    plog(XLOG_FATAL, "cannot create rpc/udp service");
    close(*soNFSp);
    return 2;
  }
  if ((*nfs_portp = (*nfs_xprtp)->xp_port) >= IPPORT_RESERVED) {
    plog(XLOG_FATAL, "Can't create privileged nfs port");
    svc_destroy(*nfs_xprtp);
    close(*soNFSp);
    return 1;
  }
  if (!svc_register(*nfs_xprtp, NFS_PROGRAM, NFS_VERSION, dispatch_fxn, 0)) {
    plog(XLOG_FATAL, "unable to register (%ld, %ld, 0)",
	 (u_long) NFS_PROGRAM, (u_long) NFS_VERSION);
    svc_destroy(*nfs_xprtp);
    close(*soNFSp);
    return 3;
  }

  return 0;			/* all is well */
}
Ejemplo n.º 6
0
void *
mount3udp_thread (void *argv)
{
        xlator_t         *nfsx   = argv;
        register SVCXPRT *transp = NULL;

        GF_ASSERT (nfsx);

        if (glusterfs_this_set(nfsx)) {
                gf_log (GF_MNT, GF_LOG_ERROR, "failed to set xlator, "
                        "nfs.mount-udp will not work");
                return NULL;
        }

        transp = svcudp_create(RPC_ANYSOCK);
        if (transp == NULL) {
                gf_log (GF_MNT, GF_LOG_ERROR, "svcudp_create error");
                return NULL;
        }
        if (!svc_register(transp, MOUNT_PROGRAM, MOUNT_V3,
                          mountudp_program_3, IPPROTO_UDP)) {
                gf_log (GF_MNT, GF_LOG_ERROR, "svc_register error");
                return NULL;
        }

        svc_run ();
        gf_log (GF_MNT, GF_LOG_ERROR, "svc_run returned");
        return NULL;
}
Ejemplo n.º 7
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 sock = 600;
	SVCXPRT *svcr = NULL;

	//create a server
	//
	sock = socket(AF_UNIX, SOCK_SEQPACKET, IPPROTO_UDP);
	svcr = svcudp_create(sock);

	//check returned value
	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.º 8
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 = 5000000; //This test doesn't care with progNum, just local test of reg/unreg...
	int port = 600;
	SVCXPRT *transp = NULL;

	//Initialization
	pmap_unset(progNum, VERSNUM);

    if (run_mode)
    {
    	printf("Before creation\n");
	}

	transp = svcudp_create(RPC_ANYSOCK);
	pmap_set(progNum, VERSNUM, IPPROTO_UDP, port);

    test_status = !pmap_unset(progNum, VERSNUM);

	//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.º 9
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.º 10
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.º 11
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.º 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
void ippool_api_init(void)
{
	int result;

	/* Register RPC interface */
	ippool_rpc_xprt = svcudp_create(RPC_ANYSOCK);
	if (ippool_rpc_xprt == NULL) {
		ippool_log(LOG_ERR, "unable to register with RPC");
		exit(1);
	}

	/* FIXME: is this really required? */
	svc_unregister(IPPOOL_PROG, IPPOOL_VERSION);
	
	/* Note: must call this or the registration fails every other time
	 * the daemon is started. */
	(void) pmap_unset(IPPOOL_PROG, IPPOOL_VERSION);


	result = svc_register(ippool_rpc_xprt, IPPOOL_PROG, IPPOOL_VERSION, ippool_prog_1, IPPROTO_UDP);
	if (result == 0) {	/* UNIX is nice and consistent about error codes ;-) */
		ippool_log(LOG_ERR, "unable to register RPC program");
		exit(1);		
	}
	result = usl_fd_add_fd(ippool_rpc_xprt->xp_sock, ippool_api_rpc_msg, ippool_rpc_xprt);
	if (result < 0) {
		ippool_log(LOG_ERR, "unable to register RPC handler");
		exit(1);
	}
}
Ejemplo n.º 14
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.º 15
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.º 16
0
/*
 * Register the autofs service for amd
 */
int
register_autofs_service(char *autofs_conftype, void (*autofs_dispatch)(struct svc_req *rqstp, SVCXPRT *transp))
{
  int autofs_socket;
  SVCXPRT *autofs_xprt = NULL;

  autofs_socket = socket(AF_INET, SOCK_DGRAM, 0);

  if (autofs_socket < 0 || bind_resv_port(autofs_socket, NULL) < 0) {
    plog(XLOG_FATAL, "Can't create privileged autofs port (socket)");
    return 1;
  }
  if ((autofs_xprt = svcudp_create(autofs_socket)) == NULL) {
    plog(XLOG_FATAL, "Can't create autofs rpc/udp service");
    return 2;
  }
  if (autofs_xprt->xp_port >= IPPORT_RESERVED) {
    plog(XLOG_FATAL, "Can't create privileged autofs port");
    return 1;
  }
  if (!svc_register(autofs_xprt, AUTOFS_PROG, AUTOFS_VERS, autofs_dispatch, 0)) {
    plog(XLOG_FATAL, "unable to register (%ld, %ld, 0)",
	 (u_long) AUTOFS_PROG, (u_long) AUTOFS_VERS);
    return 3;
  }

  return 0;			/* all is well */
}
Ejemplo n.º 17
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.º 18
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.º 19
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.º 20
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.º 21
0
int
registerrpc (u_long prognum, u_long versnum, u_long procnum,
	     char *(*progname) (char *), xdrproc_t inproc, xdrproc_t outproc)
{
  struct proglst_ *pl;
  char *buf;

  if (procnum == NULLPROC)
    {

      (void) asprintf (&buf, _("can't reassign procedure number %ld\n"),
			 NULLPROC);
      goto err_out;
    }
  if (transp == 0)
    {
      transp = svcudp_create (RPC_ANYSOCK);
      if (transp == NULL)
	{
	  buf = strdup (_("couldn't create an rpc server\n"));
	  goto err_out;
	}
    }
  (void) pmap_unset ((u_long) prognum, (u_long) versnum);
  if (!svc_register (transp, (u_long) prognum, (u_long) versnum,
		     universal, IPPROTO_UDP))
    {
      (void) asprintf (&buf, _("couldn't register prog %ld vers %ld\n"),
			 prognum, versnum);
      goto err_out;
    }
  pl = (struct proglst_ *) malloc (sizeof (struct proglst_));
  if (pl == NULL)
    {
      buf = strdup (_("registerrpc: out of memory\n"));
      goto err_out;
    }
  pl->p_progname = progname;
  pl->p_prognum = prognum;
  pl->p_procnum = procnum;
  pl->p_inproc = inproc;
  pl->p_outproc = outproc;
  pl->p_nxt = proglst;
  proglst = pl;
  return 0;

 err_out:
#ifdef USE_IN_LIBIO
  if (_IO_fwide (stderr, 0) > 0)
    (void) __fwprintf (stderr, L"%s", buf);
  else
#endif
    (void) fputs (buf, stderr);
  free (buf);
  return -1;
}
Ejemplo n.º 22
0
int
__registerrpc (u_long prognum, u_long versnum, u_long procnum,
	       char *(*progname) (char *), xdrproc_t inproc, xdrproc_t outproc)
{
  struct proglst_ *pl;
  char *buf;

  if (procnum == NULLPROC)
    {

      if (__asprintf (&buf, _("can't reassign procedure number %ld\n"),
		      NULLPROC) < 0)
	buf = NULL;
      goto err_out;
    }
  if (transp == 0)
    {
      transp = svcudp_create (RPC_ANYSOCK);
      if (transp == NULL)
	{
	  buf = strdup (_("couldn't create an rpc server\n"));
	  goto err_out;
	}
    }
  (void) pmap_unset ((u_long) prognum, (u_long) versnum);
  if (!svc_register (transp, (u_long) prognum, (u_long) versnum,
		     universal, IPPROTO_UDP))
    {
      if (__asprintf (&buf, _("couldn't register prog %ld vers %ld\n"),
		      prognum, versnum) < 0)
	buf = NULL;
      goto err_out;
    }
  pl = (struct proglst_ *) malloc (sizeof (struct proglst_));
  if (pl == NULL)
    {
      buf = strdup (_("registerrpc: out of memory\n"));
      goto err_out;
    }
  pl->p_progname = progname;
  pl->p_prognum = prognum;
  pl->p_procnum = procnum;
  pl->p_inproc = inproc;
  pl->p_outproc = outproc;
  pl->p_nxt = proglst;
  proglst = pl;
  return 0;

 err_out:
  if (buf == NULL)
    return -1;
  (void) __fxprintf (NULL, "%s", buf);
  free (buf);
  return -1;
}
Ejemplo n.º 23
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.º 24
0
void l2tp_api_init(void)
{
	int result;

	/* Register RPC interface */
	l2tp_rpc_xprt = svcudp_create(RPC_ANYSOCK);
	if (l2tp_rpc_xprt == NULL) {
		l2tp_log(LOG_ERR, "unable to register with RPC");
		exit(1);
	}

	(void) pmap_unset(L2TP_PROG, L2TP_VERSION);
	result = svc_register(l2tp_rpc_xprt, L2TP_PROG, L2TP_VERSION, l2tp_prog_1, IPPROTO_UDP);
	if (result == 0) {	/* UNIX is nice and consistent about error codes ;-) */
		l2tp_log(LOG_ERR, "unable to register RPC program");
		exit(1);
	}
	result = usl_fd_add_fd(l2tp_rpc_xprt->xp_sock, l2tp_api_rpc_msg, l2tp_rpc_xprt);
	if (result < 0) {
		l2tp_log(LOG_ERR, "unable to register RPC handler");
		exit(1);
	}

	l2tp_event_rpc_xprt = svcudp_create(RPC_ANYSOCK);
	if (l2tp_event_rpc_xprt == NULL) {
		l2tp_log(LOG_ERR, "unable to register event interface with RPC");
		exit(1);
	}
	(void) pmap_unset(L2TP_EVENT_PROG, L2TP_EVENT_VERSION);
	result = svc_register(l2tp_event_rpc_xprt, L2TP_EVENT_PROG, L2TP_EVENT_VERSION, l2tp_event_prog_1, IPPROTO_UDP);
	if (result == 0) {	/* UNIX is nice and consistent about error codes ;-) */
		l2tp_log(LOG_ERR, "unable to register RPC program");
		exit(1);
	}
	result = usl_fd_add_fd(l2tp_event_rpc_xprt->xp_sock, l2tp_api_rpc_msg, l2tp_event_rpc_xprt);
	if (result < 0) {
		l2tp_log(LOG_ERR, "unable to register event RPC handler");
		exit(1);
	}
}
Ejemplo n.º 25
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.º 26
0
int
main(int argc, char *argv[])
{
	SVCXPRT *transp;
	int sock = 0;
	int proto = 0;
	struct sockaddr_in from;
	int fromlen;

	/*
	 * See if inetd started us
	 */
	fromlen = sizeof(from);
	if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
		from_inetd = 0;
		sock = RPC_ANYSOCK;
		proto = IPPROTO_UDP;
	}

	if (!from_inetd) {
		daemon(0, 0);

		(void) pmap_unset(SPRAYPROG, SPRAYVERS);

		(void) signal(SIGINT, cleanup);
		(void) signal(SIGTERM, cleanup);
		(void) signal(SIGHUP, cleanup);
	} else {
		(void) signal(SIGALRM, die);
		alarm(TIMEOUT);
	}

	openlog("rpc.sprayd", LOG_CONS|LOG_PID, LOG_DAEMON);

	transp = svcudp_create(sock);
	if (transp == NULL) {
		syslog(LOG_ERR, "cannot create udp service");
		return 1;
	}
	if (!svc_register(transp, SPRAYPROG, SPRAYVERS, spray_service, proto)) {
		syslog(LOG_ERR,
		    "unable to register (SPRAYPROG, SPRAYVERS, %s)",
		    proto ? "udp" : "(inetd)");
		return 1;
	}

	svc_run();
	syslog(LOG_ERR, "svc_run returned");
	return 1;
}
Ejemplo n.º 27
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_SEQPACKET, IPPROTO_UDP);
	for (i = 0; i < nbCall; i++)
	{
		svcr = svcudp_create(sock);
		if (svcr != (SVCXPRT *)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.º 28
0
int
registerrpc (u_long prognum, u_long versnum, u_long procnum,
	     char *(*progname) (char *), xdrproc_t inproc, xdrproc_t outproc)
{
  struct proglst *pl;

  if (procnum == NULLPROC)
    {
      (void) fprintf (stderr,
		      _("can't reassign procedure number %ld\n"), NULLPROC);
      return -1;
    }
  if (transp == 0)
    {
      transp = svcudp_create (RPC_ANYSOCK);
      if (transp == NULL)
	{
	  (void) fputs (_("couldn't create an rpc server\n"), stderr);
	  return -1;
	}
    }
  (void) pmap_unset ((u_long) prognum, (u_long) versnum);
  if (!svc_register (transp, (u_long) prognum, (u_long) versnum,
		     universal, IPPROTO_UDP))
    {
      (void) fprintf (stderr, _("couldn't register prog %ld vers %ld\n"),
		      prognum, versnum);
      return -1;
    }
  pl = (struct proglst *) malloc (sizeof (struct proglst));
  if (pl == NULL)
    {
      (void) fprintf (stderr, _("registerrpc: out of memory\n"));
      return -1;
    }
  pl->p_progname = progname;
  pl->p_prognum = prognum;
  pl->p_procnum = procnum;
  pl->p_inproc = inproc;
  pl->p_outproc = outproc;
  pl->p_nxt = proglst;
  proglst = pl;
  return 0;
}
Ejemplo n.º 29
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.º 30
0
void
join (int type)
{
  int err;
  SVCXPRT *xprt;

  xprt = svcudp_create (RPC_ANYSOCK);
  if (xprt == NULL)
    {
      fprintf (stderr, "svcudp_create: Failed.\n");
      exit (EXIT_FAILURE);
    }

  switch (type)
    {
    case MASTER:
      /* Create master RPC server: */
      pmap_unset (LOSH, MASTER);
      err = svc_register (xprt, LOSH, MASTER, master_dispatch, IPPROTO_UDP);
      if (!err)
	{
	  fprintf (stderr, "svc_register: Failed.\n");
	  exit (EXIT_FAILURE);
	}
      break;

    case SLAVE:
      /* Create slave RPC server: */
      pmap_unset (LOSH, SLAVE);
      err = svc_register (xprt, LOSH, SLAVE, slave_dispatch, IPPROTO_UDP);
      if (!err)
	{
	  fprintf (stderr, "svc_register: Failed.\n");
	  exit (EXIT_FAILURE);
	}

      /* Join LoSh master: */
      whoismaster_broadcast ();
      recordslave_call ();
      break;
    }
}