# Events

All events in the Natural Access environment are represented by a C data structure, as shown in the following generic CTA_EVENT:

typedef struct
{
DWORD id; /* event ID (LIBEVN_xxx in 'libdef.h') */
CTAHD ctahd; /* CTA context handle */
DWORD timestamp; /* timestamp */
DWORD userid; /* use-supplied ID */
DWORD size; /* size of buffer if buffer is not NULL */
/* otherwise, may contain event-specific data */
void *buffer; /* buffer pointer */
DWORD value; /* Event status or event-specific data */
DWORD objHd; /* object handle */
} CTA_EVENT;

This structure, returned by ctaWaitEvent, informs the application which event occurred on which context, and provides additional information specific to the event. The LIB prefix in LIBEVN relates the event to a specific NMS library of functions. For example, the CTA prefix indicates Natural Access and DTM indicates the DTM service.

The event structure contains the following fields:

Field | Description
--- | ---
id | Contains an event code defined in the library header file. All DTM events are prefixed with DTMEVN_ (for example, DTMEVN_SOMETHING_HAPPENED).
ctahd | Contains the context handle (returned from ctaCreateContext).
timestamp | Contains the time an event was created in milliseconds since midnight. The resolution for AG board events is 10 milliseconds.
userid | Contains the user-supplied ID. This field is unaltered by Natural Access and facilitates asynchronous programming. Its purpose is to correlate a context with an application object and context when events occur.
size | Specifies the size (bytes) of the area pointed to by buffer. If the buffer is NULL, this field can hold an event-specific value. Can contain the dtmhd.
buffer | Points to data returned with the event. The field contains an application process address and the event's size field contains the actual size of the buffer.
value | Contains a reason code or an error code. This is an event-specific value.
objHd | Contains the dtmhd in DTM events.

The following events are specific to the DTM service:

Event | Hexadecimal | Decimal | Description
--- | --- | --- | ---
DTMEVN_MONITOR_DONE | 0XC2101 | 794881 | Monitoring ended.
DTMEVN_MONITOR_STARTED | 0XC2001 | 794625 | Monitoring started on a specified trunk.
DTMEVN_TRUNK_STATUS | 0XC2002 | 794626 | Trunk status information is available.