[asterisk-commits] qwell: trunk r47771 - in /trunk: channels/chan_zap.c configs/zapata.conf.sample

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Nov 16 15:32:24 MST 2006


Author: qwell
Date: Thu Nov 16 16:32:23 2006
New Revision: 47771

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47771
Log:
Add ability to modify range for dring matching.

Issue #8369, patch by ssuehring, modified slightly by me.

Modified:
    trunk/channels/chan_zap.c
    trunk/configs/zapata.conf.sample

Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?view=diff&rev=47771&r1=47770&r2=47771
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Thu Nov 16 16:32:23 2006
@@ -528,6 +528,7 @@
 
 struct distRingData {
 	int ring[3];
+	int range;
 };
 struct ringContextData {
 	char contextData[AST_MAX_CONTEXT];
@@ -6609,17 +6610,29 @@
 						if (option_verbose > 2)
 							/* this only shows up if you have n of the dring patterns filled in */
 							ast_verbose( VERBOSE_PREFIX_3 "Detected ring pattern: %d,%d,%d\n",curRingData[0],curRingData[1],curRingData[2]);
-	
 						for (counter = 0; counter < 3; counter++) {
 							/* Check to see if the rings we received match any of the ones in zapata.conf for this
 							channel */
 							distMatches = 0;
 							for (counter1 = 0; counter1 < 3; counter1++) {
-								if (curRingData[counter1] <= (p->drings.ringnum[counter].ring[counter1]+10) && curRingData[counter1] >=
-								(p->drings.ringnum[counter].ring[counter1]-10)) {
+								if (p->drings.ringnum[counter].range == 0) {
+									p->drings.ringnum[counter].range = 10;
+                                                        	}
+								ast_verbose( VERBOSE_PREFIX_3 "Ring pattern check range: %d\n", p->drings.ringnum[counter].range);
+								if (p->drings.ringnum[counter].ring[counter1] == -1) {
+									ast_verbose( VERBOSE_PREFIX_3 "Pattern ignore (-1) detected, so matching pattern %d regardless.\n",
+									curRingData[counter1]);
+									distMatches++;
+								}
+								else if (curRingData[counter1] <= (p->drings.ringnum[counter].ring[counter1] + p->drings.ringnum[counter].range) &&
+								    curRingData[counter1] >= (p->drings.ringnum[counter].ring[counter1] - p->drings.ringnum[counter].range)) {
+									ast_verbose( VERBOSE_PREFIX_3 "Ring pattern matched in range: %d to %d\n",
+									(p->drings.ringnum[counter].ring[counter1] - p->drings.ringnum[counter].range),
+									(p->drings.ringnum[counter].ring[counter1] + p->drings.ringnum[counter].range));
 									distMatches++;
 								}
 							}
+
 							if (distMatches == 3) {
 								/* The ring matches, set the context to whatever is for distinctive ring.. */
 								ast_copy_string(p->context, p->drings.ringContext[counter].contextData, sizeof(p->context));
@@ -6791,8 +6804,20 @@
 								p->drings.ringnum[counter].ring[2]);
 						distMatches = 0;
 						for (counter1 = 0; counter1 < 3; counter1++) {
-							if (curRingData[counter1] <= (p->drings.ringnum[counter].ring[counter1]+10) && curRingData[counter1] >=
-							(p->drings.ringnum[counter].ring[counter1]-10)) {
+							if (p->drings.ringnum[counter].range == 0) {
+								p->drings.ringnum[counter].range = 10;
+							}
+							ast_verbose( VERBOSE_PREFIX_3 "Ring pattern check range: %d\n", p->drings.ringnum[counter].range);
+							if (p->drings.ringnum[counter].ring[counter1] == -1) {
+								ast_verbose( VERBOSE_PREFIX_3 "Pattern ignore (-1) detected, so matching pattern %d regardless.\n",
+								curRingData[counter1]);
+								distMatches++;
+							}
+							else if (curRingData[counter1] <= (p->drings.ringnum[counter].ring[counter1] + p->drings.ringnum[counter].range) &&
+							    curRingData[counter1] >= (p->drings.ringnum[counter].ring[counter1] - p->drings.ringnum[counter].range)) {
+								ast_verbose( VERBOSE_PREFIX_3 "Ring pattern matched in range: %d to %d\n",
+								(p->drings.ringnum[counter].ring[counter1] - p->drings.ringnum[counter].range),
+								(p->drings.ringnum[counter].ring[counter1] + p->drings.ringnum[counter].range));
 								distMatches++;
 							}
 						}
@@ -11698,6 +11723,7 @@
 	struct zt_pvt *tmp;
 	char *ringc;
 	int y;
+	int range;
 	int found_pseudo = 0;
 
 	for (; v; v = v->next) {
@@ -11726,6 +11752,15 @@
 			ast_copy_string(drings.ringContext[1].contextData,v->value,sizeof(drings.ringContext[1].contextData));
 		} else if (!strcasecmp(v->name, "dring3context")) {
 			ast_copy_string(drings.ringContext[2].contextData,v->value,sizeof(drings.ringContext[2].contextData));
+		} else if (!strcasecmp(v->name, "dring1range")) {
+			range = atoi(v->value);
+			drings.ringnum[0].range = range;
+		} else if (!strcasecmp(v->name, "dring2range")) {
+			range = atoi(v->value);
+			drings.ringnum[1].range = range;
+		} else if (!strcasecmp(v->name, "dring3range")) {
+			range = atoi(v->value);
+			drings.ringnum[2].range = range;
 		} else if (!strcasecmp(v->name, "dring1")) {
 			ringc = v->value;
 			sscanf(ringc, "%d,%d,%d", &drings.ringnum[0].ring[0], &drings.ringnum[0].ring[1], &drings.ringnum[0].ring[2]);

Modified: trunk/configs/zapata.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/zapata.conf.sample?view=diff&rev=47771&r1=47770&r2=47771
==============================================================================
--- trunk/configs/zapata.conf.sample (original)
+++ trunk/configs/zapata.conf.sample Thu Nov 16 16:32:23 2006
@@ -649,10 +649,17 @@
 ;  You can see the dringX patterns is to set any one of the dringXcontext fields
 ;  and they will be printed on the console when an inbound call comes in.
 ;
+;  dringXrange is used to change the acceptable ranges for "tone offsets".  Defaults to 10.
+;  Note: a range of 0 is NOT what you might expect - it instead forces it to the default.
+;  A range of -1 will force it to always match.
+;  Anything lower than -1 would presumably cause it to never match.
+;
 ;dring1=95,0,0 
 ;dring1context=internal1 
+;dring1range=10
 ;dring2=325,95,0 
 ;dring2context=internal2 
+;dring2range=10
 ; If no pattern is matched here is where we go.
 ;context=default
 ;channel => 1 



More information about the asterisk-commits mailing list