# Initializing NMS OAM client applications

To access NMS OAM service functions, a client application must:

1. Initialize Natural Access.

2. Create event queues.

3. Create contexts.

4. Open NMS OAM service instances on the context, or attach to an existing shared context if one exists.

5. Register for NMS OAM alert notification messages (if the application needs to receive NMS OAM events).

## Initializing Natural Access

Use ctaInitialize to initialize Natural Access applications. When you initialize Natural Access applications you register the services that are available to the application.

Applications must invoke ctaInitialize before calling any other Natural Access functions. For general information about ctaInitialize, refer to the Natural Access Developer's Reference Manual.

### Registering the NMS OAM service

You can register services in one of the following ways:

- Invoke ctaInitialize and specify service and service manager names. To use the NMS OAM service, specify OAM as the service name and OAMMGR as the service manager name in the CTA_SERVICE_NAME structure passed in the ctaInitialize invocation. The application can use only the services specified in this invocation.

- Invoke ctaInitialize, pass NULL for svcname, and pass a user-defined Natural Access configuration file name (usually cta.cfg). ctaInitialize looks in the [ctasys] header section of the configuration file for the service and service manager names. To use the NMS OAM service, OAM and OAMMGR must appear in this section, as follows:

Service = oam, oammgr

- Initialize the application on a local host. ctdaemon automatically provides access to the services specified in the cta.cfg. If an application specifies a service in the ctaIntialize invocation that is not available on the host, an error is returned.

## Creating event queues

After initializing Natural Access, invoke ctaCreateQueue to create one or more event queues. In the function invocation, specify the service managers to be attached to each queue.

## Creating contexts

Invoke ctaCreateContext or ctaCreateContextEx (for shared contexts) to create a context. Provide the queue handle (ctaqueuehd) that was returned from ctaCreateQueue. All events for services on the context are received in the specified event queue.

Use the descriptor string argument passed with ctaCreateContext or ctaCreateContextEx to specify the resource host on which the context will be created. descriptor has the following format:

[cta://]host_address[:port]

ctaCreateContext and ctaCreateContextEx each return a context handle (ctahd). The context handle is supplied by the application when invoking service functions. Events communicated back to the application are also associated with the context.

Refer to the Natural Access Developer's Reference Manual for details on the programming models created by the use of contexts and event queues.

## Opening services

Invoke ctaOpenServices to open services on a context. When opening a service on a context, you must specify the service and the service manager, and the resources to attach to the context. Specify this information in substructures of the CTA_SERVICE_DESC structure that you pass in the function invocation. NMS OAM functions are available only to contexts on which the NMS OAM service is opened.

For more information, refer to the Natural Access Developer's Reference Manual.

To receive events from the NMS OAM service and from installed EMCs (such as Hot Swap and Clock Management), a client application must register with the NMS OAM service using oamAlertNotify.