PREV TOC HOME INDEX NEXT


gc_GetLinedevState( )


Termination Events | Cautions | Errors | Example | See Also

Name: int gc_GetLinedevState(linedev, type, state_buf)
Inputs:

LINEDEV linedev

  • line device
 

int type

  • specifies type of line device
 

int *state_buf

  • pointer to location of line device state status
Returns:

0 if successful

<0 if failure

Includes:

gclib.h

gcerr.h

Category:

optional call handling

Mode:

synchronous

Platform and Technology:

Springware: ISDN

DM3: T-1/E-1, ISDN, Analog

SS7

IP (embedded stack)

Description

The gc_GetLinedevState( ) function retrieves the status of the line device specified by the linedev parameter.

Parameter

Description

linedev Global Call line device
type specifies B channel or D channel device type associated with linedev. Valid values are:
  • GCGLS_BCHANNEL
    get state of B channel
  • GCGLS_DCHANNEL
    get state of D channel
state_buf points to the location where the state information is to be stored. Valid state values for the B channel are:
  • GCLS_INSERVICE (0)
    B channel is in service
  • GCLS_MAINTENANCE (1)
    B channel is in maintenance
  • GCLS_OUT_OF_SERVICE (2)
    B channel is out of service
Valid state values for the D channel are:
  • DATA_LINK_UP (0x02)
    layer 2 operable
  • DATA_LINK_DOWN (0x01)
    layer 2 inoperable

Termination Events

None

Cautions

If this function is invoked for an unsupported technology, the function fails. The error value EGC_UNSUPPORTED will be the Global Call value returned when the gc_ErrorInfo( ) function is used to retrieve the error code.

Errors

If this function returns <0 to indicate failure, use the gc_ErrorInfo( ) function to retrieve the reason for the error. See the "Error Handling" section in the Global Call API Programming Guide. All Global Call error codes are defined in the gcerr.h file. If the error returned is technology specific, see the technology-specific error header file(s) for the error definition (for example, ccerr.h or isdnerr.h file for the ISDN call control library).

Example

#include <stdio.h>
#include <srllib.h>
#include <gclib.h>
#include <gcerr.h>
#include <gcisdn.h> 
int get_line_dev_state(void)
{
    LINEDEV  bdd;             /* Board level device */
    LINEDEV  ldev;            /* Line device */
    char     bdevname[40];    /* Board device name */
    char     ldevname[40];    /* Line device name */
    int      type;            /* Type of line device */
    int      statebuf;        /* Buffer to store line device state */
    GC_INFO  gc_error_info;   /* GlobalCall error information data */ 
    sprintf(bdevname, ":N_dtiB1:P_isdn");
    sprintf(ldevname, ":N_dtiB1T1:P_isdn"); 
    /*
     * Open two devices, dtiB1 and dtiB1T1.
     */
    if(gc_OpenEx(&bdd, bdevname, EV_SYNC, &bdd) != GC_SUCCESS) {
        /* process error return as shown */
        gc_ErrorInfo( &gc_error_info );
        printf ("Error: gc_OpenEx() on devname: %s, GC ErrorValue: 0x%hx - %s, 
               CCLibID: %i - %s, CC ErrorValue: 0x%lx - %s\n",
               bdevname, gc_error_info.gcValue, gc_error_info.gcMsg, 
               gc_error_info.ccLibId, gc_error_info.ccLibName,
               gc_error_info.ccValue, gc_error_info.ccMsg);
        return (gc_error_info.gcValue);
    } 
    if(gc_OpenEx(&ldev, ldevname, EV_SYNC, &ldev) != GC_SUCCESS) {
        /* process error return as shown */
        gc_ErrorInfo( &gc_error_info );
        printf ("Error: gc_OpenEx() on devname: %s, GC ErrorValue: 0x%hx - %s, 
               CCLibID: %i - %s, CC ErrorValue: 0x%lx - %s\n",
               ldevname, gc_error_info.gcValue, gc_error_info.gcMsg, 
               gc_error_info.ccLibId, gc_error_info.ccLibName,
               gc_error_info.ccValue, gc_error_info.ccMsg);
        return (gc_error_info.gcValue); 
    } 
    /*
     * Find the status of the board.
     * The D Channel can be in one of two states DATA_LINK_UP or
     * DATA_LINK_DOWN.
     */
    type = GCGLS_DCHANNEL; 
    if(gc_GetLinedevState(bdd, type, &statebuf) != GC_SUCCESS) {
        gc_ErrorInfo( &gc_error_info );
        printf ("Error: gc_GetLinedevState() on linedev: 0x%lx, GC ErrorValue: 0x%hx - %s,
               CCLibID: %i - %s, CC ErrorValue: 0x%lx - %s\n",
               bdd, gc_error_info.gcValue, gc_error_info.gcMsg, 
               gc_error_info.ccLibId, gc_error_info.ccLibName,
               gc_error_info.ccValue, gc_error_info.ccMsg);
        return (gc_error_info.gcValue); 
    }
    else {
        printf("D Channel Status: %s\n", statebuf);
    } 
      /*
     * Find the status of the line.
     * the B Channel can be in one of three states GCLS_INSERVICE,
     * GCLS_MAINTENANCE, or GCLS_OUT_OF_SERVICE.
     */
    type = GCGLS_BCHANNEL; 
    if(gc_GetLinedevState(ldev, type, &statebuf) != GC_SUCCESS) {
        gc_ErrorInfo( &gc_error_info );
        printf ("Error: gc_GetLinedevState() on linedev: 0x%lx, GC ErrorValue: 0x%hx - %s,
               CCLibID: %i - %s, CC ErrorValue: 0x%lx - %s\n",
               ldev, gc_error_info.gcValue, gc_error_info.gcMsg, 
               gc_error_info.ccLibId, gc_error_info.ccLibName,
               gc_error_info.ccValue, gc_error_info.ccMsg);
        return (gc_error_info.gcValue); 
    }
    else {
        printf("B Channel Status: %s\n", statebuf);
    } 
    gc_Close(bdd);
    gc_Close(ldev); 
    return (0);
} 

See Also


PREV TOC HOME INDEX NEXT

Click here to contact Telecom Support Resources

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