[asterisk-commits] russell: trunk r98027 - in /trunk: ./ channels/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 10 18:38:24 CST 2008


Author: russell
Date: Thu Jan 10 18:38:23 2008
New Revision: 98027

URL: http://svn.digium.com/view/asterisk?view=rev&rev=98027
Log:
Add a new global and per-peer option to chan_sip, qualifyfreq, which allows you
to set the qualify frequency.

(closes issue #11597)
Reported by: wilder
Patches:
      qualifyfreq5.patch uploaded by wilder (license 362)
	   -- with some mods by me

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

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=98027&r1=98026&r2=98027
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Jan 10 18:38:23 2008
@@ -120,6 +120,8 @@
     considered advanced, so don't use them unless you have a problem.
   * Added a dial string option to be able to set the To: header in an INVITE to any
     SIP uri.
+  * Added a new global and per-peer option, qualifyfreq, which allows you to configure
+     the qualify frequency.
 
 IAX2 changes
 ------------

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=98027&r1=98026&r2=98027
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Jan 10 18:38:23 2008
@@ -181,7 +181,7 @@
 #define CALLERID_UNKNOWN        "Unknown"
 
 #define DEFAULT_MAXMS                2000             /*!< Qualification: Must be faster than 2 seconds by default */
-#define DEFAULT_FREQ_OK              60 * 1000        /*!< Qualification: How often to check for the host to be up */
+#define DEFAULT_QUALIFYFREQ          60 * 1000        /*!< Qualification: How often to check for the host to be up */
 #define DEFAULT_FREQ_NOTOK           10 * 1000        /*!< Qualification: How often to check, if the host is down... */
 
 #define DEFAULT_RETRANS              1000             /*!< How frequently to retransmit Default: 2 * 500 ms in RFC 3261 */
@@ -648,8 +648,9 @@
 static int global_autoframing;          /*!< Turn autoframing on or off. */
 static enum transfermodes global_allowtransfer;	/*!< SIP Refer restriction scheme */
 static struct sip_proxy global_outboundproxy;	/*!< Outbound proxy */
-
 static int global_matchexterniplocally; /*!< Match externip/externhost setting against localnet setting */
+static int global_qualifyfreq; /*!< Qualify frequency */
+
 
 /*! \brief Codecs that we support by default: */
 static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
@@ -1351,6 +1352,7 @@
 	int pokeexpire;			/*!<  When to expire poke (qualify= checking) */
 	int lastms;			/*!<  How long last response took (in ms), or -1 for no response */
 	int maxms;			/*!<  Max ms we will accept for the host to be up, 0 to not monitor */
+	int qualifyfreq;		/*!<  Qualification: How often to check for the host to be up */
 	struct timeval ps;		/*!<  Time for sending SIP OPTION in sip_pke_peer() */
 	struct sockaddr_in defaddr;	/*!<  Default IP address, used until registration */
 	struct ast_ha *ha;		/*!<  Access control list */
@@ -11722,6 +11724,7 @@
 		ast_cli(fd, "%s\n",status);
  		ast_cli(fd, "  Useragent    : %s\n", peer->useragent);
  		ast_cli(fd, "  Reg. Contact : %s\n", peer->fullcontact);
+		ast_cli(fd, "  Qualify Freq : %d ms\n", peer->qualifyfreq);
 		if (peer->chanvars) {
  			ast_cli(fd, "  Variables    :\n");
 			for (v = peer->chanvars ; v ; v = v->next)
@@ -11798,6 +11801,7 @@
 		astman_append(s, "%s\r\n", status);
  		astman_append(s, "SIP-Useragent: %s\r\n", peer->useragent);
  		astman_append(s, "Reg-Contact : %s\r\n", peer->fullcontact);
+		astman_append(s, "Qualify Freq : %d ms\n", peer->qualifyfreq);
 		if (peer->chanvars) {
 			for (v = peer->chanvars ; v ; v = v->next) {
  				astman_append(s, "ChanVariable:\n");
@@ -12043,6 +12047,7 @@
 		ast_cli(a->fd, "  SIP realtime:           Disabled\n" );
 	else
 		ast_cli(a->fd, "  SIP realtime:           Enabled\n" );
+	ast_cli(a->fd, "  Qualify Freq :          %d ms\n", global_qualifyfreq);
 
 	ast_cli(a->fd, "\nNetwork Settings:\n");
 	ast_cli(a->fd, "---------------------------\n");
@@ -14084,7 +14089,7 @@
 
 	/* Try again eventually */
 	peer->pokeexpire = ast_sched_replace(peer->pokeexpire, sched,
-		is_reachable ? DEFAULT_FREQ_OK : DEFAULT_FREQ_NOTOK,
+		is_reachable ? peer->qualifyfreq : DEFAULT_FREQ_NOTOK,
 		sip_poke_peer_s, peer);
 }
 
@@ -17966,6 +17971,7 @@
 	peer->rtpkeepalive = global_rtpkeepalive;
 	peer->allowtransfer = global_allowtransfer;
 	peer->autoframing = global_autoframing;
+	peer->qualifyfreq = global_qualifyfreq;
 	if (global_callcounter)
 		peer->call_limit=999;
 	strcpy(peer->vmexten, default_vmexten);
@@ -18278,6 +18284,14 @@
 				ast_log(LOG_WARNING, "Qualification of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", peer->name, v->lineno);
 				peer->maxms = 0;
 			}
+		} else if (!strcasecmp(v->name, "qualifyfreq")) {
+			int i;
+			if (sscanf(v->value, "%d", &i) == 1)
+				peer->qualifyfreq = i * 1000;  
+			else {
+				ast_log(LOG_WARNING, "Invalid qualifyfreq number '%s' at line %d of %s\n",v->value, v->lineno, config);
+				peer->qualifyfreq = global_qualifyfreq;
+			}
 		} else if (!strcasecmp(v->name, "maxcallbitrate")) {
 			peer->maxcallbitrate = atoi(v->value);
 			if (peer->maxcallbitrate < 0)
@@ -18489,7 +18503,8 @@
 	global_callevents = FALSE;
 	global_t1 = SIP_TIMER_T1;
 	global_timer_b = 64 * SIP_TIMER_T1;
-	global_t1min = DEFAULT_T1MIN;		
+	global_t1min = DEFAULT_T1MIN;
+	global_qualifyfreq = DEFAULT_QUALIFYFREQ;
 
 	global_matchexterniplocally = FALSE;
 
@@ -18758,6 +18773,14 @@
 				ast_log(LOG_WARNING, "Qualification default should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", v->lineno);
 				default_qualify = 0;
 			}
+		} else if (!strcasecmp(v->name, "qualifyfreq")) {
+			int i;
+			if (sscanf(v->value, "%d", &i) == 1)
+				global_qualifyfreq = i * 1000;
+			else {
+				ast_log(LOG_WARNING, "Invalid qualifyfreq number '%s' at line %d of %s\n", v->value, v->lineno, config);
+				global_qualifyfreq = DEFAULT_QUALIFYFREQ;
+			}
 		} else if (!strcasecmp(v->name, "callevents")) {
 			global_callevents = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "maxcallbitrate")) {

Modified: trunk/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=98027&r1=98026&r2=98027
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Thu Jan 10 18:38:23 2008
@@ -101,6 +101,10 @@
 				; and subscriptions (seconds)
 ;minexpiry=60			; Minimum length of registrations/subscriptions (default 60)
 ;defaultexpiry=120		; Default length of incoming/outgoing registration
+;qualifyfreq=60                 ; Qualification: How often to check for the 
+                                ; host to be up in seconds
+                                ; Set to low value if you use low timeout for
+                                ; NAT of UDP sessions
 ;notifymimetype=text/plain	; Allow overriding of mime type in MWI NOTIFY
 ;buggymwi=no			; Cisco SIP firmware doesn't support the MWI RFC
 				; fully. Enable this option to not get error messages
@@ -631,6 +635,7 @@
 ;                             registertrying
 ;                             timert1
 ;                             timerb
+;                             qualifyfreq
 
 ;[sip_proxy]
 ; For incoming calls only. Example: FWD (Free World Dialup)
@@ -812,6 +817,10 @@
 ;qualify=1000			; Consider it down if it's 1 second to reply
 				; Helps with NAT session
 				; qualify=yes uses default value
+;qualifyfreq=60 ; Qualification: How often to check for the 
+				; host to be up in seconds
+				; Set to low value if you use low timeout for
+				; NAT of UDP sessions
 ;
 ; Call group and Pickup group should be in the range from 0 to 63
 ;




More information about the asterisk-commits mailing list