From d90cc3e3a010cba1e8d5ba75a113017dd5ca918d Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Sat, 13 Aug 2005 09:31:07 +0000 Subject: [PATCH] Added config option 'immediate' to start pbx if no dnid has been received yet. --- capi.conf | 2 ++ chan_capi.c | 20 +++++++++++++++----- chan_capi_pvt.h | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/capi.conf b/capi.conf index b3e1185..2f8c66f 100644 --- a/capi.conf +++ b/capi.conf @@ -26,6 +26,8 @@ softdtmf=on ;enable/disable software dtmf detection, recommended for AVM ca relaxdtmf=on ;in addition to softdtmf, you can use relaxed dtmf detection accountcode= ;Asterisk accountcode to use in CDRs context=capi-in ;context for incoming calls +;immediate=yes ;immediate start of pbx with extension 's' if no digits were + ;received on incoming call (no destination number yet) ;echosquelch=1 ;_VERY_PRIMITIVE_ echo suppression ;echocancel=yes ;EICON DIVA SERVER (CAPI) echo cancelation ;echotail=64 ;echo cancel tail setting diff --git a/chan_capi.c b/chan_capi.c index 302bec5..7c2d136 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -2483,12 +2483,13 @@ static void capi_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, unsig char buffer_r[AST_CAPI_MAX_STRING]; char *buffer_rp = buffer_r; char *magicmsn = "*\0"; - char *emptydnid = "s\0"; + char *emptydnid = "\0"; + char *startdnid = "s\0"; int deflect = 0; int callpres = 0; DNID = capi_number(CONNECT_IND_CALLEDPARTYNUMBER(CMSG), 1); - if ((DNID && *DNID == 0) || !DNID) { + if (!DNID) { DNID = emptydnid; } if (CONNECT_IND_CALLEDPARTYNUMBER(CMSG)[0] > 1) { @@ -2531,12 +2532,14 @@ static void capi_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, unsig } strncpy(buffer, i->incomingmsn, sizeof(buffer) - 1); for (msn = strtok_r(buffer, ",", &buffer_rp); msn; msn = strtok_r(NULL, ",", &buffer_rp)) { - if (!DNID) { + if (!strlen(DNID)) { /* if no DNID, only accept if '*' was specified */ if (strncasecmp(msn, magicmsn, strlen(msn))) { continue; } - strncpy(i->dnid, emptydnid, sizeof(i->dnid) - 1); + if (i->immediate) { + strncpy(i->dnid, startdnid, sizeof(i->dnid) - 1); + } } else { /* make sure the number match exactly or may match on ptp mode */ cc_ast_verbose(4, 1, VERBOSE_PREFIX_1 "%s: msn='%s' DNID='%s' %s\n", @@ -2573,7 +2576,7 @@ static void capi_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, unsig if (i->isdnmode == AST_CAPI_ISDNMODE_PTP) { capi_new(i, AST_STATE_DOWN); i->state = CAPI_STATE_DID; - if ((DNID == emptydnid) && (i->owner)) { + if (strlen(i->dnid) && (i->owner)) { start_pbx_on_match(i, PLCI, CMSG->Messagenumber); } } else { @@ -3087,6 +3090,7 @@ int mkif(struct ast_capi_conf *conf) tmp->doES = conf->es; tmp->callgroup = conf->callgroup; tmp->group = conf->group; + tmp->immediate = conf->immediate; tmp->smoother = ast_smoother_new(AST_CAPI_MAX_B3_BLOCK_SIZE); @@ -3459,6 +3463,12 @@ static int conf_interface(struct ast_capi_conf *conf, struct ast_variable *v) } continue; } + if (!strcasecmp(v->name, "immediate")) { + if (ast_true(v->value)) { + conf->immediate = 1; + } + continue; + } if (!strcasecmp(v->name, "relaxdtmf")) { if (ast_true(v->value)) { conf->softdtmf = 2; diff --git a/chan_capi_pvt.h b/chan_capi_pvt.h index 44ddb2d..b8f80f8 100644 --- a/chan_capi_pvt.h +++ b/chan_capi_pvt.h @@ -195,6 +195,8 @@ struct ast_capi_pvt { int ecTail; /* isdnmode ptp or ptm */ int isdnmode; + /* Answer before getting digits? */ + int immediate; /* Common ISDN Profile (CIP) */ int cip; @@ -264,6 +266,7 @@ struct ast_capi_conf { int ecoption; int ectail; int isdnmode; + int immediate; int es; unsigned int callgroup; unsigned int group;