PREV TOC HOME INDEX NEXT


4.10.5. Handling QoS Alarms

The application must first be enabled to receive notification of alarms on the specified line device. The following code demonstrates how this is achieved.

/****************************************************************
*        NAME: enable_alarm_notification(struct channel *pline)
* DESCRIPTION: Enables all alarms notification for pline
*              Also fills in pline->mediah
*       INPUT: pline - pointer to channel data structure
*     RETURNS: None - exits if error
*    CAUTIONS: Does no sanity checking as to whether or not the technology 
*              supports alarms - assumes caller has done that already
****************************************************************/

static void enable_alarm_notification(struct channel *pline)
{
    char     str[MAX_STRING_SIZE];
    int      alarm_ldev;                /* linedevice that alarms come on */
    
    alarm_ldev = pline->ldev;           /* until proven otherwise */
    if (pline->techtype == H323) {
        /* Recall that the alarms for IP come on the media device, not the 
           network device */
        if (gc_GetResourceH(pline->ldev, &alarm_ldev, GC_MEDIADEVICE) 
                            != GC_SUCCESS) {
            sprintf(str, "gc_GetResourceH(linedev=%ld, &alarm_ldev,
                    GC_MEDIADEVICE) Failed", pline->ldev);
            printandlog(pline->index, GC_APIERR, NULL, str);
            exitdemo(1);
        }
        sprintf(str, "gc_GetResourceH(linedev=%ld, &alarm_ldev, 
                GC_MEDIADEVICE) passed, mediah = %d",
                pline->ldev, alarm_ldev);
        printandlog(pline->index, MISC, NULL, str);
        pline->mediah = alarm_ldev;         /* save for later use */
    } else {
        printandlog(pline->index, MISC, NULL, "Not setting pline->mediah 
                    since techtype != H323");
    }
    sprintf(str, "enable_alarm_notification - pline->mediah = %d\n", 
            (int) pline->mediah); 
    
    
    if (gc_SetAlarmNotifyAll(alarm_ldev, ALARM_SOURCE_ID_NETWORK_ID,
        ALARM_NOTIFY) != GC_SUCCESS) {
        sprintf(str, "gc_SetAlarmNotifyAll(linedev=%ld,
                ALARM_SOURCE_ID_NETWORK_ID, ALARM_NOTIFY) Failed", pline->ldev);
        printandlog(pline->index, GC_APIERR, NULL, str);
        exitdemo(1);
    }
    sprintf(str, "gc_SetAlarmNotifyAll(linedev=%ld, ALARM_SOURCE_ID_NETWORK_ID,
            ALARM_NOTIFY) PASSED", pline->ldev);
    printandlog(pline->index, MISC, NULL, str);
} 

When a GCEV_ALARM event occurs, use the Global Call Alarm Management System (GCAMS) functions (such as, gc_AlarmNumber( )) to retrieve information about the alarm. The following code demonstrates how to process a QoS alarm when it occurs. In this case the application simply logs information about the alarm.

/****************************************************************
*        NAME: void print_alarm_info(METAEVENTP metaeventp, 
*                                    struct channel *pline)
* DESCRIPTION: Prints alarm information
*      INPUTS: metaeventp - pointer to the alarm event
*              pline - pointer to the channel data structure
*     RETURNS: NA
*    CAUTIONS: Assumes already known to be an alarm event
****************************************************************/

static void print_alarm_info(METAEVENTP metaeventp, struct channel *pline)
{
    long              alarm_number;
    char              *alarm_name;
    unsigned long     alarm_source_objectID;
    char              *alarm_source_object_name;
    char              str[MAX_STRING_SIZE];
    
    if (gc_AlarmNumber(metaeventp, &alarm_number) != GC_SUCCESS)
    {
        sprintf(str, "gc_AlarmNumber(...) FAILED");
        printandlog(pline->index, GC_APIERR, NULL, str);
        printandlog(pline->index, STATE, NULL, " ");
        exitdemo(1);
    }
    if (gc_AlarmName(metaeventp, &alarm_name) != GC_SUCCESS)
    {
        sprintf(str, "gc_AlarmName(...) FAILED");
        printandlog(pline->index, GC_APIERR, NULL, str);
        printandlog(pline->index, STATE, NULL, " ");
        exitdemo(1);
    }
    
    if (gc_AlarmSourceObjectID(metaeventp, &alarm_source_objectID) != GC_SUCCESS)
    {
        sprintf(str, "gc_AlarmSourceObjectID(...) FAILED");
        printandlog(pline->index, GC_APIERR, NULL, str);
        printandlog(pline->index, STATE, NULL, " ");
        exitdemo(1);
    }
    
    if (gc_AlarmSourceObjectName(metaeventp, &alarm_source_object_name) 
                                 != GC_SUCCESS)
    {
        sprintf(str, "gc_AlarmSourceObjectName(...) FAILED");
        printandlog(pline->index, GC_APIERR, NULL, str);
        printandlog(pline->index, STATE, NULL, " ");
        exitdemo(1);
    }
    
    sprintf(str, "Alarm %s (%d) occurred on ASO %s (%d)",
            alarm_name, (int) alarm_number, alarm_source_object_name, 
            (int) alarm_source_objectID);
    
    printandlog(pline->index, MISC, NULL, str);
} 

See the Global Call API Programming Guide for more information about the operation of GCAMS and the Global Call API Library Reference for more information about GCAMS functions.


PREV TOC HOME INDEX NEXT

Click here to contact Telecom Support Resources

Copyright 2003, Intel Corporation
All rights reserved
This page generated February, 2003