[svn-commits] branch kpfleming/stringfields - r7791 in /team/kpfleming/stringfields: ./ app...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Jan 4 14:40:09 CST 2006


Author: kpfleming
Date: Wed Jan  4 14:40:08 2006
New Revision: 7791

URL: http://svn.digium.com/view/asterisk?rev=7791&view=rev
Log:
update to current trunk

Modified:
    team/kpfleming/stringfields/   (props changed)
    team/kpfleming/stringfields/UPGRADE.txt
    team/kpfleming/stringfields/apps/app_disa.c
    team/kpfleming/stringfields/apps/app_privacy.c
    team/kpfleming/stringfields/cdr.c
    team/kpfleming/stringfields/channel.c
    team/kpfleming/stringfields/channels/chan_sip.c
    team/kpfleming/stringfields/channels/chan_zap.c
    team/kpfleming/stringfields/configs/sip.conf.sample
    team/kpfleming/stringfields/contrib/scripts/managerproxy.pl
    team/kpfleming/stringfields/funcs/func_moh.c
    team/kpfleming/stringfields/res/res_osp.c

Propchange: team/kpfleming/stringfields/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jan  4 14:40:08 2006
@@ -1,1 +1,1 @@
-/trunk:1-7751
+/trunk:1-7790

Modified: team/kpfleming/stringfields/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/UPGRADE.txt?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/UPGRADE.txt (original)
+++ team/kpfleming/stringfields/UPGRADE.txt Wed Jan  4 14:40:08 2006
@@ -26,3 +26,6 @@
   functions.  You are encouraged to move towards the associated dialplan
   function, as these variables will be removed in a future release.
 
+The SIP channel:
+
+* The "incominglimit" setting is replaced by the "call-limit" setting in sip.conf.

Modified: team/kpfleming/stringfields/apps/app_disa.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/apps/app_disa.c?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/apps/app_disa.c (original)
+++ team/kpfleming/stringfields/apps/app_disa.c Wed Jan  4 14:40:08 2006
@@ -146,12 +146,12 @@
 	}
 	
 	if (ast_set_write_format(chan,AST_FORMAT_ULAW)) {
-		ast_log(LOG_WARNING, "Unable to set write format to Mu-law on %s\n",chan->name);
+		ast_log(LOG_WARNING, "Unable to set write format to Mu-law on %s\n", chan->name);
 		LOCAL_USER_REMOVE(u);
 		return -1;
 	}
 	if (ast_set_read_format(chan,AST_FORMAT_ULAW)) {
-		ast_log(LOG_WARNING, "Unable to set read format to Mu-law on %s\n",chan->name);
+		ast_log(LOG_WARNING, "Unable to set read format to Mu-law on %s\n", chan->name);
 		LOCAL_USER_REMOVE(u);
 		return -1;
 	}
@@ -198,8 +198,7 @@
 	for (;;) {
 		  /* if outa time, give em reorder */
 		if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > 
-		    ((k&2) ? digittimeout : firstdigittimeout))
-		{
+		    ((k&2) ? digittimeout : firstdigittimeout)) {
 			ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n",
 				((k&1) ? "extension" : "password"),chan->name);
 			break;
@@ -210,14 +209,12 @@
 		}
 			
 		f = ast_read(chan);
-		if (f == NULL) 
-		{
+		if (f == NULL) {
 			LOCAL_USER_REMOVE(u);
 			return -1;
 		}
 		if ((f->frametype == AST_FRAME_CONTROL) &&
-		    (f->subclass == AST_CONTROL_HANGUP))
-		{
+		    (f->subclass == AST_CONTROL_HANGUP)) {
 			ast_frfree(f);
 			LOCAL_USER_REMOVE(u);
 			return -1;
@@ -226,56 +223,54 @@
 			ast_frfree(f);
 			continue;
 		}
-		  /* if not DTMF, just do it again */
-		if (f->frametype != AST_FRAME_DTMF) 
-		{
+
+		/* if not DTMF, just do it again */
+		if (f->frametype != AST_FRAME_DTMF) {
 			ast_frfree(f);
 			continue;
 		}
 
 		j = f->subclass;  /* save digit */
 		ast_frfree(f);
-		if (i == 0) 
-		{
+		if (i == 0) {
 			k|=2; /* We have the first digit */ 
 			ast_playtones_stop(chan);
 		}
 		lastdigittime = ast_tvnow();
 		  /* got a DTMF tone */
-		if (i < AST_MAX_EXTENSION) /* if still valid number of digits */
-		{
-			if (!(k&1)) /* if in password state */
-			{
-				if (j == '#') /* end of password */
-				{
+		if (i < AST_MAX_EXTENSION) { /* if still valid number of digits */
+			if (!(k&1)) { /* if in password state */
+				if (j == '#') { /* end of password */
 					  /* see if this is an integer */
-					if (sscanf(args.passcode,"%d",&j) < 1)
-					   { /* nope, it must be a filename */
+					if (sscanf(args.passcode,"%d",&j) < 1) { /* nope, it must be a filename */
 						fp = fopen(args.passcode,"r");
-						if (!fp)
-						   {
+						if (!fp) {
 							ast_log(LOG_WARNING,"DISA password file %s not found on chan %s\n",args.passcode,chan->name);
 							LOCAL_USER_REMOVE(u);
 							return -1;
-						   }
+						}
 						pwline[0] = 0;
-						while(fgets(pwline,sizeof(pwline) - 1,fp))
-						   {
-							if (!pwline[0]) continue;
+						while(fgets(pwline,sizeof(pwline) - 1,fp)) {
+							if (!pwline[0])
+								continue;
 							if (pwline[strlen(pwline) - 1] == '\n') 
 								pwline[strlen(pwline) - 1] = 0;
-							if (!pwline[0]) continue;
-							  /* skip comments */
-							if (pwline[0] == '#') continue;
-							if (pwline[0] == ';') continue;
+							if (!pwline[0])
+								continue;
+							 /* skip comments */
+							if (pwline[0] == '#')
+								continue;
+							if (pwline[0] == ';')
+								continue;
 
 							AST_STANDARD_APP_ARGS(args, pwline);
 			
 							ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
 
-							  /* password must be in valid format (numeric) */
-							if (sscanf(args.passcode,"%d",&j) < 1) continue;
-							  /* if we got it */
+							/* password must be in valid format (numeric) */
+							if (sscanf(args.passcode,"%d", &j) < 1)
+								continue;
+							 /* if we got it */
 							if (!strcmp(exten,args.passcode)) {
 								if (ast_strlen_zero(args.context))
 									args.context = "disa";
@@ -283,12 +278,11 @@
 									args.mailbox = "";
 								break;
 							}
-						   }
+						}
 						fclose(fp);
-					   }
-					  /* compare the two */
-					if (strcmp(exten,args.passcode))
-					{
+					}
+					/* compare the two */
+					if (strcmp(exten,args.passcode)) {
 						ast_log(LOG_WARNING,"DISA on chan %s got bad password %s\n",chan->name,exten);
 						goto reorder;
 
@@ -302,15 +296,16 @@
 					exten[sizeof(acctcode)] = 0;
 					ast_copy_string(acctcode, exten, sizeof(acctcode));
 					exten[0] = 0;
-					ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n",chan->name);
+					ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n", chan->name);
 					continue;
 				}
 			}
 
 			exten[i++] = j;  /* save digit */
 			exten[i] = 0;
-			if (!(k&1)) continue; /* if getting password, continue doing it */
-			  /* if this exists */
+			if (!(k&1))
+				continue; /* if getting password, continue doing it */
+			/* if this exists */
 
 			if (ast_ignore_pattern(args.context, exten)) {
 				play_dialtone(chan, "");
@@ -321,7 +316,7 @@
 					did_ignore = 0;
 				}
 
-			  /* if can do some more, do it */
+			/* if can do some more, do it */
 			if (!ast_matchmore_extension(chan,args.context,exten,1, chan->cid.cid_num)) {
 				break;
 			}
@@ -341,8 +336,7 @@
 		if (!recheck || ast_exists_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
 			ast_playtones_stop(chan);
 			/* We're authenticated and have a target extension */
-			if (!ast_strlen_zero(args.cid))
-			{
+			if (!ast_strlen_zero(args.cid)) {
 				ast_callerid_split(args.cid, ourcidname, sizeof(ourcidname), ourcidnum, sizeof(ourcidnum));
 				ast_set_callerid(chan, ourcidnum, ourcidname, ourcidnum);
 			}
@@ -364,8 +358,7 @@
 	ast_indicate(chan,AST_CONTROL_CONGESTION);
 	/* something is invalid, give em reorder for several seconds */
 	time(&rstart);
-	while(time(NULL) < rstart + 10)
-	{
+	while(time(NULL) < rstart + 10) {
 		if (ast_waitfor(chan, -1) < 0)
 			break;
 		f = ast_read(chan);

Modified: team/kpfleming/stringfields/apps/app_privacy.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/apps/app_privacy.c?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/apps/app_privacy.c (original)
+++ team/kpfleming/stringfields/apps/app_privacy.c Wed Jan  4 14:40:08 2006
@@ -195,7 +195,7 @@
 		}
 		
 		/*Got a number, play sounds and send them on their way*/
-		if ((retries < maxretries) && res == 1 ) {
+		if ((retries < maxretries) && !res ) {
 			res = ast_streamfile(chan, "privacy-thankyou", chan->language);
 			if (!res)
 				res = ast_waitstream(chan, "");

Modified: team/kpfleming/stringfields/cdr.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/cdr.c?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/cdr.c (original)
+++ team/kpfleming/stringfields/cdr.c Wed Jan  4 14:40:08 2006
@@ -22,7 +22,7 @@
  *
  * \author Mark Spencer <markster at digium.com>
  * 
- * Includes code and algorithms from the Zapata library.
+ * \note Includes code and algorithms from the Zapata library.
  *
  * \note We do a lot of checking here in the CDR code to try to be sure we don't ever let a CDR slip
  * through our fingers somehow.  If someone allocates a CDR, it must be completely handled normally

Modified: team/kpfleming/stringfields/channel.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/channel.c?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/channel.c (original)
+++ team/kpfleming/stringfields/channel.c Wed Jan  4 14:40:08 2006
@@ -168,8 +168,10 @@
 
 static int show_channeltypes(int fd, int argc, char *argv[])
 {
-#define FORMAT  "%-10.10s  %-30.30s %-12.12s %-12.12s %-12.12s\n"
+#define FORMAT  "%-10.10s  %-40.40s %-12.12s %-12.12s %-12.12s\n"
 	struct chanlist *cl;
+	int count_chan = 0;
+
 	ast_cli(fd, FORMAT, "Type", "Description",       "Devicestate", "Indications", "Transfer");
 	ast_cli(fd, FORMAT, "----------", "-----------", "-----------", "-----------", "--------");
 	if (ast_mutex_lock(&chlock)) {
@@ -181,8 +183,10 @@
 			(cl->tech->devicestate) ? "yes" : "no", 
 			(cl->tech->indicate) ? "yes" : "no",
 			(cl->tech->transfer) ? "yes" : "no");
+		count_chan++;
 	}
 	ast_mutex_unlock(&chlock);
+	ast_cli(fd, "----------\n%d channel drivers registered.\n", count_chan);
 	return RESULT_SUCCESS;
 
 #undef FORMAT

Modified: team/kpfleming/stringfields/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/channels/chan_sip.c?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/channels/chan_sip.c (original)
+++ team/kpfleming/stringfields/channels/chan_sip.c Wed Jan  4 14:40:08 2006
@@ -2180,8 +2180,15 @@
 }
 
 /*! \brief  update_call_counter: Handle call_limit for SIP users 
- * Note: This is going to be replaced by app_groupcount 
- * Thought: For realtime, we should propably update storage with inuse counter... */
+ * Setting a call-limit will cause calls above the limit not to be accepted.
+ *
+ * Remember that for a type=friend, there's one limit for the user and
+ * another for the peer, not a combined call limit.
+ * This will cause unexpected behaviour in subscriptions, since a "friend"
+ * is *two* devices in Asterisk, not one.
+ *
+ * Thought: For realtime, we should propably update storage with inuse counter... 
+ */
 static int update_call_counter(struct sip_pvt *fup, int event)
 {
 	char name[256];
@@ -2276,21 +2283,54 @@
 /* Possible values taken from causes.h */
 
 	switch(cause) {
-		case 603:	/* Declined */
+		case 401:	/* Unauthorized */
+			return AST_CAUSE_CALL_REJECTED;
 		case 403:	/* Not found */
 			return AST_CAUSE_CALL_REJECTED;
 		case 404:	/* Not found */
 			return AST_CAUSE_UNALLOCATED;
+		case 405:	/* Method not allowed */
+			return AST_CAUSE_INTERWORKING;
+		case 407:	/* Proxy authentication required */
+			return AST_CAUSE_CALL_REJECTED;
 		case 408:	/* No reaction */
 			return AST_CAUSE_NO_USER_RESPONSE;
+		case 409:	/* Conflict */
+			return AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
+		case 410:	/* Gone */
+			return AST_CAUSE_UNALLOCATED;
+		case 411:	/* Length required */
+			return AST_CAUSE_INTERWORKING;
+		case 413:	/* Request entity too large */
+			return AST_CAUSE_INTERWORKING;
+		case 414:	/* Request URI too large */
+			return AST_CAUSE_INTERWORKING;
+		case 415:	/* Unsupported media type */
+			return AST_CAUSE_INTERWORKING;
+		case 420:	/* Bad extension */
+			return AST_CAUSE_NO_ROUTE_DESTINATION;
 		case 480:	/* No answer */
 			return AST_CAUSE_FAILURE;
+		case 481:	/* No answer */
+			return AST_CAUSE_INTERWORKING;
+		case 482:	/* Loop detected */
+			return AST_CAUSE_INTERWORKING;
 		case 483:	/* Too many hops */
 			return AST_CAUSE_NO_ANSWER;
+		case 484:	/* Address incomplete */
+			return AST_CAUSE_INVALID_NUMBER_FORMAT;
+		case 485:	/* Ambigous */
+			return AST_CAUSE_UNALLOCATED;
 		case 486:	/* Busy everywhere */
 			return AST_CAUSE_BUSY;
+		case 487:	/* Request terminated */
+			return AST_CAUSE_INTERWORKING;
 		case 488:	/* No codecs approved */
 			return AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
+		case 491:	/* Request pending */
+			return AST_CAUSE_INTERWORKING;
+		case 493:	/* Undecipherable */
+			return AST_CAUSE_INTERWORKING;
 		case 500:	/* Server internal failure */
 			return AST_CAUSE_FAILURE;
 		case 501:	/* Call rejected */
@@ -2299,6 +2339,18 @@
 			return AST_CAUSE_DESTINATION_OUT_OF_ORDER;
 		case 503:	/* Service unavailable */
 			return AST_CAUSE_CONGESTION;
+		case 504:	/* Gateway timeout */
+			return AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE;
+		case 505:	/* SIP version not supported */
+			return AST_CAUSE_INTERWORKING;
+		case 600:	/* Busy everywhere */
+			return AST_CAUSE_USER_BUSY;
+		case 603:	/* Decline */
+			return AST_CAUSE_CALL_REJECTED;
+		case 604:	/* Does not exist anywhere */
+			return AST_CAUSE_UNALLOCATED;
+		case 606:	/* Not acceptable */
+			return AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
 		default:
 			return AST_CAUSE_NORMAL;
 	}
@@ -4274,7 +4326,7 @@
 		" <media_control>\r\n"
 		"  <vc_primitive>\r\n"
 		"   <to_encoder>\r\n"
-		"    <picture_fast_update\r\n"
+		"    <picture_fast_update>\r\n"
 		"    </picture_fast_update>\r\n"
 		"   </to_encoder>\r\n"
 		"  </vc_primitive>\r\n"
@@ -11930,7 +11982,7 @@
 			ast_copy_string(user->musicclass, v->value, sizeof(user->musicclass));
 		} else if (!strcasecmp(v->name, "accountcode")) {
 			ast_copy_string(user->accountcode, v->value, sizeof(user->accountcode));
-		} else if (!strcasecmp(v->name, "call-limit") || !strcasecmp(v->name, "incominglimit")) {
+		} else if (!strcasecmp(v->name, "call-limit")) {
 			user->call_limit = atoi(v->value);
 			if (user->call_limit < 0)
 				user->call_limit = 0;

Modified: team/kpfleming/stringfields/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/channels/chan_zap.c?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/channels/chan_zap.c (original)
+++ team/kpfleming/stringfields/channels/chan_zap.c Wed Jan  4 14:40:08 2006
@@ -7972,13 +7972,13 @@
 		}
 		if ((dchan >= 0) && (span >= 0)) {
 			if (dchancount > 1)
-				ast_log(LOG_DEBUG, "[Span %d D-Channel %d]%s", span, dchan, s);
+				ast_verbose("[Span %d D-Channel %d]%s", span, dchan, s);
 			else
-				ast_log(LOG_DEBUG, "%s", s);
+				ast_verbose("%s", s);
 		} else
 			ast_log(LOG_ERROR, "PRI debug error: could not find pri associated it with debug message output\n");
 	} else
-		ast_log(LOG_DEBUG, "%s", s);
+		ast_verbose("%s", s);
 
 	ast_mutex_lock(&pridebugfdlock);
 

Modified: team/kpfleming/stringfields/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/configs/sip.conf.sample?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/configs/sip.conf.sample (original)
+++ team/kpfleming/stringfields/configs/sip.conf.sample Wed Jan  4 14:40:08 2006
@@ -348,9 +348,15 @@
 ;dtmfmode=info			; either RFC2833 or INFO for the BudgeTone
 ;call-limit=1			; permit only 1 outgoing call and 1 incoming call at a time
 				; from the phone to asterisk
-				; (1 for the explicit peer, 1 for the explicit user,
+				; 1 for the explicit peer, 1 for the explicit user,
 				; remember that a friend equals 1 peer and 1 user in
-				; memory)
+				; memory
+				; This will affect your subscriptions as well.
+				; There is no combined call counter for a "friend"
+				; so there's currently no way in sip.conf to limit
+				; to one inbound or outbound call per phone. Use
+				; the group counters in the dial plan for that.
+				;
 ;mailbox=1234 at default		; mailbox 1234 in voicemail context "default"
 ;disallow=all			; need to disallow=all before we can use allow=
 ;allow=ulaw			; Note: In user sections the order of codecs

Modified: team/kpfleming/stringfields/contrib/scripts/managerproxy.pl
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/contrib/scripts/managerproxy.pl?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/contrib/scripts/managerproxy.pl (original)
+++ team/kpfleming/stringfields/contrib/scripts/managerproxy.pl Wed Jan  4 14:40:08 2006
@@ -2,14 +2,14 @@
 #
 #  Simple Asterisk Manager Proxy, Version 1.01
 #  2004-09-26
-#  Copyright (c) 2004 David C. Troy &lt;dave at popvox.com>
+#  Copyright (c) 2004 David C. Troy <dave at popvox.com>
 #
 #  This code is based on Flash Operator Panel 'op_server.pl'
-#  by Nicolá³ Gudiñ¯¬
+#  by Nicolas Gudino
 #   Copyright (C) 2004.
 #
-#  David C. Troy &lt;dave at popvox.com>
-#  Nicol᳠Gudi񯠼nicolas at house.com.ar>
+#  David C. Troy <dave at popvox.com>
+#  Nicolas Gudino <nicolas at house.com.ar>
 #
 #  This program is free software, distributed under the terms of
 #  the GNU General Public License.

Modified: team/kpfleming/stringfields/funcs/func_moh.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/funcs/func_moh.c?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/funcs/func_moh.c (original)
+++ team/kpfleming/stringfields/funcs/func_moh.c Wed Jan  4 14:40:08 2006
@@ -40,7 +40,7 @@
 
 static void function_moh_write(struct ast_channel *chan, char *cmd, char *data, const char *value) 
 {
-	ast_copy_string(chan->musicclass, value, MAX_MUSICCLASS);
+	ast_copy_string(chan->musicclass, value, sizeof(chan->musicclass));
 }
 
 #ifndef BUILTIN_FUNC

Modified: team/kpfleming/stringfields/res/res_osp.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/res/res_osp.c?rev=7791&r1=7790&r2=7791&view=diff
==============================================================================
--- team/kpfleming/stringfields/res/res_osp.c (original)
+++ team/kpfleming/stringfields/res/res_osp.c Wed Jan  4 14:40:08 2006
@@ -516,6 +516,44 @@
 	return res;	
 }
 
+static int check_dest(struct ast_osp_result *result, char *token, int tokensize)
+{
+	OSPE_DEST_OSP_ENABLED enabled;
+	OSPE_DEST_PROT prot;
+	int res = 1;
+
+	/* Check destination OSP version */
+	if (!OSPPTransactionIsDestOSPEnabled(result->handle, &enabled) && (enabled == OSPE_OSP_FALSE)) {
+		result->token[0] = 0;
+	} else {
+		ast_base64encode(result->token, token, tokensize, sizeof(result->token) - 1);
+	}
+
+	/* Check destination protocol */
+	if (OSPPTransactionGetDestProtocol(result->handle, &prot)) {
+		prot = OSPE_DEST_PROT_UNDEFINED;
+	}
+	switch(prot) {
+	case OSPE_DEST_PROT_UNDEFINED:	/* Protocol is not configured, use SIP as default */
+	case OSPE_DEST_PROT_SIP:
+		ast_copy_string(result->tech, "SIP", sizeof(result->tech));
+		break;
+	case OSPE_DEST_PROT_H323_SETUP:
+		ast_copy_string(result->tech, "H323", sizeof(result->tech));
+		break;
+	case OSPE_DEST_PROT_IAX:
+		ast_copy_string(result->tech, "IAX", sizeof(result->tech));
+		break;
+	case OSPE_DEST_PROT_H323_LRQ:
+	case OSPE_DEST_PROT_UNKNOWN:
+	default:
+		ast_log(LOG_DEBUG, "Unknown destination protocol '%d', skipping...\n", prot);
+		res = 0;
+	}
+
+	return res;
+}
+
 int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, char *callerid, struct ast_osp_result *result)
 {
 	int cres;
@@ -533,8 +571,6 @@
 	char destination[2048]="";
 	char token[2000];
 	char tmp[256]="", *l, *n;
-	OSPE_DEST_PROT prot;
-	OSPE_DEST_OSP_ENABLED ospenabled;
 	char *devinfo = NULL;
 
 	result->handle = -1;
@@ -603,49 +639,27 @@
 						ast_channel_setwhentohangup (chan, timelimit);	
 					}
 					do {
-						if (!OSPPTransactionIsDestOSPEnabled (result->handle, &ospenabled) && (ospenabled == OSPE_OSP_FALSE)) {
-							result->token[0] = 0;
-						}
-						else {
-							ast_base64encode(result->token, token, tokenlen, sizeof(result->token) - 1);
-						}
-						if ((strlen(destination) > 2) && !OSPPTransactionGetDestProtocol(result->handle, &prot)) {
-							res = 1;
+						if ((strlen(destination) > 2) && (check_dest(result, token, tokenlen))) {
 							/* Strip leading and trailing brackets */
 							destination[strlen(destination) - 1] = '\0';
-							switch(prot) {
-							case OSPE_DEST_PROT_H323_SETUP:
-								ast_copy_string(result->tech, "H323", sizeof(result->tech));
-								snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
-								break;
-							case OSPE_DEST_PROT_SIP:
-								ast_copy_string(result->tech, "SIP", sizeof(result->tech));
-								snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
-								break;
-							case OSPE_DEST_PROT_IAX:
-								ast_copy_string(result->tech, "IAX", sizeof(result->tech));
-								snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
-								break;
-							default:
-								ast_log(LOG_DEBUG, "Unknown destination protocol '%d', skipping...\n", prot);
-								res = 0;
-							}
-							if (!res && result->numresults) {
+							snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
+							res = 1;
+						} else {
+							if(result->numresults) {
 								result->numresults--;
 								callidlen = sizeof(callidstr);
-								if (OSPPTransactionGetNextDestination(result->handle, OSPC_FAIL_INCOMPATIBLE_DEST, 0, NULL, NULL, &timelimit, &callidlen, callidstr, 
-										sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) {
-										break;
+								if (!OSPPTransactionGetNextDestination(result->handle, OSPC_FAIL_INCOMPATIBLE_DEST, 0, NULL, NULL, &timelimit, &callidlen, 
+									callidstr, sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, 
+									&tokenlen, token))
+								{
+									continue;
 								}
 							}
-						} else {
-							ast_log(LOG_DEBUG, "Missing destination protocol\n");
-							break;
 						}
-					} while(!res && result->numresults);
+						break;
+					} while (1);
 				}
 			}
-			
 		}
 		if (!res) {
 			OSPPTransactionDelete(result->handle);
@@ -667,7 +681,6 @@
 {
 	int res = 0;
 	int tokenlen;
-	unsigned int dummy=0;
 	unsigned int timelimit;
 	unsigned int callidlen;
 	char callidstr[OSPC_CALLID_MAXSIZE] = "";
@@ -675,62 +688,33 @@
 	char callingnum[2048]="";
 	char destination[2048]="";
 	char token[2000];
-	OSPE_DEST_PROT prot;
-	OSPE_DEST_OSP_ENABLED ospenabled;
 
 	result->tech[0] = '\0';
 	result->dest[0] = '\0';
 	result->token[0] = '\0';
 
 	if (result->handle > -1) {
-		dummy = 0;
 		if (result->numresults) {
 			tokenlen = sizeof(token);
 			while(!res && result->numresults) {
 				result->numresults--;
 				callidlen = sizeof(callidstr);
 				if (!OSPPTransactionGetNextDestination(result->handle, OSPC_FAIL_INCOMPATIBLE_DEST, 0, NULL, NULL, &timelimit, &callidlen, callidstr, 
-									sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) {
-					if (!OSPPTransactionIsDestOSPEnabled (result->handle, &ospenabled) && (ospenabled == OSPE_OSP_FALSE)) {
-						result->token[0] = 0;
-					}
-					else {
-						ast_base64encode(result->token, token, tokenlen, sizeof(result->token) - 1);
-					}
-					if ((strlen(destination) > 2) && !OSPPTransactionGetDestProtocol(result->handle, &prot)) {
-						res = 1;
+					sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) 
+				{
+					if ((strlen(destination) > 2) && check_dest(result, token, tokenlen)) {
 						/* Strip leading and trailing brackets */
 						destination[strlen(destination) - 1] = '\0';
-						switch(prot) {
-						case OSPE_DEST_PROT_H323_SETUP:
-							ast_copy_string(result->tech, "H323", sizeof(result->tech));
-							snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
-							break;
-						case OSPE_DEST_PROT_SIP:
-							ast_copy_string(result->tech, "SIP", sizeof(result->tech));
-							snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
-							break;
-						case OSPE_DEST_PROT_IAX:
-							ast_copy_string(result->tech, "IAX", sizeof(result->tech));
-							snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
-							break;
-						default:
-							ast_log(LOG_DEBUG, "Unknown destination protocol '%d', skipping...\n", prot);
-							res = 0;
-						}
-					} else {
-						ast_log(LOG_DEBUG, "Missing destination protocol\n");
-						break;
+						snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
+						res = 1;
 					}
 				}
 			}
-			
 		}
 		if (!res) {
 			OSPPTransactionDelete(result->handle);
 			result->handle = -1;
 		}
-		
 	}
 	return res;
 }



More information about the svn-commits mailing list