void dce_rpc_server_main () { unsigned32 status; int ret; strcpy(pszProtocolSequence,"ncacn_ip_tcp"); pszEndpoint = NULL; cMaxCalls = 1; pbvBindings = NULL; pthread_mutex_init(&mutex,pthread_mutexattr_default); /* No RPCs now! */ pthread_mutex_lock(&mutex); /* Initialize DCE RPC */ rpc_server_use_protseq(pszProtocolSequence,cMaxCalls,&status); CHECK_DCE_ERROR(status,ABORT); rpc_server_inq_bindings(&pbvBindings,&status); CHECK_DCE_ERROR(status,ABORT); rpc_ep_register(xgobi_goes_dce_v1_0_s_ifspec,pbvBindings,0,0,&status); CHECK_DCE_ERROR(status,ABORT); rpc_server_register_if(xgobi_goes_dce_v1_0_s_ifspec,0,0,&status); CHECK_DCE_ERROR(status,ABORT); /* p-Thread to rpc_server_listen */ ret = pthread_create(&t_handle,pthread_attr_default, (void *(*)(void *)) dce_rpc_server_listen,NULL); }
DWORD VmDnsRpcServerUseProtSeq( PCSTR pszProtSeq ) { DWORD dwError = 0; DCETHREAD_TRY { rpc_server_use_protseq( (unsigned char*) pszProtSeq, rpc_c_protseq_max_calls_default, (unsigned32*)&dwError); } DCETHREAD_CATCH_ALL(THIS_CATCH) { if ( dwError == rpc_s_ok ) { dwError = dcethread_exc_getstatus(THIS_CATCH); if (!dwError) { dwError = RPC_S_INTERNAL_ERROR; } } } DCETHREAD_ENDTRY; BAIL_ON_VMDNS_ERROR(dwError); error: return dwError; }
static DWORD bind_server( rpc_binding_vector_p_t * server_binding, rpc_if_handle_t interface_spec, PENDPOINT pEndPoints ) { DWORD dwError = 0; DWORD dwRpcStatus = 0; DWORD i; /* * Prepare the server binding handle * use all avail protocols (UDP and TCP). This basically allocates * new sockets for us and associates the interface UUID and * object UUID of with those communications endpoints. */ for (i = 0; pEndPoints[i].protocol != NULL; i++) { if (!pEndPoints[i].endpoint) { rpc_server_use_protseq((unsigned char*) pEndPoints[i].protocol, rpc_c_protseq_max_calls_default, (unsigned32*)&dwRpcStatus); BAIL_ON_DCE_ERROR(dwError, dwRpcStatus); } else { if (!strcmp(pEndPoints[i].protocol, "ncalrpc") && pEndPoints[i].endpoint[0] == '/') { dwError = prepare_domain_socket(pEndPoints[i].endpoint); BAIL_ON_SRVSVC_ERROR(dwError); } rpc_server_use_protseq_ep((unsigned char*) pEndPoints[i].protocol, rpc_c_protseq_max_calls_default, (unsigned char*) pEndPoints[i].endpoint, (unsigned32*)&dwRpcStatus); BAIL_ON_DCE_ERROR(dwError, dwRpcStatus); } } rpc_server_inq_bindings(server_binding, (unsigned32*)&dwRpcStatus); BAIL_ON_DCE_ERROR(dwError, dwRpcStatus); error: return dwError; }
static void bind_server( rpc_binding_vector_p_t * server_binding, rpc_if_handle_t interface_spec ATTRIBUTE_UNUSED, const char * protocol, const char * endpoint) { const char * function = "n/a"; unsigned32 status; /* * Prepare the server binding handle * use all avail protocols (UDP and TCP). This basically allocates * new sockets for us and associates the interface UUID and * object UUID of with those communications endpoints. */ #if 0 rpc_server_use_all_protseqs_if(0, interface_spec, &status); #else if (!endpoint) { if (!protocol) { function = "rpc_server_use_all_protseqs()"; rpc_server_use_all_protseqs(rpc_c_protseq_max_calls_default, &status); } else { function = "rpc_server_use_protseq()"; rpc_server_use_protseq((unsigned_char_p_t)protocol, rpc_c_protseq_max_calls_default, &status); } } else { function = "rpc_server_use_protseq_ep()"; rpc_server_use_protseq_ep((unsigned_char_p_t)protocol, rpc_c_protseq_max_calls_default, (unsigned_char_p_t)endpoint, &status); } #endif chk_dce_err(status, function, "", 1); rpc_server_inq_bindings(server_binding, &status); chk_dce_err(status, "rpc_server_inq_bindings()", "", 1); }
int main ( int argc, char *argv[] ) { rpc_binding_vector_t *bv_p; unsigned32 status; /* Register interface/epv associations with RPC runtime. */ printf("Registering server interface with RPC runtime...\n"); rpc_server_register_if ( mathb_v1_0_s_ifspec, NULL, NULL, &status ); ERRCHK ( status ); /* Inform RPC runtime to use a supported protocol sequences. */ rpc_server_use_protseq ( "ncadg_ip_udp", MAX_CONC_CALLS_PROTSEQ, &status ); ERRCHK ( status ); /* Get the binding handle vector from RPC runtime. */ rpc_server_inq_bindings ( &bv_p, &status ); ERRCHK ( status ); /* Register binding information with endpoint map. */ printf("Registering server endpoints with endpoint mapper (RPCD)...\n"); rpc_ep_register ( mathb_v1_0_s_ifspec, bv_p, NULL, ( unsigned_char_t * )"Basic math server, version 1.0", &status ); ERRCHK ( status ); /* Export binding information to the namespace. */ printf("Exporting server bindings into CDS namespace...\n"); rpc_ns_binding_export ( rpc_c_ns_syntax_dce, ENTRY_NAME, mathb_v1_0_s_ifspec, bv_p, NULL, &status ); ERRCHK ( status ); /* Listen for service requests. */ printf ( "Server %s listening...\n", ENTRY_NAME ); rpc_server_listen ( MAX_CONC_CALLS_TOTAL, &status ); ERRCHK ( status ); }
int main( int argc, char *argv[] ) { unsigned32 st; rpc_binding_vector_t *bvec; #ifndef _WINDOWS sigset_t sigset; pthread_t this_thread = pthread_self(); #endif #ifdef IBMOS2 pthread_inst_exception_handler(); #endif /* Register interface/epv associations with rpc runtime. */ printf("Registering server interface with RPC runtime...\n"); rpc_server_register_if( MyError_v1_0_s_ifspec, NULL, NULL, &st ); ERRORCK( "rpc_server_register_if", st ); rpc_server_use_protseq ( "ncadg_ip_udp", MAX_CALL_REQUESTS, &st ); ERRORCK( "rpc_server_use_protseq", st ); rpc_server_inq_bindings( &bvec, &st ); ERRORCK( "rpc_server_inq_binding", st ); /* Register binding information with endpoint map */ printf("Registering server endpoints with endpoint mapper (RPCD)...\n"); rpc_ep_register( MyError_v1_0_s_ifspec, bvec, NULL, (unsigned_char_t *)"MyError3, version 1.0", &st ); ERRORCK( "rpc_ep_register", st ); /* Export binding info to the namespace. */ printf("Exporting server bindings into CDS namespace...\n"); rpc_ns_binding_export( rpc_c_ns_syntax_dce, ENTRY_NAME, MyError_v1_0_s_ifspec, bvec, NULL, &st ); ERRORCK( "rpc_ns_binding_export", st ); #ifndef _WINDOWS sigemptyset ( &sigset ); sigaddset ( &sigset, SIGINT ); sigaddset ( &sigset, SIGTERM); pthread_signal_to_cancel_np ( &sigset, &this_thread ); #endif TRY /* Listen for service requests. */ printf( "Server %s listening...\n", ENTRY_NAME ); rpc_server_listen( MAX_CALL_REQUESTS, &st ); FINALLY printf("Unexporting server bindings from CDS namespace...\n"); rpc_ns_binding_unexport( rpc_c_ns_syntax_dce, ENTRY_NAME, MyError_v1_0_s_ifspec, NULL, &st ); ERRORCK( "rpc_ns_binding_unexport", st ); printf("Unregistering server interface with RPC runtime...\n"); rpc_server_unregister_if( MyError_v1_0_s_ifspec, NULL, &st ); ERRORCK( "rpc_server_unregister_if", st ); printf("Unregistering server endpoints with endpoint mapper (RPCD)...\n"); rpc_ep_unregister( MyError_v1_0_s_ifspec, bvec, NULL, &st ); ERRORCK( "rpc_ep_unregister", st ); #ifdef IBMOS2 pthread_dinst_exception_handler(); #endif exit( 0 ); ENDTRY; }
int main ( int argc, char *argv[] ) { unsigned_char_t *server_name; rpc_binding_vector_t *bind_vector_p; unsigned32 status; # ifndef _WINDOWS sigset_t sigset; pthread_t this_thread = pthread_self(); # endif # ifdef IBMOS2 pthread_inst_exception_handler(); # endif /* Register the authentification level which will be used */ printf("Registering authentication level with RPC runtime...\n"); rpc_server_register_auth_info( PRINCIPAL_NAME, rpc_c_authn_default, NULL, NULL, &status ); ERRCHK( status ); /* Register interface/epv associations with rpc runtime. */ printf("Registering server interface with RPC runtime...\n"); rpc_server_register_if ( IF_HANDLE, NULL, NULL, &status ); ERRCHK( status ); /* Inform rpc runtime of a protocol sequence to use. */ switch ( (( argc > 1 ) ? *argv[1] | ' ' : 'a') ) { case 't': rpc_server_use_protseq ("ncacn_ip_tcp", MAX_CONC_CALLS_PROTSEQ, &status ); break; case 'u': rpc_server_use_protseq ("ncadg_ip_udp", MAX_CONC_CALLS_PROTSEQ, &status ); break; case 'a': default: rpc_server_use_all_protseqs ( MAX_CONC_CALLS_PROTSEQ, &status ); } ERRCHK( status ); /* Ask the runtime which binding handle will be used. */ rpc_server_inq_bindings( &bind_vector_p, &status ); ERRCHK( status ); /* Register binding information with endpoint map */ printf("Registering server endpoints with endpoint mapper (RPCD)...\n"); rpc_ep_register( IF_HANDLE, bind_vector_p, NULL, "Message Box server, version 2.0", &status ); ERRCHK( status ); /* Export binding info to the namespace. */ printf("Exporting server bindings into CDS namespace...\n"); rpc_ns_binding_export ( rpc_c_ns_syntax_default, ENTRY_NAME, IF_HANDLE, bind_vector_p, NULL, &status ); ERRCHK( status ); # ifndef _WINDOWS /* baggage to handle ctrl-C */ sigemptyset(&sigset); sigaddset(&sigset, SIGINT); sigaddset(&sigset, SIGTERM); if (pthread_signal_to_cancel_np(&sigset, &this_thread) != 0) { printf("pthread_signal_to_cancel_np failed\n"); exit(1); } # endif /* Import the mbox structure from file FNAME */ mbox_import(FNAME); TRY { /* Listen for service requests. */ printf( "Server %s listening...\n", ENTRY_NAME ); rpc_server_listen ( MAX_CONC_CALLS_TOTAL, &status ); ERRCHK( status ); } FINALLY { /* Export the mbox structure to file FNAME */ mbox_export(FNAME); /* Unexport the binding information from the namespace. */ printf("Unexporting server bindings from CDS namespace...\n"); rpc_ns_binding_unexport ( rpc_c_ns_syntax_default, ENTRY_NAME, IF_HANDLE, NULL, &status ); ERRCHK( status ); /* Unregister interface from RPC runtime */ printf("Unregistering server interface with RPC runtime...\n"); rpc_server_unregister_if ( IF_HANDLE, NULL, &status ); ERRCHK( status ); /* Unregister interface from EPV */ printf("Unregistering server endpoints with endpoint mapper (RPCD)...\n"); rpc_ep_unregister ( IF_HANDLE, bind_vector_p, NULL, &status ); ERRCHK( status ); # ifdef IBMOS2 pthread_dinst_exception_handler(); # endif exit ( 0 ); } ENDTRY; }
int main( int argc, char *argv[] ) { unsigned32 st; rpc_binding_vector_t *bvec; #ifndef _WINDOWS sigset_t sigset; pthread_t this_thread = pthread_self(); #endif #ifdef IBMOS2 pthread_inst_exception_handler(); #endif printf("Registering server interface with RPC runtime...\n"); rpc_server_register_if( Database_v1_0_s_ifspec, NULL, NULL, &st ); ERRORCK( "rpc_server_register_if", st ); switch ( (( argc > 1 ) ? *argv[1] | ' ' : 'a') ) { case 't': rpc_server_use_protseq ("ncacn_ip_tcp", MAX_CONC_CALLS_PROTSEQ, &st ); break; case 'u': rpc_server_use_protseq ("ncadg_ip_udp", MAX_CONC_CALLS_PROTSEQ, &st ); break; case 'a': default: rpc_server_use_all_protseqs ( MAX_CONC_CALLS_PROTSEQ, &st ); } ERRORCK( "rpc_server_use_all_protseqs", st ); rpc_server_inq_bindings( &bvec, &st ); ERRORCK( "rpc_server_inq_binding", st ); printf("Registering server endpoints with endpoint mapper (RPCD)...\n"); rpc_ep_register( Database_v1_0_s_ifspec, bvec, NULL, ( unsigned_char_t * )"Database server, version 1.0" , &st ); ERRORCK( "rpc_ep_register", st ); rpc_ns_binding_export( rpc_c_ns_syntax_dce, ENTRY_NAME, Database_v1_0_s_ifspec, bvec, NULL, &st ); ERRORCK( "rpc_ns_binding_export", st ); #ifndef _WINDOWS sigemptyset ( &sigset ); sigaddset ( &sigset, SIGINT ); sigaddset ( &sigset, SIGTERM ); pthread_signal_to_cancel_np ( &sigset, &this_thread ); #endif TRY { printf ( "Server %s listening...\n", ENTRY_NAME ); rpc_server_listen( MAX_CALL_REQUESTS, &st ); } FINALLY { printf("Unexporting server bindings from CDS namespace...\n"); rpc_ns_binding_unexport( rpc_c_ns_syntax_dce, ENTRY_NAME, Database_v1_0_s_ifspec, NULL, &st ); ERRORCK( "rpc_ns_binding_unexport", st ); printf("Unregistering server interface with RPC runtime...\n"); rpc_server_unregister_if( Database_v1_0_s_ifspec, NULL, &st ); ERRORCK( "rpc_server_unregister_if", st ); printf("Unregistering server endpoints with endpoint mapper (RPCD)...\n"); rpc_ep_unregister( Database_v1_0_s_ifspec, bvec, NULL, &st ); ERRORCK( "rpc_ep_unregister", st ); #ifdef IBMOS2 pthread_dinst_exception_handler(); #endif exit( 0 ); } ENDTRY }