[svn-commits] nadi: branch group/trunk-cm-csel-hash r47786 - /team/group/trunk-cm-csel-hash...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Nov 17 03:28:22 MST 2006


Author: nadi
Date: Fri Nov 17 04:28:21 2006
New Revision: 47786

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47786
Log:
minor fixes

Modified:
    team/group/trunk-cm-csel-hash/channels/chan_misdn.c

Modified: team/group/trunk-cm-csel-hash/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/channels/chan_misdn.c?view=diff&rev=47786&r1=47785&r2=47786
==============================================================================
--- team/group/trunk-cm-csel-hash/channels/chan_misdn.c (original)
+++ team/group/trunk-cm-csel-hash/channels/chan_misdn.c Fri Nov 17 04:28:21 2006
@@ -984,7 +984,7 @@
 	int l1check,
 		port_up;
 
-	if (cm_get_int(misdn_cm, l1check, PORT, MCFG_PMP_L1_CHECK, item->port))
+	if (cm_get_bool(misdn_cm, l1check, PORT, MCFG_PMP_L1_CHECK, item->port))
 		l1check = 0;
 
 	port_up = misdn_lib_port_up(item->port, l1check);
@@ -1230,7 +1230,7 @@
 	wp = jb->wp;
 	rp = jb->rp;
 
-	for(i = 0; i < len; ++i) {
+	for (i = 0; i < len; ++i) {
 		jb->samples[wp] = data[i];
 		jb->ok[wp] = 1;
 		wp = (wp != jb->size - 1) ? wp + 1 : 0;
@@ -1319,7 +1319,7 @@
 
 /* mISDN Tech Function Headers */
 static struct ast_channel *   misdn_request        (const char *type, int format, void *data, int *cause);
-static int                    misdn_digit_begin    (struct ast_channel *chan, char digit);
+static int                    misdn_digit_begin    (struct ast_channel *ast, char digit);
 static int                    misdn_digit_end      (struct ast_channel *ast, char digit);
 static int                    misdn_call           (struct ast_channel *ast, char *dest, int timeout);
 static enum ast_bridge_result misdn_bridge         (struct ast_channel *c0, struct ast_channel *c1, int flags,
@@ -1330,11 +1330,10 @@
 static int                    misdn_write          (struct ast_channel *ast, struct ast_frame *frame);
 static int                    misdn_indication     (struct ast_channel *ast, int cond, const void *data, size_t datalen);
 static int                    misdn_fixup          (struct ast_channel *oldast, struct ast_channel *ast);
-static int                    misdn_send_text      (struct ast_channel *chan, const char *text);
+static int                    misdn_send_text      (struct ast_channel *ast, const char *text);
 
 /* Other Function Headers */
-static int                    misdn_set_opt_exec   (struct ast_channel *chan, void *data);
-static int                    config_bc_echocancel (struct misdn_bchannel *bc);
+static int                    misdn_set_opt_exec   (struct ast_channel *ast, void *data);
 
 /* Tech Structs */
 static struct ast_channel_tech misdn_tech = {
@@ -1406,8 +1405,7 @@
 static void print_bearer (struct misdn_bchannel *bc) 
 {
 	chan_misdn_log(2, bc->port, " --> Bearer: %s\n --> Codec: %claw\n",
-				   get_bearer_str(bc->capability),
-				   bc->law == INFO_CODEC_ULAW ? 'U' : 'A');
+				   get_bearer_str(bc->capability), bc->law == INFO_CODEC_ULAW ? 'U' : 'A');
 }
 
 static void print_numplan (int port, int numplan, char *type)
@@ -1490,51 +1488,22 @@
 {
 	struct ast_channel *ast = p->ast;
 
-	ast_cli(fd,
-			"* Pid:%d Prt:%d Ch:%d Mode:%s Org:%s dad:%s oad:%s rad:%s ctx:%s state:%s\n",
-			bc->pid,
-			bc->port,
-			bc->channel,
-			bc->nt ? "NT" : "TE",
-			p->orginator == ORG_AST ? "*" : "I",
-			ast ? ast->exten : "",
-			ast ? AST_CID_P(ast) : "",
-			bc->rad,
-			ast ? ast->context : "",
-			get_state_string(statemachine_get_state(p->sm)));
+	ast_cli(fd, "* Pid:%d Prt:%d Ch:%d Mode:%s Org:%s dad:%s oad:%s rad:%s ctx:%s state:%s\n",
+			bc->pid, bc->port, bc->channel, bc->nt ? "NT" : "TE", p->orginator == ORG_AST ? "*" : "I", ast ? ast->exten : "",
+			ast ? AST_CID_P(ast) : "", bc->rad, ast ? ast->context : "", get_state_string(statemachine_get_state(p->sm)));
 
 	if (misdn_debug[bc->port] > 0)
-		ast_cli(fd,
-				"  --> astname: %s\n"
-				"  --> ch_l3id: %x\n"
-				"  --> ch_addr: %x\n"
-				"  --> bc_addr: %x\n"
-				"  --> bc_l3id: %x\n"
-				"  --> display: %s\n"
-				"  --> state: %s\n"
-				"  --> capability: %s\n"
-				"  --> echo_cancel: %d\n"
-				"  --> notone : rx %d tx:%d\n"
-				"  --> bc_hold: %d\n",
-				p->ast->name,
-				p->l3id,
-				p->addr,
-				bc->addr,
-				bc->l3_id,
-				bc->display,
-				bc_state2str(bc->bc_state),
-				get_bearer_str(bc->capability),
-				bc->ec_enable,
-				p->norxtone,
-				p->notxtone,
-				bc->holded);
-}
-
-static void import_ch (struct ast_channel *chan, struct misdn_bchannel *bc, struct misdn_pvt *p)
+		ast_cli(fd,	"  --> astname: %s\n  --> ch_l3id: %x\n  --> ch_addr: %x\n  --> bc_addr: %x\n  --> bc_l3id: %x\n  --> display: %s\n"
+				"--> state: %s\n  --> capability: %s\n  --> echo_cancel: %d\n  --> notone : rx %d tx:%d\n  --> bc_hold: %d\n",
+				p->ast->name, p->l3id, p->addr, bc->addr, bc->l3_id, bc->display, bc_state2str(bc->bc_state),
+				get_bearer_str(bc->capability),	bc->ec_enable, p->norxtone, p->notxtone, bc->holded);
+}
+
+static void import_ch (struct ast_channel *ast, struct misdn_bchannel *bc, struct misdn_pvt *p)
 {
 	const char *tmp;
 
-	tmp = pbx_builtin_getvar_helper(chan, "MISDN_PID");
+	tmp = pbx_builtin_getvar_helper(ast, "MISDN_PID");
 	if (tmp) {
 		p->other_pid = atoi(tmp);
 		chan_misdn_log(2, bc->port, "IMPORT_PID: importing pid:%s\n", tmp);
@@ -1546,18 +1515,21 @@
 	}
 }
 
-static void update_name(struct ast_channel *tmp, int port, int c) 
+static int get_chan_offset (int port)
 {
 	int chan_offset = 0;
 	int tmp_port, *prev = NULL;
 
-	for (; cm_get_next_id(misdn_cm, PORT, prev, &tmp_port); prev = &tmp_port) {
-		if (tmp_port == port) break;
-		chan_offset += misdn_lib_port_is_pri(tmp_port) ? 30 : 2;	
-	}
-	ast_string_field_build(tmp, name, "%s/%d-u%d", misdn_type, chan_offset + (c < 0 ? 0 : c),
+	for (; cm_get_next_id(misdn_cm, PORT, prev, &tmp_port) && (tmp_port != port);
+		 chan_offset += misdn_lib_port_is_pri(tmp_port) ? 30 : 2, prev = &tmp_port);
+
+	return chan_offset;
+}
+
+static void update_name(struct ast_channel *tmp, int port, int c) 
+{
+	ast_string_field_build(tmp, name, "%s/%d-u%d", misdn_type, get_chan_offset(port) + (c < 0 ? 0 : c),
 						   ast_atomic_fetchadd_int(&glob_channel, 1));
-
 	chan_misdn_log(3, port, " --> updating channel name to [%s]\n", tmp->name);
 }
 
@@ -1662,17 +1634,17 @@
 	return ret;
 }
 
-static void export_chan (struct ast_channel *chan, struct misdn_bchannel *bc, struct misdn_pvt *p)
+static void export_chan (struct ast_channel *ast, struct misdn_bchannel *bc, struct misdn_pvt *p)
 {
 	char tmp[32];
 	chan_misdn_log(2, bc->port, "EXPORT_PID: pid:%d\n", bc->pid);
 	snprintf(tmp, sizeof(tmp), "%d", bc->pid);
-	pbx_builtin_setvar_helper(chan, "_MISDN_PID", tmp);
+	pbx_builtin_setvar_helper(ast, "_MISDN_PID", tmp);
 }
 
 static void send_digit_to_chan (struct misdn_pvt *p, char digit)
 {
-	struct ast_channel *chan = p->ast; 
+	struct ast_channel *ast = p->ast; 
 	static const char *dtmf_tones[] = {
 		"!941+1336/100, !0/100",	/* 0 */
 		"!697+1209/100, !0/100",	/* 1 */
@@ -1693,15 +1665,15 @@
 	};
 
 	if (digit >= '0' && digit <= '9')
-		ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
+		ast_playtones_start(ast, 0, dtmf_tones[digit-'0'], 0);
 	else if (digit >= 'A' && digit <= 'D')
-		ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0);
+		ast_playtones_start(ast, 0, dtmf_tones[digit-'A'+10], 0);
 	else if (digit == '*')
-		ast_playtones_start(chan, 0, dtmf_tones[14], 0);
+		ast_playtones_start(ast, 0, dtmf_tones[14], 0);
 	else if (digit == '#')
-		ast_playtones_start(chan, 0, dtmf_tones[15], 0);
+		ast_playtones_start(ast, 0, dtmf_tones[15], 0);
 	else if (option_debug)
-		ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
+		ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, ast->name);
 }
 
 static void send_cause_to_ast (struct ast_channel *ast, struct misdn_bchannel *bc, struct misdn_pvt *p)
@@ -2082,12 +2054,10 @@
 		ast_cli(fd, "Toggling EchoCancel %s failed Channel does not exist\n", channame);
 	} else {
 		p->toggle_ec = p->toggle_ec ? 0 : 1;
-		if (p->toggle_ec) {
-			config_bc_echocancel(p->bc);
+		if (p->toggle_ec)
 			manager_ec_enable(p->bc);
-		} else {
+		else
 			manager_ec_disable(p->bc);
-		}
 	}
 
 	return 0; 
@@ -2480,7 +2450,7 @@
 	struct misdn_bchannel *bc = p->bc;
 	int hdlc;
 
-	if (cm_get_int(misdn_cm, hdlc, PORT, MCFG_HDLC, bc->port) || hdlc < 0)
+	if (cm_get_bool(misdn_cm, hdlc, PORT, MCFG_HDLC, bc->port) || hdlc < 0)
 		hdlc = 0;
 	if (hdlc) {
 		switch (bc->capability) {
@@ -2523,17 +2493,21 @@
 	}
 }
 
-static int config_bc_echocancel (struct misdn_bchannel *bc)
-{
-	int ec;
-
-	if (cm_get_int(misdn_cm, ec, PORT, MCFG_ECHOCANCEL, bc->port))
-		ec = 0;
-	bc->ec_enable = ec ? 1 : 0;
-	if (ec > 1)
-		bc->ec_deftaps = ec;
-
-	return 0;
+static void config_bc_echocancel (struct misdn_bchannel *bc)
+{
+	char buf[BUFFERSIZE];
+
+	if (cm_get(misdn_cm, buf, sizeof(buf), PORT, MCFG_ECHOCANCEL, bc->port)) {
+		bc->ec_deftaps = 0;
+	} else {
+		if (!strcasecmp(buf, "yes") || !strcasecmp(buf, "y") || !strcasecmp(buf, "on"))
+			bc->ec_deftaps = 128;
+		else if (!strcasecmp(buf, "no") || !strcasecmp(buf, "n") || !strcasecmp(buf, "off"))
+			bc->ec_deftaps = 0;
+		else if (sscanf(buf, "%d", &bc->ec_deftaps) != 1)
+			bc->ec_deftaps = 0;
+	}
+	bc->ec_enable = bc->ec_deftaps ? 1 : 0;
 }
 
 static int config_ch (struct misdn_pvt *p, int orig)
@@ -2567,9 +2541,9 @@
 
 	cm_get_int(misdn_cm, bc->txgain, PORT, MCFG_TXGAIN, bc->port);
 	cm_get_int(misdn_cm, bc->rxgain, PORT, MCFG_RXGAIN, bc->port);
-	cm_get_int(misdn_cm, bc->send_dtmf, PORT, MCFG_SENDDTMF, bc->port);
+	cm_get_bool(misdn_cm, bc->send_dtmf, PORT, MCFG_SENDDTMF, bc->port);
 	cm_get_int(misdn_cm, bc->need_more_infos, PORT, MCFG_NEED_MORE_INFOS, bc->port);
-	cm_get_int(misdn_cm, bc->early_bconnect, PORT, MCFG_EARLY_BCONNECT, bc->port);
+	cm_get_bool(misdn_cm, bc->early_bconnect, PORT, MCFG_EARLY_BCONNECT, bc->port);
 	bc->AOCDtype = Fac_None;
 	config_bc_echocancel(bc);
 
@@ -2682,27 +2656,16 @@
 /* mISDN ast_channel Constructor */
 static struct ast_channel * misdn_new (struct misdn_pvt *p, int state,  char *exten, char *callerid, int format, int port, int c)
 {
-	int bridging,
-		chan_offset = 0,
-		tmp_port,
-		*prev;
+	int bridging;
 	char *cid_name = NULL,
 		 *cid_num = NULL;
 	struct ast_channel *tmp;
 
-	for (prev = NULL; cm_get_next_id(misdn_cm, PORT, prev, &tmp_port); prev = &tmp_port) {
-		if (tmp_port == port)
-			break;
-		chan_offset += misdn_lib_port_is_pri(tmp_port) ? 30 : 2;	
-	}
-
-	c = c < 0 ? 0 : c;
-
 	if (callerid) 
 		ast_callerid_parse(callerid, &cid_name, &cid_num);
 
 	tmp = ast_channel_alloc(1, state, cid_num, cid_name, "%s/%d-u%d", misdn_type,
-							chan_offset + c, ast_atomic_fetchadd_int(&glob_channel, 1));
+							get_chan_offset(port) + (c < 0 ? 0 : c), ast_atomic_fetchadd_int(&glob_channel, 1));
 	if (tmp) {
 		chan_misdn_log(2, 0, " --> * NEW CHANNEL dad:%s oad:%s\n", exten, callerid);
 
@@ -2814,7 +2777,7 @@
 	return p->ast;
 }
 
-static int misdn_digit_begin (struct ast_channel *chan, char digit)
+static int misdn_digit_begin (struct ast_channel *ast, char digit)
 {
 	/* XXX Modify this callback to support Asterisk controlling the length of DTMF */
 	return 0;
@@ -2978,8 +2941,7 @@
 	struct ast_channel *carr[2], *who;
 	struct ast_frame *f;
 	int to = -1,
-		bridging = 0,
-		ec = 0;
+		bridging = 0;
 
 	ch1 = misdn_pvt_by_ast(c0);
 	ch2 = misdn_pvt_by_ast(c1);
@@ -2992,14 +2954,12 @@
 
 	cm_get_int(misdn_cm, bridging, GENERAL, MCFG_BRIDGING);
 	if (bridging) {
-		cm_get_int(misdn_cm, ec, PORT, MCFG_ECHOCANCEL, ch1->bc->port);
-		if (ec) {
+		if (ch1->bc->ec_enable) {
 			chan_misdn_log(2, ch1->bc->port, "Disabling Echo Cancellor when Bridged\n");
 			ch1->bc->ec_enable = 0;
 			manager_ec_disable(ch1->bc);
 		}
-		cm_get_int(misdn_cm, ec, PORT, MCFG_ECHOCANCEL, ch2->bc->port);
-		if (ec) {
+		if (ch2->bc->ec_enable) {
 			chan_misdn_log(2, ch2->bc->port, "Disabling Echo Cancellor when Bridged\n");
 			ch2->bc->ec_enable = 0;
 			manager_ec_disable(ch2->bc); 
@@ -3522,9 +3482,9 @@
 	return 0;
 }
 
-static int misdn_send_text (struct ast_channel *chan, const char *text)
-{
-	struct misdn_pvt *p = chan->tech_pvt;
+static int misdn_send_text (struct ast_channel *ast, const char *text)
+{
+	struct misdn_pvt *p = ast->tech_pvt;
 
 	if (p && p->bc) {
 		ast_copy_string(p->bc->display, text, sizeof(p->bc->display));
@@ -4225,15 +4185,15 @@
 }
 
 /* Applications */
-static int misdn_facility_exec (struct ast_channel *chan, void *data)
-{
-	struct misdn_pvt *p = MISDN_ASTERISK_TECH_PVT(chan);
+static int misdn_facility_exec (struct ast_channel *ast, void *data)
+{
+	struct misdn_pvt *p = MISDN_ASTERISK_TECH_PVT(ast);
 	char *tok,
 		 *tokb;
 
-	chan_misdn_log(0, 0, "TYPE: %s\n", chan->tech->type);
-
-	if (strcasecmp(chan->tech->type, "mISDN")) {
+	chan_misdn_log(0, 0, "TYPE: %s\n", ast->tech->type);
+
+	if (strcasecmp(ast->tech->type, "mISDN")) {
 		ast_log(LOG_WARNING, "misdn_facility makes only sense with chan_misdn channels!\n");
 		return -1;
 	}
@@ -4265,9 +4225,9 @@
 	return 0;
 }
 
-static int misdn_set_opt_exec (struct ast_channel *chan, void *data)
-{
-	struct misdn_pvt *p = MISDN_ASTERISK_TECH_PVT(chan);
+static int misdn_set_opt_exec (struct ast_channel *ast, void *data)
+{
+	struct misdn_pvt *p = MISDN_ASTERISK_TECH_PVT(ast);
 	char *tok,
 		 *tokb;
 	int  keyidx,
@@ -4275,7 +4235,7 @@
 		 change_jitter = 0,
 		 neglect;
 
-	if (strcasecmp(chan->tech->type, "mISDN")) {
+	if (strcasecmp(ast->tech->type, "mISDN")) {
 		ast_log(LOG_WARNING, "misdn_set_opt makes only sense with chan_misdn channels!\n");
 		return -1;
 	}



More information about the svn-commits mailing list