added possibility to port specific debug, also added portspecific debugging to if,l2,l3,net. This might have created segfaults\! therefore i have tagged mISDNuser before with mISDNuser_1_0_2. i have tested most things but not all.

This commit is contained in:
crich 2006-07-18 13:50:03 +00:00
parent 3ce3fd90f5
commit 1a40af19c3
13 changed files with 262 additions and 257 deletions

View File

@ -41,7 +41,7 @@ setup_bchannel(bchannel_t *bc) {
eprint("wrong channel %d\n", bc->channel);
return(-EINVAL);
}
dprint(DBGM_BC,"%s:ch%d bst(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s:ch%d bst(%d)\n", __FUNCTION__,
bc->channel, bc->bstate);
if ((bc->bstate != BC_BSTATE_NULL) &&
(bc->bstate != BC_BSTATE_CLEANUP))
@ -76,7 +76,7 @@ setup_bchannel(bchannel_t *bc) {
static int
activate_bchannel(bchannel_t *bc)
{
dprint(DBGM_BC,"%s:ch%d bst(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s:ch%d bst(%d)\n", __FUNCTION__,
bc->channel, bc->bstate);
if (!bc->b_addr) {
wprint("%s:ch%d not setup\n", __FUNCTION__,
@ -97,7 +97,7 @@ activate_bchannel(bchannel_t *bc)
static int
deactivate_bchannel(bchannel_t *bc)
{
dprint(DBGM_BC,"%s:ch%d bst(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s:ch%d bst(%d)\n", __FUNCTION__,
bc->channel, bc->bstate);
if (!bc->b_addr) {
wprint("%s:ch%d not setup\n", __FUNCTION__,
@ -120,7 +120,7 @@ bc_cleanup(bchannel_t *bc)
{
int ret;
dprint(DBGM_BC,"%s:ch%d bst(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s:ch%d bst(%d)\n", __FUNCTION__,
bc->channel, bc->bstate);
if (!bc->b_addr) {
wprint("%s:ch%d not setup\n", __FUNCTION__,
@ -167,7 +167,7 @@ clear_bc(bchannel_t *bc)
static int
do_b_activated(bchannel_t *bc, mISDNuser_head_t *hh, msg_t *msg) {
dprint(DBGM_BC,"%s:ch%d state(%d/%d) Flags(%x) smsg(%p)\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s:ch%d state(%d/%d) Flags(%x) smsg(%p)\n", __FUNCTION__,
bc->channel, bc->cstate, bc->bstate, bc->Flags, bc->smsg);
clear_ibuffer(bc->rbuf);
if (!(bc->Flags & FLG_BC_KEEP_SEND))
@ -182,7 +182,7 @@ do_b_activated(bchannel_t *bc, mISDNuser_head_t *hh, msg_t *msg) {
static int
do_b_deactivated(bchannel_t *bc, mISDNuser_head_t *hh, msg_t *msg) {
dprint(DBGM_BC,"%s:ch%d Flags(%x) smsg(%p)\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s:ch%d Flags(%x) smsg(%p)\n", __FUNCTION__,
bc->channel, bc->Flags, bc->smsg);
bc_cleanup(bc);
free_msg(msg);
@ -205,7 +205,7 @@ do_b_setup_conf(bchannel_t *bc, mISDNuser_head_t *hh, msg_t *msg)
static int
do_b_cleanup_conf(bchannel_t *bc, mISDNuser_head_t *hh, msg_t *msg)
{
dprint(DBGM_BC,"%s:ch%d bst(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s:ch%d bst(%d)\n", __FUNCTION__,
bc->channel, bc->bstate);
bc->b_addr = 0;
if (bc->cstate == BC_CSTATE_NULL) {
@ -236,7 +236,7 @@ do_b_data_ind(bchannel_t *bc, mISDNuser_head_t *hh, msg_t *msg)
if (bc->bstate != BC_BSTATE_ACTIV)
return(-EBUSY);
dprint(DBGM_BCDATA, "%s:ch%d get %d bytes\n", __FUNCTION__,
dprint(DBGM_BCDATA, -1, "%s:ch%d get %d bytes\n", __FUNCTION__,
bc->channel, msg->len);
if (bc->rbuf) {
len = ibuf_freecount(bc->rbuf);
@ -249,7 +249,7 @@ do_b_data_ind(bchannel_t *bc, mISDNuser_head_t *hh, msg_t *msg)
sem_post(bc->rbuf->rsem);
} else
ret = -EINVAL;
dprint(DBGM_BCDATA, "%s: finish ret %d\n", __FUNCTION__, ret);
dprint(DBGM_BCDATA, -1, "%s: finish ret %d\n", __FUNCTION__, ret);
if (bc->Flags & FLG_BC_RECORD) {
if (bc->Flags & FLG_BC_RECORDING) {
write(bc->rrid, msg->data, msg->len);
@ -280,7 +280,7 @@ b_send(bchannel_t *bc)
goto out;
if (len > MAX_DATA_SIZE)
len = MAX_DATA_SIZE;
dprint(DBGM_BCDATA, "%s:ch%d %d bytes\n", __FUNCTION__, bc->channel, len);
dprint(DBGM_BCDATA, -1, "%s:ch%d %d bytes\n", __FUNCTION__, bc->channel, len);
bc->smsg = prep_l3data_msg(PH_DATA | REQUEST, bc->b_addr | FLG_MSG_DOWN,
0, len, NULL);
if (!bc->smsg) {
@ -322,10 +322,10 @@ add_nr(bchannel_t *bc, unsigned char *cpn)
memcpy(bc->nr + bc->nr[0] + 1, cpn + 2, *cpn -1);
bc->nr[0] += *cpn -1;
} else
dprint(DBGM_BC,"%s: cpn len %d\n", __FUNCTION__, *cpn);
dprint(DBGM_BC, -1,"%s: cpn len %d\n", __FUNCTION__, *cpn);
} else if (*cpn)
memcpy(bc->nr, cpn, *cpn + 1);
dprint(DBGM_BC,"%s: nr:%s\n", __FUNCTION__, &bc->nr[2]);
dprint(DBGM_BC, -1,"%s: nr:%s\n", __FUNCTION__, &bc->nr[2]);
return(0);
}
@ -337,7 +337,7 @@ send_setup_ack(bchannel_t *bc)
int len, ret;
unsigned char *p;
dprint(DBGM_BC,"%s: bc%d l3id(%x)\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s: bc%d l3id(%x)\n", __FUNCTION__,
bc->channel, bc->l3id);
msg = prep_l3data_msg(CC_SETUP_ACKNOWLEDGE | REQUEST, bc->l3id,
sizeof(SETUP_ACKNOWLEDGE_t), 128, NULL);
@ -384,7 +384,7 @@ send_setup(bchannel_t *bc)
unsigned char *p;
if (bc->cstate != BC_CSTATE_OCALL) {
dprint(DBGM_BC,"%s: bc%d state(%d/%d) not OCALL\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s: bc%d state(%d/%d) not OCALL\n", __FUNCTION__,
bc->channel, bc->cstate, bc->bstate);
return(-EINVAL);
}
@ -403,7 +403,7 @@ send_setup(bchannel_t *bc)
bc->bc[3] = 0xa3;
break;
default:
dprint(DBGM_BC,"%s: no protocol %x\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s: no protocol %x\n", __FUNCTION__,
bc->l1_prot);
free_msg(msg);
return(-ENOPROTOOPT);
@ -494,7 +494,7 @@ send_proceeding(bchannel_t *bc)
if (bc->manager->application) {
bc->Flags |= FLG_BC_APPLICATION;
len = bc->manager->application(bc->manager, PR_APP_ICALL, bc);
dprint(DBGM_BC, "%s: bc%d application ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d application ret(%d)\n", __FUNCTION__,
bc->channel, len);
}
return(ret);
@ -508,7 +508,7 @@ send_alert(bchannel_t *bc)
int len, ret;
unsigned char *p;
dprint(DBGM_BC, "%s: bc%d flg(%x) display(%s)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d flg(%x) display(%s)\n", __FUNCTION__,
bc->channel, bc->Flags, bc->display);
msg = prep_l3data_msg(CC_ALERTING | REQUEST, bc->l3id,
sizeof(ALERTING_t), 128, NULL);
@ -879,7 +879,7 @@ info_ind(bchannel_t *bc, void *arg)
set_tone(bc, FLG_BC_TONE_SILENCE);
add_nr(bc, info->CALLED_PN);
ret = match_nr(bc->manager, bc->nr, &bc->usednr);
dprint(DBGM_BC, "%s: match_nr ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: match_nr ret(%d)\n", __FUNCTION__,
ret);
if (!ret) {
send_proceeding(bc);
@ -951,7 +951,7 @@ setup_ind(bchannel_t *bc, int l3id, void *arg)
bc->Flags |= FLG_BC_PROGRESS;
add_nr(bc, setup->CALLED_PN);
ret = match_nr(bc->manager, bc->nr, &bc->usednr);
dprint(DBGM_BC, "%s: match_nr ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: match_nr ret(%d)\n", __FUNCTION__,
ret);
if (!ret) {
send_proceeding(bc);
@ -983,7 +983,7 @@ conn_ind(bchannel_t *bc, void *arg)
if ((bc->Flags & FLG_BC_APPLICATION) && bc->manager->application) {
setup_bchannel(bc);
ret = bc->manager->application(bc->manager, PR_APP_CONNECT, bc);
dprint(DBGM_BC, "%s: bc%d application ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d application ret(%d)\n", __FUNCTION__,
bc->channel, ret);
if (!ret) {
send_connect_ack(bc);
@ -1011,7 +1011,7 @@ alert_ind(bchannel_t *bc, void *arg)
bc->uu[0] = 0;
if ((bc->Flags & FLG_BC_APPLICATION) && bc->manager->application) {
ret = bc->manager->application(bc->manager, PR_APP_ALERT, bc);
dprint(DBGM_BC, "%s: bc%d application ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d application ret(%d)\n", __FUNCTION__,
bc->channel, ret);
}
return(0);
@ -1031,7 +1031,7 @@ facility_ind(bchannel_t *bc, void *arg)
}
if ((bc->Flags & FLG_BC_APPLICATION) && bc->manager->application) {
ret = bc->manager->application(bc->manager, PR_APP_FACILITY, bc);
dprint(DBGM_BC, "%s: bc%d application ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d application ret(%d)\n", __FUNCTION__,
bc->channel, ret);
}
return(0);
@ -1051,7 +1051,7 @@ userinfo_ind(bchannel_t *bc, void *arg)
}
if ((bc->Flags & FLG_BC_APPLICATION) && bc->manager->application) {
ret = bc->manager->application(bc->manager, PR_APP_USERUSER, bc);
dprint(DBGM_BC, "%s: bc%d application ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d application ret(%d)\n", __FUNCTION__,
bc->channel, ret);
}
return(0);
@ -1066,12 +1066,12 @@ disc_ind(bchannel_t *bc, void *arg)
if (disc->CAUSE) {
if (disc->CAUSE[0] >1) {
dprint(DBGM_BC, "%s: loc(%d) cause(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: loc(%d) cause(%d)\n", __FUNCTION__,
disc->CAUSE[1] & 0xf, disc->CAUSE[2] & 0x7f);
bc->cause_loc = disc->CAUSE[1] & 0xf;
bc->cause_val = disc->CAUSE[2] & 0x7f;
} else {
dprint(DBGM_BC, "%s: cause len %d\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: cause len %d\n", __FUNCTION__,
disc->CAUSE[0]);
cause = CAUSE_INVALID_CONTENTS;
}
@ -1096,7 +1096,7 @@ disc_ind(bchannel_t *bc, void *arg)
bc->uu[0] = 0;
if ((bc->Flags & FLG_BC_APPLICATION) && bc->manager->application) {
ret = bc->manager->application(bc->manager, PR_APP_HANGUP, bc);
dprint(DBGM_BC, "%s: bc%d application ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d application ret(%d)\n", __FUNCTION__,
bc->channel, ret);
}
return(0);
@ -1119,7 +1119,7 @@ rel_ind(bchannel_t *bc, void *arg)
bc->uu[0] = 0;
if (rel->CAUSE) {
if (rel->CAUSE[0] > 1) {
dprint(DBGM_BC, "%s: loc(%d) cause(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: loc(%d) cause(%d)\n", __FUNCTION__,
rel->CAUSE[1] & 0xf, rel->CAUSE[2] & 0x7f);
bc->cause_loc = rel->CAUSE[1] & 0xf;
bc->cause_val = rel->CAUSE[2] & 0x7f;
@ -1128,7 +1128,7 @@ rel_ind(bchannel_t *bc, void *arg)
}
if ((bc->Flags & FLG_BC_APPLICATION) && bc->manager->application) {
ret = bc->manager->application(bc->manager, PR_APP_CLEAR, bc);
dprint(DBGM_BC, "%s: bc%d application ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d application ret(%d)\n", __FUNCTION__,
bc->channel, ret);
}
clear_bc(bc);
@ -1155,7 +1155,7 @@ relcmpl_ind(bchannel_t *bc, void *arg)
bc->uu[0] = 0;
if (rc->CAUSE) {
if (rc->CAUSE[0] > 1) {
dprint(DBGM_BC, "%s: loc(%d) cause(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: loc(%d) cause(%d)\n", __FUNCTION__,
rc->CAUSE[1] & 0xf, rc->CAUSE[2] & 0x7f);
bc->cause_loc = rc->CAUSE[1] & 0xf;
bc->cause_val = rc->CAUSE[2] & 0x7f;
@ -1164,7 +1164,7 @@ relcmpl_ind(bchannel_t *bc, void *arg)
}
if ((bc->Flags & FLG_BC_APPLICATION) && bc->manager->application) {
ret = bc->manager->application(bc->manager, PR_APP_CLEAR, bc);
dprint(DBGM_BC, "%s: bc%d application ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d application ret(%d)\n", __FUNCTION__,
bc->channel, ret);
}
clear_bc(bc);
@ -1179,11 +1179,11 @@ relcr_ind(bchannel_t *bc, void *arg)
{
int ret, *err = arg;
dprint(DBGM_BC, "%s: bc%d cause(%x)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d cause(%x)\n", __FUNCTION__,
bc->channel, *err);
if ((bc->Flags & FLG_BC_APPLICATION) && bc->manager->application) {
ret = bc->manager->application(bc->manager, PR_APP_CLEAR, bc);
dprint(DBGM_BC, "%s: bc%d application ret(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: bc%d application ret(%d)\n", __FUNCTION__,
bc->channel, ret);
}
if (bc->cstate != BC_CSTATE_NULL) {
@ -1200,7 +1200,7 @@ cleanup_bchannel(void *arg)
{
bchannel_t *bc = arg;
dprint(DBGM_BC,"%s: bc %d\n", __FUNCTION__, bc->channel);
dprint(DBGM_BC, -1,"%s: bc %d\n", __FUNCTION__, bc->channel);
pthread_mutex_lock(&bc->lock);
msg_queue_purge(&bc->workq);
bc->smsg = NULL;
@ -1213,7 +1213,7 @@ cleanup_bchannel(void *arg)
if (!sem_trywait(&bc->work))
break;
pthread_mutex_unlock(&bc->lock);
dprint(DBGM_BC,"%s: bc %d end\n", __FUNCTION__, bc->channel);
dprint(DBGM_BC, -1,"%s: bc %d end\n", __FUNCTION__, bc->channel);
}
static void *
@ -1225,7 +1225,7 @@ main_bc_task(void *arg)
mISDNuser_head_t *hh;
pthread_cleanup_push(cleanup_bchannel, (void *)bc);
dprint(DBGM_BC,"%s bc %d\n", __FUNCTION__, bc->channel);
dprint(DBGM_BC, -1,"%s bc %d\n", __FUNCTION__, bc->channel);
while(1) {
sem_wait(&bc->work);
@ -1241,7 +1241,7 @@ main_bc_task(void *arg)
if (msg) {
hh = (mISDNuser_head_t *)msg->data;
msg_pull(msg, mISDNUSER_HEAD_SIZE);
dprint(DBGM_BC,"%s: bc%d st(%d/%d) prim(%x) dinfo(%x) len(%d)\n", __FUNCTION__,
dprint(DBGM_BC, -1,"%s: bc%d st(%d/%d) prim(%x) dinfo(%x) len(%d)\n", __FUNCTION__,
bc->channel, bc->cstate, bc->bstate, hh->prim, hh->dinfo, msg->len);
ret = -EINVAL;
switch(hh->prim) {
@ -1365,7 +1365,7 @@ init_bchannel(bchannel_t *bc, int channel)
pthread_mutex_init(&bc->lock, NULL);
sem_init (&bc->work, 0, 0);
ret = pthread_create(&bc->tid, NULL, main_bc_task, (void *)bc);
dprint(DBGM_BC, "%s: create bc%d thread %ld ret %d\n", __FUNCTION__,
dprint(DBGM_BC, -1, "%s: create bc%d thread %ld ret %d\n", __FUNCTION__,
channel, bc->tid, ret);
return(0);
}
@ -1373,7 +1373,7 @@ init_bchannel(bchannel_t *bc, int channel)
int
term_bchannel(bchannel_t *bc)
{
dprint(DBGM_BC, "%s: bc%d\n", __FUNCTION__, bc->channel);
dprint(DBGM_BC, -1, "%s: bc%d\n", __FUNCTION__, bc->channel);
bc->Flags |= FLG_BC_TERMINATE;
sem_post(&bc->work);
return(0);

View File

@ -85,7 +85,7 @@ debug_close(void)
}
int
dprint(unsigned int mask, const char *fmt, ...)
dprint(unsigned int mask, int port, const char *fmt, ...)
{
int ret = 0;
va_list args;
@ -98,7 +98,7 @@ dprint(unsigned int mask, const char *fmt, ...)
va_start(args, fmt);
if (debug_mask & mask) {
if (debug_file != stdout)
fprintf(debug_file, "%s ",tmp);
fprintf(debug_file, "%s P(%2d): ",tmp, port);
ret = vfprintf(debug_file, fmt, args);
if (debug_file != stdout)
fflush(debug_file);

View File

@ -63,7 +63,7 @@ alloc_msg(int size)
m->tail = m->data;
m->end = m->head + m->size;
m->len = 0;
dprint(DBGM_MSG,"%s: %d msg(%p)\n", __FUNCTION__,
dprint(DBGM_MSG, -1,"%s: %d msg(%p)\n", __FUNCTION__,
alloc_msg_cnt, m);
return(m);
}
@ -75,7 +75,7 @@ free_msg(msg_t *msg) {
wprint("free NULL msg\n");
return;
}
dprint(DBGM_MSG,"%s: %d/%d msg(%p) \n", __FUNCTION__,
dprint(DBGM_MSG, -1,"%s: %d/%d msg(%p) \n", __FUNCTION__,
alloc_msg_cnt, free_queue->len, msg);
if (msg->list) {
@ -89,7 +89,7 @@ free_msg(msg_t *msg) {
}
if (free_queue->len>=free_queue->maxlen) {
alloc_msg_cnt--;
dprint(DBGM_MSG, "free msg no free_queue %d/%d\n",
dprint(DBGM_MSG, -1, "free msg no free_queue %d/%d\n",
free_queue->len, free_queue->maxlen);
free(msg);
return;
@ -101,11 +101,11 @@ msg_t *
msg_copy(msg_t *msg) {
msg_t *nmsg;
dprint(DBGM_MSG,"%s: old(%p)\n", __FUNCTION__, msg);
dprint(DBGM_MSG, -1,"%s: old(%p)\n", __FUNCTION__, msg);
nmsg = alloc_msg(msg->size);
if (!nmsg)
return(NULL);
dprint(DBGM_MSG,"%s: new(%p) size(%d)\n", __FUNCTION__,
dprint(DBGM_MSG, -1,"%s: new(%p) size(%d)\n", __FUNCTION__,
nmsg, msg->size);
memcpy(nmsg, msg, sizeof(msg_t));
return(nmsg);

View File

@ -22,7 +22,7 @@ match_nr(manager_t *mgr, unsigned char *nx, nr_list_t **nrx)
return(3);
while(nr) {
p = nx + 2;
dprint(DBGM_MAN,"%s: cpn(%s) nr(%s)\n", __FUNCTION__,
dprint(DBGM_MAN, -1,"%s: cpn(%s) nr(%s)\n", __FUNCTION__,
p, nr->nr);
for(i=0;i<nr->len;i++) {
if (*p != nr->nr[i])
@ -49,12 +49,12 @@ manager2stack(void *dat, void *arg)
msg_t *msg = arg;
mISDNuser_head_t *hh;
dprint(DBGM_MAN, "%s:dat(%p) arg(%p)\n", __FUNCTION__,
dprint(DBGM_MAN, -1, "%s:dat(%p) arg(%p)\n", __FUNCTION__,
dat, arg);
if (!nst | !arg)
return(-EINVAL);
hh = (mISDNuser_head_t *)msg->data;
dprint(DBGM_MAN, "%s: prim(%x) dinfo(%x) msg->len(%d)\n", __FUNCTION__,
dprint(DBGM_MAN, -1, "%s: prim(%x) dinfo(%x) msg->len(%d)\n", __FUNCTION__,
hh->prim, hh->dinfo, msg->len);
if (hh->prim == (CC_NEW_CR | INDICATION)) /* high prio */
msg_queue_head(&nst->wqueue, arg);
@ -73,7 +73,7 @@ stack2manager(void *dat, void *arg) {
if (!msg || !mgr)
return(-EINVAL);
hh = (mISDNuser_head_t *)msg->data;
dprint(DBGM_MAN, "%s: prim(%x) dinfo(%x) msg->len(%d) bid(%x/%x)\n", __FUNCTION__,
dprint(DBGM_MAN, -1, "%s: prim(%x) dinfo(%x) msg->len(%d) bid(%x/%x)\n", __FUNCTION__,
hh->prim, hh->dinfo, msg->len, mgr->bc[0].l3id, mgr->bc[1].l3id);
if (hh->prim == (CC_SETUP | INDICATION)) {
SETUP_t *setup;
@ -133,7 +133,7 @@ appl2bc(manager_t *mgr, int prim, void *arg)
bchannel_t *bc = arg;
msg_t *msg;
dprint(DBGM_MAN, "%s(%p,%x,%p)\n", __FUNCTION__,
dprint(DBGM_MAN, -1, "%s(%p,%x,%p)\n", __FUNCTION__,
mgr, prim, arg);
if (!mgr || !bc)
return(-EINVAL);
@ -262,17 +262,17 @@ cleanup_manager(manager_t *mgr)
{
int ret, *retv;
dprint(DBGM_MAN,"%s\n", __FUNCTION__);
dprint(DBGM_MAN, -1,"%s\n", __FUNCTION__);
term_bchannel(&mgr->bc[0]);
term_bchannel(&mgr->bc[1]);
cleanup_Isdnl3(mgr->nst);
cleanup_Isdnl2(mgr->nst);
do_net_stack_cleanup(mgr->nst);
ret = pthread_join(mgr->bc[0].tid, (void *)&retv);
dprint(DBGM_MAN,"%s: join ret(%d) bc1 retv(%p)\n", __FUNCTION__,
dprint(DBGM_MAN, -1,"%s: join ret(%d) bc1 retv(%p)\n", __FUNCTION__,
ret, retv);
ret = pthread_join(mgr->bc[1].tid, (void *)&retv);
dprint(DBGM_MAN,"%s: join ret(%d) bc2 retv(%p)\n", __FUNCTION__,
dprint(DBGM_MAN, -1,"%s: join ret(%d) bc2 retv(%p)\n", __FUNCTION__,
ret, retv);
while(mgr->nrlist) {
nr_list_t *nr = mgr->nrlist;

View File

@ -41,7 +41,7 @@ do_net_stack_setup(net_stack_t *nst)
for (i=1; i<=cnt; i++) {
ret = mISDN_get_stack_info(nst->device, i, buf, 1024);
if (ret<=0)
dprint(DBGM_NET, "cannot get stackinfo err: %d\n", ret);
dprint(DBGM_NET, nst->cardnr, "cannot get stackinfo err: %d\n", ret);
stinf = (stack_info_t *)&frm->data.p;
// mISDNprint_stack_info(stdout, stinf);
if ((stinf->pid.protocol[0] == ISDN_PID_L0_NT_S0) &&
@ -51,14 +51,14 @@ do_net_stack_setup(net_stack_t *nst)
nst->d_stid = stinf->id;
nst->b_stid[0] = stinf->child[0];
nst->b_stid[1] = stinf->child[1];
dprint(DBGM_NET, "bst1 %x bst2 %x\n",
dprint(DBGM_NET, nst->cardnr, "bst1 %x bst2 %x\n",
nst->b_stid[0], nst->b_stid[1]);
break;
} else
dprint(DBGM_NET, "stack %d instcnt is %d\n",
dprint(DBGM_NET, nst->cardnr, "stack %d instcnt is %d\n",
i, stinf->instcnt);
} else
dprint(DBGM_NET, "stack %d protocol %x\n",
dprint(DBGM_NET, nst->cardnr, "stack %d protocol %x\n",
i, stinf->pid.protocol[0]);
}
if (i>cnt) {
@ -72,7 +72,7 @@ do_net_stack_setup(net_stack_t *nst)
eprint("no layer1 id found\n");
return(-EINVAL);
}
dprint(DBGM_NET, "found NT card stack card%d dst(%x) l1(%x)\n",
dprint(DBGM_NET, nst->cardnr, "found NT card stack card%d dst(%x) l1(%x)\n",
nst->cardnr, nst->d_stid, nst->l1_id);
memset(&li, 0, sizeof(layer_info_t));
strcpy(&li.name[0], "net l2");
@ -101,7 +101,7 @@ do_net_stack_setup(net_stack_t *nst)
return(ret);
}
#endif
dprint(DBGM_NET, "add nt net layer2 %x\n",
dprint(DBGM_NET, nst->cardnr, "add nt net layer2 %x\n",
nst->l2_id);
msg_queue_init(&nst->down_queue);
msg_queue_init(&nst->rqueue);
@ -175,9 +175,9 @@ init_timer(itimer_t *it, net_stack_t *nst)
}
nst->tlist = it;
}
dprint(DBGM_NET, "init timer(%x)\n", it->id);
dprint(DBGM_NET, nst->cardnr, "init timer(%x)\n", it->id);
if (test_bit(FLG_TIMER_RUNING, &it->Flags))
dprint(DBGM_NET, "init timer(%x) while running\n", it->id);
dprint(DBGM_NET, nst->cardnr, "init timer(%x) while running\n", it->id);
ret = mISDN_write_frame(it->nst->device, &frm, it->id,
MGR_INITTIMER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
if (ret)
@ -219,7 +219,7 @@ add_timer(itimer_t *it)
return(-ENODEV);
if (timer_pending(it))
return(-EBUSY);
dprint(DBGM_NET, "add timer(%x)\n", it->id);
dprint(DBGM_NET, it->nst->cardnr, "add timer(%x)\n", it->id);
test_and_set_bit(FLG_TIMER_RUNING, &it->Flags);
ret = mISDN_write_frame(it->nst->device, &frm, it->id,
MGR_ADDTIMER | REQUEST, it->expires, 0, NULL, TIMEOUT_1SEC);
@ -239,7 +239,7 @@ del_timer(itimer_t *it)
return(-ENODEV);
if (!get_timer(it->nst, it->id))
return(-ENODEV);
dprint(DBGM_NET, "del timer(%x)\n", it->id);
dprint(DBGM_NET, it->nst->cardnr, "del timer(%x)\n", it->id);
test_and_clear_bit(FLG_TIMER_RUNING, &it->Flags);
ret = mISDN_write_frame(it->nst->device, &frm, it->id,
MGR_DELTIMER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
@ -264,7 +264,7 @@ handle_timer(net_stack_t *nst, int id)
it = get_timer(nst, id);
if (!it)
return(-ENODEV);
// dprint(DBGM_NET, "handle timer(%x)\n", it->id);
// dprint(DBGM_NET, nst->cardnr, "handle timer(%x)\n", it->id);
test_and_clear_bit(FLG_TIMER_RUNING, &it->Flags);
if (it->function)
ret = it->function(it->data);
@ -278,7 +278,7 @@ write_dmsg(net_stack_t *nst, msg_t *msg)
mISDNuser_head_t *hh;
hh = (mISDNuser_head_t *)msg->data;
dprint(DBGM_NET, "%s: msg(%p) len(%d) pr(%x) di(%x)\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr, "%s: msg(%p) len(%d) pr(%x) di(%x)\n", __FUNCTION__,
msg, msg->len, hh->prim, hh->dinfo);
msg_pull(msg, mISDNUSER_HEAD_SIZE);
frm = (iframe_t *)msg_push(msg, mISDN_HEADER_LEN);
@ -302,7 +302,7 @@ write_dmsg(net_stack_t *nst, msg_t *msg)
int
phd_conf(net_stack_t *nst, iframe_t *frm, msg_t *msg)
{
dprint(DBGM_NET, "%s: di(%x)\n", __FUNCTION__, frm->dinfo);
dprint(DBGM_NET, nst->cardnr, "%s: di(%x)\n", __FUNCTION__, frm->dinfo);
if (frm->dinfo == (int)nst->phd_down_msg) {
free_msg(msg);
nst->phd_down_msg = msg_dequeue(&nst->down_queue);
@ -345,14 +345,14 @@ do_net_read(net_stack_t *nst)
__msg_trim(msg, ret);
frm = (iframe_t *)msg->data;
dprint(DBGM_NET,"%s: prim(%x) addr(%x)\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr,"%s: prim(%x) addr(%x)\n", __FUNCTION__,
frm->prim, frm->addr);
switch (frm->prim) {
case MGR_INITTIMER | CONFIRM:
case MGR_ADDTIMER | CONFIRM:
case MGR_DELTIMER | CONFIRM:
case MGR_REMOVETIMER | CONFIRM:
// dprint(DBGM_NET, "timer(%x) cnf(%x)\n",
// dprint(DBGM_NET, nst->cardnr, "timer(%x) cnf(%x)\n",
// frm->addr, frm->prim);
free_msg(msg);
return(0);
@ -387,7 +387,7 @@ do_readmsg(net_stack_t *nst, msg_t *msg)
return(-EINVAL);
frm = (iframe_t *)msg->data;
dprint(DBGM_NET,"%s: prim(%x) addr(%x)\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr,"%s: prim(%x) addr(%x)\n", __FUNCTION__,
frm->prim, frm->addr);
if (frm->prim == (MGR_TIMER | INDICATION)) {
mISDN_write_frame(nst->device, msg->data, frm->addr,
@ -411,7 +411,7 @@ do_readmsg(net_stack_t *nst, msg_t *msg)
} else if (nst->b_stid[1] == frm->addr) {
ret = b_message(nst, 1, frm, msg);
} else if (frm->prim == (MGR_DELLAYER | CONFIRM)) {
dprint(DBGM_NET,"%s: MGR_DELLAYER CONFIRM addr(%x)\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr,"%s: MGR_DELLAYER CONFIRM addr(%x)\n", __FUNCTION__,
frm->addr);
free_msg(msg);
return(0);
@ -434,7 +434,7 @@ setup_bchannel(net_stack_t *nst, mISDNuser_head_t *hh, msg_t *msg) {
return(-EINVAL);
}
ch = hh->dinfo -1;
dprint(DBGM_NET,"%s:ch%d\n", __FUNCTION__, hh->dinfo);
dprint(DBGM_NET, nst->cardnr,"%s:ch%d\n", __FUNCTION__, hh->dinfo);
msg_pull(msg, mISDNUSER_HEAD_SIZE);
id = (int *)msg->data;
nst->bcid[ch] = *id;
@ -463,7 +463,7 @@ setup_bchannel(net_stack_t *nst, mISDNuser_head_t *hh, msg_t *msg) {
}
if (ret) {
nst->b_addr[ch] = ret;
dprint(DBGM_NET,"%s: b_address%d %08x\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr,"%s: b_address%d %08x\n", __FUNCTION__,
hh->dinfo, ret);
ret = mISDN_set_stack(nst->device, nst->b_stid[ch],
pid);
@ -507,7 +507,7 @@ cleanup_bc(net_stack_t *nst, mISDNuser_head_t *hh, msg_t *msg)
free_msg(msg);
return(0);
}
dprint(DBGM_NET,"%s:ch%d\n", __FUNCTION__, ch + 1);
dprint(DBGM_NET, nst->cardnr,"%s:ch%d\n", __FUNCTION__, ch + 1);
mISDN_clear_stack(nst->device, nst->b_stid[ch]);
if (nst->b_addr[ch])
mISDN_write_frame(nst->device, buf, nst->b_addr[ch],
@ -525,7 +525,7 @@ l1_request(net_stack_t *nst, mISDNuser_head_t *hh, msg_t *msg)
iframe_t *frm;
hh = (mISDNuser_head_t *)msg->data;
dprint(DBGM_NET, "%s: msg(%p) len(%d) pr(%x) di(%x)\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr, "%s: msg(%p) len(%d) pr(%x) di(%x)\n", __FUNCTION__,
msg, msg->len, hh->prim, hh->dinfo);
msg_pull(msg, mISDNUSER_HEAD_SIZE);
frm = (iframe_t *)msg_push(msg, mISDN_HEADER_LEN);
@ -550,7 +550,7 @@ do_writemsg(net_stack_t *nst, msg_t *msg)
if (!nst || !msg)
return(-EINVAL);
hh = (mISDNuser_head_t *)msg->data;
dprint(DBGM_NET,"%s: prim(%x) dinfo(%x)\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr,"%s: prim(%x) dinfo(%x)\n", __FUNCTION__,
hh->prim, hh->dinfo);
if ((hh->prim & LAYER_MASK) == MSG_L1_PRIM) {
ret = l1_request(nst, hh, msg);
@ -593,11 +593,11 @@ main_readloop(void *arg)
tid = pthread_self();
dprint(DBGM_NET, "%s: tid %ld\n", __FUNCTION__, tid);
dprint(DBGM_NET, nst->cardnr, "%s: tid %ld\n", __FUNCTION__, tid);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
while(lp) {
// dprint(DBGM_NET, "%s: begin dev %d\n", __FUNCTION__, nst->device);
// dprint(DBGM_NET, nst->cardnr, "%s: begin dev %d\n", __FUNCTION__, nst->device);
maxfd = nst->device;
FD_ZERO(&rfd);
FD_SET(nst->device, &rfd);
@ -610,7 +610,7 @@ restart:
if (errno == EINTR) {
if (test_bit(FLG_NST_TERMINATION, &nst->flag))
break;
dprint(DBGM_NET, "%s: select restart\n", __FUNCTION__);
dprint(DBGM_NET, nst->cardnr, "%s: select restart\n", __FUNCTION__);
goto restart;
}
wprint("%s: error(%d) in select %s\n", __FUNCTION__,
@ -621,15 +621,15 @@ restart:
if (FD_ISSET(nst->device, &rfd)) {
ret = do_net_read(nst);
if (ret) {
dprint(DBGM_NET, "%s: rdfunc ret(%d)\n", __FUNCTION__, ret);
dprint(DBGM_NET, nst->cardnr, "%s: rdfunc ret(%d)\n", __FUNCTION__, ret);
}
}
if (FD_ISSET(nst->device, &efd)) {
dprint(DBGM_NET, "%s: exception\n", __FUNCTION__);
dprint(DBGM_NET, nst->cardnr, "%s: exception\n", __FUNCTION__);
}
}
}
dprint(DBGM_NET,"%s: fall trough, abort\n", __FUNCTION__);
dprint(DBGM_NET, nst->cardnr,"%s: fall trough, abort\n", __FUNCTION__);
pthread_mutex_lock(&nst->lock);
test_and_set_bit(FLG_NST_READER_ABORT, &nst->flag);
pthread_mutex_unlock(&nst->lock);
@ -646,10 +646,10 @@ do_netthread(void *arg) {
/* create reader thread */
tid = pthread_self();
dprint(DBGM_NET, "%s: tid %ld\n", __FUNCTION__, tid);
dprint(DBGM_NET, nst->cardnr, "%s: tid %ld\n", __FUNCTION__, tid);
ret = pthread_create(&nst->reader, NULL, main_readloop, (void *)nst);
tid = pthread_self();
dprint(DBGM_NET, "%s: tid %ld crated %ld\n", __FUNCTION__, tid, nst->reader);
dprint(DBGM_NET, nst->cardnr, "%s: tid %ld crated %ld\n", __FUNCTION__, tid, nst->reader);
if (ret) {
eprint("%s: cannot create reader %d\n", __FUNCTION__,
ret);
@ -681,20 +681,20 @@ do_netthread(void *arg) {
pthread_mutex_lock(&nst->lock);
if (test_and_clear_bit(FLG_NST_READER_ABORT, &nst->flag)) {
pthread_mutex_unlock(&nst->lock);
dprint(DBGM_NET,"%s: reader aborted\n", __FUNCTION__);
dprint(DBGM_NET, nst->cardnr,"%s: reader aborted\n", __FUNCTION__);
ret = pthread_join(nst->reader, &retval);
dprint(DBGM_NET,"%s: join ret(%d) reader retval %p\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr,"%s: join ret(%d) reader retval %p\n", __FUNCTION__,
ret, retval);
break;
}
if (test_bit(FLG_NST_TERMINATION, &nst->flag)) {
pthread_mutex_unlock(&nst->lock);
dprint(DBGM_NET,"%s: reader cancel\n", __FUNCTION__);
dprint(DBGM_NET, nst->cardnr,"%s: reader cancel\n", __FUNCTION__);
ret = pthread_cancel(nst->reader);
dprint(DBGM_NET,"%s: cancel reader ret(%d)\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr,"%s: cancel reader ret(%d)\n", __FUNCTION__,
ret);
ret = pthread_join(nst->reader, &retval);
dprint(DBGM_NET,"%s: join ret(%d) reader retval %p\n", __FUNCTION__,
dprint(DBGM_NET, nst->cardnr,"%s: join ret(%d) reader retval %p\n", __FUNCTION__,
ret, retval);
break;
}

View File

@ -1,4 +1,4 @@
/* $Id: net_l2.c,v 1.4 2006/03/06 13:08:28 keil Exp $
/* $Id: net_l2.c,v 1.5 2006/07/18 13:50:03 crich Exp $
*
* Author Karsten Keil (keil@isdn4linux.de)
*
@ -13,7 +13,7 @@
#include "helper.h"
// #include "debug.h"
const char *l2_revision = "$Revision: 1.4 $";
const char *l2_revision = "$Revision: 1.5 $";
static void l2m_debug(struct FsmInst *fi, char *fmt, ...);
@ -105,7 +105,7 @@ l2down_msg(layer2_t *l2, msg_t *msg) {
ret = write_dmsg(l2->nst, msg);
if (ret)
dprint(DBGM_L2, "l2down_msg: error %d\n", ret);
dprint(DBGM_L2, l2->nst->cardnr, "l2down_msg: error %d\n", ret);
return(ret);
}
@ -135,7 +135,7 @@ static int
l2mgr(layer2_t *l2, u_int prim, void *arg) {
long c = (long)arg;
dprint(DBGM_L2, "l2mgr: prim %x %c\n", prim, (char)c);
dprint(DBGM_L2, l2->nst->cardnr, "l2mgr: prim %x %c\n", prim, (char)c);
return(0);
}
@ -182,7 +182,7 @@ ReleaseWin(layer2_t *l2)
int cnt;
if((cnt = freewin(l2)))
dprint(DBGM_L2, "isdnl2 freed %d msguffs in release\n", cnt);
dprint(DBGM_L2, l2->nst->cardnr, "isdnl2 freed %d msguffs in release\n", cnt);
}
inline unsigned int
@ -438,7 +438,7 @@ send_uframe(layer2_t *l2, msg_t *msg, u_char cmd, u_char cr)
else if ((msg = alloc_msg(i + mISDNUSER_HEAD_SIZE)))
msg_reserve(msg, mISDNUSER_HEAD_SIZE);
else {
dprint(DBGM_L2,"%s: can't alloc msguff\n", __FUNCTION__);
dprint(DBGM_L2, l2->nst->cardnr,"%s: can't alloc msguff\n", __FUNCTION__);
return;
}
memcpy(msg_put(msg, i), tmp, i);
@ -924,7 +924,7 @@ enquiry_cr(layer2_t *l2, u_char typ, u_char cr, u_char pf)
} else
tmp[i++] = (l2->vr << 5) | typ | (pf ? 0x10 : 0);
if (!(msg = alloc_msg(i + mISDNUSER_HEAD_SIZE))) {
dprint(DBGM_L2, "isdnl2 can't alloc sbbuff for enquiry_cr\n");
dprint(DBGM_L2, l2->nst->cardnr, "isdnl2 can't alloc sbbuff for enquiry_cr\n");
return;
} else
msg_reserve(msg, mISDNUSER_HEAD_SIZE);
@ -1294,7 +1294,7 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
p1 = (l2->vs - l2->va) % 8;
p1 = (p1 + l2->sow) % l2->window;
if (l2->windowar[p1]) {
dprint(DBGM_L2, "isdnl2 try overwrite ack queue entry %d\n",
dprint(DBGM_L2, l2->nst->cardnr, "isdnl2 try overwrite ack queue entry %d\n",
p1);
free_msg(l2->windowar[p1]);
}
@ -1317,13 +1317,13 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
if (p1 >= i)
memcpy(msg_push(msg, i), header, i);
else {
dprint(DBGM_L2,
dprint(DBGM_L2, l2->nst->cardnr,
"isdnl2 pull_iqueue msg header(%d/%d) too short\n", i, p1);
omsg = msg;
msg = alloc_msg(omsg->len + i + mISDNUSER_HEAD_SIZE);
if (!msg) {
free_msg(omsg);
dprint(DBGM_L2,"%s: no msg mem\n", __FUNCTION__);
dprint(DBGM_L2, l2->nst->cardnr,"%s: no msg mem\n", __FUNCTION__);
return;
}
msg_reserve(msg, mISDNUSER_HEAD_SIZE);
@ -1707,7 +1707,7 @@ ph_data_mux(net_stack_t *nst, iframe_t *frm, msg_t *msg)
datap = msg_pull(msg, mISDN_HEADER_LEN);
if (msg->len <= 2) {
dprint(DBGM_L2, "%s: msg (%d) too short\n", __FUNCTION__,
dprint(DBGM_L2, nst->cardnr, "%s: msg (%d) too short\n", __FUNCTION__,
msg->len);
msg_push(msg, mISDN_HEADER_LEN);
return(ret);
@ -1715,30 +1715,30 @@ ph_data_mux(net_stack_t *nst, iframe_t *frm, msg_t *msg)
psapi = *datap++;
ptei = *datap++;
if ((psapi & 1) || !(ptei & 1)) {
dprint(DBGM_L2, "l2 D-channel frame wrong EA0/EA1\n");
dprint(DBGM_L2, nst->cardnr, "l2 D-channel frame wrong EA0/EA1\n");
msg_push(msg, mISDN_HEADER_LEN);
return(ret);
}
psapi >>= 2;
ptei >>= 1;
dprint(DBGM_L2, "%s: sapi(%d) tei(%d)\n", __FUNCTION__, psapi, ptei);
dprint(DBGM_L2, nst->cardnr, "%s: sapi(%d) tei(%d)\n", __FUNCTION__, psapi, ptei);
if (ptei == GROUP_TEI) {
if (psapi == TEI_SAPI) {
hh = (mISDNuser_head_t *)msg_push(msg, mISDNUSER_HEAD_SIZE);
hh->prim = MDL_UNITDATA | INDICATION;
if (nst->feature & FEATURE_NET_PTP) {
dprint(DBGM_L2, "%s: tei management not enabled for PTP\n", __FUNCTION__);
dprint(DBGM_L2, nst->cardnr, "%s: tei management not enabled for PTP\n", __FUNCTION__);
return(-EINVAL);
}
return(tei_mux(nst, msg));
} else {
dprint(DBGM_L2, "%s: unknown tei(%d) msg\n", __FUNCTION__,
dprint(DBGM_L2, nst->cardnr, "%s: unknown tei(%d) msg\n", __FUNCTION__,
ptei);
}
}
l2 = select_l2(nst, psapi, ptei);
if (!l2) {
dprint(DBGM_L2, "%s: no l2 for sapi(%d) tei(%d)\n", __FUNCTION__,
dprint(DBGM_L2, nst->cardnr, "%s: no l2 for sapi(%d) tei(%d)\n", __FUNCTION__,
psapi, ptei);
return(-ENXIO);
}
@ -1770,7 +1770,7 @@ ph_data_mux(net_stack_t *nst, iframe_t *frm, msg_t *msg)
c = 'L';
}
if (c) {
dprint(DBGM_L2, "l2 D-channel frame error %c\n",c);
dprint(DBGM_L2, l2->nst->cardnr, "l2 D-channel frame error %c\n",c);
FsmEvent(&l2->l2m, EV_L2_FRAME_ERROR, (void *)(long)c);
}
if (ret)
@ -1785,8 +1785,8 @@ msg_mux(net_stack_t *nst, iframe_t *frm, msg_t *msg)
int ret = -EINVAL;
msg_t *nmsg;
dprint(DBGM_L2, "%s: msg len(%d)\n", __FUNCTION__, msg->len);
dprint(DBGM_L2, "%s: adr(%x) pr(%x) di(%x) len(%d)\n", __FUNCTION__,
dprint(DBGM_L2, nst->cardnr, "%s: msg len(%d)\n", __FUNCTION__, msg->len);
dprint(DBGM_L2, nst->cardnr, "%s: adr(%x) pr(%x) di(%x) len(%d)\n", __FUNCTION__,
frm->addr, frm->prim, frm->dinfo, frm->len);
l2 = nst->layer2;
while(l2) {
@ -1852,7 +1852,7 @@ l2muxer(net_stack_t *nst, msg_t *msg)
ret = msg_mux(nst, frm, msg);
break;
default:
dprint(DBGM_L2, "%s: pr %x\n", __FUNCTION__, frm->prim);
dprint(DBGM_L2, nst->cardnr, "%s: pr %x\n", __FUNCTION__, frm->prim);
break;
}
return(ret);
@ -1869,11 +1869,11 @@ l2from_up(net_stack_t *nst, msg_t *msg) {
hh = (mISDNuser_head_t *)msg->data;
if (msg->len < mISDN_FRAME_MIN)
return(ret);
dprint(DBGM_L2, "%s: prim(%x) dinfo(%x)\n", __FUNCTION__,
dprint(DBGM_L2, nst->cardnr, "%s: prim(%x) dinfo(%x)\n", __FUNCTION__,
hh->prim, hh->dinfo);
l2 = select_l2(nst, SAPITEI(hh->dinfo));
if (!l2) {
dprint(DBGM_L2, "%s: no l2 for sapi(%d) tei(%d)\n", __FUNCTION__,
dprint(DBGM_L2, l2->nst->cardnr, "%s: no l2 for sapi(%d) tei(%d)\n", __FUNCTION__,
SAPITEI(hh->dinfo));
return(-ENXIO);
}
@ -1932,7 +1932,7 @@ tei_l2(layer2_t *l2, msg_t *msg)
if (!l2 || !msg)
return(ret);
dprint(DBGM_L2, "%s: prim(%x)\n", __FUNCTION__, hh->prim);
dprint(DBGM_L2, l2->nst->cardnr, "%s: prim(%x)\n", __FUNCTION__, hh->prim);
if (msg->len < mISDN_FRAME_MIN)
return(ret);
switch(hh->prim) {
@ -1963,14 +1963,14 @@ l2m_debug(struct FsmInst *fi, char *fmt, ...)
va_start(args, fmt);
vsprintf(tbuf, fmt, args);
dprint(DBGM_L2, "L2 %s\n", tbuf);
dprint(DBGM_L2, fi->nst->cardnr, "L2 %s\n", tbuf);
va_end(args);
}
static void
release_l2(layer2_t *l2)
{
dprint(DBGM_L2, "%s: sapi(%d) tei(%d) state(%d)\n", __FUNCTION__,
dprint(DBGM_L2, l2->nst->cardnr, "%s: sapi(%d) tei(%d) state(%d)\n", __FUNCTION__,
l2->sapi, l2->tei, l2->l2m.state);
FsmRemoveTimer(&l2->t200);
FsmRemoveTimer(&l2->t203);
@ -1988,14 +1988,14 @@ int
tei0_active(layer2_t *l2)
{
while(l2) {
dprint(DBGM_L2, "checking l2 with tei=%d, sapi=%d\n", l2->tei, l2->sapi);
dprint(DBGM_L2, l2->nst->cardnr, "checking l2 with tei=%d, sapi=%d\n", l2->tei, l2->sapi);
if (l2->tei == 0 && l2->sapi == 0)
break;
l2 = l2->next;
}
if (!l2)
return(0);
dprint(DBGM_L2, "checking l2 with state=%d\n", l2->l2m.state);
dprint(DBGM_L2, l2->nst->cardnr, "checking l2 with state=%d\n", l2->l2m.state);
if (l2->l2m.state >= ST_L2_7)
return(1);
return(0);
@ -2007,7 +2007,7 @@ new_dl2(net_stack_t *nst, int tei) {
layer2_t *nl2;
if (!(nl2 = malloc(sizeof(layer2_t)))) {
dprint(DBGM_L2, "malloc layer2 failed\n");
dprint(DBGM_L2, nst->cardnr, "malloc layer2 failed\n");
return(NULL);
}
memset(nl2, 0, sizeof(layer2_t));
@ -2064,14 +2064,14 @@ int Isdnl2Init(net_stack_t *nst)
nst->l3_l2 = l2from_up;
l2 = new_dl2(nst, 127);
if (!l2) {
dprint(DBGM_L2, "%s: failed to create L2-instance with TEI 127\n", __FUNCTION__);
dprint(DBGM_L2, l2->nst->cardnr, "%s: failed to create L2-instance with TEI 127\n", __FUNCTION__);
cleanup:
cleanup_Isdnl2(nst);
return(-ENOMEM);
}
l2 = new_dl2(nst, 0);
if (!l2) {
dprint(DBGM_L2, "%s: failed to create L2-instance with TEI 0\n", __FUNCTION__);
dprint(DBGM_L2, l2->nst->cardnr, "%s: failed to create L2-instance with TEI 0\n", __FUNCTION__);
goto cleanup;
}
if (!(nst->feature & FEATURE_NET_PTP)) {
@ -2087,7 +2087,7 @@ int Isdnl2Init(net_stack_t *nst)
void cleanup_Isdnl2(net_stack_t *nst)
{
if(nst->layer2) {
dprint(DBGM_L2, "%s: l2 list not empty\n", __FUNCTION__);
dprint(DBGM_L2, nst->cardnr, "%s: l2 list not empty\n", __FUNCTION__);
while(nst->layer2)
release_l2(nst->layer2);
}

View File

@ -1,4 +1,4 @@
/* $Id: net_l3.c,v 1.8 2006/06/16 10:02:50 crich Exp $
/* $Id: net_l3.c,v 1.9 2006/07/18 13:50:03 crich Exp $
*
* Author Karsten Keil (keil@isdn4linux.de)
*
@ -16,7 +16,7 @@
#include "helper.h"
// #include "debug.h"
const char *l3_revision = "$Revision: 1.8 $";
const char *l3_revision = "$Revision: 1.9 $";
#define PROTO_DIS_EURO 8
@ -89,7 +89,7 @@ display_NR_IE(u_char *p, char *head1, char *head2)
while(len--)
tp += sprintf(tp, "%c", *p++);
}
dprint(DBGM_L3, "%s%s %s\n", head1, head2, txt);
dprint(DBGM_L3, -1, "%s%s %s\n", head1, head2, txt);
}
static void
@ -103,7 +103,7 @@ l3_debug(layer3_t *l3, char *fmt, ...)
p += sprintf(p, "l3 ");
p += vsprintf(p, fmt, args);
va_end(args);
dprint(DBGM_L3, "%s\n", buf);
dprint(DBGM_L3, l3->nst->cardnr, "%s\n", buf);
}
static int
@ -166,7 +166,11 @@ int
L3AddTimer(L3Timer_t *t, int millisec, int timer_nr)
{
if (timer_pending(&t->tl)) {
dprint(DBGM_L3, "L3AddTimer: timer already active!\n");
if (t->pc && t->pc->l3)
dprint(DBGM_L3, t->pc->l3->nst->cardnr, "L3AddTimer: timer already active!\n");
else
dprint(DBGM_L3, 0, "L3AddTimer: timer already active!\n");
return -1;
}
init_timer(&t->tl, t->pc->l3->nst);
@ -181,7 +185,8 @@ StopAllL3Timer(layer3_proc_t *pc)
{
L3DelTimer(&pc->timer1);
L3DelTimer(&pc->timer2);
dprint(DBGM_L3, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
dprint(DBGM_L3, pc->l3->nst->cardnr, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
#warning also remove flags:
test_and_clear_bit(FLG_L3P_TIMER303_1, &pc->Flags);
test_and_clear_bit(FLG_L3P_TIMER308_1, &pc->Flags);
@ -195,11 +200,11 @@ RemoveAllL3Timer(layer3_proc_t *pc)
ret = remove_timer(&pc->timer1.tl);
if (ret)
dprint(DBGM_L3, "RemoveL3Timer1: ret %d\n", ret);
dprint(DBGM_L3, pc->l3->nst->cardnr, "RemoveL3Timer1: ret %d\n", ret);
ret = remove_timer(&pc->timer2.tl);
dprint(DBGM_L3, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
dprint(DBGM_L3, pc->l3->nst->cardnr, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
if (ret)
dprint(DBGM_L3, "RemoveL3Timer2: ret %d\n", ret);
dprint(DBGM_L3, pc->l3->nst->cardnr, "RemoveL3Timer2: ret %d\n", ret);
#warning also remove flags:
test_and_clear_bit(FLG_L3P_TIMER303_1, &pc->Flags);
test_and_clear_bit(FLG_L3P_TIMER308_1, &pc->Flags);
@ -233,10 +238,10 @@ find_proc(layer3_proc_t *master, int ces, int cr)
layer3_proc_t *p = master;
layer3_proc_t *cp;
dprint(DBGM_L3, "%s: ces(%x) cr(%x)\n", __FUNCTION__,
dprint(DBGM_L3, master?master->l3->nst->cardnr:0, "%s: ces(%x) cr(%x)\n", __FUNCTION__,
ces, cr);
while(p) {
dprint(DBGM_L3, "%s: proc %p ces(%x) cr(%x)\n", __FUNCTION__,
dprint(DBGM_L3, p->l3->nst->cardnr, "%s: proc %p ces(%x) cr(%x)\n", __FUNCTION__,
p, p->ces, p->callref);
if ((p->ces == ces) && (p->callref == cr))
break;
@ -436,7 +441,7 @@ l3dss1_msg_without_setup(layer3_proc_t *pc, u_char cause)
l3dss1_message_cause(pc, MT_RELEASE_COMPLETE, cause);
break;
default:
dprint(DBGM_L3, "mISDN l3dss1_msg_without_setup wrong cause %d\n",
dprint(DBGM_L3, pc->l3->nst->cardnr, "mISDN l3dss1_msg_without_setup wrong cause %d\n",
cause);
}
send_proc(pc, IMSG_END_PROC, NULL);
@ -758,7 +763,7 @@ l3dss1_setup(layer3_proc_t *pc, int pr, void *arg)
setup->ces = pc->ces;
newl3state(pc, 1);
L3DelTimer(&pc->timer2);
dprint(DBGM_L3, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
dprint(DBGM_L3, pc->l3->nst->cardnr, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
L3AddTimer(&pc->timer2, T_CTRL, 0x31f);
if (err) /* STATUS for none mandatory IE errors after actions are taken */
l3dss1_std_ie_err(pc, err);
@ -957,7 +962,7 @@ l3dss1_setup_acknowledge_i(layer3_proc_t *pc, int pr, void *arg)
msg_t *umsg, *msg = arg;
SETUP_ACKNOWLEDGE_t *sa;
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
if (!pc->master) {
L3DelTimer(&pc->timer1);
newl3state(pc, 25);
@ -987,7 +992,7 @@ l3dss1_proceeding_i(layer3_proc_t *pc, int pr, void *arg)
msg_t *umsg, *msg = arg;
CALL_PROCEEDING_t *proc;
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
if (!pc->master) {
L3DelTimer(&pc->timer1);
newl3state(pc, 9);
@ -1021,7 +1026,7 @@ l3dss1_alerting_i(layer3_proc_t *pc, int pr, void *arg)
msg_t *umsg, *msg = arg;
ALERTING_t *al;
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
if (!pc->master) {
L3DelTimer(&pc->timer1);
newl3state(pc, 7);
@ -1164,7 +1169,7 @@ l3dss1_hold(layer3_proc_t *pc, int pr, void *arg)
l3dss1_message_cause(pc, MT_HOLD_REJECT, CAUSE_MT_NOTIMPLEMENTED);
return;
}
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
#warning TODO: global mask for supported none mandatory services, like HOLD
if (pc->hold_state == HOLDAUX_HOLD_IND)
return;
@ -1193,7 +1198,7 @@ l3dss1_retrieve(layer3_proc_t *pc, int pr, void *arg)
l3dss1_message_cause(pc, MT_RETRIEVE_REJECT, CAUSE_MT_NOTIMPLEMENTED);
return;
}
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
if (pc->hold_state == HOLDAUX_RETR_IND)
return;
if (pc->hold_state != HOLDAUX_HOLD) {
@ -1219,7 +1224,7 @@ l3dss1_suspend(layer3_proc_t *pc, int pr, void *arg)
msg_t *umsg, *msg = arg;
SUSPEND_t *susp;
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
umsg = prep_l3data_msg(CC_SUSPEND | INDICATION, pc->ces |
(pc->callref << 16), sizeof(SUSPEND_t), msg->len, NULL);
if (!umsg)
@ -1240,7 +1245,7 @@ l3dss1_resume(layer3_proc_t *pc, int pr, void *arg)
msg_t *umsg, *msg = arg;
RESUME_t *res;
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
umsg = prep_l3data_msg(CC_RESUME | INDICATION, pc->ces |
(pc->callref << 16), sizeof(RESUME_t), msg->len, NULL);
if (!umsg)
@ -1332,7 +1337,7 @@ static layer3_proc_t
static void
l3dss1_setup_acknowledge_m(layer3_proc_t *pc, int pr, void *arg)
{
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
L3DelTimer(&pc->timer1);
create_child_proc(pc, pr, arg, 25);
}
@ -1340,7 +1345,7 @@ l3dss1_setup_acknowledge_m(layer3_proc_t *pc, int pr, void *arg)
static void
l3dss1_proceeding_m(layer3_proc_t *pc, int pr, void *arg)
{
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
L3DelTimer(&pc->timer1);
create_child_proc(pc, pr, arg, 9);
}
@ -1348,7 +1353,7 @@ l3dss1_proceeding_m(layer3_proc_t *pc, int pr, void *arg)
static void
l3dss1_alerting_m(layer3_proc_t *pc, int pr, void *arg)
{
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
L3DelTimer(&pc->timer1);
create_child_proc(pc, pr, arg, 7);
}
@ -1356,7 +1361,7 @@ l3dss1_alerting_m(layer3_proc_t *pc, int pr, void *arg)
static void
l3dss1_connect_m(layer3_proc_t *pc, int pr, void *arg)
{
dprint(DBGM_L3,"%s\n", __FUNCTION__);
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s\n", __FUNCTION__);
L3DelTimer(&pc->timer1);
create_child_proc(pc, pr, arg, 8);
}
@ -1385,7 +1390,7 @@ l3dss1_release_cmpl_m(layer3_proc_t *pc, int pr, void *arg)
if (pc->state == 6) {
msg_pull(msg, mISDNUSER_HEAD_SIZE);
if ((p = l3dss1_get_cause(pc, msg, NULL))) {
dprint(DBGM_L3,"%s cause (%d/%d)\n", __FUNCTION__,
dprint(DBGM_L3, pc->l3->nst->cardnr,"%s cause (%d/%d)\n", __FUNCTION__,
pc->cause, pc->err);
switch(pc->cause) {
case CAUSE_USER_BUSY:
@ -1589,11 +1594,11 @@ l3dss1_setup_req(layer3_proc_t *pc, int pr, void *arg)
dhexprint(DBGM_L3DATA, "l3 oframe:", &pc->obuf[0], l);
#warning testing
if (pc->l3->l2_state0 && (pc->l3->nst->feature & FEATURE_NET_PTP)) {
dprint(DBGM_L3, "%s: proc(%p) sending SETUP to CES 0\n", __FUNCTION__, pc);
dprint(DBGM_L3, pc->l3->nst->cardnr, "%s: proc(%p) sending SETUP to CES 0\n", __FUNCTION__, pc);
if (l3_msg(pc->l3, DL_DATA | REQUEST, 0, msg))
free_msg(msg);
} else {
dprint(DBGM_L3, "%s: proc(%p) sending SETUP to broadcast CES\n", __FUNCTION__, pc);
dprint(DBGM_L3, pc->l3->nst->cardnr, "%s: proc(%p) sending SETUP to broadcast CES\n", __FUNCTION__, pc);
if (l3_msg(pc->l3, DL_UNITDATA | REQUEST, 127, msg))
free_msg(msg);
}
@ -1961,7 +1966,7 @@ l3dss1_t303(layer3_proc_t *pc, int pr, void *arg)
free_msg(msg);
}
L3DelTimer(&pc->timer2);
dprint(DBGM_L3, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
dprint(DBGM_L3, pc->l3->nst->cardnr, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
L3AddTimer(&pc->timer2, T312, 0x312);
test_and_set_bit(FLG_L3P_TIMER312,
&pc->Flags);
@ -2025,7 +2030,7 @@ l3dss1_t312(layer3_proc_t *pc, int pr, void *arg)
test_and_clear_bit(FLG_L3P_TIMER312, &pc->Flags);
L3DelTimer(&pc->timer2);
dprint(DBGM_L3, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
dprint(DBGM_L3, pc->l3->nst->cardnr, "%s: pc=%p del timer2\n", __FUNCTION__, pc);
l3_debug(pc->l3, "%s: state %d", __FUNCTION__, pc->state);
if (pc->state == 22) {
StopAllL3Timer(pc);
@ -2327,7 +2332,7 @@ imsg_intrelease(layer3_proc_t *master, layer3_proc_t *child)
if ((!master) || (!child))
return(-EINVAL);
dprint(DBGM_L3, "%s: m/c(%x/%x) state(%d/%d) m->c(%p)\n", __FUNCTION__,
dprint(DBGM_L3, master->l3->nst->cardnr, "%s: m/c(%x/%x) state(%d/%d) m->c(%p)\n", __FUNCTION__,
master->ces, child->ces, master->state, child->state,
master->child);
switch (master->state) {
@ -2345,7 +2350,7 @@ imsg_intrelease(layer3_proc_t *master, layer3_proc_t *child)
case 25:
if (master->child ||
test_bit(FLG_L3P_TIMER312, &master->Flags)) {
dprint(DBGM_L3, "%s: JOLLY child=%p, flg=%d\n", __FUNCTION__, master->child, test_bit(FLG_L3P_TIMER312, &master->Flags));
dprint(DBGM_L3, master->l3->nst->cardnr, "%s: JOLLY child=%p, flg=%d\n", __FUNCTION__, master->child, test_bit(FLG_L3P_TIMER312, &master->Flags));
#warning TODO: save cause
#warning bedenke auch, dass vielleicht overlap sending mit information-messages praktisch wäre (später PTP)
} else {
@ -2542,7 +2547,7 @@ dl_data_mux(layer3_t *l3, mISDNuser_head_t *hh, msg_t *msg)
if (!l3)
return(ret);
dprint(DBGM_L3, "%s: len(%d)\n", __FUNCTION__, msg->len);
dprint(DBGM_L3, l3->nst->cardnr, "%s: len(%d)\n", __FUNCTION__, msg->len);
dhexprint(DBGM_L3DATA, "l3 iframe:", msg->data, msg->len);
if (msg->len < 3) {
l3_debug(l3, "dss1 frame too short(%d)", msg->len);
@ -2558,9 +2563,9 @@ dl_data_mux(layer3_t *l3, mISDNuser_head_t *hh, msg_t *msg)
free_msg(msg);
return(0);
}
dprint(DBGM_L3, "%s: dis(%x)\n", __FUNCTION__, msg->data[0]);
dprint(DBGM_L3, l3->nst->cardnr, "%s: dis(%x)\n", __FUNCTION__, msg->data[0]);
cr = getcallref(msg->data);
dprint(DBGM_L3, "%s: cr(%x)\n", __FUNCTION__, cr);
dprint(DBGM_L3, l3->nst->cardnr, "%s: cr(%x)\n", __FUNCTION__, cr);
if (msg->len < ((msg->data[1] & 0x0f) + 3)) {
l3_debug(l3, "dss1 frame too short(%d)", msg->len);
free_msg(msg);
@ -2589,9 +2594,9 @@ dl_data_mux(layer3_t *l3, mISDNuser_head_t *hh, msg_t *msg)
free_msg(msg);
return(0);
}
dprint(DBGM_L3, "%s: mt(%x)\n", __FUNCTION__, l3m.mt);
dprint(DBGM_L3, l3->nst->cardnr, "%s: mt(%x)\n", __FUNCTION__, l3m.mt);
proc = find_proc(l3->proc, hh->dinfo, cr);
dprint(DBGM_L3, "%s: proc(%p)\n", __FUNCTION__, proc);
dprint(DBGM_L3, l3->nst->cardnr, "%s: proc(%p)\n", __FUNCTION__, proc);
if (!proc) {
if (l3m.mt == MT_SETUP || l3m.mt == MT_RESUME) {
/* Setup/Resume creates a new transaction process */
@ -2602,7 +2607,7 @@ dl_data_mux(layer3_t *l3, mISDNuser_head_t *hh, msg_t *msg)
free_msg(msg);
return(0);
}
dprint(DBGM_L3, "%s: %s\n", __FUNCTION__, (l3m.mt==MT_SETUP)?"MT_SETUP":"MT_RESUME");
dprint(DBGM_L3, l3->nst->cardnr, "%s: %s\n", __FUNCTION__, (l3m.mt==MT_SETUP)?"MT_SETUP":"MT_RESUME");
if (!(proc = create_proc(l3, hh->dinfo, cr, NULL))) {
/* May be to answer with RELEASE_COMPLETE and
* CAUSE 0x2f "Resource unavailable", but this
@ -2611,10 +2616,10 @@ dl_data_mux(layer3_t *l3, mISDNuser_head_t *hh, msg_t *msg)
free_msg(msg);
return(0);
}
dprint(DBGM_L3, "%s: proc(%p)\n", __FUNCTION__, proc);
dprint(DBGM_L3, l3->nst->cardnr, "%s: proc(%p)\n", __FUNCTION__, proc);
APPEND_TO_LIST(proc, l3->proc);
} else {
dprint(DBGM_L3, "%s: mt(%x) do not create proc\n", __FUNCTION__,
dprint(DBGM_L3, l3->nst->cardnr, "%s: mt(%x) do not create proc\n", __FUNCTION__,
l3m.mt);
#warning TODO: it happens that a response to an outgoing setup is received after connect of another terminal. in this case we must release.
free_msg(msg);
@ -2622,7 +2627,7 @@ dl_data_mux(layer3_t *l3, mISDNuser_head_t *hh, msg_t *msg)
}
}
if ((proc->ces & 0xffffff00) == 0xff00) {
dprint(DBGM_L3, "%s: master state %d found\n", __FUNCTION__,
dprint(DBGM_L3, l3->nst->cardnr, "%s: master state %d found\n", __FUNCTION__,
proc->state);
msg_push(msg, mISDNUSER_HEAD_SIZE);
send_proc(proc, IMSG_MASTER_L2_DATA, &l3m);
@ -2639,8 +2644,8 @@ l3_muxer(net_stack_t *nst, msg_t *msg)
int ret = -EINVAL;
hh = (mISDNuser_head_t *)msg->data;
dprint(DBGM_L3, "%s: msg len(%d)\n", __FUNCTION__, msg->len);
dprint(DBGM_L3, "%s: pr(%x) di(%x)\n", __FUNCTION__,
dprint(DBGM_L3, nst->cardnr, "%s: msg len(%d)\n", __FUNCTION__, msg->len);
dprint(DBGM_L3, nst->cardnr, "%s: pr(%x) di(%x)\n", __FUNCTION__,
hh->prim, hh->dinfo);
msg_pull(msg, mISDNUSER_HEAD_SIZE);
if (hh->prim == (DL_DATA | INDICATION)) {
@ -2662,8 +2667,8 @@ manager_l3(net_stack_t *nst, msg_t *msg)
struct _l3_msg l3m;
hh = (mISDNuser_head_t *)msg->data;
dprint(DBGM_L3, "%s: msg len(%d)\n", __FUNCTION__, msg->len);
dprint(DBGM_L3, "%s: pr(%x) di(%x)\n", __FUNCTION__,
dprint(DBGM_L3, nst->cardnr, "%s: msg len(%d)\n", __FUNCTION__, msg->len);
dprint(DBGM_L3, nst->cardnr, "%s: pr(%x) di(%x)\n", __FUNCTION__,
hh->prim, hh->dinfo);
msg_pull(msg, mISDNUSER_HEAD_SIZE);
proc = find_proc(nst->layer3->proc, hh->dinfo & 0xffff,
@ -2682,12 +2687,12 @@ manager_l3(net_stack_t *nst, msg_t *msg)
proc = create_proc(nst->layer3, hh->dinfo & 0xffff,
nst->layer3->next_cr | 0x8000, NULL);
if (!proc) {
dprint(DBGM_L3, "%s: pr(%x) failed to create proc.\n",
dprint(DBGM_L3, nst->cardnr, "%s: pr(%x) failed to create proc.\n",
__FUNCTION__, hh->prim);
free_msg(msg);
return(0);
}
dprint(DBGM_L3, "%s: proc(%p)\n", __FUNCTION__, proc);
dprint(DBGM_L3, nst->cardnr, "%s: proc(%p)\n", __FUNCTION__, proc);
#warning testing
#if 0
printf("check for tei 0 active\n");
@ -2705,7 +2710,7 @@ printf("check for tei 0 active\n");
}
proc = p3i;
dprint(DBGM_L3, "%s: TEI 0 is active, so we created proc(%p)\n", __FUNCTION__, proc);
dprint(DBGM_L3, nst->cardnr, "%s: TEI 0 is active, so we created proc(%p)\n", __FUNCTION__, proc);
}
#endif
@ -2718,7 +2723,7 @@ printf("check for tei 0 active\n");
}
}
if (!proc) {
dprint(DBGM_L3, "%s: pr(%x) no proc id %x found\n", __FUNCTION__,
dprint(DBGM_L3, nst->cardnr, "%s: pr(%x) no proc id %x found\n", __FUNCTION__,
hh->prim, hh->dinfo);
free_msg(msg);
return(0);
@ -2727,7 +2732,7 @@ printf("check for tei 0 active\n");
if (msg->len)
l3m.msg = msg;
else {
dprint(DBGM_L3, "%s: pr(%x) id(%x) zero param\n", __FUNCTION__,
dprint(DBGM_L3, nst->cardnr, "%s: pr(%x) id(%x) zero param\n", __FUNCTION__,
hh->prim, hh->dinfo);
l3m.msg = NULL;
}
@ -2738,9 +2743,9 @@ printf("check for tei 0 active\n");
static void
release_l3(layer3_t *l3) {
dprint(DBGM_L3, "%s(%p)\n", __FUNCTION__, l3);
dprint(DBGM_L3, l3->nst->cardnr, "%s(%p)\n", __FUNCTION__, l3);
while(l3->proc) {
dprint(DBGM_L3, "%s: rel_proc ces(%x)\n", __FUNCTION__,
dprint(DBGM_L3, l3->nst->cardnr, "%s: rel_proc ces(%x)\n", __FUNCTION__,
l3->proc->ces);
send_proc(l3->proc, IMSG_END_PROC, NULL);
}
@ -2759,7 +2764,7 @@ mISDN_l3up(layer3_proc_t *l3p, msg_t *msg)
if (l3p->l3->nst->l3_manager)
err = l3p->l3->nst->l3_manager(l3p->l3->nst->manager, msg);
if (err)
dprint(DBGM_L3, "%s: error %d\n", __FUNCTION__, err);
dprint(DBGM_L3, l3p->l3->nst->cardnr, "%s: error %d\n", __FUNCTION__, err);
return(err);
}
@ -2800,10 +2805,10 @@ remove_proc(layer3_proc_t **procp, int ces)
found = 0;
proc = *procp;
while(proc) {
dprint(DBGM_L3, "%s: comparing %s proc(%x) ces(%x)\n", __FUNCTION__,
dprint(DBGM_L3, proc->l3->nst->cardnr, "%s: comparing %s proc(%x) ces(%x)\n", __FUNCTION__,
(proc->master)?"child":"master", proc, proc->ces);
if (proc->ces == ces) {
dprint(DBGM_L3, "%s: found proc(%x)\n", __FUNCTION__,
dprint(DBGM_L3, proc->l3->nst->cardnr, "%s: found proc(%x)\n", __FUNCTION__,
proc);
if (proc->master)
send_proc(proc, IMSG_END_PROC_M, NULL);
@ -2833,7 +2838,7 @@ l3_msg(layer3_t *l3, u_int pr, int dinfo, void *arg)
msg_t *msg = arg, *lmsg = NULL;
#warning testing
int ces = dinfo & 0xffff;
dprint(DBGM_L3, "%s: pr(%x) di(%x) arg(%p)\n", __FUNCTION__,
dprint(DBGM_L3, l3->nst->cardnr, "%s: pr(%x) di(%x) arg(%p)\n", __FUNCTION__,
pr, dinfo, arg);
switch (pr) {
case (DL_UNITDATA | REQUEST):
@ -2956,7 +2961,7 @@ int Isdnl3Init(net_stack_t *nst)
void cleanup_Isdnl3(net_stack_t *nst)
{
if (nst->layer3) {
dprint(DBGM_L3, "%s: l3 list not empty\n", __FUNCTION__);
dprint(DBGM_L3, nst->cardnr, "%s: l3 list not empty\n", __FUNCTION__);
while(nst->layer3)
release_l3(nst->layer3);
}

View File

@ -1,4 +1,4 @@
/* $Id: tei.c,v 1.4 2006/03/06 13:08:29 keil Exp $
/* $Id: tei.c,v 1.5 2006/07/18 13:50:03 crich Exp $
*
* Author Karsten Keil (keil@isdn4linux.de)
*
@ -14,7 +14,7 @@
// #include "debug.h"
// #include <linux/random.h>
const char *tei_revision = "$Revision: 1.4 $";
const char *tei_revision = "$Revision: 1.5 $";
#define ID_REQUEST 1
#define ID_ASSIGNED 2
@ -129,7 +129,7 @@ put_tei_msg(teimgr_t *tm, u_char m_id, unsigned int ri, u_char tei)
bp[7] = (tei << 1) | 1;
msg = create_link_msg(MDL_UNITDATA | REQUEST, DINFO_SKB, 8, bp, 0);
if (!msg) {
dprint(DBGM_TEI, "mISDN: No msg for TEI manager\n");
dprint(DBGM_TEI, -1, "mISDN: No msg for TEI manager\n");
return;
}
if (tei_l2(tm->l2, msg))
@ -251,7 +251,7 @@ l2_tei(teimgr_t *tm, msg_t *msg)
if (!tm || !msg)
return(ret);
hh = (mISDNuser_head_t *)msg->data;
dprint(DBGM_TEI, "%s: prim(%x)\n", __FUNCTION__, hh->prim);
dprint(DBGM_TEI, -1, "%s: prim(%x)\n", __FUNCTION__, hh->prim);
if (msg->len < mISDN_FRAME_MIN)
return(ret);
switch(hh->prim) {
@ -276,7 +276,7 @@ tei_debug(struct FsmInst *fi, char *fmt, ...)
va_start(args, fmt);
vsprintf(tbuf, fmt, args);
dprint(DBGM_L2, "tei%d %s\n", tm->l2->tei, tbuf);
dprint(DBGM_L2, -1, "tei%d %s\n", tm->l2->tei, tbuf);
va_end(args);
}
@ -337,7 +337,7 @@ tei_mux(net_stack_t *nst, msg_t *msg)
unsigned int ri, ai;
hh = (mISDNuser_head_t *)msg->data;
dprint(DBGM_TEI, "%s: prim(%x) len(%d)\n", __FUNCTION__,
dprint(DBGM_TEI, -1, "%s: prim(%x) len(%d)\n", __FUNCTION__,
hh->prim, msg->len);
if (msg->len < mISDN_FRAME_MIN)
return(-EINVAL);
@ -369,7 +369,7 @@ tei_mux(net_stack_t *nst, msg_t *msg)
dp++;
ai = (unsigned int) *dp++;
ai >>= 1;
dprint(DBGM_TEI, "tei handler mt %x ri(%x) ai(%d)\n",
dprint(DBGM_TEI, -1, "tei handler mt %x ri(%x) ai(%d)\n",
mt, ri, ai);
if (mt == ID_REQUEST) {
if (ai != 127) {

View File

@ -58,7 +58,7 @@ int tone_handler(bchannel_t *bc) {
const unsigned char *tp;
int len;
dprint(DBGM_TONE, "%s:ch%d Flags %x\n", __FUNCTION__,
dprint(DBGM_TONE, -1, "%s:ch%d Flags %x\n", __FUNCTION__,
bc->channel, bc->Flags);
if (bc->bstate != BC_BSTATE_ACTIV)
return(1);
@ -119,7 +119,7 @@ int tone_handler(bchannel_t *bc) {
} else
return(4);
if (len > ibuf_freecount(bc->sbuf)) {
dprint(DBGM_TONE, "%s:ch%d not sbuf %d/%d\n", __FUNCTION__,
dprint(DBGM_TONE, -1, "%s:ch%d not sbuf %d/%d\n", __FUNCTION__,
bc->channel, len, ibuf_freecount(bc->sbuf));
return(5);
}

View File

@ -27,7 +27,7 @@
#define DBGM_TOPLEVEL 0x40000000
#define DBGM_ALL 0xffffffff
extern int dprint(unsigned int mask, const char *fmt, ...);
extern int dprint(unsigned int mask, int port, const char *fmt, ...);
extern int eprint(const char *fmt, ...);
extern int wprint(const char *fmt, ...);
extern int debug_init(unsigned int, char *, char *, char *);

View File

@ -58,7 +58,7 @@ init_voipsocks(vapplication_t *v)
perror("binding control socket");
return 1;
}
dprint(DBGM_SOCK, "socket ports #%d/#%d\n",
dprint(DBGM_SOCK, -1, "socket ports #%d/#%d\n",
ntohs(v->daddr.sin_port), ntohs(v->caddr.sin_port));
return(0);
}
@ -75,7 +75,7 @@ SendBye(iapplication_t *ia, char *bye)
if (ia->Flags & (AP_FLG_VOIP_SENT_BYE | AP_FLG_VOIP_PEER_BYE))
return(0);
len = rtp_make_bye(c->cbuf, c->own_ssrc, bye, 1);
dprint(DBGM_SOCK, "C socket send %d bytes to %s\n",
dprint(DBGM_SOCK, -1, "C socket send %d bytes to %s\n",
len, inet_ntoa(c->cpeer.sin_addr));
ia->Flags |= AP_FLG_VOIP_SENT_BYE;
if (len) {
@ -99,7 +99,7 @@ clear_connection(iapplication_t *ia)
vconnection_t *c = ia->con;
if (c) {
dprint(DBGM_SOCK, "clear connection to %s ssrc(%lx/%lx)\n",
dprint(DBGM_SOCK, -1, "clear connection to %s ssrc(%lx/%lx)\n",
c->rmtname, c->own_ssrc, c->peer_ssrc);
if (ia->Flags & AP_FLG_VOIP_PEER_VALID) {
msg_queue_purge(&c->aqueue);
@ -136,7 +136,7 @@ free_application(iapplication_t *ia)
static void
close_voipsocks(vapplication_t *v)
{
dprint(DBGM_SOCK, "socket closed\n");
dprint(DBGM_SOCK, -1, "socket closed\n");
while(v->iapp_lst) {
free_application(v->iapp_lst);
}
@ -154,7 +154,7 @@ get_connection(vapplication_t *v, unsigned long ssrc, int exact)
ip = v->iapp_lst;
while (ip) {
if (ip->con) {
dprint(DBGM_SOCK, "ip(%p) %x %s/%s %x/%x\n",
dprint(DBGM_SOCK, -1, "ip(%p) %x %s/%s %x/%x\n",
ip, ip->Flags,
inet_ntoa(v->from.sin_addr),
inet_ntoa(ip->con->cpeer.sin_addr),
@ -330,12 +330,12 @@ play_data(iapplication_t *ip)
return(-1);
}
maxlen = ibuf_freecount(is->rbuf);
dprint(DBGM_SOUND, "%s: %d data max(%d)\n", __FUNCTION__,
dprint(DBGM_SOUND, -1, "%s: %d data max(%d)\n", __FUNCTION__,
ip->con->rlen, maxlen);
if (maxlen > ip->con->rlen)
maxlen = ip->con->rlen;
else if (maxlen < ip->con->rlen) {
dprint(DBGM_SOUND, "pb shortage, skip %d bytes (%d/%d/%d/%d/%d)\n",
dprint(DBGM_SOUND, -1, "pb shortage, skip %d bytes (%d/%d/%d/%d/%d)\n",
ip->con->rlen - maxlen, ip->con->rlen, maxlen,
is->rbuf->ridx, is->rbuf->widx, is->rbuf->size);
wprint("playbuffer shortage, skip %d bytes\n",
@ -363,14 +363,14 @@ receive_data(vapplication_t *v) {
rh = (rtp_hdr_t *)&v->buf.d;
ver = (v->buf.d[0] >> 6) & 3;
if (ver != RTP_VERSION) {
dprint(DBGM_SOCK, "rtp version %d\n",
dprint(DBGM_SOCK, -1, "rtp version %d\n",
ver);
return(-3);
}
ssrc = ntohl(rh->ssrc);
iap = get_connection(v, ssrc, 1);
if (!iap) { /* data from not known source ignored before a CTRL packet */
dprint(DBGM_SOCK, "rtp data ignored from %s ssrc(%lx)\n",
dprint(DBGM_SOCK, -1, "rtp data ignored from %s ssrc(%lx)\n",
inet_ntoa(v->from.sin_addr), ssrc);
return(-4);
}
@ -382,10 +382,10 @@ receive_data(vapplication_t *v) {
if (v->buf.d[0] & RTP_PAD_FLAG) {
iap->con->rlen -= v->buf.d[v->rlen-1];
}
dprint(DBGM_SOCK, "rtp data len(%d) pl(%x) seq(%d) ts(%lx)\n",
dprint(DBGM_SOCK, -1, "rtp data len(%d) pl(%x) seq(%d) ts(%lx)\n",
iap->con->rlen, payl, seq, ts);
if (iap->con->rlen <= 0) {
dprint(DBGM_SOCK, "rtp data len error %d\n", iap->con->rlen);
dprint(DBGM_SOCK, -1, "rtp data len error %d\n", iap->con->rlen);
return(-5);
}
iap->con->rbuf = v->buf.d + 4*cc + 12;
@ -427,7 +427,7 @@ receive_data(vapplication_t *v) {
*p++ = linear2alaw(*gp++);
#endif
} else {
dprint(DBGM_SOCK, "rtp data payload %x not supported\n", payl);
dprint(DBGM_SOCK, -1, "rtp data payload %x not supported\n", payl);
return(-7);
}
return(play_data(iap));
@ -444,7 +444,7 @@ receive_ctrl(vapplication_t *v) {
return(1);
ver = (v->buf.d[0] >> 6) & 3;
if ((ver != RTP_VERSION) && (ver != 1)) {
dprint(DBGM_SOCK, "rtp version %d\n",
dprint(DBGM_SOCK, -1, "rtp version %d\n",
ver);
return(2);
}
@ -452,11 +452,11 @@ receive_ctrl(vapplication_t *v) {
iap = get_connection(v, ssrc, 0);
if (!iap) { /* New connection */
if (isRTCPByepacket(v->buf.d, v->rlen)) {
dprint(DBGM_CONN, "bye in new connection from %s ignored\n",
dprint(DBGM_CONN, -1, "bye in new connection from %s ignored\n",
inet_ntoa(v->from.sin_addr));
return(3);
}
dprint(DBGM_CONN, "new connection from %s ssrc(%x)\n",
dprint(DBGM_CONN, -1, "new connection from %s ssrc(%x)\n",
inet_ntoa(v->from.sin_addr), ssrc);
iap = new_peer_connection(v, ssrc, ver);
if (!iap) {
@ -466,7 +466,7 @@ receive_ctrl(vapplication_t *v) {
} else {
if (isRTCPByepacket(v->buf.d, v->rlen)) {
iap->Flags |= AP_FLG_VOIP_PEER_BYE;
dprint(DBGM_CONN, "connection from %s bye\n",
dprint(DBGM_CONN, -1, "connection from %s bye\n",
inet_ntoa(v->from.sin_addr));
}
}
@ -1279,7 +1279,7 @@ SendCtrl(iapplication_t *ia)
len = rtp_make_app(c->cbuf, c->own_ssrc, 1, "ISDN",
c->amsg->data, c->amsg->len);
}
dprint(DBGM_SOCK, "C socket send %d bytes to %s\n",
dprint(DBGM_SOCK, -1, "C socket send %d bytes to %s\n",
len, inet_ntoa(c->cpeer.sin_addr));
if (len) {
dhexprint(DBGM_CDATA, "send ctrl packet:", c->cbuf, len);
@ -1314,12 +1314,12 @@ voipscan(void *arg) {
}
ret = select(v->csock + 1, &fdset, NULL, NULL, &timeout);
if (ret < 0) { /* error */
dprint(DBGM_SOCK, "socket select errno %d: %s\n",
dprint(DBGM_SOCK, -1, "socket select errno %d: %s\n",
errno, strerror(errno));
continue;
}
if (ret == 0) { /* timeout */
dprint(DBGM_SOCK, "socket select timeout\n");
dprint(DBGM_SOCK, -1, "socket select timeout\n");
continue;
}
if (FD_ISSET(v->dsock, &fdset)) { /* data packet */
@ -1327,28 +1327,28 @@ voipscan(void *arg) {
v->rlen = recvfrom(v->dsock, v->buf.d, MAX_NETBUFFER_SIZE,
0, (struct sockaddr *) &v->from, &v->fromlen);
if (v->rlen <= 0) {
dprint(DBGM_SOCK, "D socket rlen(%d)\n",
dprint(DBGM_SOCK, -1, "D socket rlen(%d)\n",
v->rlen);
continue;
}
dhexprint(DBGM_DDATA, "data packet:", v->buf.d, v->rlen);
ret = receive_data(v);
if (ret<0)
dprint(DBGM_SOCK, "receive_data ret(%d)\n", ret);
dprint(DBGM_SOCK, -1, "receive_data ret(%d)\n", ret);
}
if (FD_ISSET(v->csock, &fdset)) { /* ctrl packet */
v->fromlen = sizeof(struct sockaddr_in);
v->rlen = recvfrom(v->csock, v->buf.d, MAX_NETBUFFER_SIZE,
0, (struct sockaddr *) &v->from, &v->fromlen);
if (v->rlen <= 0) {
dprint(DBGM_SOCK, "C socket rlen(%d)\n",
dprint(DBGM_SOCK, -1, "C socket rlen(%d)\n",
v->rlen);
continue;
}
dhexprint(DBGM_CDATA, "ctrl packet:", v->buf.d, v->rlen);
ret = receive_ctrl(v);
if (ret)
dprint(DBGM_SOCK, "receive_ctrl ret(%d)\n", ret);
dprint(DBGM_SOCK, -1, "receive_ctrl ret(%d)\n", ret);
}
}
close_voipsocks(v);
@ -1449,11 +1449,11 @@ voip_sender(void *arg)
while (!(ap->Flags & AP_FLG_VOIP_ABORT)) {
is = ap->data2;
if (!is || !is->sbuf) {
dprint(DBGM_SOUND, "application data2 NULL\n");
dprint(DBGM_SOUND, -1, "application data2 NULL\n");
break;
}
if (!ap->con) {
dprint(DBGM_SOUND, "application ap->con NULL\n");
dprint(DBGM_SOUND, -1, "application ap->con NULL\n");
break;
}
avail = ibuf_usedcount(is->sbuf);
@ -1527,9 +1527,9 @@ voip_sender(void *arg)
}
#endif
ret = send_sdata(ap);
dprint(DBGM_SOUND, "send_sdata ret %d\n", ret);
dprint(DBGM_SOUND, -1, "send_sdata ret %d\n", ret);
if (ret<=0) {
dprint(DBGM_SOUND, "send_sdata ret %d\n", ret);
dprint(DBGM_SOUND, -1, "send_sdata ret %d\n", ret);
ap->Flags |= AP_FLG_VOIP_ABORT;
}
} else {

View File

@ -55,18 +55,18 @@ read_rec_ctrlfile(void)
manager_t *mgr = voip.mgr_lst;
if (RecordCtrlFile[0] == 0) {
dprint(DBGM_TOPLEVEL, "%s: no RecordCtrlFile\n", __FUNCTION__);
dprint(DBGM_TOPLEVEL, -1, "%s: no RecordCtrlFile\n", __FUNCTION__);
return(-ENOENT);
}
f = fopen(RecordCtrlFile, "r");
if (!f) {
dprint(DBGM_TOPLEVEL, "%s: cannot open %s: %s\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: cannot open %s: %s\n", __FUNCTION__,
RecordCtrlFile, strerror(errno));
return(-errno);
}
while(mgr) {
opt = getnext_record(f);
dprint(DBGM_TOPLEVEL, "%s: mgr %p ch1: %d\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: mgr %p ch1: %d\n", __FUNCTION__,
mgr, opt);
if (opt) {
mgr->bc[0].Flags |= FLG_BC_RECORD;
@ -74,7 +74,7 @@ read_rec_ctrlfile(void)
mgr->bc[0].Flags &= ~FLG_BC_RECORD;
}
opt = getnext_record(f);
dprint(DBGM_TOPLEVEL, "%s: mgr %p ch2: %d\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: mgr %p ch2: %d\n", __FUNCTION__,
mgr, opt);
if (opt) {
mgr->bc[1].Flags |= FLG_BC_RECORD;
@ -90,7 +90,7 @@ read_rec_ctrlfile(void)
static void
sig_usr1_handler(int sig)
{
dprint(DBGM_TOPLEVEL, "%s: got sig(%d)\n", __FUNCTION__, sig);
dprint(DBGM_TOPLEVEL, -1, "%s: got sig(%d)\n", __FUNCTION__, sig);
read_rec_ctrlfile();
signal(SIGUSR1, sig_usr1_handler);
}
@ -100,26 +100,26 @@ static void
sig_segfault(int sig, siginfo_t *si, void *arg) {
int i,*ip = arg;
dprint(DBGM_TOPLEVEL, "segfault %d, %p, %p\n",
dprint(DBGM_TOPLEVEL, -1, "segfault %d, %p, %p\n",
sig, si, arg);
if (si) {
dprint(DBGM_TOPLEVEL, "si: sig(%d) err(%d) code(%d) pid(%d)\n",
dprint(DBGM_TOPLEVEL, -1, "si: sig(%d) err(%d) code(%d) pid(%d)\n",
si->si_signo, si->si_errno, si->si_code, si->si_pid);
dprint(DBGM_TOPLEVEL, "si: status(%x) value(%x)\n",
dprint(DBGM_TOPLEVEL, -1, "si: status(%x) value(%x)\n",
si->si_status, si->si_value.sival_int);
dprint(DBGM_TOPLEVEL, "si: int(%x) ptr(%p) addr(%p)\n",
dprint(DBGM_TOPLEVEL, -1, "si: int(%x) ptr(%p) addr(%p)\n",
si->si_int, si->si_ptr, si->si_addr);
}
if (ip) {
ip -= 10;
for(i=0;i<20;i++)
dprint(DBGM_TOPLEVEL, "ip %3d: %x\n", i-10, ip[i]);
dprint(DBGM_TOPLEVEL, -1, "ip %3d: %x\n", i-10, ip[i]);
}
ip = (int *)si;
if (ip) {
ip -= 10;
for(i=0;i<20;i++)
dprint(DBGM_TOPLEVEL, "si %3d: %x\n", i-10, ip[i]);
dprint(DBGM_TOPLEVEL, -1, "si %3d: %x\n", i-10, ip[i]);
}
}
@ -132,7 +132,7 @@ term_handler(int sig)
manager_t *mgr = voip.mgr_lst;
tid = pthread_self();
dprint(DBGM_TOPLEVEL,"signal %d received from thread %ld\n", sig, tid);
dprint(DBGM_TOPLEVEL, -1,"signal %d received from thread %ld\n", sig, tid);
voip.flags |= AP_FLG_VOIP_ABORT;
while(mgr) {
term_netstack(mgr->nst);
@ -151,11 +151,11 @@ child_handler(int sig)
pid_t pid;
int stat;
dprint(DBGM_TOPLEVEL,"signal %d received\n", sig);
dprint(DBGM_TOPLEVEL, -1,"signal %d received\n", sig);
while (mgr) {
if (mgr->bc[0].pid) {
pid = waitpid(mgr->bc[0].pid, &stat, WNOHANG);
dprint(DBGM_TOPLEVEL, "%s: waitpid(%d) stat(%x) ret(%d)\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: waitpid(%d) stat(%x) ret(%d)\n", __FUNCTION__,
mgr->bc[0].pid, stat, pid);
if (mgr->bc[0].pid == pid) {
mgr->bc[0].pid = 0;
@ -165,7 +165,7 @@ child_handler(int sig)
}
if (mgr->bc[1].pid) {
pid = waitpid(mgr->bc[1].pid, &stat, WNOHANG);
dprint(DBGM_TOPLEVEL, "%s: waitpid(%d) stat(%x) ret(%d)\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: waitpid(%d) stat(%x) ret(%d)\n", __FUNCTION__,
mgr->bc[1].pid, stat, pid);
if (mgr->bc[1].pid == pid) {
mgr->bc[1].pid = 0;
@ -189,7 +189,7 @@ read_audio(void *arg)
int ret,i;
tid = pthread_self();
dprint(DBGM_TOPLEVEL, "%s: tid %ld\n", __FUNCTION__, tid);
dprint(DBGM_TOPLEVEL, -1, "%s: tid %ld\n", __FUNCTION__, tid);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
while(1) {
@ -199,7 +199,7 @@ read_audio(void *arg)
FD_SET(ia->data, &efd);
ret = select(ia->data +1, &rfd, NULL, &efd, NULL);
if (ret < 0) {
dprint(DBGM_TOPLEVEL, "%s: select error %d %s\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: select error %d %s\n", __FUNCTION__,
errno, strerror(errno));
if (errno == EAGAIN)
continue;
@ -209,18 +209,18 @@ read_audio(void *arg)
if (FD_ISSET(ia->data, &rfd)) {
ret = read(ia->data, ia->rtmp, MAX_AUDIO_READ);
if (ret < 0) {
dprint(DBGM_TOPLEVEL, "%s: read error %d %s\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: read error %d %s\n", __FUNCTION__,
errno, strerror(errno));
if (errno == EAGAIN)
continue;
continue;
}
if (!ret) {
dprint(DBGM_TOPLEVEL, "%s: zero read\n", __FUNCTION__);
dprint(DBGM_TOPLEVEL, -1, "%s: zero read\n", __FUNCTION__);
continue;
}
if (ret > ibuf_freecount(ia->rbuf)) {
dprint(DBGM_TOPLEVEL, "%s: rbuf overflow %d/%d\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: rbuf overflow %d/%d\n", __FUNCTION__,
ret, ibuf_freecount(ia->rbuf));
ret = ibuf_freecount(ia->rbuf);
}
@ -231,7 +231,7 @@ read_audio(void *arg)
sem_post(ia->rbuf->rsem);
}
if (FD_ISSET(ia->data, &efd)) {
dprint(DBGM_TOPLEVEL, "%s: exception\n", __FUNCTION__);
dprint(DBGM_TOPLEVEL, -1, "%s: exception\n", __FUNCTION__);
break;
}
}
@ -246,7 +246,7 @@ work_audio(void *arg)
int ret, i;
tid = pthread_self();
dprint(DBGM_TOPLEVEL, "%s: tid %ld\n", __FUNCTION__, tid);
dprint(DBGM_TOPLEVEL, -1, "%s: tid %ld\n", __FUNCTION__, tid);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
while(1) {
@ -287,7 +287,7 @@ setup_voip(iapplication_t *ap, bchannel_t *bc)
isound_t *ia;
int ret;
dprint(DBGM_APPL, "%s(%p, %p)\n", __FUNCTION__, ap, bc);
dprint(DBGM_APPL, -1, "%s(%p, %p)\n", __FUNCTION__, ap, bc);
if (!bc)
return(-EINVAL);
if (!ap)
@ -311,7 +311,7 @@ setup_voip(iapplication_t *ap, bchannel_t *bc)
bc->sbuf->wsem = &ia->work;
bc->rbuf->rsem = &ia->work;
ret = pthread_create(&ap->tid, NULL, voip_sender, (void *)ap);
dprint(DBGM_APPL, "%s: create voip_sender %ld ret %d\n", __FUNCTION__,
dprint(DBGM_APPL, -1, "%s: create voip_sender %ld ret %d\n", __FUNCTION__,
ap->tid, ret);
return(ret);
}
@ -322,7 +322,7 @@ close_voip(iapplication_t *ap, bchannel_t *bc)
isound_t *ia;
int ret, *retval;
dprint(DBGM_APPL, "%s(%p, %p)\n", __FUNCTION__, ap, bc);
dprint(DBGM_APPL, -1, "%s(%p, %p)\n", __FUNCTION__, ap, bc);
if (!bc)
return(-EINVAL);
if (!ap)
@ -333,10 +333,10 @@ close_voip(iapplication_t *ap, bchannel_t *bc)
if (!ia)
return(-EINVAL);
ret = pthread_cancel(ap->tid);
dprint(DBGM_APPL, "%s: cancel sender ret(%d)\n", __FUNCTION__,
dprint(DBGM_APPL, -1, "%s: cancel sender ret(%d)\n", __FUNCTION__,
ret);
ret = pthread_join(ap->tid, (void *)&retval);
dprint(DBGM_APPL, "%s: join sender ret(%d) rval(%p)\n", __FUNCTION__,
dprint(DBGM_APPL, -1, "%s: join sender ret(%d) rval(%p)\n", __FUNCTION__,
ret, retval);
ia->sbuf = NULL;
ia->rbuf = NULL;
@ -346,7 +346,7 @@ close_voip(iapplication_t *ap, bchannel_t *bc)
free_ibuffer(bc->rbuf);
bc->rbuf = NULL;
ret = sem_destroy(&ia->work);
dprint(DBGM_APPL, "%s: sem_destroy work %d\n", __FUNCTION__,
dprint(DBGM_APPL, -1, "%s: sem_destroy work %d\n", __FUNCTION__,
ret);
free(ia);
return(0);
@ -379,7 +379,7 @@ setup_audio(iapplication_t *ap, bchannel_t *bc)
ia->data = open("/dev/audio", O_RDWR | O_NONBLOCK);
if (ia->data < 0) {
free(ia);
dprint(DBGM_TOPLEVEL, "%s: open rdwr %d %s\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: open rdwr %d %s\n", __FUNCTION__,
errno, strerror(errno));
return(-errno);
}
@ -389,10 +389,10 @@ setup_audio(iapplication_t *ap, bchannel_t *bc)
bc->sbuf->wsem = &ia->work;
bc->rbuf->rsem = &ia->work;
ret = pthread_create(&ia->rd_t, NULL, read_audio, (void *)ia);
dprint(DBGM_TOPLEVEL, "%s: create rd_t %ld ret %d\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: create rd_t %ld ret %d\n", __FUNCTION__,
ia->rd_t, ret);
ret = pthread_create(&ia->wr_t, NULL, work_audio, (void *)ia);
dprint(DBGM_TOPLEVEL, "%s: create wr_t %ld ret %d\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: create wr_t %ld ret %d\n", __FUNCTION__,
ia->wr_t, ret);
return(0);
}
@ -413,16 +413,16 @@ close_audio(iapplication_t *ap, bchannel_t *bc)
return(-EINVAL);
close(ia->data);
ret = pthread_cancel(ia->rd_t);
dprint(DBGM_TOPLEVEL, "%s: cancel rd_t ret(%d)\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: cancel rd_t ret(%d)\n", __FUNCTION__,
ret);
ret = pthread_cancel(ia->wr_t);
dprint(DBGM_TOPLEVEL, "%s: cancel wr_t ret(%d)\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: cancel wr_t ret(%d)\n", __FUNCTION__,
ret);
ret = pthread_join(ia->rd_t, (void *)&retval);
dprint(DBGM_TOPLEVEL, "%s: join rd_t ret(%d) rval(%p)\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: join rd_t ret(%d) rval(%p)\n", __FUNCTION__,
ret, retval);
ret = pthread_join(ia->wr_t, (void *)&retval);
dprint(DBGM_TOPLEVEL, "%s: join wr_t ret(%d) rval(%p)\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: join wr_t ret(%d) rval(%p)\n", __FUNCTION__,
ret, retval);
ia->sbuf = NULL;
ia->rbuf = NULL;
@ -432,7 +432,7 @@ close_audio(iapplication_t *ap, bchannel_t *bc)
free_ibuffer(bc->rbuf);
bc->rbuf = NULL;
ret = sem_destroy(&ia->work);
dprint(DBGM_TOPLEVEL, "%s: sem_destroy work %d\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: sem_destroy work %d\n", __FUNCTION__,
ret);
free(ia);
return(0);
@ -456,7 +456,7 @@ route_call(iapplication_t *ap, bchannel_t *bc)
ap->mode = AP_MODE_INTERN_CALL;
ret = ap->mgr->app_bc(ap->mgr, PR_APP_OCHANNEL, &newbc);
if (0 >= ret)
dprint(DBGM_TOPLEVEL, "%s: no free channel ret(%d)\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: no free channel ret(%d)\n", __FUNCTION__,
ret);
if (!newbc) {
bc->cause_loc = CAUSE_LOC_PNET_LOCUSER;
@ -661,33 +661,33 @@ open_recfiles(iapplication_t *ap, bchannel_t *bc)
if (!bc)
return(-EINVAL);
if (!RecordFilePath[0]) {
dprint(DBGM_TOPLEVEL, "%s: RecordFilePath not set\n", __FUNCTION__);
dprint(DBGM_TOPLEVEL, -1, "%s: RecordFilePath not set\n", __FUNCTION__);
return(-EINVAL);
}
gettimeofday(&tv, NULL);
sprintf(filename, "%s%08lx_%02d.r",
RecordFilePath, tv.tv_sec, bc->channel);
dprint(DBGM_TOPLEVEL, "%s: rf.r:%s\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: rf.r:%s\n", __FUNCTION__,
filename);
if (bc->rrid > 0)
close(bc->rrid);
bc->rrid = open(filename, O_WRONLY|O_CREAT|O_TRUNC,S_IRWXU);
if (bc->rrid < 0) {
ret = -errno;
dprint(DBGM_TOPLEVEL, "%s: rf.r error %s\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: rf.r error %s\n", __FUNCTION__,
strerror(errno));
return(ret);
}
filename[strlen(filename)-1] = 's';
dprint(DBGM_TOPLEVEL, "%s: rf.s:%s\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: rf.s:%s\n", __FUNCTION__,
filename);
if (bc->rsid > 0)
close(bc->rsid);
bc->rsid = open(filename, O_WRONLY|O_CREAT|O_TRUNC,S_IRWXU);
if (bc->rsid < 0) {
ret = -errno;
dprint(DBGM_TOPLEVEL, "%s: rf.s error %s\n", __FUNCTION__,
dprint(DBGM_TOPLEVEL, -1, "%s: rf.s error %s\n", __FUNCTION__,
strerror(errno));
close(bc->rrid);
bc->rrid = -1;
@ -788,7 +788,7 @@ char *argv[];
global_debug, rtp_port);
nr = voip.mgr_lst->nrlist;
while(nr) {
dprint(DBGM_TOPLEVEL, "nr(%s) len(%d) flg(%x) typ(%d) name(%s)\n",
dprint(DBGM_TOPLEVEL, -1, "nr(%s) len(%d) flg(%x) typ(%d) name(%s)\n",
nr->nr, nr->len, nr->flags, nr->typ, nr->name);
nr = nr->next;
}

View File

@ -455,7 +455,7 @@ parse_isdn_packet(iapplication_t *appl, unsigned char *arg) {
pc = *p;
*p++ = 0; /* to use L3 findie, fake a dummy CR L3 frame */
pr = *p++;
dprint(DBGM_ISDN, "%s: pr(%02x) own(%d/%d) peer(%d/%d)\n", __FUNCTION__,
dprint(DBGM_ISDN, -1, "%s: pr(%02x) own(%d/%d) peer(%d/%d)\n", __FUNCTION__,
pr, oc, con->oc, pc, con->pc);
a_pc = con->pc;
a_pc++;
@ -496,7 +496,7 @@ parse_isdn_packet(iapplication_t *appl, unsigned char *arg) {
int
voip_application_handler(iapplication_t *appl, int prim, unsigned char *arg) {
dprint(DBGM_APPL, "%s(%p, %x, %p)\n", __FUNCTION__,
dprint(DBGM_APPL, -1, "%s(%p, %x, %p)\n", __FUNCTION__,
appl, prim, arg);
if (prim == AP_PR_VOIP_NEW) {