[asterisk-commits] branch crichter/0.3.0 r31323 - in
/team/crichter/0.3.0: channels/ channels/mi...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Jun 1 05:48:42 MST 2006
Author: crichter
Date: Thu Jun 1 07:48:42 2006
New Revision: 31323
URL: http://svn.digium.com/view/asterisk?rev=31323&view=rev
Log:
added bearer capability reject support. we send release instead of disconnect in case we have no real channel yet. added support for Restarting channels added support for sending complete decoding. changed some log levels.
Modified:
team/crichter/0.3.0/channels/chan_misdn.c
team/crichter/0.3.0/channels/misdn/chan_misdn_config.h
team/crichter/0.3.0/channels/misdn/ie.c
team/crichter/0.3.0/channels/misdn/isdn_lib.c
team/crichter/0.3.0/channels/misdn/isdn_lib.h
team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c
team/crichter/0.3.0/channels/misdn_config.c
team/crichter/0.3.0/configs/misdn.conf.sample
Modified: team/crichter/0.3.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_misdn.c?rev=31323&r1=31322&r2=31323&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_misdn.c (original)
+++ team/crichter/0.3.0/channels/chan_misdn.c Thu Jun 1 07:48:42 2006
@@ -150,6 +150,8 @@
ast_mutex_t lock;
+ char allowed_bearers[BUFFERSIZE+1];
+
enum misdn_chan_state state;
int holded;
int orginator;
@@ -337,12 +339,28 @@
}
+
+struct allowed_bearers {
+ int cap;
+ int val;
+ char *name;
+};
+
+struct allowed_bearers allowed_bearers_array[]={
+ {INFO_CAPABILITY_SPEECH,1,"speech"},
+ {INFO_CAPABILITY_AUDIO_3_1K,2,"3_1khz"},
+ {INFO_CAPABILITY_DIGITAL_UNRESTRICTED,4,"digital_unrestricted"},
+ {INFO_CAPABILITY_DIGITAL_RESTRICTED,8,"digital_restriced"},
+ {INFO_CAPABILITY_VIDEO,16,"video"}
+};
+
static char *bearer2str(int cap) {
static char *bearers[]={
"Speech",
"Audio 3.1k",
"Unres Digital",
"Res Digital",
+ "Video",
"Unknown Bearer"
};
@@ -359,8 +377,11 @@
case INFO_CAPABILITY_DIGITAL_RESTRICTED:
return bearers[3];
break;
+ case INFO_CAPABILITY_VIDEO:
+ return bearers[4];
+ break;
default:
- return bearers[4];
+ return bearers[5];
break;
}
}
@@ -1208,7 +1229,7 @@
struct misdn_bchannel *bc=ch->bc;
int len=ch->jb_len, threshold=ch->jb_upper_threshold;
- chan_misdn_log(1,bc->port, "config_jb: Called\n");
+ chan_misdn_log(5,bc->port, "config_jb: Called\n");
if ( ! len ) {
chan_misdn_log(1,bc->port, "config_jb: Deactivating Jitterbuffer\n");
@@ -1259,6 +1280,10 @@
break;
}
}
+
+
+
+
static int read_config(struct chan_list *ch, int orig) {
@@ -1276,7 +1301,7 @@
int port=bc->port;
- chan_misdn_log(1,port,"read_config: Getting Config\n");
+ chan_misdn_log(5,port,"read_config: Getting Config\n");
char lang[BUFFERSIZE+1];
@@ -1298,6 +1323,9 @@
misdn_cfg_get( port, MISDN_CFG_NEED_MORE_INFOS, &bc->need_more_infos, sizeof(int));
misdn_cfg_get( port, MISDN_CFG_FAR_ALERTING, &ch->far_alerting, sizeof(int));
+
+ misdn_cfg_get( port, MISDN_CFG_ALLOWED_BEARERS, &ch->allowed_bearers, BUFFERSIZE);
+
int hdlc=0;
misdn_cfg_get( port, MISDN_CFG_HDLC, &hdlc, sizeof(int));
@@ -1357,7 +1385,7 @@
misdn_cfg_get(port, MISDN_CFG_PICKUPGROUP, &pg, sizeof(pg));
misdn_cfg_get(port, MISDN_CFG_CALLGROUP, &cg, sizeof(cg));
- chan_misdn_log(2, port, " --> * CallGrp:%s PickupGrp:%s\n",ast_print_group(buf,sizeof(buf),cg),ast_print_group(buf,sizeof(buf),pg));
+ chan_misdn_log(5, port, " --> * CallGrp:%s PickupGrp:%s\n",ast_print_group(buf,sizeof(buf),cg),ast_print_group(buf,sizeof(buf),pg));
ast->pickupgroup=pg;
ast->callgroup=cg;
}
@@ -2135,18 +2163,20 @@
int bridging;
misdn_cfg_get( 0, MISDN_GEN_BRIDGING, &bridging, sizeof(int));
if (bridging) {
- int ecwb;
+ int ecwb, ec;
misdn_cfg_get( ch1->bc->port, MISDN_CFG_ECHOCANCELWHENBRIDGED, &ecwb, sizeof(int));
- if ( !ecwb ) {
+ misdn_cfg_get( ch1->bc->port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
+ if ( !ecwb && ec ) {
chan_misdn_log(2, ch1->bc->port, "Disabling Echo Cancellor when Bridged\n");
ch1->bc->ec_enable=0;
- /* manager_ec_disable(ch1->bc); */
+ manager_ec_disable(ch1->bc);
}
misdn_cfg_get( ch2->bc->port, MISDN_CFG_ECHOCANCELWHENBRIDGED, &ecwb, sizeof(int));
- if ( !ecwb ) {
+ misdn_cfg_get( ch2->bc->port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
+ if ( !ecwb && ec) {
chan_misdn_log(2, ch2->bc->port, "Disabling Echo Cancellor when Bridged\n");
ch2->bc->ec_enable=0;
- /* manager_ec_disable(ch2->bc); */
+ manager_ec_disable(ch2->bc);
}
/* trying to make a mISDN_dsp conference */
@@ -2195,7 +2225,7 @@
const struct tone_zone_sound *ts= NULL;
struct ast_channel *ast=cl->ast;
- chan_misdn_log(2,cl->bc->port,"Tone Indicate:\n");
+ chan_misdn_log(3,cl->bc->port,"Tone Indicate:\n");
if (!cl->ast) {
return 0;
@@ -2203,24 +2233,24 @@
switch (tone) {
case TONE_DIAL:
- chan_misdn_log(2,cl->bc->port," --> Dial\n");
+ chan_misdn_log(3,cl->bc->port," --> Dial\n");
ts=ast_get_indication_tone(ast->zone,"dial");
misdn_lib_tone_generator_start(cl->bc);
break;
case TONE_ALERTING:
- chan_misdn_log(2,cl->bc->port," --> Ring\n");
+ chan_misdn_log(3,cl->bc->port," --> Ring\n");
ts=ast_get_indication_tone(ast->zone,"ring");
misdn_lib_tone_generator_stop(cl->bc);
break;
case TONE_FAR_ALERTING:
/* VERY UGLY HACK, BECAUSE CHAN_SIP DOES NOT GENERATE TONES */
- chan_misdn_log(2,cl->bc->port," --> Ring\n");
+ chan_misdn_log(3,cl->bc->port," --> Ring\n");
ts=ast_get_indication_tone(ast->zone,"ring");
misdn_lib_tone_generator_start(cl->bc);
misdn_lib_echo(cl->bc,1);
break;
case TONE_BUSY:
- chan_misdn_log(2,cl->bc->port," --> Busy\n");
+ chan_misdn_log(3,cl->bc->port," --> Busy\n");
ts=ast_get_indication_tone(ast->zone,"busy");
misdn_lib_tone_generator_stop(cl->bc);
break;
@@ -2228,7 +2258,7 @@
break;
case TONE_NONE:
- chan_misdn_log(2,cl->bc->port," --> None\n");
+ chan_misdn_log(3,cl->bc->port," --> None\n");
misdn_lib_tone_generator_stop(cl->bc);
ast_playtones_stop(ast);
break;
@@ -2729,8 +2759,8 @@
}
release_unlock;
- chan_misdn_log(1, bc->port, "Trying to Release bc with l3id: %x\n",bc->l3_id);
-
+ chan_misdn_log(1, bc->port, "release_chan: bc with l3id: %x\n",bc->l3_id);
+
//releaseing jitterbuffer
if (ch->jb ) {
misdn_jb_destroy(ch->jb);
@@ -3217,6 +3247,24 @@
/** queue new chan **/
cl_queue_chan(&cl_te, ch) ;
+
+
+ if (!strstr(ch->allowed_bearers,"all")) {
+ int i;
+ for (i=0; i< sizeof(allowed_bearers_array)/sizeof(struct allowed_bearers); i++) {
+ if (allowed_bearers_array[i].cap == bc->capability) {
+ if ( !strstr( ch->allowed_bearers, allowed_bearers_array[i].name)) {
+ chan_misdn_log(0,bc->port,"Bearer Not allowed\b");
+ bc->out_cause=88;
+
+ ch->state=MISDN_EXTCANTMATCH;
+ misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE );
+ return RESPONSE_OK;
+ }
+ }
+
+ }
+ }
/* Check for Pickup Request first */
if (!strcmp(chan->exten, ast_pickup_ext())) {
@@ -3272,7 +3320,8 @@
if (bc->nt)
misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE );
else
- misdn_lib_send_event(bc, EVENT_DISCONNECT );
+ misdn_lib_send_event(bc, EVENT_RELEASE );
+
break;
}
@@ -3296,26 +3345,34 @@
if (bc->nt)
misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE );
else
- misdn_lib_send_event(bc, EVENT_DISCONNECT );
+ misdn_lib_send_event(bc, EVENT_RELEASE);
}
} else {
- int ret= misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
- if (ret == -ENOCHAN) {
- ast_log(LOG_WARNING,"Channel was catched, before we could Acknowledge\n");
- misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
+
+
+ if (bc->sending_complete) {
+ bc->out_cause=1;
+ misdn_lib_send_event(bc, EVENT_RELEASE);
+ } else {
+
+ int ret= misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
+ if (ret == -ENOCHAN) {
+ ast_log(LOG_WARNING,"Channel was catched, before we could Acknowledge\n");
+ misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
+ }
+ /* send tone to phone :) */
+
+ /** ADD IGNOREPAT **/
+
+ int stop_tone;
+ misdn_cfg_get( 0, MISDN_GEN_STOP_TONE, &stop_tone, sizeof(int));
+ if ( (!ast_strlen_zero(bc->dad)) && stop_tone )
+ tone_indicate(ch,TONE_NONE);
+ else
+ tone_indicate(ch,TONE_DIAL);
+
+ ch->state=MISDN_WAITING4DIGS;
}
- /* send tone to phone :) */
-
- /** ADD IGNOREPAT **/
-
- int stop_tone;
- misdn_cfg_get( 0, MISDN_GEN_STOP_TONE, &stop_tone, sizeof(int));
- if ( (!ast_strlen_zero(bc->dad)) && stop_tone )
- tone_indicate(ch,TONE_NONE);
- else
- tone_indicate(ch,TONE_DIAL);
-
- ch->state=MISDN_WAITING4DIGS;
}
}
@@ -3679,8 +3736,11 @@
break;
-
case EVENT_RESTART:
+
+ stop_bc_tones(ch);
+ release_chan(bc);
+
break;
default:
Modified: team/crichter/0.3.0/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/chan_misdn_config.h?rev=31323&r1=31322&r2=31323&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/chan_misdn_config.h (original)
+++ team/crichter/0.3.0/channels/misdn/chan_misdn_config.h Thu Jun 1 07:48:42 2006
@@ -23,6 +23,7 @@
/* port config items */
MISDN_CFG_FIRST = 0,
MISDN_CFG_GROUPNAME, /* char[] */
+ MISDN_CFG_ALLOWED_BEARERS, /* char[] */
MISDN_CFG_FAR_ALERTING, /* int (bool) */
MISDN_CFG_RXGAIN, /* int */
MISDN_CFG_TXGAIN, /* int */
Modified: team/crichter/0.3.0/channels/misdn/ie.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/ie.c?rev=31323&r1=31322&r2=31323&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/ie.c (original)
+++ team/crichter/0.3.0/channels/misdn/ie.c Thu Jun 1 07:48:42 2006
@@ -162,23 +162,28 @@
*stopbits = -1;
*dbits = -1;
*parity = -1;
-
+
if (!nt)
{
p = NULL;
- if (qi->QI_ELEMENT(llc))
+#ifdef LLC_SUPPORT
+ if (qi->QI_ELEMENT(llc)) {
+
p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(llc) + 1;
- else if (qi->QI_ELEMENT(bearer_capability))
+ }
+#endif
+ if (qi->QI_ELEMENT(bearer_capability))
p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(bearer_capability) + 1;
}
if (!p)
return;
+
if (p[0] < 2)
{
printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
return;
}
-
+
*coding = (p[1]&0x60) >> 5;
*capability = p[1] & 0x1f;
octet = 2;
Modified: team/crichter/0.3.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/isdn_lib.c?rev=31323&r1=31322&r2=31323&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.3.0/channels/misdn/isdn_lib.c Thu Jun 1 07:48:42 2006
@@ -465,6 +465,10 @@
bc->channel = 0;
bc->in_use = 0;
+ bc->sending_complete = 0;
+
+ bc->restart_channel=0;
+
bc->conf_id = 0;
bc->need_more_infos = 0;
@@ -551,7 +555,7 @@
unsigned char buff[32];
struct misdn_stack * stack;
- cb_log(2, 0, "$$$ CLEANUP CALLED\n");
+ cb_log(3, 0, "$$$ CLEANUP CALLED\n");
if (!bc ) return -1;
stack=get_stack_by_bc(bc);
@@ -581,15 +585,18 @@
manager_ec_disable(bc);
}
- mISDN_write_frame(stack->midev, buff, bc->layer_id|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-
- cb_log(2, stack->port, "$$$ CLEARING STACK\n");
+ if (bc->bc_state == BCHAN_SETUP)
+ mISDN_write_frame(stack->midev, buff, bc->layer_id|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
+ else
+ mISDN_write_frame(stack->midev, buff, bc->addr|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
+
+ cb_log(3, stack->port, "$$$ CLEARING STACK\n");
+
ret=mISDN_clear_stack(stack->midev,bc->b_stid);
if (ret<0) {
cb_log(-1,stack->port,"clear stack failed [%s]\n",strerror(errno));
}
-
bc->b_stid = 0;
bc_state_change(bc, BCHAN_CLEANED);
@@ -606,8 +613,7 @@
cb_event(EVENT_CLEANUP, &stack->bc[i], glob_mgr->user_data);
empty_chan_in_stack(stack,i+1);
empty_bc(&stack->bc[i]);
- queue_cleanup_bc(&stack->bc[i]);
-
+ clean_up_bc(&stack->bc[i]);
}
}
@@ -965,18 +971,17 @@
pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3)) | ISDN_LAYER((4));
}
-
+
ret = mISDN_set_stack(midev, bc->b_stid, &pid);
-
+
if (ret){
- cb_log(5, stack->port,"$$$ Set Stack Err: %d %s\n",ret,strerror(errno));
+ cb_log(-1, stack->port,"$$$ Set Stack Err: %d %s\n",ret,strerror(errno));
mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-
+
bc_state_change(bc,BCHAN_ERROR);
return(-EINVAL);
}
-
bc_state_change(bc,BCHAN_SETUP);
@@ -1475,7 +1480,7 @@
cb_log(4, stack->port, " --> lib: CLEANING UP l3id: %x\n",frm->dinfo);
empty_chan_in_stack(stack,bc->channel);
empty_bc(bc);
- queue_cleanup_bc(bc);
+ clean_up_bc(bc);
dump_chan_list(stack);
bc->pid = 0;
cb_event(EVENT_CLEANUP, bc, glob_mgr->user_data);
@@ -1513,7 +1518,7 @@
empty_chan_in_stack(stack,bc->channel);
empty_bc(bc);
}
- queue_cleanup_bc(bc);
+ clean_up_bc(bc);
}
@@ -2046,7 +2051,7 @@
case MGR_SETSTACK| INDICATION:
cb_log(2, stack->port, "BCHAN: MGR_SETSTACK|IND \n");
-
+
AGAIN:
bc->addr = mISDN_get_layerid(stack->midev, bc->b_stid, bc->layer);
if (!bc->addr) {
@@ -2919,7 +2924,7 @@
empty_chan_in_stack(stack,bc->channel);
empty_bc(bc);
- queue_cleanup_bc(bc);
+ clean_up_bc(bc);
}
/** we set it up later at RETRIEVE_ACK again.**/
@@ -2994,6 +2999,13 @@
case MGR_SETSTACK|INDICATION:
return handle_bchan(msg);
break;
+
+ case MGR_SETSTACK|CONFIRM:
+ case MGR_CLEARSTACK|CONFIRM:
+ free_msg(msg) ;
+ return 1;
+ break;
+
case DL_DATA|INDICATION:
{
int port=(frm->addr&MASTER_ID_MASK) >> 8;
@@ -3077,8 +3089,10 @@
if (handle_l1(msg))
return 0 ;
- /* The L2/L3 will be queued */
- if (queue_l2l3(msg))
+ if (handle_frm_nt(msg))
+ return 0;
+
+ if (handle_frm(msg))
return 0;
if (handle_err(msg))
@@ -3832,7 +3846,7 @@
}
void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2) {
- int conf_id=(bc1->pid<<1) +1;
+ int conf_id=bc1->pid +1;
cb_log(1, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
Modified: team/crichter/0.3.0/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/isdn_lib.h?rev=31323&r1=31322&r2=31323&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/isdn_lib.h (original)
+++ team/crichter/0.3.0/channels/misdn/isdn_lib.h Thu Jun 1 07:48:42 2006
@@ -181,7 +181,8 @@
int l3_id;
int pid;
int ces;
-
+
+ int restart_channel;
int channel;
int channel_preselected;
@@ -206,6 +207,10 @@
/* get setup ack */
int need_more_infos;
+
+ /* may there be more infos ?*/
+ int sending_complete;
+
/* wether we should use jollys dsp or not */
int nodsp;
Modified: team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c?rev=31323&r1=31322&r2=31323&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c (original)
+++ team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c Thu Jun 1 07:48:42 2006
@@ -194,8 +194,8 @@
}
{
- int sending_complete;
- dec_ie_complete(setup->COMPLETE, (Q931_info_t *)setup, &sending_complete, nt,bc);
+ dec_ie_complete(setup->COMPLETE, (Q931_info_t *)setup, &bc->sending_complete, nt,bc);
+
}
{
@@ -214,6 +214,8 @@
break;
case 0: bc->capability=INFO_CAPABILITY_SPEECH;
break;
+ case 18: bc->capability=INFO_CAPABILITY_VIDEO;
+ break;
case 8: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED;
bc->user1 = user;
bc->urate = urate;
@@ -772,7 +774,7 @@
{
int exclusive, channel;
- dec_ie_channel_id(restart->CHANNEL_ID, (Q931_info_t *)restart, &exclusive, &channel, nt,bc);
+ dec_ie_channel_id(restart->CHANNEL_ID, (Q931_info_t *)restart, &exclusive, &bc->restart_channel, nt,bc);
if (channel==0xff) /* any channel */
channel=-1;
cb_log(3, stack->port, "CC_RESTART Request on channel:%d on this port.\n");
Modified: team/crichter/0.3.0/channels/misdn_config.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn_config.c?rev=31323&r1=31322&r2=31323&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn_config.c (original)
+++ team/crichter/0.3.0/channels/misdn_config.c Thu Jun 1 07:48:42 2006
@@ -84,6 +84,7 @@
static const struct misdn_cfg_spec port_spec[] = {
{ "name", MISDN_CFG_GROUPNAME, MISDN_CTYPE_STR, "default", NONE },
+ { "allowed_bearers", MISDN_CFG_ALLOWED_BEARERS, MISDN_CTYPE_STR, "all", NONE },
{ "rxgain", MISDN_CFG_RXGAIN, MISDN_CTYPE_INT, "0", NONE },
{ "txgain", MISDN_CFG_TXGAIN, MISDN_CTYPE_INT, "0", NONE },
{ "te_choose_channel", MISDN_CFG_TE_CHOOSE_CHANNEL, MISDN_CTYPE_BOOL, "no", NONE },
Modified: team/crichter/0.3.0/configs/misdn.conf.sample
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/configs/misdn.conf.sample?rev=31323&r1=31322&r2=31323&view=diff
==============================================================================
--- team/crichter/0.3.0/configs/misdn.conf.sample (original)
+++ team/crichter/0.3.0/configs/misdn.conf.sample Thu Jun 1 07:48:42 2006
@@ -112,6 +112,11 @@
;
far_alerting=no
+
+;
+; here you can define which bearers should be allowed
+;
+allowed_bearers=all
; Prefixes for national and international, those are put before the
; oad if an according dialplan is set by the other end.
More information about the asterisk-commits
mailing list