PreviousNext

Initializing the Time-Provider Process

Initializing the RPC-based TP process prepares it to receive remote procedure calls from a DTS daemon requesting the timestamps. The following steps are involved:

1. Include the header file (dtsprovider.h) that is created by compiling /usr/include/dce/dtsprovider.idl, which contains the interface definition.

2. Register the interface with the DCE RPC runtime.

3. Select one or more protocol sequences that are compatible with both the interface and the runtime library. It is recommended that the TP process application selects all protocol sequences available on the system. Available protocol sequences are obtained by calling an RPC API routine, described in the example that follows. This ensures that transport independence is maintained in RPC applications.

4. Register the TP process with the endpoint mapper service of the DCE daemon (dced) running on the system. This makes the TP process available to the DTS daemon.

5. Obtain the name of the machine's principal and then register an authentication service to use with authenticated remote procedure calls coming from the DTS daemon. Note that DTS and the TP program are presumed to be running in an authenticated environment.

6. Listen for remote procedure calls.

The following shows these steps, including the sequence of calls needed:

/* Register the TP server interface with the RPC runtime.

* The interface specification time_provider_v1_0_ifspec

* is obtained from the generated header file dtsprovider.h

* The entry point vector is normally defined at the top of

* the TP source program similar to this:

*

* globaldef time_provider_v1_0_epv_t time_provider_epv =

* {

* ContactProvider,

* ServerRequestProviderTime

* };

*/

rpc_server_register_if (time_provider_v1_0_s_ifspec,

NULL,

(rpc_mgr_epv_t) &time_provider_epv,

&RPCstatus);

/*

* This call tells the DCE RPC runtime to listen for remote

* procedure calls using all supported protocol sequences.

* To listen for a specific protocol sequence, use the

* rpc_server_use_protreq call.

*/

rpc_server_use_all_protseqs (max_calls,

&RPCstatus);

/* This routine is called to obtain a vector of binding

* handles that were established with registration of

* protocol sequences.

*/

rpc_server_inq_bindings (&bind_vector,

&RPCstatus);

/* This routine adds the address information of the binding

* handle for the TP server to the endpoint mapper database.

*/

rpc_ep_register (time_provider_v1_0_s_ifspec,

bind_vector,

NULL,

"Time-Provider",

&RPCstatus);

/* Obtain the name of the machine's principal and register an

* authentication service to use for authenticated remote

* procedure calls coming from the time service daemon.

*/

dce_cf_prin_name_from_host (NULL,

&machinePrincipalName,

&status);

rpc_server_register_auth_info (machinePrincipalName,

rpc_c_authn_dce_private,

NULL,

NULL,

&RPCstatus);

/* This routine is called to listen for remote procedure calls

* sent by the DTS client. Possible RPC calls coming from DTS

* client are ContactProvider and ServerRequestProviderTime.

*/

rpc_server_listen (max_calls,

&RPCstatus);