void l2tp_api_cleanup(void) { if (l2tp_rpc_xprt != NULL) { svc_unregister(L2TP_PROG, L2TP_VERSION); } if (l2tp_event_rpc_xprt != NULL) { svc_unregister(L2TP_EVENT_PROG, L2TP_EVENT_VERSION); } }
int main(void) { #if defined (_WIN32) WSADATA WSAData; #endif int servernumber; #if defined (_WIN32) if (WSAStartup(MAKEWORD(2,2), &WSAData)) { WSACleanup(); return -1; } #endif for(servernumber=0; servernumber<TSP_MAX_SERVER_NUMBER; servernumber++) { svc_unregister (TSP_get_progid(servernumber), TSP_RPC_VERSION_INITIAL); pmap_unset (TSP_get_progid(servernumber), TSP_RPC_VERSION_INITIAL); } #if defined (_WIN32) WSACleanup(); #endif return 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); } }
void attribute_hidden __rpc_thread_svc_cleanup (void) { struct svc_callout *svcp; while ((svcp = svc_head) != NULL) svc_unregister (svcp->sc_prog, svcp->sc_vers); }
static void up7_destroy( Up7* const up7) { svc_unregister(LDMPROG, SEVEN); if (up7->xprt) svc_destroy(up7->xprt); up7->xprt = NULL; }
void loc_apicb_app_deinit(void) { if (svrPort == NULL) { return; } svc_unregister(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001); xprt_unregister(svrPort); svc_destroy(svrPort); svrPort = NULL; }
int svc_rpcb_setup(struct svc_serv *serv, struct net *net) { int err; err = rpcb_create_local(net); if (err) return err; /* Remove any stale portmap registrations */ svc_unregister(serv, net); return 0; }
/************************************************************************ * * * Unregister all receiver message ports. * * */ void ipgwin_unregister_msg(void) { Svcmsg *temp; while (svchead) { svc_unregister(svchead->prognum, svchead->versnum); svc_destroy(svchead->xprt); temp = svchead->next; (void)free((char *)svchead); svchead = temp; } }
static void on_stop() { DEBUG_FUNCTION; svc_exit(); svc_unregister(STORAGE_PROGRAM, STORAGE_VERSION); pmap_unset(STORAGE_PROGRAM, STORAGE_VERSION); if (storaged_svc) { svc_destroy(storaged_svc); storaged_svc = NULL; } storaged_release(); rozofs_release(); info("stopped."); closelog(); }
void nibind_svc_run(void) { fd_set readfds; for (;;) { readfds = svc_fdset; switch (select(svc_maxfd+1, &readfds, NULL, NULL, NULL)) { case -1: if (errno != EINTR) { system_log(LOG_ALERT, "unexpected errno: %m, aborting"); } break; case 0: break; default: svc_getreqset(&readfds); break; } if (waitreg == 0) { waitreg = -1; if (debug == 1) { system_log(LOG_DEBUG, "all servers registered"); } else { system_log(LOG_DEBUG, "all servers registered - signalling parent"); killparent(); } } if (restart == 1) { svc_unregister(NIBIND_PROG, NIBIND_VERS); pmap_unset(NIBIND_PROG, NIBIND_VERS); respawn(); } } }
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; }
//****************************************// //*** 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); }
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); } 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); } svc_unregister(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); } }
//! @brief main function //! @param argc The number of arguments entered on the command line //! @param argv A tabular of the arguments entered on the command line //! @return An error code int main(int argc, char** argv) { char failed; // rpc registered successfull? /* Arming SIG_TERM signal */ signal(2, clean_terminus); /* Registering RPC server */ printf("Registering RPC server...\n"); failed = registerrpc(NUMERO_PROG, NUMERO_VERSION, REGISTER_NB, register_on_server, xdr_request, xdr_response); if(failed) { /* Registering failed */ fprintf(stderr, "Failed to register rpc server\n"); exit(1); } /* Running RPC server */ svc_run(); /* Unregistering RPC server */ svc_unregister(NUMERO_PROG, NUMERO_VERSION); return 0; }
/************************************************************************ * * * This routine is used to register a specific function which will be * * called when there is a message. * * User function to be called can be NULL, indicating unregistering * * message, or user-func address, which takes a form of * * func(u_long proc_id, where proc_id is ID number. * * Ipgmsg *msg) where msg is a message. * * * * Return program number for success and 0 for failure. * * * * In RPC term, SERVER registers/unregisters program and version number * * */ u_long ipgwin_register_msg_receive( u_long prognum, /* program ID */ u_long versnum, /* program version */ void (*userfunc)(u_long, Ipgmsg*)) { Svcmsg *current, *prev; /* ptrs used for message item */ Svcmsg *newitem; /* new created item */ SVCXPRT *transp; /* transport info */ int protocol; /* protocol */ /* Check if the msgid has been registered or not. If the message */ /* has been registered, only change the user function. If the user */ /* function is NULL, delete the message item from the list. If the */ /* message has not been registered, add the new message item at the */ /* first of the list. */ for (current=prev=svchead; current; prev=current, current=current->next) { if ((current->prognum == prognum) && (current->versnum == versnum)) /* Found */ { svc_unregister(current->prognum, current->versnum); svc_destroy(current->xprt); if (current == prev) /* Only one item on the list */ svchead = NULL; else prev->next = current->next; (void)free((char *)current); if (userfunc == NULL) return(prognum) ; else break; } } /* Create an RPC with TCP socket */ if ((transp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL) { STDERR("Can't create RPC"); return(0); } /* Get the "transient" program number if prognum is zero */ if (prognum == 0) { /* The "transient" program number starts at 0x40000000 */ /* Get the unused number. */ prognum = 0x40000000; while (!pmap_set(prognum, versnum, IPPROTO_TCP, transp->xp_port)) prognum++; /* We don't need to register it at svc_register since pmap_set */ /* has done it. */ protocol = 0; } else { /* Erase the pormapper's table */ pmap_unset(prognum, versnum); protocol = IPPROTO_TCP; } /* Register the portmapper. */ /* Note that Sun suggests that the program number ranges from */ /* 0x20000000 to 0x5fffffff. However, our routine doesn't */ /* check for this limit. */ #ifdef SOLARIS if (!svc_register(transp, prognum, versnum, ipgwin_priv_msg_receive, protocol)) #elif LINUX if (!svc_register(transp, prognum, versnum, ipgwin_priv_msg_receive, protocol)) #else if (!svc_register(transp, prognum, versnum, (void (*)(DOTDOTDOT))ipgwin_priv_msg_receive, protocol)) #endif { STDERR("ipgwin_register_msg_receive:Can't register RPC"); svc_destroy(transp); return(0); } /* Create new item */ if ((newitem = (Svcmsg *)malloc(sizeof(Svcmsg))) == NULL) { PERROR("ipgwin_register_message_receive:malloc:Message is not registered"); return(0); } newitem->xprt = transp; newitem->prognum = prognum; newitem->versnum = versnum; newitem->msgfunc = userfunc; /* Add a new item at the front of the list */ newitem->next = svchead; svchead = newitem; return(prognum); }
void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net) { svc_unregister(serv, net); rpcb_put_local(net); }
static void push(int inlen, char *indata) { char host[MAXHOSTNAMELEN]; CLIENT *client; SVCXPRT *transp; int sock = RPC_ANYSOCK, status; u_int prog; bool_t sts = 0; pid_t pid; struct rusage res; snprintf(host, sizeof host, "%*.*s", inlen, inlen, indata); client = clnt_create(host, YPPROG, YPVERS, "tcp"); if (client == NULL) { if (Verbose) fprintf(stderr, "Target Host: %s\n", host); clnt_pcreateerror("yppush: Cannot create client"); return; } transp = svcudp_create(sock); if (transp == NULL) { fprintf(stderr, "yppush: Cannot create callback transport.\n"); return; } if (transp->xp_port >= IPPORT_RESERVED) { SVC_DESTROY(transp); fprintf(stderr, "yppush: Cannot allocate reserved port.\n"); return; } for (prog=0x40000000; prog<0x5fffffff; prog++) { if ((sts = svc_register(transp, prog, 1, yppush_xfrrespprog_1, IPPROTO_UDP))) break; } if (!sts) { fprintf(stderr, "yppush: Cannot register callback.\n"); return; } switch (pid=fork()) { case -1: fprintf(stderr, "yppush: Cannot fork.\n"); exit(1); case 0: my_svc_run(); exit(0); default: close(transp->xp_sock); transp->xp_sock = -1; req_xfr(pid, prog, transp, host, client); wait4(pid, &status, 0, &res); svc_unregister(prog, 1); if (client != NULL) clnt_destroy(client); /* XXX transp leak? */ } }
//! @brief A function that finish cleaning in the case the program is badly interrupted void clean_terminus() { printf("Cleaning...\n"); svc_unregister(NUMERO_PROG, NUMERO_VERSION); exit(1); }
int unregister_autofs_service(char *autofs_conftype) { svc_unregister(AUTOFS_PROG, AUTOFS_VERS); return 0; }
void ippool_api_cleanup(void) { if (ippool_rpc_xprt != NULL) { svc_unregister(IPPOOL_PROG, IPPOOL_VERSION); } }