[asterisk-commits] file: branch file/pimp_sip_nat r382367 - in /team/file/pimp_sip_nat: ./ apps/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Mar 3 18:05:11 CST 2013


Author: file
Date: Sun Mar  3 18:05:02 2013
New Revision: 382367

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382367
Log:
Multiple revisions 382117,382196,382201,382206,382229,382237,382270,382301,382317,382326,382342,382362

........
  r382117 | root | 2013-02-26 16:18:07 -0400 (Tue, 26 Feb 2013) | 49 lines
  
  Merged revisions 382106,382109,382113 via svnmerge from 
  file:///srv/subversion/repos/asterisk/trunk
  
  ................
    r382106 | tzafrir | 2013-02-26 13:29:14 -0600 (Tue, 26 Feb 2013) | 11 lines
    
    Remove unneeded linux-gnueabi*
    
    As of r380522 the configure scripts converts the value of linux-gnueabi*
    of OSARCH to "linux-gnu". So no point in testing for those values.
    ........
    
    Merged revisions 382087 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 382096 from http://svn.asterisk.org/svn/asterisk/branches/11
  ................
    r382109 | wdoekes | 2013-02-26 13:36:30 -0600 (Tue, 26 Feb 2013) | 13 lines
    
    Correct RPID parsing for unquoted display-name.
    
    Parsing Remote-Party-ID will now succeed if display-name is of the
    *(token LWS) kind and not just the quoted-string kind.
    
    Review: https://reviewboard.asterisk.org/r/2341/
    ........
    
    Merged revisions 382107 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 382108 from http://svn.asterisk.org/svn/asterisk/branches/11
  ................
    r382113 | tzafrir | 2013-02-26 14:05:02 -0600 (Tue, 26 Feb 2013) | 14 lines
    
    Consider linux-gnuspe as linux-gnu
    
    * The powerpcspe Linux port uses linux-gnuspe as the OS string.
    * Our build system shouldn't really care for that, so just call it linux-gnu.
    * Original report: Roland Stigge , http://bugs.debian.org/701505
    
    Review: https://reviewboard.asterisk.org/r/2357/
    ........
    
    Merged revisions 382110 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 382111 from http://svn.asterisk.org/svn/asterisk/branches/11
  ................
........
  r382196 | root | 2013-02-27 13:18:00 -0400 (Wed, 27 Feb 2013) | 20 lines
  
  Merged revisions 382182 via svnmerge from 
  file:///srv/subversion/repos/asterisk/trunk
  
  ................
    r382182 | file | 2013-02-27 10:19:51 -0600 (Wed, 27 Feb 2013) | 13 lines
    
    Relax dialog checking in get_sip_pvt_byid_locked so it works when the dialog is forked.
    
    (closes issue ASTERISK-20638)
    Reported by: eelcob
    Patches:
          pedantic-call-pickup-from-tag.patch uploaded by eelcob (license 6442)
    ........
    
    Merged revisions 382171 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 382174 from http://svn.asterisk.org/svn/asterisk/branches/11
  ................
........
  r382201 | file | 2013-02-27 13:38:04 -0400 (Wed, 27 Feb 2013) | 1 line
  
  Fix a bug where an INVITE without SDP would cause a crash.
........
  r382206 | root | 2013-02-27 17:17:59 -0400 (Wed, 27 Feb 2013) | 13 lines
  
  Merged revisions 382203-382204 via svnmerge from 
  file:///srv/subversion/repos/asterisk/trunk
  
  ........
    r382203 | rmudgett | 2013-02-27 14:21:40 -0600 (Wed, 27 Feb 2013) | 1 line
    
    Fix compiler warning by eliminating the need for a cast.
  ........
    r382204 | rmudgett | 2013-02-27 14:31:56 -0600 (Wed, 27 Feb 2013) | 1 line
    
    More places to eliminate the cast to argv but were not giving warnings.
  ........
........
  r382229 | mmichelson | 2013-02-28 12:50:27 -0400 (Thu, 28 Feb 2013) | 6 lines
  
  Initialize pass/fail result of ACL check.
  
  Calls were being denied because this variable was used
  uninitialized. This should prevent false positives in the ACL checking.
........
  r382237 | root | 2013-02-28 13:18:08 -0400 (Thu, 28 Feb 2013) | 67 lines
  
  Merged revisions 382232,382236 via svnmerge from 
  file:///srv/subversion/repos/asterisk/trunk
  
  ................
    r382232 | mjordan | 2013-02-28 10:56:20 -0600 (Thu, 28 Feb 2013) | 33 lines
    
    Let channels joining a MeetMe conference opt out of the denoiser
    
    For some channel drivers, specifically those that have a varying rate in the
    number of audio samples, the audio quality for a MeetMe conference can be
    exceedingly poor. This is due to a unilateral application of the DENOISE
    function in func_speex to channels joining the conference.
    
    The denoiser function in the speex library is initialized with the number of
    audio samples in each sample that will be provided to it. If the number of
    audio samples changes, the denoiser has to be thrown away and re-initialized.
    
    While this could be worked around by removing func_speex, that doesn't help
    if you actually use the denoiser with other channels on the system.
    
    This patches does the following:
     * Checks for the presence of func_speex as opposed to codec_speex when
       determining if the DENOISE function is present (which is where the function
       is actually implemented)
     * Adds an option to MeetMe 'n' that causes the denoiser to not be applied
       to a channel when it joins. This keeps the current behavior the default, but
       let's users disable the denoiser if it causes problems on their system.
    
    Review: https://reviewboard.asterisk.org/r/2358
    
    (closes issue AST-1062)
    Reported by: Thomas Arimont
    ........
    
    Merged revisions 382227 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 382230 from http://svn.asterisk.org/svn/asterisk/branches/11
  ................
    r382236 | mjordan | 2013-02-28 11:17:35 -0600 (Thu, 28 Feb 2013) | 25 lines
    
    Prevent deadlock in chan_iax2 when attempting to set caller ID
    
    A deadlock can occur in chan_iax2 when it attempts to set the caller ID, as it
    already holds the iax2 private lock and improperly fails to obtain the channel
    lock before calling ast_set_callerid. By not safely obtaining the channel lock,
    a locking inversion can take place, causing a deadlock.
    
    This patch solves this by calling the required deadlock avoidance functions
    that obtain the channel lock before setting the caller ID.
    
    Thanks to Pavel for fixing my syntax errors and testing this patch out.
    
    (closes issue ASTERISK-21128)
    Reported by: Pavel Troller
    Tested by: Pavel Troller
    patches:
      ASTERISK-21128-1.8.diff uploaded by mjordan (license 6283)
      ASTERISK-21128-modified-1.8.diff uploaded by Pavel Troller (license 6302)
    ........
    
    Merged revisions 382233 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 382234 from http://svn.asterisk.org/svn/asterisk/branches/11
  ................
........
  r382270 | mmichelson | 2013-02-28 14:49:24 -0400 (Thu, 28 Feb 2013) | 18 lines
  
  Add options to determine how endpoints are identified.
  
  Prior to this commit, the method by which endpoints were identified was
  dependent on what endpoint identification modules were loaded. While this
  works, it's not likely to be useful for most deployments. Instead, having
  control within the configuration of how identification should occur per
  endpoint is more useful.
  
  There is now an "identify_by" option that accepts a comma-delimited list of
  methods by which the endpoint can be identified. By default, this is set to
  "username,location" which allows for the endpoint to be identified by both
  by username and by its IP address. The option can be changed to only allow
  one method or the other.
  
  Using this allows for easy expansion in case new methods of endpoint identification
  are devised.
........
  r382301 | mmichelson | 2013-02-28 18:17:52 -0400 (Thu, 28 Feb 2013) | 6 lines
  
  Fix size issue when converting UUID to string.
  
  We were passing the size of a pointer in, which is not
  appropriate.
........
  r382317 | root | 2013-02-28 19:17:31 -0400 (Thu, 28 Feb 2013) | 42 lines
  
  Multiple revisions 382292,382294-382295,382297,382299
  
  ........
    r382292 | qwell | 2013-02-28 15:21:50 -0600 (Thu, 28 Feb 2013) | 7 lines
    
    Don't undefine bzero()/bcopy().
    
    This was causing build failures against external libraries that happened to use
    them, unless silly hacks were added to the modules that used those headers.
    
    Review: https://reviewboard.asterisk.org/r/2359/
  ........
    r382294 | rmudgett | 2013-02-28 15:29:57 -0600 (Thu, 28 Feb 2013) | 1 line
    
    threadpool: Whitespace and comment corrections.
  ........
    r382295 | rmudgett | 2013-02-28 15:31:14 -0600 (Thu, 28 Feb 2013) | 1 line
    
    threadpool: Make ast_threadpool_push() return -1 if shutting_down
  ........
    r382297 | file | 2013-02-28 15:37:57 -0600 (Thu, 28 Feb 2013) | 10 lines
    
    Fix a bug with ICE and strictrtp where media could get dropped.
    
    If the end result of the ICE negotiation resulted in the path for media
    changing it was possible for the strictrtp code to discard the RTP packets.
    This change causes strictrtp to enter learning mode once again when the
    ICE negotiation has completed successfully.
    ........
    
    Merged revisions 382296 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
    r382299 | file | 2013-02-28 15:59:56 -0600 (Thu, 28 Feb 2013) | 5 lines
    
    While the ICE negotiation is occurring leave strictrtp in an open state, media can and will come from different places.
    ........
    
    Merged revisions 382298 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 382292,382294-382295,382297,382299 from file:///srv/subversion/repos/asterisk/trunk
........
  r382326 | root | 2013-03-01 01:17:57 -0400 (Fri, 01 Mar 2013) | 40 lines
  
  Fix / Clean Up Some Items To Handle The New auto_* NAT Options
  
  The original report had to do with a realtime peer behind NAT being pruned and
  the peer's private address being used instead of its external address.  Upon
  debugging, it was discovered that this was being caused by the addition of
  the auto_force_rport and auto_comedia settings.
  
  This patch does the following:
  
  * Adds a missing note to the CHANGES file indicating that the default global nat
    setting is auto_force_rport
  
  * Constify the 'req' parameter for check_via()
  
  * Add calls to check_via() in a couple of places in order for the auto_*
    settings to do their job in attempting to determine if NAT is involved
  
  * Set the flags SIP_NAT_FORCE_RPORT and SIP_PAGE2_SYMMETRICRTP if the auto_*
    settings are in use where it was needed
  
  * Moves the copying of peer flags up in build_peer() to before they are used;
    this fixes the realtime prune issue
  
  * Update the contrib/realtime schemas to allow the nat column to handle the
    different nat setting combinations we have
  
  This patch received a review and "Ship It!" on the issue itself.
  
  (closes issue ASTERISK-20904)
  Reported by: JoshE
  Tested by: JoshE, Michael L. Young
  Patches:
    asterisk-20904-nat-auto-and-rt-peersv2.diff Michael L. Young (license 5026)
  ........
  
  Merged revisions 382322 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 382323 from file:///srv/subversion/repos/asterisk/trunk
........
  r382342 | root | 2013-03-01 14:18:32 -0400 (Fri, 01 Mar 2013) | 7 lines
  
  Add support for registering a sorcery handler which supports multiple fields using a regex.
  
  Review: https://reviewboard.asterisk.org/r/2332/
  ........
  
  Merged revisions 382340 from file:///srv/subversion/repos/asterisk/trunk
........
  r382362 | file | 2013-03-02 12:49:39 -0400 (Sat, 02 Mar 2013) | 2 lines
  
  Slightly reduce memory usage and copying.
........

Merged revisions 382117,382196,382201,382206,382229,382237,382270,382301,382317,382326,382342,382362 from http://svn.asterisk.org/svn/asterisk/team/group/pimp_my_sip

Modified:
    team/file/pimp_sip_nat/   (props changed)
    team/file/pimp_sip_nat/CHANGES
    team/file/pimp_sip_nat/apps/app_meetme.c
    team/file/pimp_sip_nat/channels/chan_iax2.c
    team/file/pimp_sip_nat/channels/chan_sip.c
    team/file/pimp_sip_nat/channels/chan_skinny.c
    team/file/pimp_sip_nat/configure
    team/file/pimp_sip_nat/configure.ac
    team/file/pimp_sip_nat/contrib/realtime/mysql/sippeers.sql
    team/file/pimp_sip_nat/contrib/realtime/postgresql/realtime.sql
    team/file/pimp_sip_nat/include/asterisk.h
    team/file/pimp_sip_nat/include/asterisk/res_sip.h
    team/file/pimp_sip_nat/include/asterisk/sorcery.h
    team/file/pimp_sip_nat/include/asterisk/threadpool.h
    team/file/pimp_sip_nat/main/Makefile
    team/file/pimp_sip_nat/main/sorcery.c
    team/file/pimp_sip_nat/main/threadpool.c
    team/file/pimp_sip_nat/res/res_rtp_asterisk.c
    team/file/pimp_sip_nat/res/res_sip/sip_configuration.c
    team/file/pimp_sip_nat/res/res_sip_acl.c
    team/file/pimp_sip_nat/res/res_sip_authenticator_digest.c
    team/file/pimp_sip_nat/res/res_sip_endpoint_identifier_ip.c
    team/file/pimp_sip_nat/res/res_sip_endpoint_identifier_user.c
    team/file/pimp_sip_nat/res/res_sip_session.c
    team/file/pimp_sip_nat/tests/test_sorcery.c

Propchange: team/file/pimp_sip_nat/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/file/pimp_sip_nat/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Mar  3 18:05:02 2013
@@ -1,1 +1,1 @@
-/team/group/pimp_my_sip:1-382114
+/team/group/pimp_my_sip:1-382366

Modified: team/file/pimp_sip_nat/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/CHANGES?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/CHANGES (original)
+++ team/file/pimp_sip_nat/CHANGES Sun Mar  3 18:05:02 2013
@@ -73,6 +73,14 @@
  * Added the 'queue_log_realtime_use_gmt' option to have timestamps in GMT
    for realtime queue log entries.
 
+MeetMe
+-------------------
+* Added the 'n' option to MeetMe to prevent application of the DENOISE function
+  to a channel joining a conference. Some channel drivers that vary the number
+  of audio samples in a voice frame will experience significant quality problems
+  if a denoiser is attached to the channel; this option gives them the ability
+  to remove the denoiser without having to unload func_speex.
+
 Queue
 -------------------
  * Add queue available hint.  exten => 8501,hint,Queue:markq_avail
@@ -389,6 +397,9 @@
    which set the force_rport and comedia options automatically if Asterisk
    detects that an incoming SIP request crossed a NAT after being sent by
    the remote endpoint.
+
+ * The default global nat setting in sip.conf has been changed from force_rport
+   to auto_force_rport.
 
  * NAT settings are now a combinable list of options. The equivalent of the
    deprecated nat=yes is nat=force_rport,comedia. nat=no behaves as before.

Modified: team/file/pimp_sip_nat/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/apps/app_meetme.c?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/apps/app_meetme.c (original)
+++ team/file/pimp_sip_nat/apps/app_meetme.c Sun Mar  3 18:05:02 2013
@@ -147,6 +147,14 @@
 						specify a musiconhold class to use. If one is not provided, it will use the
 						channel's currently set music class, or <literal>default</literal>.</para>
 						<argument name="class" required="true" />
+					</option>
+					<option name="n">
+						<para>Disable the denoiser. By default, if <literal>func_speex</literal> is loaded, Asterisk
+						will apply a denoiser to channels in the MeetMe conference. However, channel
+						drivers that present audio with a varying rate will experience degraded
+						performance with a denoiser attached. This parameter allows a channel joining
+						the conference to choose not to have a denoiser attached without having to
+						unload <literal>func_speex</literal>.</para>
 					</option>
 					<option name="o">
 						<para>Set talker optimization - treats talkers who aren't speaking as
@@ -657,6 +665,8 @@
 #define CONFFLAG_INTROUSER_VMREC    (1ULL << 33)
 /*! If there's only one person left in a conference when someone leaves, kill the conference */
 #define CONFFLAG_KILL_LAST_MAN_STANDING ((uint64_t)1 << 34)
+/*! If set, don't enable a denoiser for the channel */
+#define CONFFLAG_DONT_DENOISE       (1ULL << 33)
 
 enum {
 	OPT_ARG_WAITMARKED = 0,
@@ -687,6 +697,7 @@
 	AST_APP_OPTION('k', CONFFLAG_KILL_LAST_MAN_STANDING ),
 	AST_APP_OPTION_ARG('M', CONFFLAG_MOH, OPT_ARG_MOH_CLASS ),
 	AST_APP_OPTION('m', CONFFLAG_STARTMUTED ),
+	AST_APP_OPTION('n', CONFFLAG_DONT_DENOISE ),
 	AST_APP_OPTION('o', CONFFLAG_OPTIMIZETALKER ),
 	AST_APP_OPTION('P', CONFFLAG_ALWAYSPROMPT ),
 	AST_APP_OPTION_ARG('p', CONFFLAG_KEYEXIT, OPT_ARG_EXITKEYS ),
@@ -3218,7 +3229,8 @@
 	}
 
 	/* Reduce background noise from each participant */
-	if ((mod_speex = ast_module_helper("", "codec_speex", 0, 0, 0, 0))) {
+	if (!ast_test_flag64(confflags, CONFFLAG_DONT_DENOISE) &&
+		(mod_speex = ast_module_helper("", "func_speex", 0, 0, 0, 0))) {
 		ast_free(mod_speex);
 		ast_func_write(chan, "DENOISE(rx)", "on");
 	}

Modified: team/file/pimp_sip_nat/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/channels/chan_iax2.c?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/channels/chan_iax2.c (original)
+++ team/file/pimp_sip_nat/channels/chan_iax2.c Sun Mar  3 18:05:02 2013
@@ -11573,13 +11573,15 @@
 			ast_string_field_set(iaxs[fr->callno], cid_name, connected.id.name.str);
 			iaxs[fr->callno]->calling_pres = ast_party_id_presentation(&connected.id);
 
-			if (iaxs[fr->callno]->owner) {
+			iax2_lock_owner(fr->callno);
+			if (iaxs[fr->callno] && iaxs[fr->callno]->owner) {
 				ast_set_callerid(iaxs[fr->callno]->owner,
 					S_COR(connected.id.number.valid, connected.id.number.str, ""),
 					S_COR(connected.id.name.valid, connected.id.name.str, ""),
 					NULL);
 				ast_channel_caller(iaxs[fr->callno]->owner)->id.number.presentation = connected.id.number.presentation;
 				ast_channel_caller(iaxs[fr->callno]->owner)->id.name.presentation = connected.id.name.presentation;
+				ast_channel_unlock(iaxs[fr->callno]->owner);
 			}
 		}
 		ast_party_connected_line_free(&connected);

Modified: team/file/pimp_sip_nat/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/channels/chan_sip.c?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/channels/chan_sip.c (original)
+++ team/file/pimp_sip_nat/channels/chan_sip.c Sun Mar  3 18:05:02 2013
@@ -1399,7 +1399,7 @@
 static int get_also_info(struct sip_pvt *p, struct sip_request *oreq);
 static int parse_ok_contact(struct sip_pvt *pvt, struct sip_request *req);
 static int set_address_from_contact(struct sip_pvt *pvt);
-static void check_via(struct sip_pvt *p, struct sip_request *req);
+static void check_via(struct sip_pvt *p, const struct sip_request *req);
 static int get_rpid(struct sip_pvt *p, struct sip_request *oreq);
 static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq, char **name, char **number, int *reason, char **reason_str);
 static enum sip_get_dest_result get_destination(struct sip_pvt *p, struct sip_request *oreq, int *cc_recall_core_id);
@@ -8747,9 +8747,8 @@
 
 	if (useglobal_nat && addr) {
 		/* Setup NAT structure according to global settings if we have an address */
-		ast_copy_flags(&p->flags[0], &global_flags[0], SIP_NAT_FORCE_RPORT);
 		ast_sockaddr_copy(&p->recv, addr);
-
+		check_via(p, req);
 		do_setnat(p);
 	}
 
@@ -12116,8 +12115,9 @@
 
 	if (useglobal_nat && addr) {
 		ast_copy_flags(&p->flags[0], &global_flags[0], SIP_NAT_FORCE_RPORT);
+		ast_copy_flags(&p->flags[2], &global_flags[2], SIP_PAGE3_NAT_AUTO_RPORT);
 		ast_sockaddr_copy(&p->recv, addr);
-		do_setnat(p);
+		check_via(p, req);
 	}
 
 	ast_string_field_set(p, fromdomain, default_fromdomain);
@@ -17243,7 +17243,16 @@
 		return get_pai(p, req);
 	}
 
+	/*
+	 * RPID is not:
+	 *   rpid = (name-addr / addr-spec) *(SEMI rpi-token)
+	 * But it is:
+	 *   rpid = [display-name] LAQUOT addr-spec RAQUOT *(SEMI rpi-token)
+	 * Ergo, calling parse_name_andor_addr() on it wouldn't be
+	 * correct because that would allow addr-spec style too.
+	 */
 	start = tmp;
+	/* Quoted (note that we're not dealing with escapes properly) */
 	if (*start == '"') {
 		*start++ = '\0';
 		end = strchr(start, '"');
@@ -17252,6 +17261,17 @@
 		*end++ = '\0';
 		cid_name = start;
 		start = ast_skip_blanks(end);
+	/* Unquoted */
+	} else {
+		cid_name = start;
+		start = end = strchr(start, '<');
+		if (!start) {
+			return 0;
+		}
+		/* trim blanks if there are any. the mandatory NUL is done below */
+		while (--end >= cid_name && *end < 33) {
+			*end = '\0';
+		}
 	}
 
 	if (*start != '<')
@@ -17641,7 +17661,10 @@
 			frommismatch = !!strcmp(fromtag, sip_pvt_ptr->theirtag);
 			tomismatch = !!strcmp(totag, sip_pvt_ptr->tag);
 
-			if (frommismatch || tomismatch) {
+                        /* Don't check from if the dialog is not established, due to multi forking the from
+                         * can change when the call is not answered yet.
+                         */
+			if ((frommismatch && ast_test_flag(&sip_pvt_ptr->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED)) || tomismatch) {
 				sip_pvt_unlock(sip_pvt_ptr);
 				if (frommismatch) {
 					ast_debug(4, "Matched %s call for callid=%s - pedantic from tag check fails; their tag is %s our tag is %s\n",
@@ -17935,7 +17958,7 @@
 }
 
 /*! \brief check Via: header for hostname, port and rport request/answer */
-static void check_via(struct sip_pvt *p, struct sip_request *req)
+static void check_via(struct sip_pvt *p, const struct sip_request *req)
 {
 	char via[512];
 	char *c, *maddr;
@@ -18067,6 +18090,21 @@
 				of, ast_sockaddr_stringify(&p->recv));
 		}
 		return AUTH_DONT_KNOW;
+	}
+
+	/*  build_peer, called through sip_find_peer, is not able to check the
+	 *  sip_pvt->natdetected flag in order to determine if the peer is behind
+	 *  NAT or not when SIP_PAGE3_NAT_AUTO_RPORT or SIP_PAGE3_NAT_AUTO_COMEDIA
+	 *  are set on the peer.  So we check for that here and set the peer's
+	 *  address accordingly.
+	 */
+	if (p->natdetected && ast_test_flag(&peer->flags[2], SIP_PAGE3_NAT_AUTO_RPORT)) {
+		ast_set_flag(&peer->flags[0], SIP_NAT_FORCE_RPORT);
+		ast_sockaddr_copy(&peer->addr, &p->recv);
+	}
+
+	if (p->natdetected && ast_test_flag(&peer->flags[2], SIP_PAGE3_NAT_AUTO_COMEDIA)) {
+		ast_set_flag(&peer->flags[1], SIP_PAGE2_SYMMETRICRTP);
 	}
 
 	if (!ast_apply_acl(peer->acl, addr, "SIP Peer ACL: ")) {
@@ -28403,7 +28441,10 @@
 	owner_chan_ref = sip_pvt_lock_full(p);
 
 	copy_socket_data(&p->socket, &req->socket);
-	ast_sockaddr_copy(&p->recv, addr);
+
+	if (ast_sockaddr_isnull(&p->recv)) { /* This may already be set before getting here */
+		ast_sockaddr_copy(&p->recv, addr);
+	}
 
 	/* if we have an owner, then this request has been authenticated */
 	if (p->owner) {
@@ -30614,7 +30655,7 @@
 			} else if (!strcasecmp(v->name, "host")) {
 				if (!strcasecmp(v->value, "dynamic")) {
 					/* They'll register with us */
-					if ((!found && !realtime) || !peer->host_dynamic) {
+					if ((!found && !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) || !peer->host_dynamic) {
 						/* Initialize stuff if this is a new peer, or if it used to
 						 * not be dynamic before the reload. */
 						ast_sockaddr_setnull(&peer->addr);
@@ -30967,6 +31008,10 @@
 		set_socket_transport(&peer->socket, peer->default_outbound_transport);
 	}
 
+	ast_copy_flags(&peer->flags[0], &peerflags[0], mask[0].flags);
+	ast_copy_flags(&peer->flags[1], &peerflags[1], mask[1].flags);
+	ast_copy_flags(&peer->flags[2], &peerflags[2], mask[2].flags);
+
 	if (ast_str_strlen(fullcontact)) {
 		ast_string_field_set(peer, fullcontact, ast_str_buffer(fullcontact));
 		peer->rt_fromcontact = TRUE;
@@ -31060,9 +31105,6 @@
 		sip_poke_peer(peer, 0);
 	}
 
-	ast_copy_flags(&peer->flags[0], &peerflags[0], mask[0].flags);
-	ast_copy_flags(&peer->flags[1], &peerflags[1], mask[1].flags);
-	ast_copy_flags(&peer->flags[2], &peerflags[2], mask[2].flags);
 	if (ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
 		sip_cfg.allowsubscribe = TRUE;	/* No global ban any more */
 	}

Modified: team/file/pimp_sip_nat/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/channels/chan_skinny.c?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/channels/chan_skinny.c (original)
+++ team/file/pimp_sip_nat/channels/chan_skinny.c Sun Mar  3 18:05:02 2013
@@ -4034,7 +4034,7 @@
 		ast_cli(fd, "none");
 }
 
-static char *_skinny_show_devices(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[])
+static char *_skinny_show_devices(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char * const *argv)
 {
 	struct skinny_device *d;
 	struct skinny_line *l;
@@ -4142,10 +4142,10 @@
 		return NULL;
 	}
 
-	return _skinny_show_devices(a->fd, NULL, NULL, NULL, a->argc, (const char **) a->argv);
-}
-
-static char *_skinny_show_device(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
+	return _skinny_show_devices(a->fd, NULL, NULL, NULL, a->argc, a->argv);
+}
+
+static char *_skinny_show_device(int type, int fd, struct mansession *s, const struct message *m, int argc, const char * const *argv)
 {
 	struct skinny_device *d;
 	struct skinny_line *l;
@@ -4282,10 +4282,10 @@
 		return complete_skinny_show_device(a->line, a->word, a->pos, a->n);
 	}
 
-	return _skinny_show_device(0, a->fd, NULL, NULL, a->argc, (const char **) a->argv);
-}
-
-static char *_skinny_show_lines(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[])
+	return _skinny_show_device(0, a->fd, NULL, NULL, a->argc, a->argv);
+}
+
+static char *_skinny_show_lines(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char * const *argv)
 {
 	struct skinny_line *l;
 	struct skinny_subchannel *sub;
@@ -4406,10 +4406,10 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	return _skinny_show_lines(a->fd, NULL, NULL, NULL, a->argc, (const char **) a->argv);
-}
-
-static char *_skinny_show_line(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
+	return _skinny_show_lines(a->fd, NULL, NULL, NULL, a->argc, a->argv);
+}
+
+static char *_skinny_show_line(int type, int fd, struct mansession *s, const struct message *m, int argc, const char * const *argv)
 {
 	struct skinny_device *d;
 	struct skinny_line *l;
@@ -4593,7 +4593,7 @@
 		return complete_skinny_show_line(a->line, a->word, a->pos, a->n);
 	}
 
-	return _skinny_show_line(0, a->fd, NULL, NULL, a->argc, (const char **) a->argv);
+	return _skinny_show_line(0, a->fd, NULL, NULL, a->argc, a->argv);
 }
 
 /*! \brief List global settings for the Skinny subsystem. */
@@ -4638,7 +4638,7 @@
 	return CLI_SUCCESS;
 }
 
-static char *_skinny_message_set(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
+static char *_skinny_message_set(int type, int fd, struct mansession *s, const struct message *m, int argc, const char * const *argv)
 {
 	struct skinny_device *d;
 	char text_buf[32];
@@ -4685,10 +4685,10 @@
 		return complete_skinny_show_device(a->line, a->word, a->pos, a->n);
 	}
 
-	return _skinny_message_set(0, a->fd, NULL, NULL, a->argc, (const char **) a->argv);
-}
-
-static char *_skinny_message_clear(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
+	return _skinny_message_set(0, a->fd, NULL, NULL, a->argc, a->argv);
+}
+
+static char *_skinny_message_clear(int type, int fd, struct mansession *s, const struct message *m, int argc, const char * const *argv)
 {
 	struct skinny_device *d;
 
@@ -4721,7 +4721,7 @@
 		return complete_skinny_show_device(a->line, a->word, a->pos, a->n);
 	}
 
-	return _skinny_message_clear(0, a->fd, NULL, NULL, a->argc, (const char **) a->argv);
+	return _skinny_message_clear(0, a->fd, NULL, NULL, a->argc, a->argv);
 }
 
 static struct ast_cli_entry cli_skinny[] = {

Modified: team/file/pimp_sip_nat/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/configure.ac?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/configure.ac (original)
+++ team/file/pimp_sip_nat/configure.ac Sun Mar  3 18:05:02 2013
@@ -178,7 +178,7 @@
      OSARCH=cygwin
      PBX_WINARCH=1
      ;;
-     linux-gnueabi*)
+     linux-gnueabi* |  linux-gnuspe)
      OSARCH=linux-gnu
      ;;
      kfreebsd*-gnu)

Modified: team/file/pimp_sip_nat/contrib/realtime/mysql/sippeers.sql
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/contrib/realtime/mysql/sippeers.sql?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/contrib/realtime/mysql/sippeers.sql (original)
+++ team/file/pimp_sip_nat/contrib/realtime/mysql/sippeers.sql Sun Mar  3 18:05:02 2013
@@ -24,7 +24,7 @@
       `transport` enum('udp','tcp','udp,tcp','tcp,udp') DEFAULT NULL,
       `dtmfmode` enum('rfc2833','info','shortinfo','inband','auto') DEFAULT NULL,
       `directmedia` enum('yes','no','nonat','update') DEFAULT NULL,
-      `nat` enum('yes','no','never','route') DEFAULT NULL,
+      `nat` varchar(29) DEFAULT NULL,
       `callgroup` varchar(40) DEFAULT NULL,
       `pickupgroup` varchar(40) DEFAULT NULL,
       `language` varchar(40) DEFAULT NULL,

Modified: team/file/pimp_sip_nat/contrib/realtime/postgresql/realtime.sql
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/contrib/realtime/postgresql/realtime.sql?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/contrib/realtime/postgresql/realtime.sql (original)
+++ team/file/pimp_sip_nat/contrib/realtime/postgresql/realtime.sql Sun Mar  3 18:05:02 2013
@@ -48,7 +48,7 @@
 "language" character varying(2),
 mailbox character varying(50),
 md5secret character varying(80),
-nat character varying(5) DEFAULT 'no' NOT NULL,
+nat character varying(29) DEFAULT '' NOT NULL,
 permit character varying(95),
 deny character varying(95),
 mask character varying(95),

Modified: team/file/pimp_sip_nat/include/asterisk.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/include/asterisk.h?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/include/asterisk.h (original)
+++ team/file/pimp_sip_nat/include/asterisk.h Sun Mar  3 18:05:02 2013
@@ -213,17 +213,6 @@
 struct ast_str;
 struct ast_sched_context;
 
-#ifdef bzero
-#undef bzero
-#endif
-
-#ifdef bcopy
-#undef bcopy
-#endif
-
-#define bzero  0x__dont_use_bzero__use_memset_instead""
-#define bcopy  0x__dont_use_bcopy__use_memmove_instead()
-
 /* Some handy macros for turning a preprocessor token into (effectively) a quoted string */
 #define __stringify_1(x)	#x
 #define __stringify(x)		__stringify_1(x)

Modified: team/file/pimp_sip_nat/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/include/asterisk/res_sip.h?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/include/asterisk/res_sip.h (original)
+++ team/file/pimp_sip_nat/include/asterisk/res_sip.h Sun Mar  3 18:05:02 2013
@@ -215,6 +215,16 @@
 	unsigned int nonce_lifetime;
 	/* Used to determine what to use when authenticating */
 	enum ast_sip_auth_type type;
+};
+
+/*!
+ * \brief Different methods by which incoming requests can be matched to endpoints
+ */
+enum ast_sip_endpoint_identifier_type {
+	/*! Identify based on user name in From header */
+	AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME = (1 << 0),
+	/*! Identify based on source location of the SIP message */
+	AST_SIP_ENDPOINT_IDENTIFY_BY_LOCATION = (1 << 1),
 };
 
 /*!
@@ -270,6 +280,8 @@
 	AST_LIST_HEAD_NOLOCK(, ast_sip_registration) registrations;
 	/*! Frequency to send OPTIONS requests to endpoint. 0 is disabled. */
 	unsigned int qualify_frequency;
+	/*! Method(s) by which the endpoint should be identified. */
+	enum ast_sip_endpoint_identifier_type ident_method;
 };
 
 /*!

Modified: team/file/pimp_sip_nat/include/asterisk/sorcery.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/include/asterisk/sorcery.h?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/include/asterisk/sorcery.h (original)
+++ team/file/pimp_sip_nat/include/asterisk/sorcery.h Sun Mar  3 18:05:02 2013
@@ -132,6 +132,17 @@
 typedef int (*sorcery_field_handler)(const void *obj, const intptr_t *args, char **buf);
 
 /*!
+ * \brief A callback function for translating multiple values into an ast_variable list
+ *
+ * \param obj Object to get values from
+ * \param fields Pointer to store the list of fields
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+typedef int (*sorcery_fields_handler)(const void *obj, struct ast_variable **fields);
+
+/*!
  * \brief A callback function for performing a transformation on an object set
  *
  * \param set The existing object set
@@ -345,6 +356,21 @@
  * \param diff Diff handler
  */
 void ast_sorcery_object_set_diff_handler(struct ast_sorcery *sorcery, const char *type, sorcery_diff_handler diff);
+
+/*!
+ * \brief Register a regex for multiple fields within an object
+ *
+ * \param sorcery Pointer to a sorcery structure
+ * \param type Type of object
+ * \param regex A regular expression pattern for the fields
+ * \param config_handler A custom handler for translating the string representation of the fields
+ * \param sorcery_handler A custom handler for translating the native representation of the fields
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_sorcery_object_fields_register(struct ast_sorcery *sorcery, const char *type, const char *regex, aco_option_handler config_handler,
+									   sorcery_fields_handler sorcery_handler);
 
 /*!
  * \brief Register a field within an object

Modified: team/file/pimp_sip_nat/include/asterisk/threadpool.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/include/asterisk/threadpool.h?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/include/asterisk/threadpool.h (original)
+++ team/file/pimp_sip_nat/include/asterisk/threadpool.h Sun Mar  3 18:05:02 2013
@@ -103,6 +103,9 @@
 	 *
 	 * When the threadpool's size increases, it can never increase
 	 * beyond this number of threads.
+	 *
+	 * Zero is a valid value if the threadpool does not have a
+	 * maximum size.
 	 */
 	int max_size;
 	/*!
@@ -146,7 +149,7 @@
  * \brief Create a new threadpool
  *
  * This function creates a threadpool. Tasks may be pushed onto this thread pool
- * in and will be automatically acted upon by threads within the pool.
+ * and will be automatically acted upon by threads within the pool.
  *
  * Only a single threadpool with a given name may exist. This function will fail
  * if a threadpool with the given name already exists.

Modified: team/file/pimp_sip_nat/main/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/main/Makefile?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/main/Makefile (original)
+++ team/file/pimp_sip_nat/main/Makefile Sun Mar  3 18:05:02 2013
@@ -37,7 +37,7 @@
 AST_LIBS+=$(ASTSSL_LIBS)
 AST_LIBS+=$(JANSSON_LIB)
 
-ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-gnueabi kfreebsd-gnu linux-gnueabihf),)
+ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc kfreebsd-gnu),)
   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
   AST_LIBS+=-ldl
   endif

Modified: team/file/pimp_sip_nat/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/main/sorcery.c?view=diff&rev=382367&r1=382366&r2=382367
==============================================================================
--- team/file/pimp_sip_nat/main/sorcery.c (original)
+++ team/file/pimp_sip_nat/main/sorcery.c Sun Mar  3 18:05:02 2013
@@ -90,8 +90,11 @@
 	/*! \brief Name of the field */
 	char name[MAX_OBJECT_FIELD];
 
-	/*! \brief Callback function for translation */
+	/*! \brief Callback function for translation of a single value */
 	sorcery_field_handler handler;
+
+	/*! \brief Callback function for translation of multiple values */
+	sorcery_fields_handler multiple_handler;
 
 	/*! \brief Position of the field */
 	intptr_t args[];
@@ -514,6 +517,24 @@
 	}
 
 	object_type->diff = diff;
+}
+
+int ast_sorcery_object_fields_register(struct ast_sorcery *sorcery, const char *type, const char *regex, aco_option_handler config_handler, sorcery_fields_handler sorcery_handler)
+{
+	RAII_VAR(struct ast_sorcery_object_type *, object_type, ao2_find(sorcery->types, type, OBJ_KEY), ao2_cleanup);
+	RAII_VAR(struct ast_sorcery_object_field *, object_field, NULL, ao2_cleanup);
+
+	if (!object_type || !object_type->type.item_alloc || !config_handler || !(object_field = ao2_alloc(sizeof(*object_field), NULL))) {
+		return -1;
+	}
+
+	ast_copy_string(object_field->name, regex, sizeof(object_field->name));
+	object_field->multiple_handler = sorcery_handler;
+
+	ao2_link(object_type->fields, object_field);
+	__aco_option_register(object_type->info, regex, ACO_REGEX, object_type->file->types, "", OPT_CUSTOM_T, config_handler, 0, 0);
+
+	return 0;
 }
 
 int __ast_sorcery_object_field_register(struct ast_sorcery *sorcery, const char *type, const char *name, const char *default_val, enum aco_option_type opt_type,
@@ -662,24 +683,30 @@
 
 	i = ao2_iterator_init(object_type->fields, 0);
 
-	for (; (object_field = ao2_iterator_next(&i)); ao2_ref(object_field, -1)) {
-		RAII_VAR(char *, buf, NULL, ast_free);
-		struct ast_variable *tmp;
-
-		/* Any fields with no handler just get skipped */
-		if (!object_field->handler) {
+	for (; (object_field = ao2_iterator_next(&i)) && !res; ao2_ref(object_field, -1)) {
+		struct ast_variable *tmp = NULL;
+
+		if (object_field->multiple_handler) {
+			if ((res = object_field->multiple_handler(object, &tmp))) {
+				ast_variables_destroy(tmp);
+			}
+		} else if (object_field->handler) {
+			char *buf = NULL;
+
+			if ((res = object_field->handler(object, object_field->args, &buf)) ||
+				!(tmp = ast_variable_new(object_field->name, S_OR(buf, ""), ""))) {
+				res = -1;
+			}
+
+			ast_free(buf);
+		} else {
 			continue;
 		}
 
-		if ((res = object_field->handler(object, object_field->args, &buf)) ||
-		    !(tmp = ast_variable_new(object_field->name, S_OR(buf, ""), ""))) {
-			res = -1;
-			ao2_ref(object_field, -1);
-			break;
-		}
-
-		tmp->next = fields;
-		fields = tmp;
+		if (!res) {
+			tmp->next = fields;
+			fields = tmp;
+		}
 	}
 
 	ao2_iterator_destroy(&i);


[... 583 lines stripped ...]



More information about the asterisk-commits mailing list