예제 #1
0
파일: clnt_perror.c 프로젝트: ebichu/dd-wrt
void
clnt_perror (CLIENT * rpch, const char *msg)
{
#ifdef USE_IN_LIBIO
  if (_IO_fwide (stderr, 0) > 0)
    (void) fwprintf (stderr, L"%s", clnt_sperror (rpch, msg));
  else
#endif
    (void) fputs (clnt_sperror (rpch, msg), stderr);
}
예제 #2
0
int
main(int argc, char **argv)
{
	CLIENT		*cl;
	square_in	in;
	square_out	*outp;
	struct timeval	tv;

	if (argc != 4)
		err_quit("usage: client <hostname> <integer-value> <protocol>");

	cl = Clnt_create(argv[1], SQUARE_PROG, SQUARE_VERS, argv[3]);

	Clnt_control(cl, CLGET_TIMEOUT, (char *) &tv);
	printf("timeout = %ld sec, %ld usec\n", tv.tv_sec, tv.tv_usec);
	if (clnt_control(cl, CLGET_RETRY_TIMEOUT, (char *) &tv) == TRUE)
		printf("retry timeout = %ld sec, %ld usec\n", tv.tv_sec, tv.tv_usec);

	in.arg1 = atol(argv[2]);
	if ( (outp = squareproc_1(&in, cl)) == NULL)
		err_quit("%s", clnt_sperror(cl, argv[1]));

	printf("result: %ld\n", outp->res1);
	exit(0);
}
예제 #3
0
static int ippool_addr_alloc(CLIENT *cl, char *pool_name, u_int32_t *addr)
{
	int result;
	struct ippool_api_addr_alloc_msg_data clnt_res;

	result = ippool_addr_alloc_1(pool_name, &clnt_res, cl);
	if (result != RPC_SUCCESS) {
		fatal("ippool: %s", clnt_sperror(cl, ippool_server));
	}
	if (clnt_res.result_code < 0) {
		if (ippool_debug) {
			warn("IP address allocation from pool %s failed: %s", 
			     pool_name, strerror(-clnt_res.result_code));
		}
		result = clnt_res.result_code;
		goto out;
	}

	*addr = clnt_res.addr.s_addr;

	if (ippool_debug) {
		dbglog("Allocated address %s from pool %s", inet_ntoa(clnt_res.addr.s_addr), pool_name);
	}
out:
	return result;
}
예제 #4
0
int main(int argc, char **argv) {
  CLIENT *cl;
  add_in in;
  add_out *out;

  if (argc!=4) { 
    printf("Usage: %s <machine> <int1> <int2>\n\n",argv[0]); return 1; 
  }

  cl = clnt_create(argv[1], ADD_PROGRAM, ADD_VERSION, "tcp");
  if (cl==NULL) {
    perror("Error creating RPC client!");
    return 1;
  }
  in.arg1 = atol(argv[2]);
  in.arg2 = atol(argv[3]);
  out = add_1(&in, cl);
  
  if (out==NULL) {
    printf("Error: %s\n",clnt_sperror(cl,argv[1]));
    return 1;
  }
  else {
    printf("We received the result: %ld\n",*out);
  }
  return 0;
}
예제 #5
0
static void ippool_addr_free(CLIENT *cl, char *pool_name, u_int32_t addr)
{
	int result;
	int clnt_res;
	struct ippool_api_ip_addr free_addr;

	free_addr.s_addr = addr;
	result = ippool_addr_free_1(pool_name, free_addr, &clnt_res, cl);
	if (result != RPC_SUCCESS) {
		fatal("ippool: %s", clnt_sperror(cl, ippool_server));
	}
	if (clnt_res < 0) {
		if (ippool_debug) {
			warn("IP address %s free to pool %s failed: %s", 
			     inet_ntoa(free_addr), pool_name, strerror(-clnt_res));
		}
		goto out;
	}

	if (ippool_debug) {
		dbglog("Freed address %s to pool %s", inet_ntoa(free_addr), pool_name);
	}
out:
	return;
}
예제 #6
0
static void pppol2tp_send_accm_ind(uint32_t send_accm, uint32_t recv_accm)
{
	int result;
	struct timeval timeout = { 0, 0 };
	struct l2tp_session_ppp_accm_ind_1_argument args;

	if (pppol2tp_client == NULL) {
		result = pppol2tp_rpc_client_create();
		if (result < 0) {
			goto out;
		}
	}

	memset(&args, 0, sizeof(args));
	args.tunnel_id = pppol2tp_tunnel_id;
	args.session_id = pppol2tp_session_id;
	args.send_accm = ntohl(send_accm);
	args.recv_accm = ntohl(recv_accm);
	result = clnt_call(pppol2tp_client, L2TP_SESSION_PPP_ACCM_IND, 
			   (xdrproc_t) xdr_l2tp_session_ppp_accm_ind_1_argument,
			   (char *) &args, NULL, NULL, timeout);
	if ((result != RPC_SUCCESS) && (result != RPC_TIMEDOUT)) {
		char *err_msg = clnt_sperror(pppol2tp_client, "ppp_accm_ind");
		err_msg[strlen(err_msg) - 1] = '\0';
		dbglog(err_msg);
	}
out:
	return;
}
예제 #7
0
void
clnt_perror(
	CLIENT *rpch,
	const char *s)
{
	(void) fprintf(stderr,"%s\n",clnt_sperror(rpch,s));
}
예제 #8
0
static void uptime(void)
{
	bayonne_status *stats;
	char dur[12];
	unsigned long upt;

	stats = bayonne_status_2("", rpc);
	if(!stats)
	{
        	printf( "RPC CALL: %s\n", clnt_sperror(rpc, "" ) );
                clnt_destroy(rpc);
                exit( 1 );
        }

	upt = stats->node_uptime;

        if(upt < 100 * 3600)
                snprintf(dur, sizeof(dur), "%02d:%02d:%02d",
                        upt / 3600, (upt / 60) % 60, upt % 60);
        else
                snprintf(dur, sizeof(dur), "%d days", upt / (3600 * 24));
	
	printf("%s server version %s, timeslots=%d, active=%d, up %s\n",
		stats->node_server, stats->node_version, 
		stats->node_count, stats->node_active, dur);
	
	clnt_destroy(rpc);
	exit(0);
}
예제 #9
0
static void
authgss_destroy_context(AUTH *auth)
{
	struct rpc_gss_data	*gd;
	OM_uint32		 min_stat;
	enum clnt_stat		 callstat;

	log_debug("in authgss_destroy_context()");
	
	gd = AUTH_PRIVATE(auth);
	
	if (gd->gc.gc_ctx.length != 0) {
		if (gd->established) {
			gd->gc.gc_proc = RPCSEC_GSS_DESTROY;
			callstat = clnt_call(gd->clnt, NULLPROC,
					     xdr_void, NULL,
					     xdr_void, NULL,
					     AUTH_TIMEOUT);
			log_debug("%s",
				  clnt_sperror(gd->clnt,
					       "authgss_destroy_context"));
		}
		gss_release_buffer(&min_stat, &gd->gc.gc_ctx);
		/* XXX ANDROS check size of context  - should be 8 */
		memset(&gd->gc.gc_ctx, 0, sizeof(gd->gc.gc_ctx));
	}
	if (gd->ctx != GSS_C_NO_CONTEXT) {
		gss_delete_sec_context(&min_stat, &gd->ctx, NULL);
		gd->ctx = GSS_C_NO_CONTEXT;
	}
	gd->established = FALSE;

	log_debug("finished authgss_destroy_context()");
}
예제 #10
0
static void
onehost(char *host)
{
	utmpidlearr up;
	CLIENT *rusers_clnt;
	struct sockaddr_in addr;
	struct hostent *hp;
	struct timeval tv;

	hp = gethostbyname(host);
	if (hp == NULL)
		errx(1, "unknown host \"%s\"", host);

	rusers_clnt = clnt_create(host, RUSERSPROG, RUSERSVERS_IDLE, "udp");
	if (rusers_clnt == NULL)
		errx(1, "%s", clnt_spcreateerror(""));

	bzero((char *)&up, sizeof(up));
	tv.tv_sec = 15;	/* XXX ?? */
	tv.tv_usec = 0;
	if (clnt_call(rusers_clnt, RUSERSPROC_NAMES, (xdrproc_t)xdr_void, NULL,
	    (xdrproc_t)xdr_utmpidlearr, &up, tv) != RPC_SUCCESS)
		errx(1, "%s", clnt_sperror(rusers_clnt, ""));
	memcpy(&addr.sin_addr.s_addr, hp->h_addr, sizeof(addr.sin_addr.s_addr));
	rusers_reply((caddr_t)&up, &addr);
	clnt_destroy(rusers_clnt);
}
예제 #11
0
파일: simulate.c 프로젝트: ANFS/ANFS-utils
static void
simulate_unmon (char *calling, char *unmonitoring, char *as, char *proggy)
{
  CLIENT *client;
  sm_stat *result;
  mon_id mon_id;

  xlog (D_GENERAL, "Calling %s (as %s) to unmonitor %s", calling, as,
	   unmonitoring);

  if ((client = clnt_create (calling, SM_PROG, SM_VERS, "udp")) == NULL)
    xlog_err ("%s", clnt_spcreateerror ("clnt_create"));

  mon_id.my_id.my_name = xstrdup (as);
  mon_id.my_id.my_prog = atoi (proggy) * SIM_SM_PROG;
  mon_id.my_id.my_vers = SIM_SM_VERS;
  mon_id.my_id.my_proc = SIM_SM_MON;
  mon_id.mon_name = unmonitoring;

  if (!(result = sm_unmon_1 (&mon_id, client)))
    xlog_err ("%s", clnt_sperror (client, "sm_unmon_1"));

  free (mon_id.my_id.my_name);
  xlog (D_GENERAL, "SM_UNMON request returned state: %d\n", result->state);
  exit (0);
}
예제 #12
0
파일: client.c 프로젝트: arjunsr/myfinger
int
main(int argc, char *argv[])
{
  
  CLIENT *client_handle;
  myfinger_in input;
  myfinger_out *output;

  if (argc !=3) {
    printf("%s <username> <host>\n",argv[0]);
    exit(1);
  }
  client_handle=clnt_create(argv[2], MYFINGER_PROGRAM,MYFINGER_VERSION, "tcp");

  if ( strlen(argv[1]) < 4096 )
    strncpy(input.user_name,argv[1],strlen(argv[1]));

  if ( (output=myfinger_1(&input,client_handle))== NULL ) {
    printf("%s",clnt_sperror(client_handle,argv[1]));
    exit(1);
  }
  printf("[CLIENT]: Result-> %s",output->output);
  return 0;

}
예제 #13
0
/*
 * Function: auth_gssapi_destroy
 *
 * Purpose: Destroy a GSS-API authentication structure.
 *
 * Effects:  This function destroys the GSS-API authentication
 * context, and sends a message to the server instructing it to
 * invokte gss_process_token() and thereby destroy its corresponding
 * context.  Since the client doesn't really care whether the server
 * gets this message, no failures are reported.
 */
static void auth_gssapi_destroy(AUTH *auth)
{
     struct timeval timeout;
     OM_uint32 gssstat, minor_stat;
     gss_cred_id_t cred;
     int callstat;
     
     if (AUTH_PRIVATE(auth)->client_handle.length == 0) {
	  PRINTF(("gssapi_destroy: no client_handle, not calling destroy\n"));
	  goto skip_call;
     }
     
     PRINTF(("gssapi_destroy: marshalling new creds\n"));
     if (!marshall_new_creds(auth, TRUE, &AUTH_PRIVATE(auth)->client_handle)) {
	  PRINTF(("gssapi_destroy: marshall_new_creds failed\n"));
	  goto skip_call;
     }
     
     PRINTF(("gssapi_destroy: calling GSSAPI_DESTROY\n"));
     timeout.tv_sec = 1;
     timeout.tv_usec = 0;
     callstat = clnt_call(AUTH_PRIVATE(auth)->clnt, AUTH_GSSAPI_DESTROY,
			  xdr_void, NULL, xdr_void, NULL, timeout);
     if (callstat != RPC_SUCCESS)
	  clnt_sperror(AUTH_PRIVATE(auth)->clnt,
		       "gssapi_destroy: GSSAPI_DESTROY failed");
     
skip_call:
     PRINTF(("gssapi_destroy: deleting context\n"));
     gssstat = gss_delete_sec_context(&minor_stat,
				      &AUTH_PRIVATE(auth)->context,
				      NULL);
     if (gssstat != GSS_S_COMPLETE)
	  AUTH_GSSAPI_DISPLAY_STATUS(("deleting context", gssstat,
				      minor_stat));
     if (AUTH_PRIVATE(auth)->def_cred) {
	  cred = GSS_C_NO_CREDENTIAL;
	  gssstat = gss_release_cred(&minor_stat, &cred);
	  if (gssstat != GSS_S_COMPLETE)
	       AUTH_GSSAPI_DISPLAY_STATUS(("deleting default credential",
					   gssstat, minor_stat));
     }
     
     if (AUTH_PRIVATE(auth)->client_handle.length != 0)
	  gss_release_buffer(&minor_stat,
			     &AUTH_PRIVATE(auth)->client_handle);
     
#if 0
     PRINTF(("gssapi_destroy: calling GSSAPI_EXIT\n"));
     AUTH_PRIVATE(auth)->established = FALSE;
     callstat = clnt_call(AUTH_PRIVATE(auth)->clnt, AUTH_GSSAPI_EXIT,
			  xdr_void, NULL, xdr_void, NULL, timeout);
#endif
     
     free(auth->ah_private);
     free(auth);
     PRINTF(("gssapi_destroy: done\n"));
}
예제 #14
0
/*
	getTimeFromServer ()
	@description:	Redireciona o processamento para o servidor.
					O servidor retorna uma struct com todas as
					informações de data e hora.

	@return (struct tm*) struct tm obtida da "time.h"
	===========================================
*/
struct tm * getTimeFromServer () {
	// Criando conexão TCP com o servidor
	// ===========================================
	CLIENT *cl; /* definido em rpc.h */
	chronos_in in;
	chronos_out *outp;
	cl = clnt_create(SERVER_IP, chronos_PROG, chronos_VERS, "udp");


	// Get current timestamp
	// ===========================================
	time_t rawtime;
	struct tm * timeinfo;
	time ( &rawtime );
	timeinfo = localtime ( &rawtime );
	//printf ( "Current local time and date: %s\n", asctime (timeinfo) );


	// Gerando struct de envio
	// ===========================================
	in.tm_sec	= timeinfo->tm_sec;
	in.tm_min	= timeinfo->tm_min;
	in.tm_hour	= timeinfo->tm_hour;
	in.tm_mday	= timeinfo->tm_mday;
	in.tm_mon	= timeinfo->tm_mon;
	in.tm_year	= timeinfo->tm_year;
	in.tm_wday	= timeinfo->tm_wday;
	in.tm_yday	= timeinfo->tm_yday;
	in.tm_isdst	= timeinfo->tm_isdst;
	

	// Chamada do RPC a partir do seu identificador
	// ===========================================
	if ((outp = chronosproc_1(&in, cl)) == NULL) {
		perror(clnt_sperror(cl, SERVER_IP)); exit(1); 
	}




	// Gerando struct tm a ser retornada
	// ===========================================
	struct tm * server_time;
	server_time = (struct tm*) malloc(sizeof(struct tm));

	server_time->tm_sec		= outp->tm_sec;
	server_time->tm_min		= outp->tm_min;
	server_time->tm_hour	= outp->tm_hour;
	server_time->tm_mday	= outp->tm_mday;
	server_time->tm_mon		= outp->tm_mon;
	server_time->tm_year	= outp->tm_year;
	server_time->tm_wday	= outp->tm_wday;
	server_time->tm_yday	= outp->tm_yday;
	server_time->tm_isdst	= outp->tm_isdst;

	return server_time;
}
예제 #15
0
void
clnt_perror(CLIENT *rpch, const char *s)
{

	assert(rpch != NULL);
	assert(s != NULL);

	(void) fprintf(stderr, "%s\n", clnt_sperror(rpch,s));
}
예제 #16
0
void
clnt_perror(CLIENT *rpch, const char *s)
{

	if (rpch == NULL || s == NULL)
		return;

	(void)fprintf(stderr, "%s\n", clnt_sperror(rpch, s));
}
예제 #17
0
void
clnt_perror(
	CLIENT *rpch,
	char *s)
{
        char* const     msg = clnt_sperror(rpch,s);

	(void) fprintf(stderr, "%s", msg);
        free(msg);
}
예제 #18
0
int main(int argc, char **argv)
{
        struct timeval          stvTimeout;
	char *tp = "udp";
	char *host;
	char opt;
	
	host = getenv("BAYONNE_HOST");
	if(!host)
		host = "localhost";

        stvTimeout.tv_sec =  23;
        stvTimeout.tv_usec = 0;

	while((opt = getopt(argc, argv, "t:h:p:")) != -1)
		switch(opt)
		{
		case 't':
			stvTimeout.tv_sec = atoi(optarg);
			break;
		case 'h':
			host = optarg;
			break;
		case 'p':
			tp = optarg;
			break;
		default:
			goto use;
		}

	rpc = clnt_create(host, BAYONNE_PROGRAM, BAYONNE_VERSION, tp);

        if (!rpc)
        {
                printf( "CLNT_CREATE %s\n", clnt_spcreateerror( "" ) );
                exit( 1 );
        }

        if(!clnt_control(rpc, CLSET_TIMEOUT,( char *) &stvTimeout ) )
        {
                printf( "CLNT_CONTROL: %s\n",clnt_sperror(rpc, "" ) );
                clnt_destroy(rpc);
                exit( 1 );
        }

	if(optind >= argc)
		uptime();

use:
	fprintf(stderr, "use: bts_uptime [-h host] [-p proto] [-t timeout]\n");

	exit(-1);

}
예제 #19
0
파일: simulate.c 프로젝트: ANFS/ANFS-utils
static void
simulate_crash (char *host)
{
  CLIENT *client;

  if ((client = clnt_create (host, SM_PROG, SM_VERS, "udp")) == NULL)
    xlog_err ("%s", clnt_spcreateerror ("clnt_create"));

  if (!sm_simu_crash_1 (NULL, client))
    xlog_err ("%s", clnt_sperror (client, "sm_simu_crash_1"));

  exit (0);
}
예제 #20
0
파일: 1-basic.c 프로젝트: ystk/debian-ltp
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] = "udp";
	CLIENT *clnt = NULL;
	enum clnt_stat rslt;
    int recVar = -1; 
    struct timeval total_timeout;
    char *chrRslt = 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;/**/
	
	//First of all, create client using top level API
	clnt = clnt_create(argc[1], progNum, VERSNUM, nettype);	
	
	//Then call remote procedure
	rslt = clnt_call((CLIENT *)clnt, PROCNUM, 
						    (xdrproc_t)xdr_void, (char *)NULL, // xdr_in
                    		(xdrproc_t)xdr_int, (char *)&recVar, // xdr_out
						    total_timeout);	/**/
						    
	chrRslt = clnt_sperror(clnt, "#SUCCESS");
	
	//If we are here, test has passed
	test_status = (chrRslt == (char *)NULL);
	
	//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;
}
예제 #21
0
int main(int argc, char* argv[])
{
	CLIENT *c1;
	finger_out *outp;
	if(argc!=2)
		err_quit("usage: client <hostname>");
	
	c1 = clnt_create(argv[1], FINGER, FINGER_VERSION, "tcp");
	
	if( (outp=myfinger_1(NULL, c1))==NULL )
		err_quit(clnt_sperror(c1, argv[1]));

	printf("result: %s\n", outp->message);
	exit(0);
}
예제 #22
0
파일: storage.c 프로젝트: MengWenkui/dnfs
/* 
 * copy data using rpc
 */
int rpccall_co_write(co_write_in *arg, co_write_out *res, char *ipp)
{
	CLIENT *clnt;
	clnt = clnt_create(ipp, CO_PROG, CO_VERS, "tcp");
	if(!clnt) {
		PDEBUG("%s: create client handle failed\n", ipp);
		return -EREMOTE;
	}
	if(co_write_1(arg, res, clnt) != RPC_SUCCESS) {
		PDEBUG(clnt_sperror(clnt, "call co_write_1 failed"));
		return -EREMOTE;
	}
	clnt_destroy(clnt);
	return 0;
}
예제 #23
0
char *CCPppcontroller::GetLastRPCError( int *aIntErr )
{
	struct rpc_err rpcerr;

	// check that the handle is valid
	if( cl == NULL ) {
		return NULL;
	}

	// pass the aIntErr
	if( aIntErr != NULL ) {
		clnt_geterr( cl, &rpcerr );
		*aIntErr = rpcerr.re_status;
	}

	// return the errorstring
	return clnt_sperror( cl, NULL );
}
예제 #24
0
파일: client.c 프로젝트: piaoyimq/CppSpace
int
main(int argc, char **argv)
{
	CLIENT		*cl;
	square_in	in;
	square_out	*outp;

	if (argc != 4)
		err_quit("usage: client <hostname> <integer-value> <protocol>");

	cl = Clnt_create(argv[1], SQUARE_PROG, SQUARE_VERS, argv[3]);

	in.arg1 = atol(argv[2]);
	if ( (outp = squareproc_1(&in, cl)) == NULL)
		err_quit("%s", clnt_sperror(cl, argv[1]));

	printf("result: %ld\n", outp->res1);
	exit(0);
}
예제 #25
0
int
main(int argc, char **argv)
{
	CLIENT		*cl;
	square_in	in;
	square_out	out;

	if (argc != 3)
		err_quit("usage: client <hostname> <integer-value>");

	cl = Clnt_create(argv[1], SQUARE_PROG, SQUARE_VERS, "tcp");

	in.arg1 = atol(argv[2]);
	if (squareproc_2(&in, &out, cl) != RPC_SUCCESS)
		err_quit("%s", clnt_sperror(cl, argv[1]));

	printf("result: %ld\n", out.res1);
	exit(0);
}
예제 #26
0
int
ypxfrd_get_map(char *host, char *map, char *domain, char *tmpname)
{
	CLIENT *clnt;
	struct ypxfr_mapname req;
	struct xfr resp;
	struct timeval timeout = { 0, 25 };
	int status = 0;

	req.xfrmap = map;
	req.xfrdomain = domain;
	req.xfrmap_filename = "";
	req.xfr_db_type = XFR_DB_BSD_HASH;	/*
	req.xfr_byte_order = XFR_ENDIAN_ANY;	 * Berkeley DB isn't
						 * byte-order sensitive.
						 */

	bzero((char *)&resp, sizeof(resp));

	if ((clnt = clnt_create(host, YPXFRD_FREEBSD_PROG,
				YPXFRD_FREEBSD_VERS, "tcp")) == NULL) {
		return(1);
	}

	if ((fp = open(tmpname, O_RDWR|O_CREAT, PERM_SECURE)) == -1) {
		clnt_destroy(clnt);
		yp_error("couldn't open %s: %s", tmpname, strerror(errno));
		return(1);
	}

	if (clnt_call(clnt,YPXFRD_GETMAP,
			(xdrproc_t)xdr_ypxfr_mapname, (char *)&req,
			(xdrproc_t)xdr_my_xfr, (char *)&resp,
			timeout) != RPC_SUCCESS) {
		yp_error("%s", clnt_sperror(clnt,"call to rpc.ypxfrd failed"));
		status++;
		unlink(tmpname);
	}

	clnt_destroy(clnt);
	close(fp);
	return(status);
}
예제 #27
0
파일: nsm.c 프로젝트: JasonZen/nfs-ganesha
void nsm_unmonitor_all(void)
{
	enum clnt_stat ret;
	struct sm_stat res;
	struct my_id nsm_id;
	struct timeval tout = { 25, 0 };

	nsm_id.my_prog = NLMPROG;
	nsm_id.my_vers = NLM4_VERS;
	nsm_id.my_proc = NLMPROC4_SM_NOTIFY;

	pthread_mutex_lock(&nsm_mutex);

	/* create a connection to nsm on the localhost */
	if (!nsm_connect()) {
		LogCrit(COMPONENT_NLM,
			"Can not unmonitor all clnt_create returned NULL");
		pthread_mutex_unlock(&nsm_mutex);
		return;
	}

	/* Set this after we call nsm_connect() */
	nsm_id.my_name = nodename;

	ret = clnt_call(nsm_clnt,
			nsm_auth,
			SM_UNMON_ALL,
			(xdrproc_t) xdr_my_id,
			&nsm_id,
			(xdrproc_t) xdr_sm_stat,
			&res,
			tout);

	if (ret != RPC_SUCCESS) {
		LogCrit(COMPONENT_NLM,
			"Can not unmonitor all ret %d %s",
			ret,
			clnt_sperror(nsm_clnt, ""));
	}

	nsm_disconnect();
	pthread_mutex_unlock(&nsm_mutex);
}
예제 #28
0
파일: client.c 프로젝트: Habush/vu
int main(int argc, char **argv) {
    CLIENT *cl;
    param in, *tmp;
    add_out *out;

    if (argc<4) { 
        printf("Usage: %s <machine> <int1> <int2> <int3> ...\n\n", argv[0]);
        return 1;
    }
    cl = clnt_create(argv[1], ADD_PROG, ADD_VERS, "udp");

    tmp = &in;
    in.arg = strdup(argv[2]);
    
    printf("Arg: ***%s***\n",in.arg);

    argc -= 3;
    argv += 3;

    while (argc>0) {
        tmp->next = (struct param*) malloc(sizeof(struct param));
        tmp = tmp->next;
        tmp->arg = strdup(argv[0]);

        printf("Arg: ***%s***\n",tmp->arg);

        argc--;
        argv++;
    }
    tmp->next = NULL;

    out = add_1(&in, cl);
    
    if (out==NULL) {
        printf("Error: %s\n",clnt_sperror(cl,argv[1]));
    }
    else {
        printf("We received the result: %d\n",*out);
    }
    return 0;
}
예제 #29
0
static void
ypxfr_exit(ypxfrstat retval, char *temp)
{
	CLIENT *clnt;
	int sock = RPC_ANYSOCK;
	struct timeval timeout;

	/* Clean up no matter what happened previously. */
	if (temp != NULL) {
		if (dbp != NULL)
			(void)(dbp->close)(dbp);
		if (unlink(temp) == -1) {
			yp_error("failed to unlink %s",strerror(errno));
		}
	}

	if (ypxfr_prognum) {
		timeout.tv_sec = 20;
		timeout.tv_usec = 0;

		if ((clnt = clntudp_create(&ypxfr_callback_addr, ypxfr_prognum,
					1, timeout, &sock)) == NULL) {
			yp_error("%s", clnt_spcreateerror("failed to "
			    "establish callback handle"));
			exit(1);
		}

		ypxfr_resp.status = (yppush_status)retval;

		if (yppushproc_xfrresp_1(&ypxfr_resp, clnt) == NULL) {
			yp_error("%s", clnt_sperror(clnt, "callback failed"));
			clnt_destroy(clnt);
			exit(1);
		}
		clnt_destroy(clnt);
	} else {
		yp_error("Exiting: %s", ypxfrerr_string(retval));
	}

	exit(0);
}
예제 #30
0
/* ARGSUSED */
int
main(int argc, char *argv[])
{
	char *wallhost, res;
	CLIENT *cl;
	struct timeval tv;

	if ((argc < 2) || (argc > 3))
		usage();

	wallhost = argv[1];

	makemsg(argv[2]);

	/*
	 * Create client "handle" used for calling MESSAGEPROG on the
	 * server designated on the command line. We tell the rpc package
	 * to use the "tcp" protocol when contacting the server.
	*/
	cl = clnt_create(wallhost, WALLPROG, WALLVERS, "udp");
	if (cl == NULL) {
		/*
		 * Couldn't establish connection with server.
		 * Print error message and die.
		 */
		errx(1, "%s", clnt_spcreateerror(wallhost));
	}

	tv.tv_sec = 15;		/* XXX ?? */
	tv.tv_usec = 0;
	if (clnt_call(cl, WALLPROC_WALL, (xdrproc_t)xdr_wrapstring, &mbuf,
	    (xdrproc_t)xdr_void, &res, tv) != RPC_SUCCESS) {
		/*
		 * An error occurred while calling the server.
		 * Print error message and die.
		 */
		errx(1, "%s", clnt_sperror(cl, wallhost));
	}

	return (0);
}