- int ret;
- int i, ii;
- int useable, nt, te, pri, bri, pots;
-#ifdef SOCKET_MISDN
- struct mISDN_devinfo devinfo;
- int sock;
-
- /* open mISDN */
- sock = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE);
- if (sock < 0)
- {
- fprintf(stderr, "Cannot open mISDN due to %s. (Does your Kernel support socket based mISDN?)\n", strerror(errno));
- exit(EXIT_FAILURE);
- }
-
- /* get number of stacks */
- i = 1;
- ret = ioctl(sock, IMGETCOUNT, &ii);
- if (ret < 0)
- {
- fprintf(stderr, "Cannot get number of mISDN devices. (ioctl IMGETCOUNT failed ret=%d)\n", ret);
- goto done;
- }
-#else
- int p;
- unsigned char buff[1025];
- iframe_t *frm = (iframe_t *)buff;
- stack_info_t *stinf;
- int device;
-
- /* open mISDN */
- if ((device = mISDN_open()) < 0)
- {
- fprintf(stderr, "Cannot open mISDN device ret=%d errno=%d (%s) Check for mISDN modules!\nAlso did you create \"/dev/mISDN\"? Do: \"mknod /dev/mISDN c 46 0\"\n", device, errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
-
- /* get number of stacks */
- i = 1;
- ii = mISDN_get_stack_count(device);
-#endif
- printf("\n");
- if (ii <= 0)
- {
- printf("Found no card. Please be sure to load card drivers.\n");
- goto done;
- }
-
- /* loop the number of cards and get their info */
- while(i <= ii)
- {
- nt = te = bri = pri = pots = 0;
- useable = 0;
-
-#ifdef SOCKET_MISDN
- devinfo.id = i - 1;
- ret = ioctl(sock, IMGETDEVINFO, &devinfo);
- if (ret <= 0)
- {
- fprintf(stderr, "Cannot get device information for port %d. (ioctl IMGETDEVINFO failed ret=%d)\n", i, ret);
- break;
- }
-
- /* output the port info */
- printf("Port %2d name='%s': ", i, devinfo.name);
- if (devinfo.Dprotocols & (1 << ISDN_P_TE_S0))
- {
- bri = 1;
- te = 1;
- }
- if (devinfo.Dprotocols & (1 << ISDN_P_NT_S0))
- {
- bri = 1;
- nt = 1;
- }
-#ifdef ISDN_P_TE_E1
- if (devinfo.Dprotocols & (1 << ISDN_P_TE_E1))
- {
- pri = 1;
- te = 1;
- }
-#endif
-#ifdef ISDN_P_NT_E1
- if (devinfo.Dprotocols & (1 << ISDN_P_NT_E1))
- {
- pri = 1;
- nt = 1;
- }
-#endif
-#ifdef ISDN_P_FXS
- if (devinfo.Dprotocols & (1 << ISDN_P_FXS))
- {
- pots = 1;
- te = 1;
- }
-#endif
-#ifdef ISDN_P_FXO
- if (devinfo.Dprotocols & (1 << ISDN_P_FXO))
- {
- pots = 1;
- nt = 1;
- }
-#endif
- if ((te || nt) && (bri || pri || pots))
- useable = 1;
-
- if (te && bri)
- printf("TE-mode BRI S/T interface line (for phone lines)");
- if (nt && bri)
- printf("NT-mode BRI S/T interface port (for phones)");
- if (te && pri)
- printf("TE-mode PRI E1 interface line (for phone lines)");
- if (nt && pri)
- printf("NT-mode PRI E1 interface port (for E1 terminals)");
- if (te && pots)
- printf("FXS POTS interface port (for analog lines)");
- if (nt && pots)
- printf("FXO POTS interface port (for analog phones)");
- if (pots)
- {
- useable = 0;
- printf("\n -> Analog interfaces are not supported.");
- } else
- if (!useable)
- {
- printf("unsupported interface protocol bits 0x%016x", devinfo.Dprotocols);
- }
- printf("\n");
-
- printf(" - %d B-channels\n", devinfo.nrbchan);
-#else
- ret = mISDN_get_stack_info(device, i, buff, sizeof(buff));
- if (ret <= 0)
- {
- fprintf(stderr, "mISDN_get_stack_info() failed: port=%d error=%d\n", i, ret);
- break;
- }
- stinf = (stack_info_t *)&frm->data.p;
-
- /* output the port info */
- printf("Port %2d: ", i);
- switch(stinf->pid.protocol[0] & ~ISDN_PID_FEATURE_MASK)
- {
- case ISDN_PID_L0_TE_S0:
- useable = 1;
- te = 1;
- bri = 1;
- printf("TE-mode BRI S/T interface line (for phone lines)");
- break;
- case ISDN_PID_L0_NT_S0:
- useable = 1;
- nt = 1;
- bri = 1;
- printf("NT-mode BRI S/T interface port (for phones)");
- break;
- case ISDN_PID_L0_TE_E1:
- useable = 1;
- te = 1;
- pri = 1;
- printf("TE-mode PRI E1 interface line (for phone lines)");
- break;
- case ISDN_PID_L0_NT_E1:
- useable = 1;
- nt = 1;
- pri = 1;
- printf("NT-mode PRI E1 interface port (for E1 terminals)");
- break;
- default:
- useable = 0;
- printf("unknown type 0x%08x",stinf->pid.protocol[0]);
- }
- printf("\n");
-
- if (nt)
- {
- if (stinf->pid.protocol[1] == 0)
- {
- useable = 0;
- printf(" -> Missing layer 1 NT-mode protocol.\n");
- }
- p = 2;
- while(p <= MAX_LAYER_NR) {
- if (stinf->pid.protocol[p])
- {
- useable = 0;
- printf(" -> Layer %d protocol 0x%08x is detected, port already in use by another application.\n", p, stinf->pid.protocol[p]);
- }
- p++;
- }
- if (useable)
- {
- if (pri)
- printf(" -> Interface is Point-To-Point (PRI).\n");
- else
- printf(" -> Interface can be Poin-To-Point/Multipoint.\n");
- }
- }
- if (te)
- {
- if (stinf->pid.protocol[1] == 0)
- {
- useable = 0;
- printf(" -> Missing layer 1 protocol.\n");
- }
- if (stinf->pid.protocol[2] == 0)
- {
- useable = 0;
- printf(" -> Missing layer 2 protocol.\n");
- }
- if (stinf->pid.protocol[2] & ISDN_PID_L2_DF_PTP)
- {
- printf(" -> Interface is Poin-To-Point.\n");
- }
- if (stinf->pid.protocol[3] == 0)
- {
- useable = 0;
- printf(" -> Missing layer 3 protocol.\n");
- } else
- {
- printf(" -> Protocol: ");
- switch(stinf->pid.protocol[3] & ~ISDN_PID_FEATURE_MASK)
- {
- case ISDN_PID_L3_DSS1USER:
- printf("DSS1 (Euro ISDN)");
- break;
-
- default:
- useable = 0;
- printf("unknown protocol 0x%08x",stinf->pid.protocol[3]);
- }
- printf("\n");
- }
- p = 4;
- while(p <= MAX_LAYER_NR) {
- if (stinf->pid.protocol[p])
- {
- useable = 0;
- printf(" -> Layer %d protocol 0x%08x is detected, port already in use by another application.\n", p, stinf->pid.protocol[p]);
- }
- p++;
- }
- }
- printf(" - %d B-channels\n", stinf->childcnt);
-#endif
-
- if (!useable)
- printf(" * Port NOT useable for LCR\n");
-
- printf("--------\n");
-
- i++;
- }
- printf("\n");
-
-done:
-#ifdef SOCKET_MISDN
- close(sock);
-#else
- /* close mISDN */
- if ((ret = mISDN_close(device)))
- FATAL("mISDN_close() failed: err=%d '%s'\n", ret, strerror(ret));
-#endif
-}
-
-
-/*
- * enque data from upper buffer
- */
-void PmISDN::txfromup(unsigned char *data, int length)
-{
-#ifdef SOCKET_MISDN
- unsigned char buf[MISDN_HEADER_LEN+((length>ISDN_LOAD)?length:ISDN_LOAD)];