[asterisk-commits] oej: trunk r47201 - in /trunk: channels/chan_sip.c configs/sip.conf.sample

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Nov 4 12:13:31 MST 2006


Author: oej
Date: Sat Nov  4 13:13:30 2006
New Revision: 47201

URL: http://svn.digium.com/view/asterisk?rev=47201&view=rev
Log:
Adding new config option "limitpeersonly" to only apply call limits
to the peer side of a type=friend. 

This is for trying to support BJ in his quest to solve some issues
with the queue system and type=friend objects.

BJ: Please test!

Modified:
    trunk/channels/chan_sip.c
    trunk/configs/sip.conf.sample

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=47201&r1=47200&r2=47201&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sat Nov  4 13:13:30 2006
@@ -512,6 +512,7 @@
 static struct ast_codec_pref default_prefs;		/*!< Default codec prefs */
 
 /* Global settings only apply to the channel */
+static int global_limitonpeers;		/*!< Match call limit on peers only */
 static int global_rtautoclear;
 static int global_notifyringing;	/*!< Send notifications on ringing */
 static int global_alwaysauthreject;	/*!< Send 401 Unauthorized for all failing requests */
@@ -3042,16 +3043,29 @@
 	ast_copy_string(name, fup->username, sizeof(name));
 
 	/* Check the list of users only for incoming calls */
-	if (!outgoing && (u = find_user(name, 1)) ) {
-		inuse = &u->inUse;
-		call_limit = &u->call_limit;
-		inringing = NULL;
+	if (!outgoing) {
+		if (global_limitonpeers == FALSE && (u = find_user(name, 1)))  {
+			inuse = &u->inUse;
+			call_limit = &u->call_limit;
+			inringing = NULL;
+		} else {
+			/* If limitonpeers is on, we only apply the limits to the
+				peer part of the type=friend. This is mainly to
+				help the queue system */
+			p = find_peer(name, NULL, 1);	/* Check the peer */
+			if (p != NULL) {
+				inuse = &p->inUse;
+				call_limit = &p->call_limit;
+				inringing = &p->inRinging;
+			}
+		}
 	} else if ( (p = find_peer(fup->peername, NULL, 1) ) ) { /* Try to find peer */
 		inuse = &p->inUse;
 		call_limit = &p->call_limit;
 		inringing = &p->inRinging;
 		ast_copy_string(name, fup->peername, sizeof(name));
-	} else {
+	} 
+	if (!p && !u) {
 		if (option_debug > 1)
 			ast_log(LOG_DEBUG, "%s is not a local device, no call limit\n", name);
 		return 0;
@@ -10271,6 +10285,7 @@
 	ast_cli(fd, "  Our auth realm          %s\n", global_realm);
 	ast_cli(fd, "  Realm. auth:            %s\n", authl ? "Yes": "No");
  	ast_cli(fd, "  Always auth rejects:    %s\n", global_alwaysauthreject ? "Yes" : "No");
+	ast_cli(fd, "  Call limit peers only:  %s\n", global_limitonpeers ? "Yes" : "No");
 	ast_cli(fd, "  User Agent:             %s\n", global_useragent);
 	ast_cli(fd, "  MWI checking interval:  %d secs\n", global_mwitime);
 	ast_cli(fd, "  Reg. context:           %s\n", S_OR(global_regcontext, "(not set)"));
@@ -15966,6 +15981,7 @@
 	global_regcontext[0] = '\0';
 	expiry = DEFAULT_EXPIRY;
 	global_notifyringing = DEFAULT_NOTIFYRINGING;
+	global_limitonpeers = FALSE;		/*!< Match call limit on peers only */
 	global_alwaysauthreject = 0;
 	global_allowsubscribe = FALSE;
 	ast_copy_string(global_useragent, DEFAULT_USERAGENT, sizeof(global_useragent));
@@ -16090,6 +16106,8 @@
 			ast_copy_string(default_notifymime, v->value, sizeof(default_notifymime));
 		} else if (!strcasecmp(v->name, "notifyringing")) {
 			global_notifyringing = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "limitpeersonly")) {
+			global_limitonpeers = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "alwaysauthreject")) {
 			global_alwaysauthreject = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "mohinterpret") 

Modified: trunk/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/sip.conf.sample?rev=47201&r1=47200&r2=47201&view=diff
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Sat Nov  4 13:13:30 2006
@@ -125,6 +125,12 @@
 				; for peers and users as well
 ;callevents=no			; generate manager events when sip ua 
 				; performs events (e.g. hold)
+;limitpeersonly=no		; Apply all call limits ("limit=") only to peers, never
+				; to users. This improves handling of call limits
+				; and device states in certain situations. The user part
+				; of a type=friend will still be affected by the call
+				; limit, but Asterisk will only use one object for
+				; counting the simultaneous calls.
 ;alwaysauthreject = yes		; When an incoming INVITE or REGISTER is to be rejected,
  		    		; for any reason, always reject with '401 Unauthorized'
  				; instead of letting the requester know whether there was



More information about the asterisk-commits mailing list