PreviousNext

Configuring a New DCE Server

Management applications use the dced_server_create( ) routine to add a new server to a host. After a server is configured, it can be remotely controlled by modifying its configuration attributes, starting and stopping it, enabling or disabling the RPC interfaces it supports, and deleting its configuration.

Configuring the server involves describing the server for DCE by allocating and filling in a server_t data structure, as shown in the following example. Note that not all server_t fields are assigned values in this example.

int i;

dced_binding_handle_t dced_bh;

server_t conf, exec;

dced_string_t server_name;

uuid_t srvrconf_id, srvrexec_id;

dced_attr_list_t attr_list;

error_status_t status;

static service_t nil_service;

.

.

.

dced_binding_create("srvrconf@hosts/somehost",

dced_c_binding_syntax_default,

&dced_bh,

&status);

dced_inq_id(dced_bh, server_name, &srvrconf_id, &status);

if(status == error_status_ok) {

puts("Configuration already exists for this server.");

dced_binding_free(dced_bh, &status);

return;

}

/* ___________setup a server_t structure ________________*/

uuid_create(&(conf.id), &status);

conf.name = server_name;

conf.entryname = (dced_string_t)"/.:/greeter";

conf.services.count = 1;


/* ___service_t structures represent each interface supported ___*/

conf.services.list =

(service_t *)malloc(conf.services.count * sizeof(service_t));

for(i=0; i<conf.services.count; i++) {

rpc_if_inq_id(greetif_v1_0_c_ifspec,

&(conf.services.list[i].ifspec),

&status);

conf.services.list[i] = nil_service;

conf.services.list[i].ifname = (dced_string_t)"greet";

conf.services.list[i].annotation = (dced_string_t)"The greet application";

conf.services.list[i].flags = 0;

}


/* ______________server_fixedattr_t structure _______________*/

conf.fixed.startupflags =

server_c_startup_explicit | server_c_startup_on_failure;

conf.fixed.flags = 0;

conf.fixed.program = (dced_string_t)"/server/path/and/program/name";


dced_server_create(dced_bh, &conf, &status);

dced_binding_free(dced_bh, &status);

dced_binding_create( )
To configure a server, the application must first create a dced binding to the srvrconf portion of the server management service on a specified host. The binding handle created is used in all subsequent calls to appropriate dced API routines.

dced_inq_id( )
This routine returns the UUID that dced associates with the name input. Each configured server has an associated UUID used by dced to identify it. In this example, we will not try to create a configuration for a server that already exists.

Set Up a server_t Structure for the Server
The server_t structure contains all the information DCE uses to specify a server.

Set Up service_t Structures for Each Interface
Each service that the server supports is represented by a service_t data structure that contains the interface specification, among other things. In this example the client stub for the interface was compiled with the program so that the interface specification (greetif_v1_0_c_ifspec) could be obtained without building the structure from scratch.

Set Up a server_fixedattr_t Structure
Other fixed attributes required for all servers describe how the server can start, the program name and path name for the server so that dced knows which program to start, and the program's arguments, among other things.

dced_server_create( )
This routine uses the filled-in server_t structure to create a srvrconf entry for dced. The data is stored in memory for quick access whenever the server is started.

dced_binding_free( )
Each call to the dced_binding_create( ) routine requires a corresponding call to dced_binding_free( ) to release the binding resources allocated.