- create a pseudo channel for each interface for incoming signalling

without B-channel.
This commit is contained in:
MelwareDE 2005-10-01 15:17:10 +00:00
parent ec3ac2ee78
commit b65c13d415
3 changed files with 44 additions and 30 deletions

25
README
View File

@ -45,7 +45,6 @@ This chan_capi version includes:
- Reject call waiting (ACO)
- DID for Point to Point mode (a.k.a overlap receiving)
- Rx/Tx gains (rxgain=1.0)
- Call deflection on circuit busy (deflect=12345678)
- (Inter)national dialing prefix (for callerid) configurable in capi.conf
- CLI command "capi info" shows B channel status of chan_capi
The called party can press # to drop the call
@ -255,6 +254,15 @@ With a DIVA Server, following features are provided:
Asterisk variables used/set by chan_capi
========================================
BCHANNELINFO
On incomming call, this variable is set with the B-channel information value:
'0' : B-channel is used (default)
'1' : D-channel is used (not implemented yet)
'2' : neither B nor D channel is used (e.g. call waiting)
Call-Waiting: an incoming call with BCHANNELINFO not '0' cannot be accepted.
Another connection must be dropped before accepting or use
capicommand(deflect|<number>) to initiate call deflection to another destination.
CALLEDTON
The 'type of number' value of the called number is saved in this variable on
incomming call.
@ -264,6 +272,12 @@ _CALLERHOLDID
This variable is inherited as CALLERHOLDID to the dialed channel and will be used
if e.g. capicommand(ect) is used to transfer the held call.
CALLINGSUBADDRESS
If set on dial(), the calling subaddress will be set to the content.
CALLEDSUBADDRESS
If set on dial(), the called subaddress will be set to the content.
CONNECTEDNUMBER
Can be set before answering and if set, the content is used for
IE 'Connected Number' on answering.
@ -278,17 +292,12 @@ PRI_CAUSE
REDIRECTINGNUMBER
On incoming call, if the call was redirected to you by someone, the
number of the redirecting party is saved in this variable.
RDNIS is set as well.
REDIRECTREASON
If the incoming call was redirected to you, this variable is set
with the reason value.
CALLINGSUBADDRESS
If set on dial(), the calling subaddress will be set to the content.
CALLEDSUBADDRESS
If set on dial(), the called subaddress will be set to the content.
Functions (available with newer Asterisk only)
==============================================

View File

@ -1578,7 +1578,8 @@ struct ast_channel *capi_request(char *type, int format, void *data)
ast_mutex_lock(&iflock);
for (i = iflist; (i && notfound); i = i->next) {
if (i->owner) {
if ((i->owner) || (i->channeltype != CAPI_CHANNELTYPE_B)) {
/* if already in use or no real channel */
continue;
}
/* unused channel */
@ -3088,6 +3089,7 @@ static void capi_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, unsig
char *magicmsn = "*\0";
char *emptydnid = "\0";
int callpres = 0;
char bchannelinfo[2] = { '0', 0 };
if (*interface) {
/* chan_capi does not support
@ -3117,17 +3119,8 @@ static void capi_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, unsig
cc_ast_verbose(1, 1, VERBOSE_PREFIX_3 "CONNECT_IND (PLCI=%#x,DID=%s,CID=%s,CIP=%#x,CONTROLLER=%#x)\n",
PLCI, DNID, CID, CONNECT_IND_CIPVALUE(CMSG), controller);
if ((CONNECT_IND_BCHANNELINFORMATION(CMSG)) &&
((CONNECT_IND_BCHANNELINFORMATION(CMSG)[1] == 0x02) &&
(capi_controllers[controller]->isdnmode == AST_CAPI_ISDNMODE_MSN))) {
/*
* this is a call waiting CONNECT_IND with BChannelinformation[1] == 0x02
* meaning "no B or D channel for this call", since we can't do anything with call waiting now
* just reject it with "user busy"
* however...if we are a p2p BRI then the telco switch will allow us to choose the b channel
* so it will look like a callwaiting connect_ind to us
*/
ast_log(LOG_NOTICE, "Received a call waiting CONNECT_IND\n");
if (CONNECT_IND_BCHANNELINFORMATION(CMSG)) {
bchannelinfo[0] = CONNECT_IND_BCHANNELINFORMATION(CMSG)[1] + '0';
}
/* well...somebody is calling us. let's set up a channel */
@ -3140,6 +3133,13 @@ static void capi_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, unsig
if (!(i->controllers & (1 << controller))) {
continue;
}
if (i->channeltype == CAPI_CHANNELTYPE_B) {
if (bchannelinfo[0] != '0')
continue;
} else {
if (bchannelinfo[0] == '0')
continue;
}
strncpy(buffer, i->incomingmsn, sizeof(buffer) - 1);
for (msn = strtok_r(buffer, ",", &buffer_rp); msn; msn = strtok_r(NULL, ",", &buffer_rp)) {
if (!strlen(DNID)) {
@ -3204,6 +3204,7 @@ static void capi_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, unsig
ast_mutex_lock(&i->lock);
ast_mutex_unlock(&iflock);
pbx_builtin_setvar_helper(i->owner, "BCHANNELINFO", bchannelinfo);
sprintf(buffer, "%d", callednplan);
pbx_builtin_setvar_helper(i->owner, "CALLEDTON", buffer);
/*
@ -4117,7 +4118,7 @@ int mkif(struct ast_capi_conf *conf)
char *contr;
unsigned long contrmap = 0;
for (i = 0; i < conf->devices; i++) {
for (i = 0; i <= conf->devices; i++) {
tmp = malloc(sizeof(struct ast_capi_pvt));
if (!tmp) {
return -1;
@ -4125,8 +4126,14 @@ int mkif(struct ast_capi_conf *conf)
memset(tmp, 0, sizeof(struct ast_capi_pvt));
ast_pthread_mutex_init(&(tmp->lock),NULL);
strncpy(tmp->name, conf->name, sizeof(tmp->name) - 1);
if (i == 0) {
snprintf(tmp->name, sizeof(tmp->name) - 1, "%s-pseudo-D", conf->name);
tmp->channeltype = CAPI_CHANNELTYPE_D;
} else {
strncpy(tmp->name, conf->name, sizeof(tmp->name) - 1);
tmp->channeltype = CAPI_CHANNELTYPE_B;
}
strncpy(tmp->context, conf->context, sizeof(tmp->context) - 1);
strncpy(tmp->incomingmsn, conf->incomingmsn, sizeof(tmp->incomingmsn) - 1);
strncpy(tmp->prefix, conf->prefix, sizeof(tmp->prefix)-1);
@ -4157,11 +4164,6 @@ int mkif(struct ast_capi_conf *conf)
unit = AST_CAPI_MAX_CONTROLLERS - 1;
contrmap |= (1 << unit);
if (capi_controllers[unit]) {
capi_controllers[unit]->isdnmode = conf->isdnmode;
/* ast_log(LOG_NOTICE, "contr %d isdnmode %d\n",
unit, isdnmode); */
}
contr = strtok_r(NULL, ",", &buffer_rp);
}

View File

@ -193,6 +193,9 @@ struct ast_capi_gains {
#define CAPI_ISDN_STATE_DID 0x0080
#define CAPI_ISDN_STATE_PBX 0x8000
#define CAPI_CHANNELTYPE_B 0
#define CAPI_CHANNELTYPE_D 1
/* ! Private data for a capi device */
struct ast_capi_pvt {
ast_mutex_t lock;
@ -281,6 +284,8 @@ struct ast_capi_pvt {
int doholdtype;
/* line interconnect allowed */
int bridge;
/* channeltype */
int channeltype;
/* Common ISDN Profile (CIP) */
int cip;
@ -367,8 +372,6 @@ struct ast_capi_controller {
int nbchannels;
/* free bchans */
int nfreebchannels;
/* DID */
int isdnmode;
/* features: */
int dtmf;
int echocancel;