Wed Oct 28 11:53:01 2009

Asterisk developer's documentation


portinfo.c File Reference

Interface to mISDN - port info. More...

#include "isdn_lib.h"
#include "isdn_lib_intern.h"

Include dependency graph for portinfo.c:

Go to the source code of this file.

Functions

void isdn_port_info (void)
int main ()


Detailed Description

Interface to mISDN - port info.

Author:
Christian Richter <crich@beronet.com>

Definition in file portinfo.c.


Function Documentation

void isdn_port_info ( void   ) 

Definition at line 14 of file portinfo.c.

References buff, and errno.

Referenced by main().

00015 {
00016    int err;
00017    int i, ii, p;
00018    int useable, nt, pri;
00019    unsigned char buff[1025];
00020    iframe_t *frm = (iframe_t *)buff;
00021    stack_info_t *stinf;
00022    int device;
00023 
00024    /* open mISDN */
00025    if ((device = mISDN_open()) < 0)
00026    {
00027       fprintf(stderr, "mISDN_open() failed: ret=%d errno=%d (%s) Check for mISDN modules and device.\n", device, errno, strerror(errno));
00028       exit(-1);
00029    }
00030 
00031    /* get number of stacks */
00032    i = 1;
00033    ii = mISDN_get_stack_count(device);
00034    printf("\n");
00035    if (ii <= 0)
00036    {
00037       printf("Found no card. Please be sure to load card drivers.\n");
00038    }
00039 
00040    /* loop the number of cards and get their info */
00041    while(i <= ii)
00042    {
00043       err = mISDN_get_stack_info(device, i, buff, sizeof(buff));
00044       if (err <= 0)
00045       {
00046          fprintf(stderr, "mISDN_get_stack_info() failed: port=%d err=%d\n", i, err);
00047          break;
00048       }
00049       stinf = (stack_info_t *)&frm->data.p;
00050 
00051       nt = pri = 0;
00052       useable = 1;
00053 
00054       /* output the port info */
00055       printf("Port %2d: ", i);
00056       switch(stinf->pid.protocol[0] & ~ISDN_PID_FEATURE_MASK)
00057       {
00058          case ISDN_PID_L0_TE_S0:
00059          printf("TE-mode BRI S/T interface line (for phone lines)");
00060 #if 0
00061          if (stinf->pid.protocol[0] & ISDN_PID_L0_TE_S0_HFC & ISDN_PID_FEATURE_MASK)
00062             printf(" HFC multiport card");
00063 #endif
00064          break;
00065          case ISDN_PID_L0_NT_S0:
00066          nt = 1;
00067          printf("NT-mode BRI S/T interface port (for phones)");
00068 #if 0
00069          if (stinf->pid.protocol[0] & ISDN_PID_L0_NT_S0_HFC & ISDN_PID_FEATURE_MASK)
00070             printf(" HFC multiport card");
00071 #endif
00072          break;
00073          case ISDN_PID_L0_TE_U:
00074          printf("TE-mode BRI U   interface line");
00075          break;
00076          case ISDN_PID_L0_NT_U:
00077          nt = 1;
00078          printf("NT-mode BRI U   interface port");
00079          break;
00080          case ISDN_PID_L0_TE_UP2:
00081          printf("TE-mode BRI Up2 interface line");
00082          break;
00083          case ISDN_PID_L0_NT_UP2:
00084          nt = 1;
00085          printf("NT-mode BRI Up2 interface port");
00086          break;
00087          case ISDN_PID_L0_TE_E1:
00088          pri = 1;
00089          printf("TE-mode PRI E1  interface line (for phone lines)");
00090 #if 0
00091          if (stinf->pid.protocol[0] & ISDN_PID_L0_TE_E1_HFC & ISDN_PID_FEATURE_MASK)
00092             printf(" HFC-E1 card");
00093 #endif
00094          break;
00095          case ISDN_PID_L0_NT_E1:
00096          nt = 1;
00097          pri = 1;
00098          printf("NT-mode PRI E1  interface port (for phones)");
00099 #if 0
00100          if (stinf->pid.protocol[0] & ISDN_PID_L0_NT_E1_HFC & ISDN_PID_FEATURE_MASK)
00101             printf(" HFC-E1 card");
00102 #endif
00103          break;
00104          default:
00105          useable = 0;
00106          printf("unknown type 0x%08x",stinf->pid.protocol[0]);
00107       }
00108       printf("\n");
00109 
00110       if (nt)
00111       {
00112          if (stinf->pid.protocol[1] == 0)
00113          {
00114             useable = 0;
00115             printf(" -> Missing layer 1 NT-mode protocol.\n");
00116          }
00117          p = 2;
00118          while(p <= MAX_LAYER_NR) {
00119             if (stinf->pid.protocol[p])
00120             {
00121                useable = 0;
00122                printf(" -> Layer %d protocol 0x%08x is detected, but not allowed for NT lib.\n", p, stinf->pid.protocol[p]);
00123             }
00124             p++;
00125          }
00126          if (useable)
00127          {
00128             if (pri)
00129                printf(" -> Interface is Point-To-Point (PRI).\n");
00130             else
00131                printf(" -> Interface can be Poin-To-Point/Multipoint.\n");
00132          }
00133       } else
00134       {
00135          if (stinf->pid.protocol[1] == 0)
00136          {
00137             useable = 0;
00138             printf(" -> Missing layer 1 protocol.\n");
00139          }
00140          if (stinf->pid.protocol[2] == 0)
00141          {
00142             useable = 0;
00143             printf(" -> Missing layer 2 protocol.\n");
00144          }
00145          if (stinf->pid.protocol[2] & ISDN_PID_L2_DF_PTP)
00146          {
00147             printf(" -> Interface is Poin-To-Point.\n");
00148          }
00149          if (stinf->pid.protocol[3] == 0)
00150          {
00151             useable = 0;
00152             printf(" -> Missing layer 3 protocol.\n");
00153          } else
00154          {
00155             printf(" -> Protocol: ");
00156             switch(stinf->pid.protocol[3] & ~ISDN_PID_FEATURE_MASK)
00157             {
00158                case ISDN_PID_L3_DSS1USER:
00159                printf("DSS1 (Euro ISDN)");
00160                break;
00161 
00162                default:
00163                useable = 0;
00164                printf("unknown protocol 0x%08x",stinf->pid.protocol[3]);
00165             }
00166             printf("\n");
00167          }
00168          p = 4;
00169          while(p <= MAX_LAYER_NR) {
00170             if (stinf->pid.protocol[p])
00171             {
00172                useable = 0;
00173                printf(" -> Layer %d protocol 0x%08x is detected, but not allowed for TE lib.\n", p, stinf->pid.protocol[p]);
00174             }
00175             p++;
00176          }
00177          printf(" -> childcnt: %d\n",stinf->childcnt);
00178       }
00179 
00180       if (!useable)
00181          printf(" * Port NOT useable for PBX\n");
00182 
00183       printf("--------\n");
00184 
00185       i++;
00186    }
00187    printf("\n");
00188 
00189    /* close mISDN */
00190    if ((err = mISDN_close(device)))
00191    {
00192       fprintf(stderr, "mISDN_close() failed: err=%d '%s'\n", err, strerror(err));
00193       exit(-1);
00194    }
00195 }

int main (  ) 

Definition at line 198 of file portinfo.c.

References isdn_port_info().

00199 {
00200   isdn_port_info();
00201   return 0;
00202 }


Generated on Wed Oct 28 11:53:02 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6