[asterisk-commits] murf: branch group/newcdr r171448 - in /team/group/newcdr: ./ apps/ channels/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 26 14:46:09 CST 2009


Author: murf
Date: Mon Jan 26 14:46:08 2009
New Revision: 171448

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=171448
Log:
Merged revisions 170498,170501,170505,170569,170608,170652,170677,170720,170790,170794,170837,170902,170943,170980,171043,171081,171121,171123,171188,171263,171326,171364,171400-171401 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r170498 | file | 2009-01-23 10:32:26 -0700 (Fri, 23 Jan 2009) | 4 lines

Reset the ast_str used for escape substitution. We need to do this since it is a thread local variable that may contain the value of a previous substitution.
(closes issue #14312)
Reported by: pj

................
r170501 | mvanbaak | 2009-01-23 10:46:02 -0700 (Fri, 23 Jan 2009) | 1 line

let's use SENTINEL where needed
................
r170505 | file | 2009-01-23 11:09:45 -0700 (Fri, 23 Jan 2009) | 11 lines

Merged revisions 170504 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r170504 | file | 2009-01-23 14:04:08 -0400 (Fri, 23 Jan 2009) | 4 lines
  
  Use the on hold flag to see if the call is on hold or not. It is possible that our address for them will still be valid even though they are on hold.
  (closes issue #14295)
  Reported by: klaus3000
........

................
r170569 | file | 2009-01-23 12:09:18 -0700 (Fri, 23 Jan 2009) | 11 lines

Merged revisions 170568 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r170568 | file | 2009-01-23 15:06:54 -0400 (Fri, 23 Jan 2009) | 4 lines
  
  When a call is forwarded stop any active indications. The new channel will provide an indication, if need be, itself.
  (closes issue #14310)
  Reported by: RadicAlish
........

................
r170608 | tilghman | 2009-01-23 12:25:10 -0700 (Fri, 23 Jan 2009) | 9 lines

Merged revisions 170588 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r170588 | tilghman | 2009-01-23 13:20:44 -0600 (Fri, 23 Jan 2009) | 2 lines
  
  Additions to AST-2009-001
........

................
r170652 | file | 2009-01-23 13:18:05 -0700 (Fri, 23 Jan 2009) | 11 lines

Merged revisions 170648 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r170648 | file | 2009-01-23 16:16:39 -0400 (Fri, 23 Jan 2009) | 4 lines
  
  When a channel is answered make sure any indications currently playing stop. Usually the phone would do this but if the channel was already answered then they are being generated by Asterisk and we darn well need to stop them.
  (closes issue #14249)
  Reported by: RadicAlish
........

................
r170677 | mmichelson | 2009-01-23 13:23:00 -0700 (Fri, 23 Jan 2009) | 22 lines

Merged revisions 170671 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r170671 | mmichelson | 2009-01-23 14:21:51 -0600 (Fri, 23 Jan 2009) | 14 lines

Update contrib/i18n.testsuite.conf to not use deprecated syntax

* Convert Wait,1 to Wait(1)
* Convert SetLanguage to Set(CHANNEL(language))
* Use 'n' for all priorities beyond the first

Also added test for Chinese numbers, too.

(closes issue #14320)
Reported by: dant
Patches:
      i18n.testsuite.conf.issue14320.v2.diff uploaded by dant (license 670)


........

................
r170720 | mmichelson | 2009-01-23 13:56:07 -0700 (Fri, 23 Jan 2009) | 16 lines

Merged revisions 170719 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r170719 | mmichelson | 2009-01-23 14:55:26 -0600 (Fri, 23 Jan 2009) | 8 lines

Add notes to the idlecheck explanation in res_odbc.conf.sample

(closes issue #14319)
Reported by: klaus3000
Patches:
      patch_idlecheck_res_odbc.conf.sample.txt uploaded by klaus3000 (license 65)


........

................
r170790 | russell | 2009-01-23 15:58:37 -0700 (Fri, 23 Jan 2009) | 2 lines

Don't blow up if a branch name has an underscore in it

................
r170794 | rmudgett | 2009-01-23 16:10:34 -0700 (Fri, 23 Jan 2009) | 1 line

Fix asterisk.pdf generation if branch name has an underscore in it.
................
r170837 | tilghman | 2009-01-24 06:55:53 -0700 (Sat, 24 Jan 2009) | 9 lines

Merged revisions 170836 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r170836 | tilghman | 2009-01-24 07:55:02 -0600 (Sat, 24 Jan 2009) | 2 lines
  
  Remove superfluous implementation note (closes issue #14319)
........

................
r170902 | russell | 2009-01-24 12:33:15 -0700 (Sat, 24 Jan 2009) | 2 lines

Add a todo to finish the XML docs in this module

................
r170943 | russell | 2009-01-24 19:49:30 -0700 (Sat, 24 Jan 2009) | 6 lines

Change ARRAY_LEN() to be more C++ safe.

When the second part of this macro is written as 0[a] instead of a[0], it will
force a failure if the macro is used on a C++ object that overloads the []
operator.

................
r170980 | seanbright | 2009-01-25 06:35:48 -0700 (Sun, 25 Jan 2009) | 16 lines

Merged revisions 170979 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r170979 | seanbright | 2009-01-25 08:33:20 -0500 (Sun, 25 Jan 2009) | 9 lines
  
  Resolve a logic error that was causing Page() to crash when more than one
  channel was specified.
  
  (closes issue #14308)
  Reported by: bluefox
  Patches:
        20090124__bug14308.diff.txt uploaded by seanbright (license 71)
  Tested by: kc0bvu
........

................
r171043 | mvanbaak | 2009-01-25 07:35:17 -0700 (Sun, 25 Jan 2009) | 7 lines

Make the sample skinny.conf work

(closes issue #14325)
Reported by: DEA
Patches:
      skinny.conf.sample-trunk.txt uploaded by DEA (license 3)

................
r171081 | mvanbaak | 2009-01-25 09:50:53 -0700 (Sun, 25 Jan 2009) | 2 lines

dont segfault when a MWI event occurs on a line without a registered device

................
r171121 | tilghman | 2009-01-25 13:31:57 -0700 (Sun, 25 Jan 2009) | 14 lines

Blocked revisions 171120 via svnmerge

........
  r171120 | tilghman | 2009-01-25 14:30:41 -0600 (Sun, 25 Jan 2009) | 8 lines
  
  Add thread to kill zombies, when child processes don't die immediately on
  SIGHUP.
  (closes issue #13968)
   Reported by: eldadran
   Patches: 
         20090114__bug13968.diff.txt uploaded by Corydon76 (license 14)
   Tested by: eldadran
........

................
r171123 | tilghman | 2009-01-25 13:41:19 -0700 (Sun, 25 Jan 2009) | 8 lines

Blocked revisions 171122 via svnmerge

........
  r171122 | tilghman | 2009-01-25 14:40:44 -0600 (Sun, 25 Jan 2009) | 2 lines
  
  Err, yeah.
........

................
r171188 | tilghman | 2009-01-25 16:58:00 -0700 (Sun, 25 Jan 2009) | 13 lines

Merged revisions 171187 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r171187 | tilghman | 2009-01-25 17:44:01 -0600 (Sun, 25 Jan 2009) | 6 lines
  
  Correctly track the hookstate
  (closes issue #13686)
   Reported by: itiliti
   Patches: 
         20081013__bug13686.diff.txt uploaded by Corydon76 (license 14)
........

................
r171263 | oej | 2009-01-26 05:32:30 -0700 (Mon, 26 Jan 2009) | 2 lines

Add extensions and context on manager event when new channel is created.

................
r171326 | oej | 2009-01-26 06:44:40 -0700 (Mon, 26 Jan 2009) | 17 lines

Merged revisions 171264 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r171264 | oej | 2009-01-26 13:51:53 +0100 (MÃ¥n, 26 Jan 2009) | 9 lines

Don't retransmit 401 on REGISTER requests when alwaysauthreject=yes

(closes issue #14284)
Reported by: klaus3000
Patches: 
      patch_chan_sip_unreliable_1.4.23_14284.txt uploaded by klaus3000 (license 65)
Tested by: klaus3000


........

................
r171364 | oej | 2009-01-26 08:11:39 -0700 (Mon, 26 Jan 2009) | 4 lines

Just moving around variable declarations so that we have all globals in the same place.
Default setting is set before we activate the channel or at reloads, not where we declare the variable.


................
r171400 | oej | 2009-01-26 08:51:00 -0700 (Mon, 26 Jan 2009) | 4 lines

Continue to move variables into the sip_cfg structure to make them easier to handle in the future as a group of settings for a group of devices. 
At some point, I want one sip_cfg per domain handled, so we can have "group" settings.


................
r171401 | oej | 2009-01-26 08:56:13 -0700 (Mon, 26 Jan 2009) | 2 lines

Moving generic setting to friends

................

Modified:
    team/group/newcdr/   (props changed)
    team/group/newcdr/apps/app_dial.c
    team/group/newcdr/apps/app_page.c
    team/group/newcdr/apps/app_voicemail.c
    team/group/newcdr/channels/chan_h323.c
    team/group/newcdr/channels/chan_iax2.c
    team/group/newcdr/channels/chan_oss.c
    team/group/newcdr/channels/chan_sip.c
    team/group/newcdr/channels/chan_skinny.c
    team/group/newcdr/configs/skinny.conf.sample
    team/group/newcdr/contrib/i18n.testsuite.conf
    team/group/newcdr/doc/tex/Makefile
    team/group/newcdr/include/asterisk/utils.h
    team/group/newcdr/main/channel.c
    team/group/newcdr/res/res_agi.c

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
    automerge = yes

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 26 14:46:08 2009
@@ -1,1 +1,1 @@
-/trunk:1-170463
+/trunk:1-171444

Modified: team/group/newcdr/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/apps/app_dial.c?view=diff&rev=171448&r1=171447&r2=171448
==============================================================================
--- team/group/newcdr/apps/app_dial.c (original)
+++ team/group/newcdr/apps/app_dial.c Mon Jan 26 14:46:08 2009
@@ -778,6 +778,9 @@
 			}
 			/* Hangup the original channel now, in case we needed it */
 			ast_hangup(original);
+		}
+		if (single) {
+			ast_indicate(in, -1);
 		}
 	}
 }

Modified: team/group/newcdr/apps/app_page.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/apps/app_page.c?view=diff&rev=171448&r1=171447&r2=171448
==============================================================================
--- team/group/newcdr/apps/app_page.c (original)
+++ team/group/newcdr/apps/app_page.c Mon Jan 26 14:46:08 2009
@@ -170,12 +170,15 @@
 	/* Count number of extensions in list by number of ampersands + 1 */
 	num_dials = 1;
 	tmp = args.devices;
-	while (*tmp && *tmp++ == '&') {
-		num_dials++;
-	}
-
-	if (!(dial_list = ast_calloc(num_dials, sizeof(void *)))) {
-		ast_log(LOG_ERROR, "Can't allocate %ld bytes for dial list\n", (long)(sizeof(void *) * num_dials));
+	while (*tmp) {
+		if (*tmp == '&') {
+			num_dials++;
+		}
+		tmp++;
+	}
+
+	if (!(dial_list = ast_calloc(num_dials, sizeof(struct ast_dial *)))) {
+		ast_log(LOG_ERROR, "Can't allocate %ld bytes for dial list\n", (long)(sizeof(struct ast_dial *) * num_dials));
 		return -1;
 	}
 

Modified: team/group/newcdr/apps/app_voicemail.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/apps/app_voicemail.c?view=diff&rev=171448&r1=171447&r2=171448
==============================================================================
--- team/group/newcdr/apps/app_voicemail.c (original)
+++ team/group/newcdr/apps/app_voicemail.c Mon Jan 26 14:46:08 2009
@@ -10191,6 +10191,8 @@
 	/* Add 16 for fudge factor */
 	struct ast_str *str = ast_str_thread_get(&global_app_buf, strlen(value) + 16);
 
+	ast_str_reset(str);
+	
 	/* Substitute strings \r, \n, and \t into the appropriate characters */
 	for (current = (char *) value; *current; current++) {
 		if (*current == '\\') {

Modified: team/group/newcdr/channels/chan_h323.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/channels/chan_h323.c?view=diff&rev=171448&r1=171447&r2=171448
==============================================================================
--- team/group/newcdr/channels/chan_h323.c (original)
+++ team/group/newcdr/channels/chan_h323.c Mon Jan 26 14:46:08 2009
@@ -1224,7 +1224,7 @@
 	struct ast_variable *var, *tmp;
 	struct oh323_alias *a;
 
-	var = ast_load_realtime("h323", "name", alias, NULL);
+	var = ast_load_realtime("h323", "name", alias, SENTINEL);
 
 	if (!var)
 		return NULL;
@@ -1438,10 +1438,10 @@
 	const char *username;
 
 	if (userbyalias)
-		var = ast_load_realtime("h323", "name", username = cd->call_source_aliases, NULL);
+		var = ast_load_realtime("h323", "name", username = cd->call_source_aliases, SENTINEL);
 	else {
 		username = (char *)NULL;
-		var = ast_load_realtime("h323", "host", cd->sourceIp, NULL);
+		var = ast_load_realtime("h323", "host", cd->sourceIp, SENTINEL);
 	}
 
 	if (!var)
@@ -1554,9 +1554,9 @@
 
 	/* First check on peer name */
 	if (peername)
-		var = ast_load_realtime("h323", "name", peername, NULL);
+		var = ast_load_realtime("h323", "name", peername, SENTINEL);
 	else if (sin) /* Then check on IP address for dynamic peers */
-		var = ast_load_realtime("h323", "host", addr = ast_inet_ntoa(sin->sin_addr), NULL);
+		var = ast_load_realtime("h323", "host", addr = ast_inet_ntoa(sin->sin_addr), SENTINEL);
 	else
 		return NULL;
 

Modified: team/group/newcdr/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/channels/chan_iax2.c?view=diff&rev=171448&r1=171447&r2=171448
==============================================================================
--- team/group/newcdr/channels/chan_iax2.c (original)
+++ team/group/newcdr/channels/chan_iax2.c Mon Jan 26 14:46:08 2009
@@ -6504,6 +6504,10 @@
 	p = find_peer(peer, 1);
 	ast_mutex_lock(&iaxsl[callno]);
 	if (!p || !iaxs[callno]) {
+		if (iaxs[callno]) {
+			/* Anything, as long as it's non-blank */
+			ast_string_field_set(iaxs[callno], secret, "badsecret");
+		}
 		if (authdebug && !p)
 			ast_log(LOG_NOTICE, "No registration for peer '%s' (from %s)\n", peer, ast_inet_ntoa(sin->sin_addr));
 		goto return_unref;
@@ -6583,21 +6587,24 @@
 			goto return_unref;
 		} else
 			ast_set_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED);
-	} else if (!ast_strlen_zero(md5secret) || !ast_strlen_zero(secret)) {
-		if (authdebug)
-			ast_log(LOG_NOTICE, "Inappropriate authentication received\n");
+	} else if (!ast_strlen_zero(p->secret) || !ast_strlen_zero(p->inkeys)) {
+		if (authdebug &&
+				((!ast_strlen_zero(p->secret) && (p->authmethods & IAX_AUTH_MD5) && !ast_strlen_zero(iaxs[callno]->challenge)) ||
+				 (!ast_strlen_zero(p->inkeys) && (p->authmethods & IAX_AUTH_RSA) && !ast_strlen_zero(iaxs[callno]->challenge)))) {
+			ast_log(LOG_NOTICE, "Inappropriate authentication received for '%s'\n", p->name);
+		}
 		goto return_unref;
 	}
+	ast_devstate_changed(AST_DEVICE_UNKNOWN, "IAX2/%s", p->name); /* Activate notification */
+
+return_unref:
 	ast_string_field_set(iaxs[callno], peer, peer);
 	/* Choose lowest expiry number */
 	if (expire && (expire < iaxs[callno]->expiry)) 
 		iaxs[callno]->expiry = expire;
 
-	ast_devstate_changed(AST_DEVICE_UNKNOWN, "IAX2/%s", p->name); /* Activate notification */
-
 	res = 0;
 
-return_unref:
 	if (p)
 		peer_unref(p);
 
@@ -7333,7 +7340,6 @@
 	struct iax2_peer *p;
 	char challenge[10];
 	const char *peer_name;
-	int res = -1;
 	int sentauthmethod;
 
 	peer_name = ast_strdupa(iaxs[callno]->peer);
@@ -7347,11 +7353,7 @@
 	ast_mutex_lock(&iaxsl[callno]);
 	if (!iaxs[callno])
 		goto return_unref;
-	if (!p && !delayreject) {
-		ast_log(LOG_WARNING, "No such peer '%s'\n", peer_name);
-		goto return_unref;
-	}
-	
+
 	memset(&ied, 0, sizeof(ied));
 	/* The selection of which delayed reject is sent may leak information,
 	 * if it sets a static response.  For example, if a host is known to only
@@ -7369,12 +7371,12 @@
 	}
 	iax_ie_append_str(&ied, IAX_IE_USERNAME, peer_name);
 
-	res = 0;
-
 return_unref:
-	peer_unref(p);
-
-	return res ? res : send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_REGAUTH, 0, ied.buf, ied.pos, -1);;
+	if (p) {
+		peer_unref(p);
+	}
+
+	return iaxs[callno] ? send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_REGAUTH, 0, ied.buf, ied.pos, -1) : -1;
 }
 
 static int registry_rerequest(struct iax_ies *ies, int callno, struct sockaddr_in *sin)

Modified: team/group/newcdr/channels/chan_oss.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/channels/chan_oss.c?view=diff&rev=171448&r1=171447&r2=171448
==============================================================================
--- team/group/newcdr/channels/chan_oss.c (original)
+++ team/group/newcdr/channels/chan_oss.c Mon Jan 26 14:46:08 2009
@@ -255,9 +255,9 @@
 	int total_blocks;			/*!< total blocks in the output device */
 	int sounddev;
 	enum { M_UNSET, M_FULL, M_READ, M_WRITE } duplex;
-	int autoanswer;
-	int autohangup;
-	int hookstate;
+	int autoanswer;             /*!< Boolean: whether to answer the immediately upon calling */
+	int autohangup;             /*!< Boolean: whether to hangup the call when the remote end hangs up */
+	int hookstate;              /*!< Boolean: 1 if offhook; 0 if onhook */
 	char *mixer_cmd;			/*!< initial command to issue to the mixer */
 	unsigned int queuesize;		/*!< max fragments in queue */
 	unsigned int frags;			/*!< parameter for SETFRAGMENT */
@@ -289,8 +289,8 @@
 	char ext[AST_MAX_EXTENSION];
 	char ctx[AST_MAX_CONTEXT];
 	char language[MAX_LANGUAGE];
-	char cid_name[256];			/*XXX */
-	char cid_num[256];			/*XXX */
+	char cid_name[256];         /*!< Initial CallerID name */
+	char cid_num[256];          /*!< Initial CallerID number  */
 	char mohinterpret[MAX_MUSICCLASS];
 
 	/*! buffers used in oss_write */
@@ -622,6 +622,7 @@
 		f.frametype = AST_FRAME_CONTROL;
 		f.subclass = AST_CONTROL_ANSWER;
 		ast_queue_frame(c, &f);
+		o->hookstate = 1;
 	} else {
 		ast_verbose("<< Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
 		f.frametype = AST_FRAME_CONTROL;
@@ -637,8 +638,10 @@
  */
 static int oss_answer(struct ast_channel *c)
 {
+	struct chan_oss_pvt *o = c->tech_pvt;
 	ast_verbose(" << Console call has been answered >> \n");
 	ast_setstate(c, AST_STATE_UP);
+	o->hookstate = 1;
 	return 0;
 }
 
@@ -821,7 +824,6 @@
 			ast_log(LOG_WARNING, "Unable to start PBX on %s\n", c->name);
 			ast_hangup(c);
 			o->owner = c = NULL;
-			/* XXX what about the channel itself ? */
 		}
 	}
 	console_video_start(get_video_desc(c), c); /* XXX cleanup */
@@ -1067,7 +1069,7 @@
 		return CLI_FAILURE;
 	}
 	o->hookstate = 0;
-	if (o->owner)				/* XXX must be true, right ? */
+	if (o->owner)
 		ast_queue_frame(o->owner, &f);
 	return CLI_SUCCESS;
 }
@@ -1483,7 +1485,7 @@
 		close(o->sounddev);
 		if (o->owner)
 			ast_softhangup(o->owner, AST_SOFTHANGUP_APPUNLOAD);
-		if (o->owner)			/* XXX how ??? */
+		if (o->owner)
 			return -1;
 		next = o->next;
 		ast_free(o->name);

Modified: team/group/newcdr/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/channels/chan_sip.c?view=diff&rev=171448&r1=171447&r2=171448
==============================================================================
--- team/group/newcdr/channels/chan_sip.c (original)
+++ team/group/newcdr/channels/chan_sip.c Mon Jan 26 14:46:08 2009
@@ -522,8 +522,6 @@
 #define DEFAULT_QUALIFY_GAP   100
 #define DEFAULT_QUALIFY_PEERS 1
 
-static int global_qualify_gap = DEFAULT_QUALIFY_GAP;              /*!< Time between our group of peer pokes */
-static int global_qualify_peers = DEFAULT_QUALIFY_PEERS;          /*!< Number of peers to poke at a given time */
 
 #define CALLERID_UNKNOWN        "Unknown"
 
@@ -543,6 +541,7 @@
 #define SIP_MAX_HEADERS              64               /*!< Max amount of SIP headers to read */
 #define SIP_MAX_LINES                64               /*!< Max amount of lines in SIP attachment (like SDP) */
 #define SIP_MIN_PACKET               4096             /*!< Initialize size of memory to allocate for packets */
+#define MAX_HISTORY_ENTRIES 	     50	              /*!< Max entires in the history list for a sip_pvt */
 
 #define INITIAL_CSEQ                 101              /*!< Our initial sip sequence number */
 
@@ -753,7 +752,7 @@
  * For outbound proxies, a sip_peer will contain a reference to a 
  * dynamically allocated instance of a sip_proxy. A sip_pvt may also
  * contain a reference to a peer's outboundproxy, or it may contain
- * a reference to the global_outboundproxy.
+ * a reference to the sip_cfg.outboundproxy.
  */
 struct sip_proxy {
 	char name[MAXHOSTNAMELEN];      /*!< DNS name of domain/host or IP */
@@ -1015,8 +1014,6 @@
 	configuring devices 
 */
 /*@{*/ 
-static char default_context[AST_MAX_CONTEXT];
-static char default_subscribecontext[AST_MAX_CONTEXT];
 static char default_language[MAX_LANGUAGE];
 static char default_callerid[AST_MAX_EXTENSION];
 static char default_fromdomain[AST_MAX_EXTENSION];
@@ -1040,6 +1037,7 @@
 */
 /*@{*/ 
 /*! \brief a place to store all global settings for the sip channel driver 
+	These are settings that will be possibly to apply on a group level later on.
 */
 struct sip_settings {
 	int peer_rtupdate;		/*!< G: Update database with registration data for peer? */
@@ -1057,15 +1055,21 @@
 	int callevents;			/*!< Whether we send manager events or not */
 	int regextenonqualify;  	/*!< Whether to add/remove regexten when qualifying peers */
 	int matchexterniplocally;	/*!< Match externip/externhost setting against localnet setting */
+	int notifyringing;		/*!< Send notifications on ringing */
+	int notifyhold;			/*!< Send notifications on hold */
+	enum notifycid_setting notifycid; /*!< Send CID with ringing notifications */
+	enum transfermodes allowtransfer;	/*!< SIP Refer restriction scheme */
+	int allowsubscribe;	        /*!< Flag for disabling ALL subscriptions, this is FALSE only if all peers are FALSE 
+					    the global setting is in globals_flags[1] */
+	char realm[MAXHOSTNAMELEN]; 		/*!< Default realm */
+	struct sip_proxy outboundproxy;	/*!< Outbound proxy */
+	char default_context[AST_MAX_CONTEXT];
+	char default_subscribecontext[AST_MAX_CONTEXT];
 };
 
 static struct sip_settings sip_cfg;
 
-static int global_notifyringing;	/*!< Send notifications on ringing */
-static int global_notifyhold;		/*!< Send notifications on hold */
 static int global_match_auth_username;		/*!< Match auth username if available instead of From: Default off. */
-
-static enum notifycid_setting global_notifycid; /*!< Send CID with ringing notifications */
 
 static int global_relaxdtmf;		/*!< Relax DTMF */
 static int global_rtptimeout;		/*!< Time out call if no RTP */
@@ -1076,9 +1080,6 @@
 static int global_callcounter;		/*!< Enable call counters for all devices. This is currently enabled by setting the peer
 						call-limit to 999. When we remove the call-limit from the code, we can make it
 						with just a boolean flag in the device structure */
-static enum transfermodes global_allowtransfer;	/*!< SIP Refer restriction scheme */
-static int global_allowsubscribe;	/*!< Flag for disabling ALL subscriptions, this is FALSE only if all peers are FALSE 
-					    the global setting is in globals_flags[1] */
 static unsigned int global_tos_sip;		/*!< IP type of service for SIP packets */
 static unsigned int global_tos_audio;		/*!< IP type of service for audio RTP packets */
 static unsigned int global_tos_video;		/*!< IP type of service for video RTP packets */
@@ -1089,7 +1090,6 @@
 static unsigned int global_cos_text;		/*!< 802.1p class of service for text RTP packets */
 static int recordhistory;		/*!< Record SIP history. Off by default */
 static int dumphistory;			/*!< Dump history to verbose before destroying SIP dialog */
-static char global_realm[MAXHOSTNAMELEN]; 		/*!< Default realm */
 static char global_regcontext[AST_MAX_CONTEXT];		/*!< Context for auto-extensions */
 static char global_useragent[AST_MAX_EXTENSION];	/*!< Useragent for the SIP channel */
 static char global_sdpsession[AST_MAX_EXTENSION];	/*!< SDP session name for the SIP channel */
@@ -1099,8 +1099,9 @@
 static int global_t1min;		/*!< T1 roundtrip time minimum */
 static int global_timer_b;    			/*!< Timer B - RFC 3261 Section 17.1.1.2 */
 static int global_autoframing;          	/*!< Turn autoframing on or off. */
-static struct sip_proxy global_outboundproxy;	/*!< Outbound proxy */
 static int global_qualifyfreq;			/*!< Qualify frequency */
+static int global_qualify_gap;              /*!< Time between our group of peer pokes */
+static int global_qualify_peers;          /*!< Number of peers to poke at a given time */
 
 
 /*! \brief Codecs that we support by default: */
@@ -1708,8 +1709,6 @@
 	struct sip_subscription_mwi *mwi;       /*!< If this is a subscription MWI dialog, to which subscription */
 };
 
-/*! Max entires in the history list for a sip_pvt */
-#define MAX_HISTORY_ENTRIES 50
 
 /*! \brief
  * Here we implement the container for dialogs (sip_pvt), defining
@@ -2223,7 +2222,7 @@
 static int transmit_response_with_unsupported(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *unsupported);
 static int transmit_response_with_auth(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *rand, enum xmittype reliable, const char *header, int stale);
 static int transmit_response_with_allow(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable);
-static void transmit_fake_auth_response(struct sip_pvt *p, struct sip_request *req, int reliable);
+static void transmit_fake_auth_response(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable);
 static int transmit_request(struct sip_pvt *p, int sipmethod, int inc, enum xmittype reliable, int newbranch);
 static int transmit_request_with_auth(struct sip_pvt *p, int sipmethod, int seqno, enum xmittype reliable, int newbranch);
 static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init);
@@ -2858,14 +2857,14 @@
 static void ref_proxy(struct sip_pvt *pvt, struct sip_proxy *proxy)
 {
 	struct sip_proxy *old_obproxy = pvt->outboundproxy;
-	/* The global_outboundproxy is statically allocated, and so
+	/* The sip_cfg.outboundproxy is statically allocated, and so
 	 * we don't ever need to adjust refcounts for it
 	 */
-	if (proxy && proxy != &global_outboundproxy) {
+	if (proxy && proxy != &sip_cfg.outboundproxy) {
 		ao2_ref(proxy, +1);
 	}
 	pvt->outboundproxy = proxy;
-	if (old_obproxy && old_obproxy != &global_outboundproxy) {
+	if (old_obproxy && old_obproxy != &sip_cfg.outboundproxy) {
 		ao2_ref(old_obproxy, -1);
 	}
 }
@@ -3033,11 +3032,11 @@
 		append_history(dialog, "OBproxy", "Using peer obproxy %s", peer->outboundproxy->name);
 		return peer->outboundproxy;
 	}
-	if (global_outboundproxy.name[0]) {
+	if (sip_cfg.outboundproxy.name[0]) {
 		if (sipdebug)
 			ast_debug(1, "OBPROXY: Applying global OBproxy to this call\n");
-		append_history(dialog, "OBproxy", "Using global obproxy %s", global_outboundproxy.name);
-		return &global_outboundproxy;
+		append_history(dialog, "OBproxy", "Using global obproxy %s", sip_cfg.outboundproxy.name);
+		return &sip_cfg.outboundproxy;
 	}
 	if (sipdebug)
 		ast_debug(1, "OBPROXY: Not applying OBproxy to this call\n");
@@ -5227,7 +5226,7 @@
 		/* Decrement onhold count if applicable */
 		sip_pvt_lock(fup);
 		ao2_lock(p);
-		if (ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD) && global_notifyhold) {
+		if (ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD) && sip_cfg.notifyhold) {
 			ast_clear_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD);
 			ao2_unlock(p);
 			sip_pvt_unlock(fup);
@@ -6670,7 +6669,7 @@
 	ast_string_field_set(p, mohinterpret, default_mohinterpret);
 	ast_string_field_set(p, mohsuggest, default_mohsuggest);
 	p->capability = global_capability;
-	p->allowtransfer = global_allowtransfer;
+	p->allowtransfer = sip_cfg.allowtransfer;
 	if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833) ||
 	    (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO))
 		p->noncodeccapability |= AST_RTP_DTMF;
@@ -6679,7 +6678,7 @@
 		set_t38_capabilities(p);
 		p->t38.jointcapability = p->t38.capability;
 	}
-	ast_string_field_set(p, context, default_context);
+	ast_string_field_set(p, context, sip_cfg.default_context);
 	ast_string_field_set(p, parkinglot, default_parkinglot);
 
 	AST_LIST_HEAD_INIT_NOLOCK(&p->request_queue);
@@ -8024,7 +8023,7 @@
 				      "Uniqueid: %s\r\n",
 				      p->owner->name,
 				      p->owner->uniqueid);
-		if (global_notifyhold)
+		if (sip_cfg.notifyhold)
 			sip_peer_hold(p, FALSE);
 		ast_clear_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD); /* Clear both flags */
 	} else if (!sin.sin_addr.s_addr || (sendonly && sendonly != -1)) {
@@ -8053,7 +8052,7 @@
 			ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_INACTIVE);
 		else
 			ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_ACTIVE);
-		if (global_notifyhold && !already_on_hold)
+		if (sip_cfg.notifyhold && !already_on_hold)
 			sip_peer_hold(p, TRUE);
 	}
 	
@@ -8729,7 +8728,7 @@
 	}
 	/* Stale means that they sent us correct authentication, but 
 	   based it on an old challenge (nonce) */
-	snprintf(tmp, sizeof(tmp), "Digest algorithm=MD5, realm=\"%s\", nonce=\"%s\"%s", global_realm, randdata, stale ? ", stale=true" : "");
+	snprintf(tmp, sizeof(tmp), "Digest algorithm=MD5, realm=\"%s\", nonce=\"%s\"%s", sip_cfg.realm, randdata, stale ? ", stale=true" : "");
 	respprep(&resp, p, msg, req);
 	add_header(&resp, header, tmp);
 	add_header_contentLength(&resp, 0);
@@ -10027,7 +10026,7 @@
 
 	return (c->pbx &&
 			(!strcasecmp(c->macroexten, p->exten) || !strcasecmp(c->exten, p->exten)) &&
-			(global_notifycid == IGNORE_CONTEXT || !strcasecmp(c->context, p->context)));
+			(sip_cfg.notifycid == IGNORE_CONTEXT || !strcasecmp(c->context, p->context)));
 }
 
 /*! \brief Used in the SUBSCRIBE notification subsystem (RFC3265) */
@@ -10049,7 +10048,7 @@
 
 	switch (state) {
 	case (AST_EXTENSION_RINGING | AST_EXTENSION_INUSE):
-		statestring = (global_notifyringing) ? "early" : "confirmed";
+		statestring = (sip_cfg.notifyringing) ? "early" : "confirmed";
 		local_state = NOTIFY_INUSE;
 		pidfstate = "busy";
 		pidfnote = "Ringing";
@@ -10188,13 +10187,13 @@
 	case DIALOG_INFO_XML: /* SNOM subscribes in this format */
 		ast_str_append(&tmp, 0, "<?xml version=\"1.0\"?>\n");
 		ast_str_append(&tmp, 0, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%d\" state=\"%s\" entity=\"%s\">\n", p->dialogver++, full ? "full" : "partial", mto);
-		if ((state & AST_EXTENSION_RINGING) && global_notifyringing) {
+		if ((state & AST_EXTENSION_RINGING) && sip_cfg.notifyringing) {
 			const char *local_display = p->exten, *local_target = mto;
 
 			/* There are some limitations to how this works.  The primary one is that the
 			   callee must be dialing the same extension that is being monitored.  Simply dialing
 			   the hint'd device is not sufficient. */
-			if (global_notifycid) {
+			if (sip_cfg.notifycid) {
 				struct ast_channel *caller = ast_channel_search_locked(find_calling_channel, p);
 
 				if (caller) {
@@ -11601,7 +11600,7 @@
 		ast_copy_string(a1_hash, md5secret, sizeof(a1_hash));
 	else {
 		char a1[256];
-		snprintf(a1, sizeof(a1), "%s:%s:%s", username, global_realm, secret);
+		snprintf(a1, sizeof(a1), "%s:%s:%s", username, sip_cfg.realm, secret);
 		ast_md5_hash(a1_hash, a1);
 	}
 
@@ -11729,7 +11728,7 @@
 /*! \brief Send a fake 401 Unauthorized response when the administrator
   wants to hide the names of local devices  from fishers
  */
-static void transmit_fake_auth_response(struct sip_pvt *p, struct sip_request *req, int reliable)
+static void transmit_fake_auth_response(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable)
 {
 	ast_string_field_build(p, randdata, "%08lx", ast_random());	/* Create nonce for challenge */
 	transmit_response_with_auth(p, "401 Unauthorized", req, p->randdata, reliable, "WWW-Authenticate", 0);
@@ -11934,7 +11933,7 @@
 		case AUTH_PEER_NOT_DYNAMIC:
 		case AUTH_ACL_FAILED:
 			if (sip_cfg.alwaysauthreject) {
-				transmit_fake_auth_response(p, &p->initreq, 1);
+				transmit_fake_auth_response(p, &p->initreq, XMIT_UNRELIABLE);
 			} else {
 				/* URI not found */
 				if (res == AUTH_PEER_NOT_DYNAMIC) {
@@ -12441,7 +12440,7 @@
 	/* By default, use the context in the channel sending the REFER */
 	if (ast_strlen_zero(transfer_context)) {
 		transfer_context = S_OR(transferer->owner->macrocontext,
-					S_OR(transferer->context, default_context));
+					S_OR(transferer->context, sip_cfg.default_context));
 	}
 
 	ast_copy_string(referdata->refer_to_context, transfer_context, sizeof(referdata->refer_to_context));
@@ -12509,7 +12508,7 @@
 	/* By default, use the context in the channel sending the REFER */
 	if (ast_strlen_zero(transfer_context)) {
 		transfer_context = S_OR(p->owner->macrocontext,
-					S_OR(p->context, default_context));
+					S_OR(p->context, sip_cfg.default_context));
 	}
 	if (ast_exists_extension(NULL, transfer_context, c, 1, NULL)) {
 		/* This is a blind transfer */
@@ -14759,7 +14758,7 @@
 	ast_cli(a->fd, "  Enable call counters:   %s\n", cli_yesno(global_callcounter));
 	ast_cli(a->fd, "  SIP domain support:     %s\n", cli_yesno(!AST_LIST_EMPTY(&domain_list)));
 	ast_cli(a->fd, "  Realm. auth:            %s\n", cli_yesno(authl != NULL));
-	ast_cli(a->fd, "  Our auth realm          %s\n", global_realm);
+	ast_cli(a->fd, "  Our auth realm          %s\n", sip_cfg.realm);
 	ast_cli(a->fd, "  Call to non-local dom.: %s\n", cli_yesno(sip_cfg.allow_external_domains));
 	ast_cli(a->fd, "  URI user is phone no:   %s\n", cli_yesno(ast_test_flag(&global_flags[0], SIP_USEREQPHONE)));
  	ast_cli(a->fd, "  Always auth rejects:    %s\n", cli_yesno(sip_cfg.alwaysauthreject));
@@ -14855,18 +14854,18 @@
 	ast_cli(a->fd, "  Reg. default duration:  %d secs\n", default_expiry);
 	ast_cli(a->fd, "  Outbound reg. timeout:  %d secs\n", global_reg_timeout);
 	ast_cli(a->fd, "  Outbound reg. attempts: %d\n", global_regattempts_max);
-	ast_cli(a->fd, "  Notify ringing state:   %s\n", cli_yesno(global_notifyringing));
-	if (global_notifyringing) {
+	ast_cli(a->fd, "  Notify ringing state:   %s\n", cli_yesno(sip_cfg.notifyringing));
+	if (sip_cfg.notifyringing) {
 		ast_cli(a->fd, "    Include CID:          %s%s\n",
-				cli_yesno(global_notifycid),
-				global_notifycid == IGNORE_CONTEXT ? " (Ignoring context)" : "");
-	}
-	ast_cli(a->fd, "  Notify hold state:      %s\n", cli_yesno(global_notifyhold));
-	ast_cli(a->fd, "  SIP Transfer mode:      %s\n", transfermode2str(global_allowtransfer));
+				cli_yesno(sip_cfg.notifycid),
+				sip_cfg.notifycid == IGNORE_CONTEXT ? " (Ignoring context)" : "");
+	}
+	ast_cli(a->fd, "  Notify hold state:      %s\n", cli_yesno(sip_cfg.notifyhold));
+	ast_cli(a->fd, "  SIP Transfer mode:      %s\n", transfermode2str(sip_cfg.allowtransfer));
 	ast_cli(a->fd, "  Max Call Bitrate:       %d kbps\n", default_maxcallbitrate);
 	ast_cli(a->fd, "  Auto-Framing:           %s\n", cli_yesno(global_autoframing));
-	ast_cli(a->fd, "  Outb. proxy:            %s %s\n", ast_strlen_zero(global_outboundproxy.name) ? "<not set>" : global_outboundproxy.name,
-							global_outboundproxy.force ? "(forced)" : "");
+	ast_cli(a->fd, "  Outb. proxy:            %s %s\n", ast_strlen_zero(sip_cfg.outboundproxy.name) ? "<not set>" : sip_cfg.outboundproxy.name,
+							sip_cfg.outboundproxy.force ? "(forced)" : "");
 	ast_cli(a->fd, "  Session Timers:         %s\n", stmode2str(global_st_mode));
 	ast_cli(a->fd, "  Session Refresher:      %s\n", strefresher2str (global_st_refresher));
 	ast_cli(a->fd, "  Session Expires:        %d secs\n", global_max_se);
@@ -14879,7 +14878,7 @@
 	ast_cli(a->fd, "-----------------\n");
 	ast_cli(a->fd, "  Allowed transports:     %s\n", get_transport_list(default_transports)); 
 	ast_cli(a->fd, "  Outbound transport:	  %s\n", get_transport(default_primary_transport));
-	ast_cli(a->fd, "  Context:                %s\n", default_context);
+	ast_cli(a->fd, "  Context:                %s\n", sip_cfg.default_context);
 	ast_cli(a->fd, "  Nat:                    %s\n", nat2str(ast_test_flag(&global_flags[0], SIP_NAT)));
 	ast_cli(a->fd, "  DTMF:                   %s\n", dtmfmode2str(ast_test_flag(&global_flags[0], SIP_DTMF)));
 	ast_cli(a->fd, "  Qualify:                %d\n", default_qualify);
@@ -17960,7 +17959,7 @@
 	build_contact(p);
 
 	if (ast_strlen_zero(p->context))
-		ast_string_field_set(p, context, default_context);
+		ast_string_field_set(p, context, sip_cfg.default_context);
 
 	if (ast_shutting_down())
 		transmit_response_with_allow(p, "503 Unavailable", req, 0);
@@ -18717,7 +18716,7 @@
 		if (res < 0) { /* Something failed in authentication */
 			if (res == AUTH_FAKE_AUTH) {
 				ast_log(LOG_NOTICE, "Sending fake auth rejection for device %s\n", get_header(req, "From"));
-				transmit_fake_auth_response(p, req, 1);
+				transmit_fake_auth_response(p, req, XMIT_RELIABLE);
 			} else {
 				ast_log(LOG_NOTICE, "Failed to authenticate device %s\n", get_header(req, "From"));
 				transmit_response_reliable(p, "403 Forbidden", req);
@@ -18751,7 +18750,7 @@
 
 		/* Initialize the context if it hasn't been already */
 		if (ast_strlen_zero(p->context))
-			ast_string_field_set(p, context, default_context);
+			ast_string_field_set(p, context, sip_cfg.default_context);
 
 
 		/* Check number of concurrent calls -vs- incoming limit HERE */
@@ -19404,7 +19403,7 @@
 		return 0;
 	}
 	if (ast_strlen_zero(p->context))
-		ast_string_field_set(p, context, default_context);
+		ast_string_field_set(p, context, sip_cfg.default_context);
 
 	/* If we do not support SIP domains, all transfers are local */
 	if (sip_cfg.allow_external_domains && check_sip_domain(p->refer->refer_to_domain, NULL, 0)) {
@@ -19842,7 +19841,7 @@
 		ast_log(LOG_NOTICE, "Client '%s' using deprecated BYE/Also transfer method.  Ask vendor to support REFER instead\n",
 			ast_inet_ntoa(p->recv.sin_addr));
 		if (ast_strlen_zero(p->context))
-			ast_string_field_set(p, context, default_context);
+			ast_string_field_set(p, context, sip_cfg.default_context);
 		res = get_also_info(p, req);
 		if (!res) {
 			c = p->owner;
@@ -19931,7 +19930,7 @@
 	/* Check if we have a global disallow setting on subscriptions. 
 		if so, we don't have to check peer settings after auth, which saves a lot of processing
 	*/
-	if (!global_allowsubscribe) {
+	if (!sip_cfg.allowsubscribe) {
  		transmit_response(p, "403 Forbidden (policy)", req);
 		pvt_set_needdestroy(p, "forbidden");
 		return 0;
@@ -19985,7 +19984,7 @@
 	if (res < 0) {
 		if (res == AUTH_FAKE_AUTH) {
 			ast_log(LOG_NOTICE, "Sending fake auth rejection for device %s\n", get_header(req, "From"));
-			transmit_fake_auth_response(p, req, 1);
+			transmit_fake_auth_response(p, req, XMIT_UNRELIABLE);
 		} else {
 			ast_log(LOG_NOTICE, "Failed to authenticate device %s for SUBSCRIBE\n", get_header(req, "From"));
 			transmit_response_reliable(p, "403 Forbidden", req);
@@ -21041,7 +21040,7 @@
 		/* Might be a timeout now -- see if we're on hold */
 		struct sockaddr_in sin;
 		ast_rtp_get_peer(dialog->rtp, &sin);
-		if (sin.sin_addr.s_addr || (ast_rtp_get_rtpholdtimeout(dialog->rtp) &&
+		if (!ast_test_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD) || (ast_rtp_get_rtpholdtimeout(dialog->rtp) &&
 		     (t > dialog->lastrtprx + ast_rtp_get_rtpholdtimeout(dialog->rtp)))) {
 			/* Needs a hangup */
 			if (ast_rtp_get_rtptimeout(dialog->rtp)) {
@@ -22215,8 +22214,8 @@
 	}
 	ast_copy_flags(&peer->flags[0], &global_flags[0], SIP_FLAGS_TO_COPY);
 	ast_copy_flags(&peer->flags[1], &global_flags[1], SIP_PAGE2_FLAGS_TO_COPY);
-	ast_string_field_set(peer, context, default_context);

[... 744 lines stripped ...]



More information about the asterisk-commits mailing list