From 6eea9479e7c33d3bb4cadec615eb4c1e1b334428 Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Thu, 24 Feb 2005 13:57:45 +0000
Subject: [PATCH] Allow global "qualify" option (bug #3649)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5071 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_sip.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 48db9a05a7..a1f4014248 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -136,8 +136,11 @@ static char default_fromdomain[AST_MAX_EXTENSION] = "";
 #define DEFAULT_NOTIFYMIME "application/simple-message-summary"
 static char default_notifymime[AST_MAX_EXTENSION] = DEFAULT_NOTIFYMIME;
 
+
+static int default_qualify = 0;		/* Default Qualify= setting */
+
 static struct ast_flags global_flags = {0};		/* global SIP_ flags */
-static struct ast_flags global_flags_page2 = {0};		/* more global SIP_ flags */
+static struct ast_flags global_flags_page2 = {0};	/* more global SIP_ flags */
 
 static int srvlookup = 0;		/* SRV Lookup on or off. Default is off, RFC behavior is on */
 
@@ -9205,7 +9208,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
 		peer->callgroup = 0;
 		peer->pickupgroup = 0;
 		peer->rtpkeepalive = global_rtpkeepalive;
-		peer->maxms = 0;
+		peer->maxms = default_qualify;
 		peer->prefs = prefs;
 		oldha = peer->ha;
 		peer->ha = NULL;
@@ -9431,6 +9434,7 @@ static int reload_config(void)
 	strncpy(default_context, DEFAULT_CONTEXT, sizeof(default_context) - 1);
 	default_language[0] = '\0';
 	default_fromdomain[0] = '\0';
+	default_qualify = 0;
 	externhost[0] = '\0';
 	externexpire = 0;
 	externrefresh = 10;
@@ -9621,6 +9625,15 @@ static int reload_config(void)
 			} else {
 				ast_log(LOG_WARNING, "Invalid port number '%s' at line %d of %s\n", v->value, v->lineno, config);
 			}
+		} else if (!strcasecmp(v->name, "qualify")) {
+			if (!strcasecmp(v->value, "no")) {
+				default_qualify = 0;
+			} else if (!strcasecmp(v->value, "yes")) {
+				default_qualify = DEFAULT_MAXMS;
+			} else if (sscanf(v->value, "%d", &default_qualify) != 1) {
+				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, "callevents")) {
 			callevents = ast_true(v->value);
 		}
-- 
GitLab