[svn-commits] rmudgett: branch 1.6.0 r207286 - in /branches/1.6.0: channels/ channels/misdn...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 17 20:35:10 CDT 2009


Author: rmudgett
Date: Fri Jul 17 20:35:06 2009
New Revision: 207286

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=207286
Log:
Merged revisions 145293,158010 from
https://origsvn.digium.com/svn/asterisk/branches/1.4
to make merging easier.  These changes are already on trunk.

................
  r145293 | rmudgett | 2008-09-30 18:55:24 -0500 (Tue, 30 Sep 2008) | 54 lines

  channels/chan_misdn.c
  channels/misdn/isdn_lib.c
  *  Miscellaneous other fixes from trunk to make merging easier later.

  ........
  r145200 | rmudgett | 2008-09-30 16:00:54 -0500 (Tue, 30 Sep 2008) | 7 lines

  *  Miscellaneous formatting changes to make v1.4 and trunk
  more merge compatible in the mISDN area.

  channels/chan_misdn.c
  *  Eliminated redundant code in cb_events() EVENT_SETUP

  ........
  r144257 | crichter | 2008-09-24 03:42:55 -0500 (Wed, 24 Sep 2008) | 9 lines

  improved helptext of misdn_set_opt.
  ........
  r142181 | rmudgett | 2008-09-09 12:30:52 -0500 (Tue, 09 Sep 2008) | 1 line

  Cleaned up comment

  ........
  r138738 | rmudgett | 2008-08-18 16:07:28 -0500 (Mon, 18 Aug 2008) | 30 lines

  channels/chan_misdn.c
  *  Made bearer2str() use allowed_bearers_array[]
  *  Made use the causes.h defines instead of hardcoded numbers.
  *  Made use Asterisk presentation indicator values if either of the
  mISDN presentation or screen options are negative.
  *  Updated the misdn_set_opt application option descriptions.
  *  Renamed the awkward Caller ID presentation misdn_set_opt
  application option value not_screened to restricted.
  Deprecated the not_screened option value.

  channels/misdn/isdn_lib.c
  *  Made use the causes.h defines instead of hardcoded numbers.
  *  Fixed some spelling errors and typos.
  *  Added all defined facility code strings to fac2str().

  channels/misdn/isdn_lib.h
  *  Added doxygen comments to struct misdn_bchannel.

  channels/misdn/isdn_lib_intern.h
  *  Added doxygen comments to struct misdn_stack.

  channels/misdn_config.c
  configs/misdn.conf.sample
  *  Updated the mISDN presentation and screen parameter descriptions.

  doc/misdn.txt (doc/tex/misdn.tex)
  *  Updated the misdn_set_opt application option descriptions.
  *  Fixed some spelling errors and typos.
................
  r158010 | rmudgett | 2008-11-19 19:46:09 -0600 (Wed, 19 Nov 2008) | 9 lines

  Merged revision 157977 from
  https://origsvn.digium.com/svn/asterisk/team/group/issue8824

  ........
  Fixes JIRA ABE-1726

  The dial extension could be empty if you are using MISDN_KEYPAD
  to control ISDN provider features.
................

Modified:
    branches/1.6.0/channels/chan_misdn.c
    branches/1.6.0/channels/misdn/isdn_lib.c
    branches/1.6.0/channels/misdn/isdn_lib.h
    branches/1.6.0/channels/misdn/isdn_lib_intern.h
    branches/1.6.0/channels/misdn_config.c
    branches/1.6.0/configs/misdn.conf.sample
    branches/1.6.0/doc/tex/misdn.tex
    branches/1.6.0/main/callerid.c

Modified: branches/1.6.0/channels/chan_misdn.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.0/channels/chan_misdn.c?view=diff&rev=207286&r1=207285&r2=207286
==============================================================================
--- branches/1.6.0/channels/chan_misdn.c (original)
+++ branches/1.6.0/channels/chan_misdn.c Fri Jul 17 20:35:06 2009
@@ -586,51 +586,35 @@
 
 
 struct allowed_bearers {
-	int cap;
-	int val;
-	char *name;
-	int deprecated;
+	char *name;			/*!< Bearer capability name string used in /etc/misdn.conf allowed_bearers */
+	char *display;		/*!< Bearer capability displayable name */
+	int cap;			/*!< SETUP message bearer capability field code value */
+	int deprecated;		/*!< TRUE if this entry is deprecated. (Misspelled or bad name to use) */
 };
 
-static 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_restricted"},
-	{INFO_CAPABILITY_DIGITAL_RESTRICTED,8,"digital_restriced", 1}, /* Allow misspelling for backwards compatibility */
-	{INFO_CAPABILITY_VIDEO,16,"video"}
+/* *INDENT-OFF* */
+static const struct allowed_bearers allowed_bearers_array[]= {
+	/* Name,                      Displayable Name       Bearer Capability,                    Deprecated */
+	{ "speech",                  "Speech",               INFO_CAPABILITY_SPEECH,               0 },
+	{ "3_1khz",                  "3.1KHz Audio",         INFO_CAPABILITY_AUDIO_3_1K,           0 },
+	{ "digital_unrestricted",    "Unrestricted Digital", INFO_CAPABILITY_DIGITAL_UNRESTRICTED, 0 },
+	{ "digital_restricted",      "Restricted Digital",   INFO_CAPABILITY_DIGITAL_RESTRICTED,   0 },
+	{ "digital_restriced",       "Restricted Digital",   INFO_CAPABILITY_DIGITAL_RESTRICTED,   1 }, /* Allow misspelling for backwards compatibility */
+	{ "video",                   "Video",                INFO_CAPABILITY_VIDEO,                0 }
 };
-
-static char *bearer2str(int cap) {
-	static char *bearers[]={
-		"Speech",
-		"Audio 3.1k",
-		"Unres Digital",
-		"Res Digital",
-		"Video",
-		"Unknown Bearer"
-	};
-	
-	switch (cap) {
-	case INFO_CAPABILITY_SPEECH:
-		return bearers[0];
-		break;
-	case INFO_CAPABILITY_AUDIO_3_1K:
-		return bearers[1];
-		break;
-	case INFO_CAPABILITY_DIGITAL_UNRESTRICTED:
-		return bearers[2];
-		break;
-	case INFO_CAPABILITY_DIGITAL_RESTRICTED:
-		return bearers[3];
-		break;
-	case INFO_CAPABILITY_VIDEO:
-		return bearers[4];
-		break;
-	default:
-		return bearers[5];
-		break;
-	}
+/* *INDENT-ON* */
+
+static const char *bearer2str(int cap)
+{
+	unsigned index;
+
+	for (index = 0; index < ARRAY_LEN(allowed_bearers_array); ++index) {
+		if (allowed_bearers_array[index].cap == cap) {
+			return allowed_bearers_array[index].display;
+		}
+	}
+
+	return "Unknown Bearer";
 }
 
 
@@ -898,7 +882,7 @@
 		} else {
 misdn_overlap_dial_task_disconnect:
 			hanguptone_indicate(ch);
-			ch->bc->out_cause=1;
+			ch->bc->out_cause = AST_CAUSE_UNALLOCATED;
 			ch->state=MISDN_CLEANING;
 			misdn_lib_send_event(ch->bc, EVENT_DISCONNECT);
 		}
@@ -965,10 +949,11 @@
 	level = atoi(a->argv[3]);
 
 	switch (a->argc) {
-	case 4:	
+	case 4:
 	case 5:
 		{
-			int only = 0, i;
+			int i;
+			int only = 0;
 			if (a->argc == 5) {
 				if (strncasecmp(a->argv[4], "only", strlen(a->argv[4])))
 					return CLI_SHOWUSAGE;
@@ -983,7 +968,7 @@
 			ast_cli(a->fd, "changing debug level for all ports to %d%s\n",misdn_debug[0], only?" (only)":"");
 		}
 		break;
-	case 6: 
+	case 6:
 	case 7:
 		{
 			int port;
@@ -1187,8 +1172,6 @@
 		ast_cli(fd, "[%s] %s   (Default: %s)\n\t%s\n", section, name, def, desc);
 	else
 		ast_cli(fd, "[%s] %s\n\t%s\n", section, name, desc);
-
-	return;
 }
 
 static char *handle_cli_misdn_show_config(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -1419,7 +1402,7 @@
 
 static char *handle_cli_misdn_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	struct chan_list *help = NULL;
+	struct chan_list *help;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -1437,7 +1420,7 @@
 
 	help = cl_te;
   
-	ast_cli(a->fd, "Channel List: %p\n", cl_te); 
+	ast_cli(a->fd, "Channel List: %p\n", cl_te);
 
 	for (; help; help = help->next) {
 		struct misdn_bchannel *bc = help->bc;   
@@ -1481,7 +1464,7 @@
 
 static char *handle_cli_misdn_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	struct chan_list *help = NULL;
+	struct chan_list *help;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -1560,7 +1543,7 @@
 	     port = misdn_cfg_get_next_port(port)) {
 		char buf[128];
 		get_show_stack_details(port, buf);
-		ast_cli(a->fd,"  %s  Debug:%d%s\n", buf, misdn_debug[port], misdn_debug_only[port] ? "(only)" : "");
+		ast_cli(a->fd, "  %s  Debug:%d%s\n", buf, misdn_debug[port], misdn_debug_only[port] ? "(only)" : "");
 	}
 
 	return CLI_SUCCESS;
@@ -1614,7 +1597,7 @@
 		return CLI_SHOWUSAGE;
 
 	port = atoi(a->argv[3]);
-  
+
 	ast_cli(a->fd, "BEGIN STACK_LIST:\n");
 	get_show_stack_details(port, buf);
 	ast_cli(a->fd, "  %s  Debug:%d%s\n", buf, misdn_debug[port], misdn_debug_only[port] ? "(only)" : "");
@@ -1691,9 +1674,8 @@
 
 		misdn_lib_send_event(bc, EVENT_FACILITY);
 	} else if (strstr(a->argv[3],"CFDeactivate")) {
-
 		if (a->argc < 6) {
-			ast_verbose("CFActivate requires 1 arg: FromNumber\n\n");
+			ast_verbose("CFDeactivate requires 1 arg: FromNumber\n\n");
 			return 0;
 		}
 		port = atoi(a->argv[4]);
@@ -1715,6 +1697,9 @@
 
 static char *handle_cli_misdn_send_restart(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
+	int port;
+	int channel;
+
 	switch (cmd) {
 	case CLI_INIT:
 		e->command = "misdn send restart";
@@ -1729,10 +1714,13 @@
 	if (a->argc < 4 || a->argc > 5)
 		return CLI_SHOWUSAGE;
 
-	if (a->argc == 5)
- 		misdn_lib_send_restart(atoi(a->argv[3]), atoi(a->argv[4]));
-	else
- 		misdn_lib_send_restart(atoi(a->argv[3]), -1);
+	port = atoi(a->argv[3]);
+	if (a->argc == 5) {
+		channel = atoi(a->argv[4]);
+ 		misdn_lib_send_restart(port, channel);
+	} else {
+ 		misdn_lib_send_restart(port, -1);
+	}
 
 	return CLI_SUCCESS;
 }
@@ -1814,7 +1802,7 @@
 		return CLI_SUCCESS;
 	}
 
-	tmp->toggle_ec = tmp->toggle_ec?0:1;
+	tmp->toggle_ec = tmp->toggle_ec ? 0 : 1;
 
 	if (tmp->toggle_ec) {
 #ifdef MISDN_1_2
@@ -1998,51 +1986,46 @@
 		}
 	}
 
-
 	misdn_cfg_get(port, MISDN_CFG_PRES, &pres, sizeof(pres));
 	misdn_cfg_get(port, MISDN_CFG_SCREEN, &screen, sizeof(screen));
 	chan_misdn_log(2, port, " --> pres: %d screen: %d\n", pres, screen);
 		
-	if ( (pres + screen) < 0 ) {
-
+	if (pres < 0 || screen < 0) {
 		chan_misdn_log(2, port, " --> pres: %x\n", ast->cid.cid_pres);
 			
 		switch (ast->cid.cid_pres & 0x60) {
-				
 		case AST_PRES_RESTRICTED:
 			bc->pres = 1;
-			chan_misdn_log(2, port, " --> PRES: Restricted (0x1)\n");
+			chan_misdn_log(2, port, " --> PRES: Restricted (1)\n");
 			break;
 		case AST_PRES_UNAVAILABLE:
 			bc->pres = 2;
-			chan_misdn_log(2, port, " --> PRES: Unavailable (0x2)\n");
+			chan_misdn_log(2, port, " --> PRES: Unavailable (2)\n");
 			break;
 		default:
 			bc->pres = 0;
-			chan_misdn_log(2, port, " --> PRES: Allowed (0x0)\n");
-		}
-			
+			chan_misdn_log(2, port, " --> PRES: Allowed (0)\n");
+			break;
+		}
+
 		switch (ast->cid.cid_pres & 0x3) {
-
+		default:
 		case AST_PRES_USER_NUMBER_UNSCREENED:
 			bc->screen = 0;
-			chan_misdn_log(2, port, " --> SCREEN: Unscreened (0x0)\n");
+			chan_misdn_log(2, port, " --> SCREEN: Unscreened (0)\n");
 			break;
 		case AST_PRES_USER_NUMBER_PASSED_SCREEN:
 			bc->screen = 1;
-			chan_misdn_log(2, port, " --> SCREEN: Passed Screen (0x1)\n");
+			chan_misdn_log(2, port, " --> SCREEN: Passed Screen (1)\n");
 			break;
 		case AST_PRES_USER_NUMBER_FAILED_SCREEN:
 			bc->screen = 2;
-			chan_misdn_log(2, port, " --> SCREEN: Failed Screen (0x2)\n");
+			chan_misdn_log(2, port, " --> SCREEN: Failed Screen (2)\n");
 			break;
 		case AST_PRES_NETWORK_NUMBER:
 			bc->screen = 3;
-			chan_misdn_log(2, port, " --> SCREEN: Network Nr. (0x3)\n");
-			break;
-		default:
-			bc->screen = 0;
-			chan_misdn_log(2, port, " --> SCREEN: Unscreened (0x0)\n");
+			chan_misdn_log(2, port, " --> SCREEN: Network Nr. (3)\n");
+			break;
 		}
 	} else {
 		bc->screen = screen;
@@ -2187,11 +2170,11 @@
 	misdn_cfg_get(port, MISDN_CFG_INCOMING_EARLY_AUDIO, &ch->incoming_early_audio, sizeof(ch->incoming_early_audio));
 
 	misdn_cfg_get(port, MISDN_CFG_SENDDTMF, &bc->send_dtmf, sizeof(bc->send_dtmf));
-	
-	misdn_cfg_get( port, MISDN_CFG_ASTDTMF, &ch->ast_dsp, sizeof(int));
+
+	misdn_cfg_get(port, MISDN_CFG_ASTDTMF, &ch->ast_dsp, sizeof(int));
 
 	if (ch->ast_dsp) {
-		ch->ignore_dtmf=1;
+		ch->ignore_dtmf = 1;
 	}
 
 	misdn_cfg_get(port, MISDN_CFG_NEED_MORE_INFOS, &bc->need_more_infos, sizeof(bc->need_more_infos));
@@ -2372,22 +2355,10 @@
 	int r;
 	int exceed;
 	int bridging;
-	struct chan_list *ch = MISDN_ASTERISK_TECH_PVT(ast);
+	struct chan_list *ch;
 	struct misdn_bchannel *newbc;
-	char *opts = NULL, *ext, *tokb;
-	char *dest_cp = ast_strdupa(dest);
-
-	ext = strtok_r(dest_cp, "/", &tokb);
-
-	if (ext) {
-		ext = strtok_r(NULL, "/", &tokb);
-		if (ext) {
-			opts = strtok_r(NULL, "/", &tokb);
-		} else {
-			chan_misdn_log(0, 0, "misdn_call: No Extension given!\n");
-			return -1;
-		}
-	}
+	char *opts, *ext;
+	char *dest_cp;
 
 	if (!ast) {
 		ast_log(LOG_WARNING, " --> ! misdn_call called on ast_channel *ast where ast == NULL\n");
@@ -2401,6 +2372,7 @@
 		return -1;
 	}
 
+	ch = MISDN_ASTERISK_TECH_PVT(ast);
 	if (!ch) {
 		ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast->name);
 		ast->hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
@@ -2409,13 +2381,28 @@
 	}
 	
 	newbc = ch->bc;
-	
 	if (!newbc) {
 		ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast->name);
 		ast->hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
 		ast_setstate(ast, AST_STATE_DOWN);
 		return -1;
 	}
+	
+	/*
+	 * dest is ---v
+	 * Dial(mISDN/g:group_name[/extension[/options]])
+	 * Dial(mISDN/port[:preselected_channel][/extension[/options]])
+	 *
+	 * The dial extension could be empty if you are using MISDN_KEYPAD
+	 * to control ISDN provider features.
+	 */
+	dest_cp = ast_strdupa(dest);
+	strsep(&dest_cp, "/");/* Discard port/group token */
+	ext = strsep(&dest_cp, "/");
+	if (!ext) {
+		ext = "";
+	}
+	opts = dest_cp;
 	
 	port = newbc->port;
 
@@ -2507,7 +2494,7 @@
 	struct chan_list *p;
 	const char *tmp;
 
-	if (!ast || ! (p = MISDN_ASTERISK_TECH_PVT(ast)) ) return -1;
+	if (!ast || !(p = MISDN_ASTERISK_TECH_PVT(ast))) return -1;
 	
 	chan_misdn_log(1, p ? (p->bc ? p->bc->port : 0) : 0, "* ANSWER:\n");
 	
@@ -2523,7 +2510,6 @@
 	}
 
 	tmp = pbx_builtin_getvar_helper(p->ast, "CRYPT_KEY");
-
 	if (!ast_strlen_zero(tmp)) {
 		chan_misdn_log(1, p->bc->port, " --> Connection will be BF crypted\n");
 		ast_copy_string(p->bc->crypt_key, tmp, sizeof(p->bc->crypt_key));
@@ -2565,7 +2551,7 @@
 	struct misdn_bchannel *bc;
 	char buf[2] = { digit, 0 };
 	
-	if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast))) return -1;
+	if (!ast || !(p = MISDN_ASTERISK_TECH_PVT(ast))) return -1;
 
 	bc = p->bc;
 	chan_misdn_log(1, bc ? bc->port : 0, "* IND : Digit %c\n", digit);
@@ -2596,7 +2582,7 @@
 			if ( bc->send_dtmf ) 
 				send_digit_to_chan(p,digit);
 		break;
-}
+	}
 
 	return 0;
 }
@@ -2667,7 +2653,7 @@
 			p->state = MISDN_ALERTING;
 			chan_misdn_log(2, p->bc->port, " --> * IND :\tringing pid:%d\n", p->bc ? p->bc->pid : -1);
 			misdn_lib_send_event( p->bc, EVENT_ALERTING);
-			
+
 			if (p->other_ch && p->other_ch->bc) {
 				if (misdn_inband_avail(p->other_ch->bc)) {
 					chan_misdn_log(2, p->bc->port, " --> other End is mISDN and has inband info available\n");
@@ -2682,8 +2668,8 @@
 
 			chan_misdn_log(3, p->bc->port, " --> * SEND: State Ring pid:%d\n", p->bc ? p->bc->pid : -1);
 			ast_setstate(ast, AST_STATE_RING);
-			
-			if ( !p->bc->nt && (p->originator == ORG_MISDN) && !p->incoming_early_audio ) 
+
+			if (!p->bc->nt && (p->originator == ORG_MISDN) && !p->incoming_early_audio)
 				chan_misdn_log(2, p->bc->port, " --> incoming_early_audio off\n");
 			else 
 				return -1;
@@ -3162,7 +3148,7 @@
 		return 0;
 	}
 
-	chan_misdn_log(9, ch->bc->port, "Sending :%d bytes 2 MISDN\n", frame->samples);
+	chan_misdn_log(9, ch->bc->port, "Sending :%d bytes to MISDN\n", frame->samples);
 	if ( !ch->bc->nojitter && misdn_cap_is_speech(ch->bc->capability) ) {
 		/* Buffered Transmit (triggered by read from isdn side)*/
 		if (misdn_jb_fill(ch->jb, frame->data, frame->samples) < 0) {
@@ -3172,7 +3158,7 @@
 		
 	} else {
 		/*transmit without jitterbuffer*/
-		i=misdn_lib_tx2misdn_frm(ch->bc, frame->data, frame->samples);
+		i = misdn_lib_tx2misdn_frm(ch->bc, frame->data, frame->samples);
 	}
 
 	return 0;
@@ -3366,7 +3352,6 @@
 	struct chan_list *cl;
 
 	cl = ast_calloc(1, sizeof(*cl));
-
 	if (!cl) {
 		chan_misdn_log(-1, 0, "misdn_request: malloc failed!");
 		return NULL;
@@ -3386,20 +3371,28 @@
 	struct ast_channel *tmp = NULL;
 	char group[BUFFERSIZE + 1] = "";
 	char dial_str[128];
-	char *buf2 = ast_strdupa(data), *ext = NULL, *port_str;
-	char *tokb = NULL, *p = NULL;
-	int channel = 0, port = 0;
+	char *buf2 = ast_strdupa(data);
+	char *ext;
+	char *port_str;
+	char *p = NULL;
+	int channel = 0;
+	int port = 0;
 	struct misdn_bchannel *newbc = NULL;
 	int dec = 0;
 	struct chan_list *cl;
 
-	snprintf(dial_str, sizeof(dial_str), "%s/%s", misdn_type, (char*)data);
-
-	port_str = strtok_r(buf2, "/", &tokb);
-
-	ext = strtok_r(NULL, "/", &tokb);
-
-	if (port_str) {
+	snprintf(dial_str, sizeof(dial_str), "%s/%s", misdn_type, (char *) data);
+
+	/*
+	 * data is ---v
+	 * Dial(mISDN/g:group_name[/extension[/options]])
+	 * Dial(mISDN/port[:preselected_channel][/extension[/options]])
+	 *
+	 * The dial extension could be empty if you are using MISDN_KEYPAD
+	 * to control ISDN provider features.
+	 */
+	port_str = strsep(&buf2, "/");
+	if (!ast_strlen_zero(port_str)) {
 		if (port_str[0] == 'g' && port_str[1] == ':' ) {
 			/* We make a group call lets checkout which ports are in my group */
 			port_str += 2;
@@ -3415,12 +3408,17 @@
 			port = atoi(port_str);
 		}
 	} else {
-		ast_log(LOG_WARNING, " --> ! IND : CALL dad:%s WITHOUT PORT/Group, check extensions.conf\n", ext);
+		ast_log(LOG_WARNING, " --> ! IND : Dial(%s) WITHOUT Port or Group, check extensions.conf\n", dial_str);
 		return NULL;
 	}
 
+	ext = strsep(&buf2, "/");
+	if (!ext) {
+		ext = "";
+	}
+
 	if (misdn_cfg_is_group_method(group, METHOD_STANDARD_DEC)) {
-		chan_misdn_log(4, port, " --> STARTING STANDARDDEC...\n");
+		chan_misdn_log(4, port, " --> STARTING STANDARD DEC...\n");
 		dec = 1;
 	}
 
@@ -3633,9 +3631,9 @@
 		c = 0;
 
 	ast_string_field_build(tmp, name, "%s/%d-u%d",
-				 misdn_type, chan_offset+c, glob_channel++);
-
-	chan_misdn_log(3 , port, " --> updating channel name to [%s]\n", tmp->name);
+		misdn_type, chan_offset + c, glob_channel++);
+
+	chan_misdn_log(3, port, " --> updating channel name to [%s]\n", tmp->name);
 }
 
 static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char *exten, char *callerid, int format, int port, int c)
@@ -3649,16 +3647,16 @@
 	for (; tmp_port > 0; tmp_port = misdn_cfg_get_next_port(tmp_port)) {
 		if (tmp_port == port)
 			break;
-		chan_offset += misdn_lib_port_is_pri(tmp_port) ? 30 : 2;	
+		chan_offset += misdn_lib_port_is_pri(tmp_port) ? 30 : 2;
 	}
 	if (c < 0)
 		c = 0;
 
-	if (callerid) 
+	if (callerid) {
 		ast_callerid_parse(callerid, &cid_name, &cid_num);
+	}
 
 	tmp = ast_channel_alloc(1, state, cid_num, cid_name, "", exten, "", 0, "%s/%d-u%d", misdn_type, chan_offset + c, glob_channel++);
-
 	if (tmp) {
 		chan_misdn_log(2, 0, " --> * NEW CHANNEL dad:%s oad:%s\n", exten, callerid);
 
@@ -3694,7 +3692,6 @@
 
 		if (pipe(chlist->pipe) < 0)
 			ast_log(LOG_ERROR, "Pipe failed\n");
-
 		ast_channel_set_fd(tmp, 0, chlist->pipe[0]);
 
 		if (state == AST_STATE_RING)
@@ -3702,7 +3699,7 @@
 		else
 			tmp->rings = 0;
 		
-	        ast_jb_configure(tmp, misdn_get_global_jbconf());
+		ast_jb_configure(tmp, misdn_get_global_jbconf());
 	} else {
 		chan_misdn_log(-1, 0, "Unable to allocate channel structure\n");
 	}
@@ -4101,7 +4098,7 @@
 
 	chan_misdn_log(1, bc->port, "* Starting Ast ctx:%s dad:%s oad:%s with 's' extension\n", ast->context, ast->exten, ast->cid.cid_num);
   
-	strncpy(ast->exten, "s", 2);
+	strcpy(ast->exten, "s");
   
 	if (!ast_canmatch_extension(ast, ast->context, ast->exten, 1, bc->oad) || pbx_start_chan(ch) < 0) {
 		ast = NULL;
@@ -4154,12 +4151,13 @@
 
 	switch (bc->cause) {
 
-	case 1: /** Congestion Cases **/
-	case 2:
-	case 3:
- 	case 4:
- 	case 22:
- 	case 27:
+	case AST_CAUSE_UNALLOCATED:
+	case AST_CAUSE_NO_ROUTE_TRANSIT_NET:
+	case AST_CAUSE_NO_ROUTE_DESTINATION:
+ 	case 4:	/* Send special information tone */
+ 	case AST_CAUSE_NUMBER_CHANGED:
+ 	case AST_CAUSE_DESTINATION_OUT_OF_ORDER:
+		/* Congestion Cases */
 		/*
 		 * Not Queueing the Congestion anymore, since we want to hear
 		 * the inband message
@@ -4171,9 +4169,8 @@
 		*/
 		break;
 
-	case 21:
-	case 17: /* user busy */
-
+	case AST_CAUSE_CALL_REJECTED:
+	case AST_CAUSE_USER_BUSY:
 		ch->state = MISDN_BUSY;
 
 		if (!ch->need_busy) {
@@ -4195,7 +4192,9 @@
 /*! \brief Import parameters from the dialplan environment variables */
 void import_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
 {
-	const char *tmp = pbx_builtin_getvar_helper(chan, "MISDN_PID");
+	const char *tmp;
+
+	tmp = pbx_builtin_getvar_helper(chan, "MISDN_PID");
 	if (tmp) {
 		ch->other_pid = atoi(tmp);
 		chan_misdn_log(3, bc->port, " --> IMPORT_PID: importing pid:%s\n", tmp);
@@ -4219,8 +4218,9 @@
 	}
 
 	tmp = pbx_builtin_getvar_helper(chan, "MISDN_KEYPAD");
-	if (tmp)
+	if (tmp) {
 		ast_copy_string(bc->keypad, tmp, sizeof(bc->keypad));
+	}
 }
 
 /*! \brief Export parameters to the dialplan environment variables */
@@ -4305,6 +4305,7 @@
 static enum event_response_e
 cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
 {
+	int msn_valid;
 	struct chan_list *held_ch;
 	struct chan_list *ch = find_chan_by_bc(cl_te, bc);
 	
@@ -4403,7 +4404,9 @@
 	case EVENT_DTMF_TONE:
 	{
 		/*  sending INFOS as DTMF-Frames :) */
-		struct ast_frame fr = { 0, };
+		struct ast_frame fr;
+
+		memset(&fr, 0, sizeof(fr));
 		fr.frametype = AST_FRAME_DTMF;
 		fr.subclass = bc->dtmf ;
 		fr.src = NULL;
@@ -4440,7 +4443,7 @@
 				ast_copy_string(bc->info_dad, bc->keypad, sizeof(bc->info_dad));
 			}
 
-			strncat(bc->dad,bc->info_dad, sizeof(bc->dad) - strlen(bc->dad) - 1);
+			strncat(bc->dad, bc->info_dad, sizeof(bc->dad) - strlen(bc->dad) - 1);
 			ast_copy_string(ch->ast->exten, bc->dad, sizeof(ch->ast->exten));
 
 			/* Check for Pickup Request first */
@@ -4477,7 +4480,7 @@
 				if (bc->nt)
 					hanguptone_indicate(ch);
 				ch->state = MISDN_EXTCANTMATCH;
-				bc->out_cause = 1;
+				bc->out_cause = AST_CAUSE_UNALLOCATED;
 
 				misdn_lib_send_event(bc, EVENT_DISCONNECT);
 				break;
@@ -4503,6 +4506,7 @@
 			/*  sending INFOS as DTMF-Frames :) */
 			struct ast_frame fr;
 			int digits;
+
 			memset(&fr, 0, sizeof(fr));
 			fr.frametype = AST_FRAME_DTMF;
 			fr.subclass = bc->info_dad[0] ;
@@ -4530,10 +4534,9 @@
 	case EVENT_SETUP:
 	{
 		struct chan_list *ch = find_chan_by_bc(cl_te, bc);
-		int msn_valid = misdn_cfg_is_msn_valid(bc->port, bc->dad);
 		struct ast_channel *chan;
 		int exceed;
-		int pres,screen;
+		int pres, screen;
 		int ai;
 		int im;
 
@@ -4548,6 +4551,7 @@
 			}
 		}
 
+		msn_valid = misdn_cfg_is_msn_valid(bc->port, bc->dad);
 		if (!bc->nt && ! msn_valid) {
 			chan_misdn_log(1, bc->port, " --> Ignoring Call, its not in our MSN List\n");
 			return RESPONSE_IGNORE_SETUP; /*  Ignore MSNs which are not in our List */
@@ -4557,22 +4561,7 @@
 			int cause;
 			chan_misdn_log(0, bc->port, " --> Call Waiting on PMP sending RELEASE_COMPLETE\n");
 			misdn_cfg_get(bc->port, MISDN_CFG_REJECT_CAUSE, &cause, sizeof(cause));
-			bc->out_cause = cause ? cause : 16;
-			return RESPONSE_RELEASE_SETUP;
-		}
-
-		print_bearer(bc);
-    
-		if (!bc->nt && ! msn_valid) {
-			chan_misdn_log(1, bc->port, " --> Ignoring Call, its not in our MSN List\n");
-			return RESPONSE_IGNORE_SETUP; /*  Ignore MSNs which are not in our List */
-		}
-
-		if (bc->cw) {
-			int cause;
-			chan_misdn_log(0, bc->port, " --> Call Waiting on PMP sending RELEASE_COMPLETE\n");
-			misdn_cfg_get(bc->port, MISDN_CFG_REJECT_CAUSE, &cause, sizeof(cause));
-			bc->out_cause = cause ? cause : 16;
+			bc->out_cause = cause ? cause : AST_CAUSE_NORMAL_CLEARING;
 			return RESPONSE_RELEASE_SETUP;
 		}
 
@@ -4591,7 +4580,6 @@
 		ch->originator = ORG_MISDN;
 
 		chan = misdn_new(ch, AST_STATE_RESERVED, bc->dad, bc->oad, AST_FORMAT_ALAW, bc->port, bc->channel);
-
 		if (!chan) {
 			ast_free(ch);
 			misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
@@ -4621,17 +4609,19 @@
 			break;
 		case 2:
 			pres = AST_PRES_UNAVAILABLE;
-			chan_misdn_log(2, bc->port, " --> PRES: Restricted (2)\n");
+			chan_misdn_log(2, bc->port, " --> PRES: Unavailable (2)\n");
 			break;
 		default:
 			pres = AST_PRES_ALLOWED;
-			chan_misdn_log(2, bc->port, " --> PRES: Restricted (%d)\n", bc->pres);
+			chan_misdn_log(2, bc->port, " --> PRES: Allowed (%d)\n", bc->pres);
+			break;
 		}
 
 		switch (bc->screen) {
+		default:
 		case 0:
 			screen = AST_PRES_USER_NUMBER_UNSCREENED;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (0)\n");
+			chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (%d)\n", bc->screen);
 			break;
 		case 1:
 			screen = AST_PRES_USER_NUMBER_PASSED_SCREEN;
@@ -4645,12 +4635,9 @@
 			screen = AST_PRES_NETWORK_NUMBER;
 			chan_misdn_log(2, bc->port, " --> SCREEN: Network Number (3)\n");
 			break;
-		default:
-			screen = AST_PRES_USER_NUMBER_UNSCREENED;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (%d)\n", bc->screen);
-		}
-
-		chan->cid.cid_pres = pres + screen;
+		}
+
+		chan->cid.cid_pres = pres | screen;
 
 		pbx_builtin_setvar_helper(chan, "TRANSFERCAPABILITY", ast_transfercapability2str(bc->capability));
 		chan->transfercapability = bc->capability;
@@ -4849,7 +4836,6 @@
 	break;
 	case EVENT_PROCEEDING:
 	{
-		
 		if (misdn_cap_is_speech(bc->capability) &&
 		     misdn_inband_avail(bc) ) {
 			start_bc_tones(ch);
@@ -5104,7 +5090,7 @@
 	{
 		if (ch->bc->AOCD_need_export)
 			export_aoc_vars(ch->originator, ch->ast, ch->bc);
-		if (!misdn_cap_is_speech(ch->bc->capability) ) {
+		if (!misdn_cap_is_speech(ch->bc->capability)) {
 			struct ast_frame frame;
 			/*In Data Modes we queue frames*/
 			frame.frametype  = AST_FRAME_VOICE; /*we have no data frames yet*/
@@ -5140,7 +5126,7 @@
 			}
 			
 			if (FD_ISSET(ch->pipe[1], &wrfs)) {
-				chan_misdn_log(9, bc->port, "writing %d bytes 2 asterisk\n", bc->bframe_len);
+				chan_misdn_log(9, bc->port, "writing %d bytes to asterisk\n", bc->bframe_len);
 				if (write(ch->pipe[1], bc->bframe, bc->bframe_len) <= 0) {
 					chan_misdn_log(0, bc->port, "Write returned <=0 (err=%s) --> hanging up channel\n", strerror(errno));
 
@@ -5155,7 +5141,7 @@
 	}
 	break;
 	case EVENT_TIMEOUT:
-		{
+	{
 		if (ch && bc)
 			chan_misdn_log(1, bc->port, "--> state: %s\n", misdn_get_ch_state(ch));
 
@@ -5170,7 +5156,7 @@
 		case MISDN_PROCEEDING:
 		case MISDN_CALLING_ACKNOWLEDGE:
 			if (bc->nt) {
-				bc->progress_indicator = 8;
+				bc->progress_indicator = INFO_PI_INBAND_AVAILABLE;
 				hanguptone_indicate(ch);
 			}
 				
@@ -5180,7 +5166,7 @@
 
 		case MISDN_WAITING4DIGS:
 			if (bc->nt) {
-				bc->progress_indicator = 8;
+				bc->progress_indicator = INFO_PI_INBAND_AVAILABLE;
 				bc->out_cause = AST_CAUSE_UNALLOCATED;
 				hanguptone_indicate(ch);
 				misdn_lib_send_event(bc, EVENT_DISCONNECT);
@@ -5857,7 +5843,10 @@
 			/* CRICH: callingpres!!! */
 			if (strstr(tok,"allowed")) {
 				ch->bc->pres = 0;
+			} else if (strstr(tok, "restricted")) {
+				ch->bc->pres = 1;
 			} else if (strstr(tok, "not_screened")) {
+				chan_misdn_log(0, ch->bc->port, "SETOPT: callerpres: not_screened is deprecated\n");
 				ch->bc->pres = 1;
 			}
 			break;
@@ -5928,15 +5917,13 @@
 	jb->state_empty = 0;
 	jb->bytes_wrote = 0;
 	jb->samples = ast_malloc(size * sizeof(char));
-
 	if (!jb->samples) {
 		ast_free(jb);
 		chan_misdn_log(-1, 0, "No free Mem for jb->samples\n");
 		return NULL;
 	}
-	
+
 	jb->ok = ast_malloc(size * sizeof(char));
-
 	if (!jb->ok) {
 		ast_free(jb->samples);
 		ast_free(jb);
@@ -5996,7 +5983,7 @@
 
 		rp = wp;
 		for (j = 0; j < jb->upper_threshold; j++)
-			rp = rp != 0 ? rp - 1 : jb->size - 1;
+			rp = (rp != 0) ? rp - 1 : jb->size - 1;
 		jb->rp = rp;
 		jb->state_full = 0;
 		jb->state_empty = 1;

Modified: branches/1.6.0/channels/misdn/isdn_lib.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.0/channels/misdn/isdn_lib.c?view=diff&rev=207286&r1=207285&r2=207286
==============================================================================
--- branches/1.6.0/channels/misdn/isdn_lib.c (original)
+++ branches/1.6.0/channels/misdn/isdn_lib.c Fri Jul 17 20:35:06 2009
@@ -25,6 +25,14 @@
 #include "isdn_lib_intern.h"
 #include "isdn_lib.h"
 
+/* 
+ * Define ARRAY_LEN() because I cannot
+ * #include "asterisk/utils.h"
+ */
+#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
+
+#include "asterisk/causes.h"
+
 void misdn_join_conf(struct misdn_bchannel *bc, int conf_id);
 void misdn_split_conf(struct misdn_bchannel *bc, int conf_id);
 
@@ -137,17 +145,16 @@
 }
 
 
-struct misdn_stack* get_stack_by_bc(struct misdn_bchannel *bc)
-{
-	struct misdn_stack *stack=get_misdn_stack();
-
-	if (!bc) return NULL;
-	
-	for ( ; stack; stack=stack->next) {
-		int i;
-		for (i=0; i <=stack->b_num; i++) {
-			if ( bc->port == stack->port) return stack;
-		}
+struct misdn_stack *get_stack_by_bc(struct misdn_bchannel *bc)
+{
+	struct misdn_stack *stack = get_misdn_stack();
+
+	if (!bc)
+		return NULL;
+	
+	for ( ; stack; stack = stack->next) {
+		if (bc->port == stack->port)
+			return stack;
 	}
 
 	return NULL;
@@ -163,12 +170,13 @@
 	}
 	
 	if (stack) {
-		sprintf(buf, "* Port %d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d", stack->port, stack->nt?"NT":"TE", stack->ptp?"PTP":"PMP", stack->l2link?"UP":"DOWN", stack->l1link?"UP":"DOWN",stack->blocked);
-
+		sprintf(buf, "* Port %d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d",
+			stack->port, stack->nt ? "NT" : "TE", stack->ptp ? "PTP" : "PMP",
+			stack->l2link ? "UP" : "DOWN", stack->l1link ? "UP" : "DOWN",
+			stack->blocked);
 	} else {
 		buf[0]=0;
 	}
-	
 }
 
 
@@ -193,8 +201,9 @@
 
 
 struct misdn_lib {
+	/*! \brief mISDN device handle returned by mISDN_open() */
 	int midev;
-	int midev_nt;
+	int midev_nt;	/* Not used */
 
 	pthread_t event_thread;
 	pthread_t event_handler_thread;
@@ -260,9 +269,6 @@
 struct misdn_bchannel *stack_holder_find(struct misdn_stack *stack, unsigned long l3id);
 
 /* from isdn_lib.h */
-int init_bc(struct misdn_stack * stack,  struct misdn_bchannel *bc, int midev, int port, int bidx, char *msn, int firsttime);
-struct misdn_stack* stack_init(int midev,  int port, int ptp);
-void stack_destroy(struct misdn_stack* stack);
 	/* user iface */
 int te_lib_init( void ) ; /* returns midev */
 void te_lib_destroy(int midev) ;
@@ -437,8 +443,10 @@
 int misdn_inband_avail(struct misdn_bchannel *bc)
 {
 
-	/*if ! early_bconnect we have never inband available*/
-	if ( ! bc->early_bconnect ) return 0;
+	if (!bc->early_bconnect) {
+		/* We have opted to never receive any available inband recorded messages */
+		return 0;
+	}
 	
 	switch (bc->progress_indicator) {
 	case INFO_PI_INBAND_AVAILABLE:
@@ -515,7 +523,7 @@
 
  	if (dec) {
 		for (i = bnums; i >=0; i--) {
-			if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 Dchannel ;) and work with chan preselection */
+			if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 D channel ;) and work with chan preselection */
 				if (!stack->channels[i]) {
 					cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
 					chan=i+1;
@@ -525,7 +533,7 @@
 		}
 	} else {
 		for (i = 0; i <= bnums; i++) {
-			if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 Dchannel ;) and work with chan preselection */
+			if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 D channel ;) and work with chan preselection */
 				if (!stack->channels[i]) {
 					cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
 					chan=i+1;
@@ -538,13 +546,13 @@
 	if (!chan) {
 		cb_log (1, stack->port, " !! NO FREE CHAN IN STACK\n");
 		dump_chan_list(stack);
-		bc->out_cause=34;
+		bc->out_cause = AST_CAUSE_NORMAL_CIRCUIT_CONGESTION;
 		return -1;
 	}	
 
 	if (set_chan_in_stack(stack, chan)<0) {
 		cb_log (0, stack->port, "Channel Already in use:%d\n", chan);
-		bc->out_cause=44;
+		bc->out_cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL;
 		return -1;
 	}
 
@@ -681,9 +689,9 @@
 
 	bc->orig=0;
   
-	bc->cause=16;
-	bc->out_cause=16;
-	bc->pres=0 ; /* screened */
+	bc->cause = AST_CAUSE_NORMAL_CLEARING;
+	bc->out_cause = AST_CAUSE_NORMAL_CLEARING;
+	bc->pres = 0;	/* allowed */
 	
 	bc->evq=EVENT_NOTHING;
 
@@ -915,7 +923,7 @@
 			}
 		}	/* end for */
 		if (proc_id == MAXPROCS) {
-			cb_log(0, stack->port, "Couldnt Create New ProcId.\n");
+			cb_log(0, stack->port, "Couldn't Create New ProcId.\n");
 			return -1;
 		}
 
@@ -967,7 +975,10 @@
 int setup_bc(struct misdn_bchannel *bc)
 {
 	unsigned char buff[1025];
-	int midev, channel, b_stid, i;
+	int midev;
+	int channel;
+	int b_stid;
+	int i;
 	mISDN_pid_t pid;
 	int ret;
 
@@ -986,13 +997,13 @@
 		case BCHAN_CLEANED:
 			break;
 		default:
-			cb_log(4, stack->port, "$$$ bc already upsetted stid :%x (state:%s)\n", b_stid, bc_state2str(bc->bc_state) );
+			cb_log(4, stack->port, "$$$ bc already setup stid :%x (state:%s)\n", b_stid, bc_state2str(bc->bc_state) );
 			return -1;
 	}
 	
 	cb_log(5, stack->port, "$$$ Setting up bc with stid :%x\n", b_stid);
 	
-	/*check if the b_stid is alread initialized*/
+	/*check if the b_stid is already initialized*/
 	for (i=0; i <= stack->b_num; i++) {
 		if (stack->bc[i].b_stid == b_stid) {
 			cb_log(0, bc->port, "setup_bc: b_stid:%x already in use !!!\n", b_stid);
@@ -1042,10 +1053,9 @@
 				li.name[l-1] = 0;
 			}
 			li.pid.layermask = ISDN_LAYER((4));
-			li.pid.protocol[4] = ISDN_PID_L4_B_USER
-;
+			li.pid.protocol[4] = ISDN_PID_L4_B_USER;
+
 			bc->layer=4;
-			
 		}  
 		
 		ret = mISDN_new_layer(midev, &li);
@@ -1134,7 +1144,7 @@
 
 
 /** IFACE **/
-int init_bc(struct misdn_stack *stack,  struct misdn_bchannel *bc, int midev, int port, int bidx,  char *msn, int firsttime)
+static int init_bc(struct misdn_stack *stack, struct misdn_bchannel *bc, int midev, int port, int bidx, char *msn, int firsttime)
 {
 	unsigned char buff[1025] = "";
 	iframe_t *frm = (iframe_t *)buff;
@@ -1147,7 +1157,9 @@
 	memset(bc, 0,sizeof(struct misdn_bchannel));
 
 	bc->send_lock=malloc(sizeof(struct send_lock));
-
+	if (!bc->send_lock) {
+		return -1;
+	}
 	pthread_mutex_init(&bc->send_lock->lock, NULL);
 	
 	if (msn) {
@@ -1172,6 +1184,9 @@
 		clear_ibuffer( ibuf);
 		
 		ibuf->rsem=malloc(sizeof(sem_t));
+		if (!ibuf->rsem) {
+			return -1;
+		}
 		
 		bc->astbuf=ibuf;
 
@@ -1198,7 +1213,7 @@
 
 
 
-struct misdn_stack* stack_init( int midev, int port, int ptp )
+static struct misdn_stack *stack_init(int midev, int port, int ptp)
 {
 	int ret;
 	unsigned char buff[1025];
@@ -1384,7 +1399,7 @@
 }
 
 
-void stack_destroy(struct misdn_stack* stack)
+static void stack_destroy(struct misdn_stack *stack)
 {
 	char buf[1024];
 	if (!stack) return;
@@ -1644,7 +1659,7 @@
 			struct misdn_bchannel dummybc;
       
 			if (!bc) {
-				cb_log(4, stack->port, " --> Didn't found BC so temporarly creating dummy BC (l3id:%x) on this port.\n", frm->dinfo);
+				cb_log(4, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x) on this port.\n", frm->dinfo);
 				misdn_make_dummy(&dummybc, stack->port, frm->dinfo, stack->nt, 0);
 				
 				bc=&dummybc; 
@@ -1671,7 +1686,7 @@
 				dump_chan_list(stack);
 
 				if (bc->stack_holder) {
-					cb_log(4,stack->port, "REMOVEING Holder\n");
+					cb_log(4,stack->port, "REMOVING Holder\n");
 					stack_holder_remove( stack, bc);
 					free(bc);
 				}
@@ -1690,7 +1705,7 @@
 }
 
 
-/*Emptys bc if it's reserved (no SETUP out yet)*/
+/* Empties bc if it's reserved (no SETUP out yet) */
 void misdn_lib_release(struct misdn_bchannel *bc)
 {
 	struct misdn_stack *stack=get_stack_by_bc(bc);
@@ -1799,10 +1814,10 @@
 	frm.addr=stack->upper_id | FLG_MSG_DOWN;
 
 	frm.prim = CC_RELEASE_CR|INDICATION;
-	cb_log(4, stack->port, " --> CC_RELEASE_CR: Faking Realease_cr for %x l3id:%x\n",frm.addr, frm.dinfo);
+	cb_log(4, stack->port, " --> CC_RELEASE_CR: Faking Release_cr for %x l3id:%x\n",frm.addr, frm.dinfo);
 	/** removing procid **/
 	if (!bc) {
-		cb_log(4, stack->port, " --> Didn't found BC so temporarly creating dummy BC (l3id:%x) on this port.\n", hh->dinfo);
+		cb_log(4, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x) on this port.\n", hh->dinfo);
 		misdn_make_dummy(&dummybc, stack->port, hh->dinfo, stack->nt, 0);
 		bc=&dummybc; 
 	}
@@ -1813,7 +1828,7 @@
 			stack->procids[bc->l3_id&0xff] = 0 ;
 		}
 	}
-	else cb_log(0, stack->port, "Couldnt find BC so I couldnt remove the Process!!!! this is a bad port.\n");
+	else cb_log(0, stack->port, "Couldn't find BC so I couldn't remove the Process!!!! this is a bad port.\n");
 
 	if (handle_cr(stack, &frm)<0) {
 	}
@@ -1848,7 +1863,8 @@
 		switch(hh->prim){
 		case CC_RETRIEVE|INDICATION:
 		{
-			struct misdn_bchannel *bc, *hold_bc;
+			struct misdn_bchannel *bc;
+			struct misdn_bchannel *hold_bc;
 
 			iframe_t frm; /* fake te frm to add callref to global callreflist */
 			frm.dinfo = hh->dinfo;
@@ -1872,7 +1888,7 @@
 			cb_log(4, stack->port, "bc_l3id:%x holded_bc_l3id:%x\n",bc->l3_id, hold_bc->l3_id);
 
 			if (hold_bc) {
-				cb_log(4, stack->port, "REMOVEING Holder\n");
+				cb_log(4, stack->port, "REMOVING Holder\n");
 
 				/*swap the backup to our new channel back*/
 				stack_holder_remove(stack, hold_bc);
@@ -2062,7 +2078,7 @@
 				cb_log(3 , stack->port, "%% GOT L2 DeActivate Info.\n");
 
 				if (stack->l2upcnt>3) {
-					cb_log(0 , stack->port, "!!! Could not Get the L2 up after 3 Attemps!!!\n");
+					cb_log(0 , stack->port, "!!! Could not Get the L2 up after 3 Attempts!!!\n");
 				}  else {
 #if 0
 					if (stack->nt) misdn_lib_reinit_nt_stack(stack->port);
@@ -2095,7 +2111,7 @@
 		bc=find_bc_by_l3id(stack, hh->dinfo);
     
 		if (!bc) {
-			cb_log(4, stack->port, " --> Didn't found BC so temporarly creating dummy BC (l3id:%x).\n", hh->dinfo);
+			cb_log(4, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x).\n", hh->dinfo);
 			misdn_make_dummy(&dummybc, stack->port,  hh->dinfo, stack->nt, 0);
 			bc=&dummybc; 
 		}
@@ -2134,7 +2150,7 @@
 			} else {
 				if (reject) {
 					switch(bc->cause){
-						case 17:
+						case AST_CAUSE_USER_BUSY:
 							cb_log(1, stack->port, "Siemens Busy reject..\n");
 
 							break;
@@ -2708,12 +2724,12 @@
 				switch (response) {
 				case RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE:
 
-					cb_log(0, stack->port, "TOTALY IGNORING SETUP \n");					
+					cb_log(0, stack->port, "TOTALLY IGNORING SETUP\n");					
 					
 					break;
 				case RESPONSE_IGNORE_SETUP:
 					/* I think we should send CC_RELEASE_CR, but am not sure*/
-					bc->out_cause=16;
+					bc->out_cause = AST_CAUSE_NORMAL_CLEARING;
 				
 				case RESPONSE_RELEASE_SETUP:
 					misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
@@ -2736,7 +2752,7 @@
 			}
 
 			if (event == EVENT_RELEASE_COMPLETE) {
-				/* release bchannel only after we've anounced the RELEASE_COMPLETE */
+				/* release bchannel only after we've announced the RELEASE_COMPLETE */
 				int channel=bc->channel;
 				int tmpcause=bc->cause;	
 				int tmp_out_cause=bc->out_cause;	
@@ -2745,8 +2761,8 @@
 				bc->out_cause=tmp_out_cause;
 				clean_up_bc(bc);
 				
-				if (tmpcause == 44) {
-					cb_log(0,stack->port,"**** Received CAUSE:44, so not cleaning up channel %d\n", channel);
+				if (tmpcause == AST_CAUSE_REQUESTED_CHAN_UNAVAIL) {
+					cb_log(0,stack->port,"**** Received CAUSE:%d, so not cleaning up channel %d\n", AST_CAUSE_REQUESTED_CHAN_UNAVAIL, channel);
 					cb_log(0,stack->port,"**** This channel is now no longer available,\nplease try to restart it with 'misdn send restart <port> <channel>'\n");
 					set_chan_in_stack(stack, channel);
 					bc->channel=channel;
@@ -2773,7 +2789,7 @@
 		} else {
 			struct misdn_bchannel dummybc;
 			if (frm->prim!=(CC_FACILITY|INDICATION))
-				cb_log(0, stack->port, " --> Didn't find BC so temporarly creating dummy BC (l3id:%x) on this port.\n", frm->dinfo);
+				cb_log(0, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x) on this port.\n", frm->dinfo);

[... 1184 lines stripped ...]



More information about the svn-commits mailing list