PREV TOC HOME INDEX NEXT


4.7.6. Sample Code for Managing QoS Threshold Alarms

The following code demonstrates how to set and retrieve QoS threshold values and how to handle alarm events related to QoS.

/*****************************************************************************
Routine:                QoS_sample_code
Assumptions/Warnings:   None
Description:            Illustrates the setting/getting of QoS thresholds
Parameters:             None
Returns:                None
******************************************************************************/

void QoS_sample_code(void)
{
    LINEDEV                 ldev;
    int                     mediah;

    /* open IP device with media */
    if (gc_OpenEx(&ldev, ":N_iptB1T1:P_H323_NTSC:M_ipmB1C1", EV_SYNC, 0) 
                  != GC_SUCCESS)
    {
        /* handle gc_OpenEx() failure */
        return;
    }

    /* wait for GCEV_UNBLOCKED event (code not shown) */

    /* get device handle for media resource */
    if (gc_GetResourceH(ldev, &mediah, GC_MEDIADEVICE) != GC_SUCCESS)
    {
        /* handle gc_GetResourceH() failure */
        return;
    }
    
    /* enable alarm notification on media device (to get GCEV_ALARM event) */
    if (gc_SetAlarmNotifyAll(mediah, ALARM_SOURCE_ID_NETWORK_ID, ALARM_NOTIFY) 
                              != GC_SUCCESS)
    {
        /* handle gc_SetAlarmNotifyAll() failure */
        return;
    }

    /* get default QoS threshold values */
    GetAlarmParm(mediah, ALARM_SOURCE_ID_NETWORK_ID,
                 ParmSetID_qosthreshold_alarm, EV_SYNC);
    /* change QoS thresholds */
    SetAlarmParm(mediah, ALARM_SOURCE_ID_NETWORK_ID,
                 ParmSetID_qosthreshold_alarm, EV_SYNC);

    /* get new QoS thresholds */
    GetAlarmParm(mediah, ALARM_SOURCE_ID_NETWORK_ID,
                 ParmSetID_qosthreshold_alarm, EV_SYNC);

    /* set up call and monitor for GCEV_ALARM events on media devices 
            (code not shown)
                    .
                    .
                    .
    
    */

    /* close device */
    if (gc_Close(ldev) != GC_SUCCESS)
    {
        /* handle gc_Close() failure */
        return;
    }
}

/*****************************************************************************
Routine:                GetAlarmParm
Assumptions/Warnings:   None
Description:            calls gc_GetAlarmParm()
Parameters:             parameters to gc_GetAlarmParm() function call
Returns:                None
******************************************************************************/

void GetAlarmParm(LINEDEV ldev, unsigned long aso_id, int ParmSetID,
                         unsigned long mode)
{
    ALARM_PARM_LIST alarm_parm_list;
    IPM_QOS_THRESHOLD_DATA QoS_parm[3];
    IPM_QOS_THRESHOLD_DATA *QoS_parmp;
    int n;

    /* get QoS thresholds for DTMFDISCARDED, LOSTPACKETS and JITTER */
    alarm_parm_list.n_parms = 3;
    for (n=0; n < alarm_parm_list.n_parms; n++)
    {
        alarm_parm_list.alarm_parm_fields[n].alarm_parm_data.pstruct 
            = (void *) &QoS_parm[n];
    }
    
    QoS_parm[0].eQoSType = QOSTYPE_DTMFDISCARDED;
    QoS_parm[1].eQoSType = QOSTYPE_LOSTPACKETS;
    QoS_parm[2].eQoSType = QOSTYPE_JITTER;

    if (gc_GetAlarmParm(ldev, aso_id, ParmSetID, &alarm_parm_list, mode) 
                        != GC_SUCCESS)
    {
        /* handle gc_GetAlarmParm() failure */
        return;
    }

    /* display threshold values retrieved */
    printf("n_parms = %d\n", alarm_parm_list.n_parms);

    for (n=0; n < alarm_parm_list.n_parms; n++)
    {
        QoS_parmp = alarm_parm_list.alarm_parm_fields[n].alarm_parm_data.pstruct;

        printf("QoS type = %d\n", QoS_parmp->eQoSType);
        printf("\tTime Interval = %u\n", QoS_parmp->unTimeInterval);
        printf("\tDebounce On = %u\n", QoS_parmp->unDebounceOn);
        printf("\tDebounce Off = %u\n", QoS_parmp->unDebounceOff);
        printf("\tFault Threshold = %u\n", QoS_parmp->unFaultThreshold);
        printf("\tPercent Success Threshold = %u\n", 
                       QoS_parmp->unPercentSuccessThreshold);
        printf("\tPercent Fail Threshold = %u\n", 
                       QoS_parmp->unPercentFailThreshold);
        printf("\n\n");
    }
}

/*****************************************************************************
Routine:                SetAlarmParm
Assumptions/Warnings:   None.
Description:            calls gc_SetAlarmParm()
Parameters:             parameters to gc_SetAlarmParm() function call
Returns:                None
******************************************************************************/

void SetAlarmParm(LINEDEV ldev, unsigned long aso_id, int ParmSetID,
                         unsigned long mode)
{
    ALARM_PARM_LIST alarm_parm_list;
    IPM_QOS_THRESHOLD_DATA QoS_parm[1];

    alarm_parm_list.n_parms = 1;
    alarm_parm_list.alarm_parm_fields[0].alarm_parm_data.pstruct = 
        (void *) &QoS_parm[0];
    
    QoS_parm[0].eQoSType = QOSTYPE_LOSTPACKETS;
    QoS_parm[0].unTimeInterval = 50;
    QoS_parm[0].unDebounceOn = 100;
    QoS_parm[0].unDebounceOff = 100;
    QoS_parm[0].unFaultThreshold = 10;
    QoS_parm[0].unPercentSuccessThreshold = 90;
    QoS_parm[0].unPercentFailThreshold = 10;
    
    if (gc_SetAlarmParm(ldev, aso_id, ParmSetID, &alarm_parm_list, mode) 
                        != GC_SUCCESS)
    {
        /* handle gc_SetAlarmParm() failure */
        return;
    }
}

/*****************************************************************************
Routine:                handle_alarm
Assumptions/Warnings:   None.
Description:            handles the GCEV_ALARM event
Parameters:             metaevent:  pointer to METAEVENT for event
Returns:                None
******************************************************************************/

void handle_alarm(METAEVENT *metaevent)
{
    ALARM_LIST      alarm_list;
    int             i;
    unsigned long   aso_id;
    long            alarm_number;
    char            *alarm_name;

    /*
     * retrieve and display aso id, alarm number, alarm name 
     * associated with GCEV_ALARM that occurred
     */
    if (gc_AlarmSourceObjectID(metaevent, &aso_id) != GC_SUCCESS)
    {
        /* handle gc_AlarmSourceObjectID() failure */
        return;
    }
    printf("aso id = 0x%ul\n", aso_id);

    if (gc_AlarmNumber(metaevent, &alarm_number) != GC_SUCCESS)
    {
        /* handle gc_AlarmNumber() failure */
        return;
    }
    printf("alarm number = 0x%lx\n", alarm_number);

    if (gc_AlarmNumberToName(aso_id, alarm_number, &alarm_name) != GC_SUCCESS)
    {
        /* handle gc_AlarmNumberToName() failure */
        return;
    }
    printf ("alarm name = %s\n", alarm_name);

    /* retrieve and display ON/OFF status of all alarms */
    if (gc_GetAlarmConfiguration(metaevent->linedev, ALARM_SOURCE_ID_NETWORK_ID,
            &alarm_list, ALARM_CONFIG_STATUS) != GC_SUCCESS)
    {
        /* handle gc_GetAlarmConfiguration() failure */
        return;
    }
    for (i = 0; i< alarm_list.n_alarms; i++)
    {
        printf("alarm number = %d",alarm_list.alarm_fields[i].alarm_number);

        switch (alarm_list.alarm_fields[i].alarm_data.intvalue)
        {
        case ALARM_ON:
            printf("\talarm status = ALARM_ON\n");
            break;
        case ALARM_OFF:
            printf("\talarm status = ALARM_OFF\n");
            break;
        default:
            printf("\talarm status = %d (unknown)\n", 
                alarm_list.alarm_fields[i].alarm_data.intvalue);
            break;
        }
    }
} 

PREV TOC HOME INDEX NEXT

Click here to contact Telecom Support Resources

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