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