Don't use hardcoded card type/driver type constants - those have been

removed.
This commit is contained in:
martin 2002-03-24 20:37:45 +00:00
parent 0bc69b6498
commit 6a2e4de618
7 changed files with 48 additions and 267 deletions

View File

@ -59,11 +59,11 @@ download(fd, controller, filename)
perror("ctrl info req");
exit(1);
}
if (info.ctrl_type != CTRL_DAIC) {
if (strncmp(info.devname, "daic", 4) != 0) {
fprintf(stderr, "this is not a Diehl active isdn card...\n");
exit(1);
}
if (info.card_type == CARD_TYPEA_DAIC_QUAD)
if (strcmp(info.devname, "daic0 port0") == 0)
num_ports = 4;
memset(&dr, 0, sizeof dr);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997,1999 Martin Husemann <martin@duskware.de>
* Copyright (c) 1997-2002 Martin Husemann <martin@duskware.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -139,115 +139,13 @@ listall(int fd)
memset(&info, 0, sizeof info);
ioctl(fd, I4B_CTRL_INFO_REQ, &info);
num = info.ncontroller;
printf("There are %d controllers available:\n", num);
for (i = 0; i < num; i++) {
num = info.maxbri;
printf("There are %d controllers available:\n", info.ncontroller);
for (i = 0; i <= num; i++) {
info.controller = i;
ioctl(fd, I4B_CTRL_INFO_REQ, &info);
switch (info.ctrl_type) {
case CTRL_PASSIVE:
printf("controller #%d: Siemens based passive card: ", i);
switch (info.card_type) {
case CARD_TYPEP_8:
printf("Teles S0\n");
break;
case CARD_TYPEP_16:
printf("Teles S0/16\n");
break;
case CARD_TYPEP_16_3:
printf("Teles S0/16.3\n");
break;
case CARD_TYPEP_AVMA1:
printf("AVM A1\n");
break;
case CARD_TYPEP_163P:
printf("Teles S0/PnP\n");
break;
case CARD_TYPEP_CS0P:
printf("Creatix S0/P&P\n");
break;
case CARD_TYPEP_USRTA:
printf("USR Sportster internal TA\n");
break;
case CARD_TYPEP_DRNNGO:
printf("Dr. Neuhaus Niccy GO@\n");
break;
case CARD_TYPEP_SWS:
printf("Sedlbauer Win Speed\n");
break;
case CARD_TYPEP_DYNALINK:
printf("Dynalink IS64PH\n");
break;
case CARD_TYPEP_BLMASTER:
printf("ISDN Blaster / ISDN Master\n");
break;
case CARD_TYPEP_PCFRITZ:
printf("AVM PCMCIA Fritz!Card\n");
break;
case CARD_TYPEP_ELSAQS1ISA:
printf("ELSA QuickStep 1000pro ISA\n");
break;
case CARD_TYPEP_ELSAQS1PCI:
printf("ELSA QuickStep 1000pro PCI\n");
break;
case CARD_TYPEP_SIEMENSITALK:
printf("Siemens I-Talk\n");
break;
case CARD_TYPEP_ELSAMLIMC:
printf("ELSA MicroLink ISDN/MC\n");
break;
case CARD_TYPEP_ELSAMLMCALL:
printf("ELSA MicroLink MCall\n");
break;
case CARD_TYPEP_ITKIX1:
printf("ITK ix1 micro\n");
break;
case CARD_TYPEP_AVMA1PCI:
printf("AVM Fritz!Card PCI\n");
break;
case CARD_TYPEP_ASUSCOMIPAC:
printf ("Asuscom ISDNlink 128 K PnP\n");
break;
case CARD_TYPEP_WINB6692:
printf ("Winbond W6692 based\n");
break;
case CARD_TYPEP_16_3C:
printf ("Teles S0/16.3c PnP\n");
break;
case CARD_TYPEP_ACERP10:
printf ("Acer ISDN P10\n");
break;
case CARD_TYPEP_TELEINT_NO_1:
printf ("TELEINT ISDN SPEED No. 1\n");
break;
default:
printf("unknown card type %d\n", info.card_type);
break;
}
break;
case CTRL_DAIC:
printf("controller #%d: Diehl active ISDN card: ", i);
switch (info.card_type) {
case CARD_TYPEA_DAIC_S:
printf("S\n");
break;
case CARD_TYPEA_DAIC_SX:
printf("SX\n");
break;
case CARD_TYPEA_DAIC_SCOM:
printf("SCOM\n");
break;
case CARD_TYPEA_DAIC_QUAD:
printf("QUADRO\n");
break;
default:
printf("unknown type %d\n", info.card_type);
break;
}
break;
default:
printf("unknown controller type\n");
break;
if (ioctl(fd, I4B_CTRL_INFO_REQ, &info) == 0) {
printf("BRI %d: %s\n", i, info.devname);
printf("\t%s\n", info.cardname);
}
}
}

View File

@ -27,7 +27,7 @@
* i4b daemon - controller state support routines
* ----------------------------------------------
*
* $Id: controller.c,v 1.1.1.1 2001/01/06 13:00:12 martin Exp $
* $Id: controller.c,v 1.2 2002/03/24 20:37:47 martin Exp $
*
* $FreeBSD$
*
@ -38,71 +38,8 @@
#include "isdnd.h"
static int
init_controller_state(int controller, int ctrl_type, int card_type, int tei);
init_controller_state(int controller, const char *devname, const char *cardname, int tei);
/*---------------------------------------------------------------------------*
* get name of a controller
*---------------------------------------------------------------------------*/
const char *
name_of_controller(int ctrl_type, int card_type)
{
static char *passive_card[] = {
"Teles S0/8",
"Teles S0/16",
"Teles S0/16.3",
"AVM A1 or Fritz!Card",
"Teles S0/16.3 PnP",
"Creatix S0 PnP",
"USRobotics Sportster ISDN TA",
"Dr. Neuhaus NICCY Go@",
"Sedlbauer win speed",
"Dynalink IS64PH",
"ISDN Master, MasterII or Blaster",
"AVM PCMCIA Fritz!Card",
"ELSA QuickStep 1000pro/ISA",
"ELSA QuickStep 1000pro/PCI",
"Siemens I-Talk",
"ELSA MicroLink ISDN/MC",
"ELSA MicroLink MCall",
"ITK ix1 micro",
"AVM Fritz!Card PCI",
"ELSA PCC-16",
"AVM Fritz!Card PnP",
"Siemens I-Surf 2.0 PnP",
"Asuscom ISDNlink 128K PnP",
"ASUSCOM P-IN100-ST-D (Winbond W6692)",
"Teles S0/16.3c PnP",
"AcerISDN P10 PnP",
"TELEINT ISDN SPEED No. 1"
};
static char *daic_card[] = {
"EICON.Diehl S",
"EICON.Diehl SX/SXn",
"EICON.Diehl SCOM",
"EICON.Diehl QUADRO",
};
if(ctrl_type == CTRL_PASSIVE)
{
int index = card_type - CARD_TYPEP_8;
if (index >= 0 && index < (sizeof passive_card / sizeof passive_card[0]))
return passive_card[index];
}
else if(ctrl_type == CTRL_DAIC)
{
int index = card_type - CARD_TYPEA_DAIC_S;
if (index >= 0 && index < (sizeof daic_card / sizeof daic_card[0] ))
return daic_card[index];
}
else if(ctrl_type == CTRL_TINADD)
{
return "Stollmann tina-dd";
}
return "unknown card type";
}
/*---------------------------------------------------------------------------*
* init controller state array
*---------------------------------------------------------------------------*/
@ -123,21 +60,16 @@ init_controller(void)
do_exit(1);
}
if((ncontroller = max = mcir.ncontroller) == 0)
if(mcir.maxbri < 0)
{
log(LL_ERR, "init_controller: no ISDN controller found!");
do_exit(1);
}
if(mcir.ctrl_type == -1 || mcir.card_type == -1)
{
log(LL_ERR, "init_controller: ctrl/card is invalid!");
do_exit(1);
do_exit(1); /* XXX - fix when we handle attach/detach */
}
ncontroller = max = mcir.maxbri+1;
/* init controller tab */
if((init_controller_state(i, mcir.ctrl_type, mcir.card_type, mcir.tei)) == ERROR)
if((init_controller_state(i, mcir.devname, mcir.cardname, mcir.tei)) == ERROR)
{
log(LL_ERR, "init_controller: init_controller_state for controller %d failed", i);
do_exit(1);
@ -150,7 +82,7 @@ init_controller(void)
* init controller state table entry
*--------------------------------------------------------------------------*/
static int
init_controller_state(int controller, int ctrl_type, int card_type, int tei)
init_controller_state(int controller, const char *devname, const char *cardname, int tei)
{
if((controller < 0) || (controller >= ncontroller))
{
@ -160,72 +92,27 @@ init_controller_state(int controller, int ctrl_type, int card_type, int tei)
/* init controller tab */
if(ctrl_type == CTRL_PASSIVE)
{
if((card_type > CARD_TYPEP_UNK) &&
(card_type <= CARD_TYPEP_MAX))
{
isdn_ctrl_tab[controller].ctrl_type = ctrl_type;
isdn_ctrl_tab[controller].card_type = card_type;
isdn_ctrl_tab[controller].state = CTRL_UP;
isdn_ctrl_tab[controller].stateb1 = CHAN_IDLE;
isdn_ctrl_tab[controller].stateb2 = CHAN_IDLE;
isdn_ctrl_tab[controller].freechans = MAX_CHANCTRL;
isdn_ctrl_tab[controller].tei = tei;
isdn_ctrl_tab[controller].l1stat = LAYER_IDLE;
isdn_ctrl_tab[controller].l2stat = LAYER_IDLE;
DBGL(DL_RCCF, (log(LL_DBG, "init_controller_state: controller %d is %s",
controller,
name_of_controller(isdn_ctrl_tab[controller].ctrl_type,
isdn_ctrl_tab[controller].card_type))));
}
else
{
log(LL_ERR, "init_controller_state: unknown card type %d", card_type);
return(ERROR);
}
}
else if(ctrl_type == CTRL_DAIC)
{
isdn_ctrl_tab[controller].ctrl_type = ctrl_type;
isdn_ctrl_tab[controller].card_type = card_type;
isdn_ctrl_tab[controller].state = CTRL_DOWN;
isdn_ctrl_tab[controller].stateb1 = CHAN_IDLE;
isdn_ctrl_tab[controller].stateb2 = CHAN_IDLE;
isdn_ctrl_tab[controller].freechans = MAX_CHANCTRL;
isdn_ctrl_tab[controller].tei = tei;
isdn_ctrl_tab[controller].l1stat = LAYER_IDLE;
isdn_ctrl_tab[controller].l2stat = LAYER_IDLE;
memset(isdn_ctrl_tab[controller].device_name, 0,
sizeof(isdn_ctrl_tab[controller].device_name));
strncpy(isdn_ctrl_tab[controller].device_name,
devname,
sizeof(isdn_ctrl_tab[controller].device_name)-1);
memset(isdn_ctrl_tab[controller].controller, 0,
sizeof(isdn_ctrl_tab[controller].controller));
strncpy(isdn_ctrl_tab[controller].controller,
cardname,
sizeof(isdn_ctrl_tab[controller].controller)-1);
isdn_ctrl_tab[controller].present = 1;
isdn_ctrl_tab[controller].state = CTRL_UP;
isdn_ctrl_tab[controller].stateb1 = CHAN_IDLE;
isdn_ctrl_tab[controller].stateb2 = CHAN_IDLE;
isdn_ctrl_tab[controller].freechans = MAX_CHANCTRL;
isdn_ctrl_tab[controller].tei = tei;
isdn_ctrl_tab[controller].l1stat = LAYER_IDLE;
isdn_ctrl_tab[controller].l2stat = LAYER_IDLE;
DBGL(DL_RCCF, (log(LL_DBG, "init_controller_state: controller %d (%s) is %s",
controller, devname, cardname)));
log(LL_DMN, "init_controller_state: controller %d is %s",
controller,
name_of_controller(isdn_ctrl_tab[controller].ctrl_type,
isdn_ctrl_tab[controller].card_type));
}
else if(ctrl_type == CTRL_TINADD)
{
isdn_ctrl_tab[controller].ctrl_type = ctrl_type;
isdn_ctrl_tab[controller].card_type = 0;
isdn_ctrl_tab[controller].state = CTRL_DOWN;
isdn_ctrl_tab[controller].stateb1 = CHAN_IDLE;
isdn_ctrl_tab[controller].stateb2 = CHAN_IDLE;
isdn_ctrl_tab[controller].freechans = MAX_CHANCTRL;
isdn_ctrl_tab[controller].tei = tei;
isdn_ctrl_tab[controller].l1stat = LAYER_IDLE;
isdn_ctrl_tab[controller].l2stat = LAYER_IDLE;
log(LL_DMN, "init_controller_state: controller %d is %s",
controller,
name_of_controller(isdn_ctrl_tab[controller].ctrl_type,
isdn_ctrl_tab[controller].card_type));
}
else
{
log(LL_ERR, "init_controller_state: unknown controller type %d", ctrl_type);
return(ERROR);
}
return(GOOD);
}
@ -235,6 +122,8 @@ init_controller_state(int controller, int ctrl_type, int card_type, int tei)
void
init_active_controller(void)
{
/* XXX - replace by something usefull */
#if 0
int ret;
int unit = 0;
int controller;
@ -255,6 +144,7 @@ init_active_controller(void)
}
}
}
#endif
}
/*--------------------------------------------------------------------------*

View File

@ -27,7 +27,7 @@
* i4b daemon - curses fullscreen output
* -------------------------------------
*
* $Id: curses.c,v 1.1.1.1 2001/01/06 13:00:13 martin Exp $
* $Id: curses.c,v 1.2 2002/03/24 20:37:47 martin Exp $
*
* $FreeBSD$
*
@ -734,8 +734,7 @@ display_cards(void)
for (i = 0; i < ncontroller; i++)
{
mvwprintw(chan_w, 4+i, 2, " #%d %s", i,
name_of_controller(isdn_ctrl_tab[i].ctrl_type,
isdn_ctrl_tab[i].card_type));
isdn_ctrl_tab[i].controller);
}
wrefresh(chan_w);

View File

@ -27,7 +27,7 @@
* i4b daemon - main header file
* -----------------------------
*
* $Id: isdnd.h,v 1.4 2002/03/16 17:03:43 martin Exp $
* $Id: isdnd.h,v 1.5 2002/03/24 20:37:48 martin Exp $
*
* $FreeBSD$
*
@ -511,8 +511,9 @@ typedef struct cfg_entry {
* this struct describes state of controller with 2 b channels
*---------------------------------------------------------------------------*/
typedef struct isdn_ctrl_state {
int ctrl_type; /* type: active/passive */
int card_type; /* manufacturer (CARD_XXXX) */
char device_name[80]; /* device name, e.g. "isic0" */
char controller[80]; /* manufacturer/name */
int present; /* 0 = detached, 1 = available */
int protocol; /* ISDN D-channel protocol */
int state; /* controller state */
#define CTRL_DOWN 0 /* controller inoparable */
@ -791,7 +792,6 @@ void msg_l12stat_ind(msg_l12stat_ind_t *ml);
void msg_teiasg_ind(msg_teiasg_ind_t *mt);
void msg_proceeding_ind ( msg_proceeding_ind_t *mp );
void msg_packet_ind( msg_packet_ind_t *mp );
const char * name_of_controller(int ctrl_type, int card_type);
void next_state ( cfg_entry_t *cep, int event );
char * print_i4b_cause( cause_t code );
char * printstate ( cfg_entry_t *cep );

View File

@ -33,7 +33,7 @@
* i4b daemon - network monitor server module
* ------------------------------------------
*
* $Id: monitor.c,v 1.2 2002/03/18 22:49:57 martin Exp $
* $Id: monitor.c,v 1.3 2002/03/24 20:37:48 martin Exp $
*
* $FreeBSD$
*
@ -644,7 +644,7 @@ monitor_handle_connect(int sockfd, int is_local)
u_int8_t ictrl[I4B_MON_ICTRL_SIZE];
I4B_PREP_CMD(ictrl, I4B_MON_ICTRL_CODE);
I4B_PUT_STR(ictrl, I4B_MON_ICTRL_NAME, name_of_controller(isdn_ctrl_tab[i].ctrl_type, isdn_ctrl_tab[i].card_type));
I4B_PUT_STR(ictrl, I4B_MON_ICTRL_NAME, isdn_ctrl_tab[i].controller);
I4B_PUT_2B(ictrl, I4B_MON_ICTRL_BUSID, 0);
I4B_PUT_4B(ictrl, I4B_MON_ICTRL_FLAGS, 0);
I4B_PUT_4B(ictrl, I4B_MON_ICTRL_NCHAN, 2);

View File

@ -35,7 +35,7 @@
* trace.c - print traces of D (B) channel activity for isdn4bsd
* -------------------------------------------------------------
*
* $Id: trace.c,v 1.2 2001/03/24 18:08:11 martin Exp $
* $Id: trace.c,v 1.3 2002/03/24 20:37:49 martin Exp $
*
* $FreeBSD$
*
@ -196,8 +196,6 @@ main(int argc, char *argv[])
case 'u':
unit = atoi(optarg);
if(unit < 0 || unit >= MAX_CONTROLLERS)
usage();
break;
case 'x':
@ -218,14 +216,10 @@ main(int argc, char *argv[])
case 'R':
Rx = atoi(optarg);
if(Rx < 0 || Rx >= MAX_CONTROLLERS)
usage();
break;
case 'T':
Tx = atoi(optarg);
if(Tx < 0 || Tx >= MAX_CONTROLLERS)
usage();
break;
case '?':