[asterisk-commits] tilghman: branch tilghman/optional_api_162 r221041 - in /team/tilghman/option...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 29 23:18:31 CDT 2009


Author: tilghman
Date: Tue Sep 29 23:18:26 2009
New Revision: 221041

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=221041
Log:
Merged revisions 220589,220632,220722,220725,220836,220905,220922,220934,220996,221027 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

................
  r220589 | tilghman | 2009-09-26 10:12:54 -0500 (Sat, 26 Sep 2009) | 9 lines
  
  Merged revisions 220586 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/trunk
  
  ........
    r220586 | tilghman | 2009-09-26 10:10:28 -0500 (Sat, 26 Sep 2009) | 2 lines
    
    Allow AES to compile, when OpenSSL is not present.
  ........
................
  r220632 | mvanbaak | 2009-09-27 15:45:24 -0500 (Sun, 27 Sep 2009) | 10 lines
  
  Merged revisions 220629 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/trunk
  
  ........
    r220629 | mvanbaak | 2009-09-27 22:40:16 +0200 (Sun, 27 Sep 2009) | 3 lines
    
    add name argument for the CALLERID dialplan function to the xml documentation.
    Pointed out to me on IRC by snuff-home. Thanks
  ........
................
  r220722 | jpeeler | 2009-09-28 14:11:53 -0500 (Mon, 28 Sep 2009) | 16 lines
  
  Merged revisions 220718 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/trunk
  
  ........
    r220718 | jpeeler | 2009-09-28 14:10:10 -0500 (Mon, 28 Sep 2009) | 10 lines
    
    Fix building of registration entry in build_peer when using callbackextension
    
    Check for remotesecret option was unintentionally always true, which therefore
    caused the secret option to never be used. Thanks to dvossel for pointing out
    the exact fix.
    
    (closes issue #15943)
    Reported by: tpsast
  ........
................
  r220725 | seanbright | 2009-09-28 14:13:58 -0500 (Mon, 28 Sep 2009) | 17 lines
  
  Merged revisions 220721 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/trunk
  
  ................
    r220721 | seanbright | 2009-09-28 15:11:20 -0400 (Mon, 28 Sep 2009) | 10 lines
    
    Merged revisions 220717 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r220717 | seanbright | 2009-09-28 15:09:25 -0400 (Mon, 28 Sep 2009) | 3 lines
      
      When selecting DONT_OPTIMIZE in menuselect, explicitly pass -O0 to the compiler
      so we override any default optimization levels for a particular install.
    ........
  ................
................
  r220836 | jpeeler | 2009-09-29 12:06:31 -0500 (Tue, 29 Sep 2009) | 19 lines
  
  Merged revisions 220833 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/trunk
  
  ........
    r220833 | jpeeler | 2009-09-29 11:58:29 -0500 (Tue, 29 Sep 2009) | 12 lines
    
    Make deletion of temporary greetings work properly with IMAP_STORAGE
    
    When imapgreetings was set to yes, the message was being deleted but wasn't
    actually being expunged. When imapgreetings was set to no, the file based
    message was not being deleted at all. All good now!
    
    (closes issue #14949)
    Reported by: noahisaac
    Patches:
          vm_tempgreeting_removal.patch uploaded by noahisaac (license 748), 
          modified by me
  ........
................
  r220905 | mnicholson | 2009-09-29 14:49:50 -0500 (Tue, 29 Sep 2009) | 12 lines
  
  Merged revisions 220904 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/trunk
  
  ........
    r220904 | mnicholson | 2009-09-29 14:49:02 -0500 (Tue, 29 Sep 2009) | 5 lines
    
    Fix options 'm' and 's'. They were swapped in the code.  Also document the fact that app_confbridge does not automatically answer the channel.
    
    (closes issue #15964)
    Reported by: shrift
  ........
................
  r220922 | mmichelson | 2009-09-29 15:21:11 -0500 (Tue, 29 Sep 2009) | 8 lines
  
  Blocked revisions 220920 via svnmerge
  
  ........
    r220920 | mmichelson | 2009-09-29 15:20:48 -0500 (Tue, 29 Sep 2009) | 3 lines
    
    Get rid of annoying and cryptic debug messages.
  ........
................
  r220934 | mnicholson | 2009-09-29 15:24:33 -0500 (Tue, 29 Sep 2009) | 8 lines
  
  Avoid a deadlock in chanspy, just in case the spyee is masqueraded and chanspy_ds_chan_fixup() is called with the channel locked.
    
  (closes issue #15965)
  Reported by: atis
  Patches:
        chanspy-deadlock-fix1.diff uploaded by mnicholson (license 96)
  Tested by: atis
................
  r220996 | mmichelson | 2009-09-29 16:28:16 -0500 (Tue, 29 Sep 2009) | 16 lines
  
  Blocked revisions 220995 via svnmerge
  
  ........
    r220995 | mmichelson | 2009-09-29 16:28:04 -0500 (Tue, 29 Sep 2009) | 11 lines
    
    Fix channel reference leak.
    
    ast_cel_report_event would geet a reference to the
    bridged channel. However, certain return paths, such
    as if CEL was not enabled, would result in a reference
    leak. All return paths now properly unref the channel.
    
    (closes issue #15991)
    Reported by: mmichelson
  ........
................
  r221027 | tilghman | 2009-09-29 17:27:59 -0500 (Tue, 29 Sep 2009) | 23 lines
  
  Merged revisions 220906 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/trunk
  
  ................
    r220906 | tilghman | 2009-09-29 14:57:37 -0500 (Tue, 29 Sep 2009) | 16 lines
    
    Merged revisions 220873 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r220873 | tilghman | 2009-09-29 12:59:26 -0500 (Tue, 29 Sep 2009) | 9 lines
      
      Reduce CPU usage related to building a peer merely for devicestates.
      This fixes a 100% CPU problem in the SIP driver, found by profiling
      the driver while the problem was occurring.
      (closes issue #14309)
       Reported by: pkempgen
       Patches: 
             20090924__issue14309.diff.txt uploaded by tilghman (license 14)
       Tested by: pkempgen, vrban
    ........
  ................
................

Modified:
    team/tilghman/optional_api_162/   (props changed)
    team/tilghman/optional_api_162/Makefile.rules
    team/tilghman/optional_api_162/apps/app_chanspy.c
    team/tilghman/optional_api_162/apps/app_confbridge.c
    team/tilghman/optional_api_162/apps/app_voicemail.c
    team/tilghman/optional_api_162/channels/chan_sip.c
    team/tilghman/optional_api_162/funcs/func_callerid.c
    team/tilghman/optional_api_162/include/asterisk/aes.h

Propchange: team/tilghman/optional_api_162/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Sep 29 23:18:26 2009
@@ -1,1 +1,1 @@
-/branches/1.6.2:1-220373
+/branches/1.6.2:1-221040

Propchange: team/tilghman/optional_api_162/
------------------------------------------------------------------------------
Binary property 'trunk-blocked' - no diff available.

Propchange: team/tilghman/optional_api_162/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: team/tilghman/optional_api_162/Makefile.rules
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/optional_api_162/Makefile.rules?view=diff&rev=221041&r1=221040&r2=221041
==============================================================================
--- team/tilghman/optional_api_162/Makefile.rules (original)
+++ team/tilghman/optional_api_162/Makefile.rules Tue Sep 29 23:18:26 2009
@@ -39,6 +39,8 @@
 
 ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)),)
     _ASTCFLAGS+=$(OPTIMIZE)
+else
+    _ASTCFLAGS+=-O0
 endif
 
 # shortcuts for common combinations of flags; these must be recursively expanded so that

Modified: team/tilghman/optional_api_162/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/optional_api_162/apps/app_chanspy.c?view=diff&rev=221041&r1=221040&r2=221041
==============================================================================
--- team/tilghman/optional_api_162/apps/app_chanspy.c (original)
+++ team/tilghman/optional_api_162/apps/app_chanspy.c Tue Sep 29 23:18:26 2009
@@ -454,9 +454,10 @@
 	ast_channel_unlock(chan);
 
 	ast_mutex_lock(&spyee_chanspy_ds->lock);
-	if (spyee_chanspy_ds->chan) {
-		spyee = spyee_chanspy_ds->chan;
-		ast_channel_lock(spyee);
+	while ((spyee = spyee_chanspy_ds->chan) && ast_channel_trylock(spyee)) {
+		/* avoid a deadlock here, just in case spyee is masqueraded and
+		 * chanspy_ds_chan_fixup() is called with the channel locked */
+		DEADLOCK_AVOIDANCE(&spyee_chanspy_ds->lock);
 	}
 	ast_mutex_unlock(&spyee_chanspy_ds->lock);
 

Modified: team/tilghman/optional_api_162/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/optional_api_162/apps/app_confbridge.c?view=diff&rev=221041&r1=221040&r2=221041
==============================================================================
--- team/tilghman/optional_api_162/apps/app_confbridge.c (original)
+++ team/tilghman/optional_api_162/apps/app_confbridge.c Tue Sep 29 23:18:26 2009
@@ -97,6 +97,7 @@
                 <description>
                         <para>Enters the user into a specified conference bridge. The user can exit the conference by hangup only.</para>
                         <para>The join sound can be set using the <literal>CONFBRIDGE_JOIN_SOUND</literal> variable and the leave sound can be set using the <literal>CONFBRIDGE_LEAVE_SOUND</literal> variable. These can be unique to the caller.</para>
+			<note>This application will not automatically answer the channel.</note>
                 </description>
         </application>
 ***/
@@ -135,10 +136,10 @@
 	AST_APP_OPTION('A', OPTION_MARKEDUSER),
 	AST_APP_OPTION('a', OPTION_ADMIN),
 	AST_APP_OPTION('c', OPTION_ANNOUNCEUSERCOUNT),
-	AST_APP_OPTION('m', OPTION_MENU),
+	AST_APP_OPTION('m', OPTION_STARTMUTED),
 	AST_APP_OPTION_ARG('M', OPTION_MUSICONHOLD, OPTION_MUSICONHOLD_CLASS),
 	AST_APP_OPTION('1', OPTION_NOONLYPERSON),
-	AST_APP_OPTION('s', OPTION_STARTMUTED),
+	AST_APP_OPTION('s', OPTION_MENU),
 	AST_APP_OPTION('w', OPTION_WAITMARKED),
 	AST_APP_OPTION('q', OPTION_QUIET),
 });

Modified: team/tilghman/optional_api_162/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/optional_api_162/apps/app_voicemail.c?view=diff&rev=221041&r1=221040&r2=221041
==============================================================================
--- team/tilghman/optional_api_162/apps/app_voicemail.c (original)
+++ team/tilghman/optional_api_162/apps/app_voicemail.c Tue Sep 29 23:18:26 2009
@@ -327,7 +327,7 @@
 static int init_mailstream(struct vm_state *vms, int box);
 static void write_file(char *filename, char *buffer, unsigned long len);
 static char *get_header_by_tag(char *header, char *tag, char *buf, size_t len);
-static void vm_imap_delete(int msgnum, struct ast_vm_user *vmu);
+static void vm_imap_delete(char *file, int msgnum, struct ast_vm_user *vmu);
 static char *get_user_by_mailbox(char *mailbox, char *buf, size_t len);
 static struct vm_state *get_vm_state_by_imapuser(const char *user, int interactive);
 static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, const char *context, int interactive);
@@ -650,7 +650,7 @@
 #define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
 #define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
 #define COPY(a,b,c,d,e,f,g,h) (copy_file(g,h));
-#define DELETE(a,b,c,d) (vm_imap_delete(b,d))
+#define DELETE(a,b,c,d) (vm_imap_delete(a,b,d))
 #else
 #define RETRIEVE(a,b,c,d)
 #define DISPOSE(a,b)
@@ -1474,14 +1474,15 @@
 /* All IMAP-specific functions should go in this block. This
  * keeps them from being spread out all over the code */
 #ifdef IMAP_STORAGE
-static void vm_imap_delete(int msgnum, struct ast_vm_user *vmu)
+static void vm_imap_delete(char *file, int msgnum, struct ast_vm_user *vmu)
 {
 	char arg[10];
 	struct vm_state *vms;
 	unsigned long messageNum;
 
-	/* Greetings aren't stored in IMAP, so we can't delete them there */
-	if (msgnum < 0) {
+	/* If greetings aren't stored in IMAP, just delete the file */
+	if (msgnum < 0 && !imapgreetings) {
+		ast_filedelete(file, NULL);
 		return;
 	}
 
@@ -1503,6 +1504,7 @@
 	snprintf (arg, sizeof(arg), "%lu",messageNum);
 	ast_mutex_lock(&vms->lock);
 	mail_setflag (vms->mailstream,arg,"\\DELETED");
+	mail_expunge(vms->mailstream);
 	ast_mutex_unlock(&vms->lock);
 }
 
@@ -6421,7 +6423,7 @@
 #ifdef IMAP_STORAGE
 	vm_delete(fn);  /* Delete the file, but not the IMAP message */
 	if (ast_test_flag(vmu, VM_DELETE))  { /* Delete the IMAP message if delete = yes */
-		vm_imap_delete(vms->curmsg, vmu);
+		vm_imap_delete(NULL, vms->curmsg, vmu);
 		vms->newmessages--;  /* Fix new message count */
 	}
 #endif

Modified: team/tilghman/optional_api_162/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/optional_api_162/channels/chan_sip.c?view=diff&rev=221041&r1=221040&r2=221041
==============================================================================
--- team/tilghman/optional_api_162/channels/chan_sip.c (original)
+++ team/tilghman/optional_api_162/channels/chan_sip.c Tue Sep 29 23:18:26 2009
@@ -2449,7 +2449,7 @@
 
 /*--- Device object handling */
 static struct sip_peer *temp_peer(const char *name);
-static struct sip_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime);
+static struct sip_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime, int devstate_only);
 static int update_call_counter(struct sip_pvt *fup, int event);
 static void sip_destroy_peer(struct sip_peer *peer);
 static void sip_destroy_peer_fn(void *peer);
@@ -4652,7 +4652,7 @@
 
 
 	/* Peer found in realtime, now build it in memory */
-	peer = build_peer(newpeername, var, varregs, TRUE);
+	peer = build_peer(newpeername, var, varregs, TRUE, devstate_only);
 	if (!peer) {
 		if(peerlist)
 			ast_config_destroy(peerlist);
@@ -23046,7 +23046,7 @@
 }
 
 /*! \brief Build peer from configuration (file or realtime static/dynamic) */
-static struct sip_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime)
+static struct sip_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime, int devstate_only)
 {
 	struct sip_peer *peer = NULL;
 	struct ast_ha *oldha = NULL;
@@ -23119,265 +23119,314 @@
 	peer->transports = 0;
 
 	for (; v || ((v = alt) && !(alt=NULL)); v = v->next) {
-		if (handle_common_options(&peerflags[0], &mask[0], v))
-			continue;
-		if (!strcasecmp(v->name, "transport") && !ast_strlen_zero(v->value)) {
-			char *val = ast_strdupa(v->value);
-			char *trans;
-
-			while ((trans = strsep(&val, ","))) {
-				trans = ast_skip_blanks(trans);
-
-				if (!strncasecmp(trans, "udp", 3))
-					peer->transports |= SIP_TRANSPORT_UDP;
-				else if (!strncasecmp(trans, "tcp", 3))
-					peer->transports |= SIP_TRANSPORT_TCP;
-				else if (!strncasecmp(trans, "tls", 3))
-					peer->transports |= SIP_TRANSPORT_TLS;
-				else
-					ast_log(LOG_NOTICE, "'%s' is not a valid transport type. if no other is specified, udp will be used.\n", trans);
-
-				if (!peer->default_outbound_transport) { /*!< The first transport listed should be default outbound */
-					peer->default_outbound_transport = peer->transports;
+		if (!devstate_only) {
+			if (handle_common_options(&peerflags[0], &mask[0], v)) {
+				continue;
+			}
+			if (!strcasecmp(v->name, "transport") && !ast_strlen_zero(v->value)) {
+				char *val = ast_strdupa(v->value);
+				char *trans;
+
+				while ((trans = strsep(&val, ","))) {
+					trans = ast_skip_blanks(trans);
+
+					if (!strncasecmp(trans, "udp", 3)) {
+						peer->transports |= SIP_TRANSPORT_UDP;
+					} else if (!strncasecmp(trans, "tcp", 3)) {
+						peer->transports |= SIP_TRANSPORT_TCP;
+					} else if (!strncasecmp(trans, "tls", 3)) {
+						peer->transports |= SIP_TRANSPORT_TLS;
+					} else {
+						ast_log(LOG_NOTICE, "'%s' is not a valid transport type. if no other is specified, udp will be used.\n", trans);
+					}
+
+					if (!peer->default_outbound_transport) { /*!< The first transport listed should be default outbound */
+						peer->default_outbound_transport = peer->transports;
+					}
+				}
+			} else if (realtime && !strcasecmp(v->name, "regseconds")) {
+				ast_get_time_t(v->value, &regseconds, 0, NULL);
+			} else if (realtime && !strcasecmp(v->name, "name")) {
+				ast_copy_string(peer->name, v->value, sizeof(peer->name));
+			} else if (realtime && !strcasecmp(v->name, "fullcontact")) {
+				if (alt_fullcontact && !alt) {
+					/* Reset, because the alternate also has a fullcontact and we
+					 * do NOT want the field value to be doubled. It might be
+					 * tempting to skip this, but the first table might not have
+					 * fullcontact and since we're here, we know that the alternate
+					 * absolutely does. */
+					alt_fullcontact = 0;
+					ast_str_reset(fullcontact);
+				}
+				/* Reconstruct field, because realtime separates our value at the ';' */
+				if (fullcontact->used > 0) {
+					ast_str_append(&fullcontact, 0, ";%s", v->value);
+				} else {
+					ast_str_set(&fullcontact, 0, "%s", v->value);
+				}
+			} else if (!strcasecmp(v->name, "type")) {
+				if (!strcasecmp(v->value, "peer")) {
+					peer->type |= SIP_TYPE_PEER;
+				} else if (!strcasecmp(v->value, "user")) {
+					peer->type |= SIP_TYPE_USER;
+				} else if (!strcasecmp(v->value, "friend")) {
+					peer->type = SIP_TYPE_USER | SIP_TYPE_PEER;
+				}
+			} else if (!strcasecmp(v->name, "remotesecret")) {
+				ast_string_field_set(peer, remotesecret, v->value);
+			} else if (!strcasecmp(v->name, "secret")) {
+				ast_string_field_set(peer, secret, v->value);
+			} else if (!strcasecmp(v->name, "md5secret")) {
+				ast_string_field_set(peer, md5secret, v->value);
+			} else if (!strcasecmp(v->name, "auth")) {
+				peer->auth = add_realm_authentication(peer->auth, v->value, v->lineno);
+			} else if (!strcasecmp(v->name, "callerid")) {
+				char cid_name[80] = { '\0' }, cid_num[80] = { '\0' };
+
+				ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
+				ast_string_field_set(peer, cid_name, cid_name);
+				ast_string_field_set(peer, cid_num, cid_num);
+			} else if (!strcasecmp(v->name, "fullname")) {
+				ast_string_field_set(peer, cid_name, v->value);
+			} else if (!strcasecmp(v->name, "cid_number")) {
+				ast_string_field_set(peer, cid_num, v->value);
+			} else if (!strcasecmp(v->name, "context")) {
+				ast_string_field_set(peer, context, v->value);
+			} else if (!strcasecmp(v->name, "subscribecontext")) {
+				ast_string_field_set(peer, subscribecontext, v->value);
+			} else if (!strcasecmp(v->name, "fromdomain")) {
+				ast_string_field_set(peer, fromdomain, v->value);
+			} else if (!strcasecmp(v->name, "usereqphone")) {
+				ast_set2_flag(&peer->flags[0], ast_true(v->value), SIP_USEREQPHONE);
+			} else if (!strcasecmp(v->name, "fromuser")) {
+				ast_string_field_set(peer, fromuser, v->value);
+			} else if (!strcasecmp(v->name, "outboundproxy")) {
+				char *port, *next, *force, *proxyname;
+				int forceopt = FALSE;
+				/* Set peer channel variable */
+				next = proxyname = ast_strdupa(v->value);
+				if ((port = strchr(proxyname, ':'))) {
+					*port++ = '\0';
+					next = port;
+				}
+				if ((force = strchr(next, ','))) {
+					*force++ = '\0';
+					forceopt = strcmp(force, "force");
+				}
+				/* Allocate proxy object */
+				peer->outboundproxy = proxy_allocate(proxyname, port, forceopt);
+			} else if (!strcasecmp(v->name, "host")) {
+				if (!strcasecmp(v->value, "dynamic")) {
+					/* They'll register with us */
+					if (!found || !peer->host_dynamic) {
+						/* Initialize stuff if this is a new peer, or if it used to
+						 * not be dynamic before the reload. */
+						memset(&peer->addr.sin_addr, 0, 4);
+						if (peer->addr.sin_port) {
+							/* If we've already got a port, make it the default rather than absolute */
+							peer->defaddr.sin_port = peer->addr.sin_port;
+							peer->addr.sin_port = 0;
+						}
+					}
+					peer->host_dynamic = TRUE;
+				} else {
+					/* Non-dynamic.  Make sure we become that way if we're not */
+					AST_SCHED_DEL_UNREF(sched, peer->expire,
+							unref_peer(peer, "removing register expire ref"));
+					peer->host_dynamic = FALSE;
+					srvlookup = v->value;
+					if (global_dynamic_exclude_static) {
+						int err = 0;
+						global_contact_ha = ast_append_ha("deny", (char *)ast_inet_ntoa(peer->addr.sin_addr), global_contact_ha, &err);
+						if (err) {
+							ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
+						}
+					}
+				}
+			} else if (!strcasecmp(v->name, "defaultip")) {
+				if (ast_get_ip(&peer->defaddr, v->value)) {
+					unref_peer(peer, "unref_peer: from build_peer defaultip");
+					return NULL;
+				}
+			} else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) {
+				int ha_error = 0;
+				peer->ha = ast_append_ha(v->name, v->value, peer->ha, &ha_error);
+				if (ha_error) {
+					ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
+				}
+			} else if (!strcasecmp(v->name, "contactpermit") || !strcasecmp(v->name, "contactdeny")) {
+				int ha_error = 0;
+				peer->contactha = ast_append_ha(v->name + 7, v->value, peer->contactha, &ha_error);
+				if (ha_error) {
+					ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
+				}
+			} else if (!strcasecmp(v->name, "port")) {
+				if (!realtime && peer->host_dynamic) {
+					peer->defaddr.sin_port = htons(atoi(v->value));
+				} else {
+					peer->addr.sin_port = htons(atoi(v->value));
+				}
+			} else if (!strcasecmp(v->name, "callingpres")) {
+				peer->callingpres = ast_parse_caller_presentation(v->value);
+				if (peer->callingpres == -1) {
+					peer->callingpres = atoi(v->value);
+				}
+			} else if (!strcasecmp(v->name, "username") || !strcmp(v->name, "defaultuser")) {	/* "username" is deprecated */
+				ast_string_field_set(peer, username, v->value);
+				if (!strcasecmp(v->name, "username")) {
+					if (deprecation_warning) {
+						ast_log(LOG_NOTICE, "The 'username' field for sip peers has been deprecated in favor of the term 'defaultuser'\n");
+						deprecation_warning = 0;
+					}
+					peer->deprecated_username = 1;
+				}
+			} else if (!strcasecmp(v->name, "language")) {
+				ast_string_field_set(peer, language, v->value);
+			} else if (!strcasecmp(v->name, "regexten")) {
+				ast_string_field_set(peer, regexten, v->value);
+			} else if (!strcasecmp(v->name, "callbackextension")) {
+				ast_copy_string(callback, v->value, sizeof(callback));
+			} else if (!strcasecmp(v->name, "amaflags")) {
+				format = ast_cdr_amaflags2int(v->value);
+				if (format < 0) {
+					ast_log(LOG_WARNING, "Invalid AMA Flags for peer: %s at line %d\n", v->value, v->lineno);
+				} else {
+					peer->amaflags = format;
+				}
+			} else if (!strcasecmp(v->name, "accountcode")) {
+				ast_string_field_set(peer, accountcode, v->value);
+			} else if (!strcasecmp(v->name, "mohinterpret")) {
+				ast_string_field_set(peer, mohinterpret, v->value);
+			} else if (!strcasecmp(v->name, "mohsuggest")) {
+				ast_string_field_set(peer, mohsuggest, v->value);
+			} else if (!strcasecmp(v->name, "parkinglot")) {
+				ast_string_field_set(peer, parkinglot, v->value);
+			} else if (!strcasecmp(v->name, "mailbox")) {
+				add_peer_mailboxes(peer, v->value);
+			} else if (!strcasecmp(v->name, "hasvoicemail")) {
+				/* People expect that if 'hasvoicemail' is set, that the mailbox will
+				 * be also set, even if not explicitly specified. */
+				if (ast_true(v->value) && AST_LIST_EMPTY(&peer->mailboxes)) {
+					add_peer_mailboxes(peer, name);
+				}
+			} else if (!strcasecmp(v->name, "subscribemwi")) {
+				ast_set2_flag(&peer->flags[1], ast_true(v->value), SIP_PAGE2_SUBSCRIBEMWIONLY);
+			} else if (!strcasecmp(v->name, "vmexten")) {
+				ast_string_field_set(peer, vmexten, v->value);
+			} else if (!strcasecmp(v->name, "callgroup")) {
+				peer->callgroup = ast_get_group(v->value);
+			} else if (!strcasecmp(v->name, "allowtransfer")) {
+				peer->allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED;
+			} else if (!strcasecmp(v->name, "pickupgroup")) {
+				peer->pickupgroup = ast_get_group(v->value);
+			} else if (!strcasecmp(v->name, "allow")) {
+				int error =  ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, TRUE);
+				if (error) {
+					ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
+				}
+			} else if (!strcasecmp(v->name, "disallow")) {
+				int error =  ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, FALSE);
+				if (error) {
+					ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
+				}
+			} else if (!strcasecmp(v->name, "registertrying")) {
+				ast_set2_flag(&peer->flags[1], ast_true(v->value), SIP_PAGE2_REGISTERTRYING);
+			} else if (!strcasecmp(v->name, "autoframing")) {
+				peer->autoframing = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "rtptimeout")) {
+				if ((sscanf(v->value, "%30d", &peer->rtptimeout) != 1) || (peer->rtptimeout < 0)) {
+					ast_log(LOG_WARNING, "'%s' is not a valid RTP hold time at line %d.  Using default.\n", v->value, v->lineno);
+					peer->rtptimeout = global_rtptimeout;
+				}
+			} else if (!strcasecmp(v->name, "rtpholdtimeout")) {
+				if ((sscanf(v->value, "%30d", &peer->rtpholdtimeout) != 1) || (peer->rtpholdtimeout < 0)) {
+					ast_log(LOG_WARNING, "'%s' is not a valid RTP hold time at line %d.  Using default.\n", v->value, v->lineno);
+					peer->rtpholdtimeout = global_rtpholdtimeout;
+				}
+			} else if (!strcasecmp(v->name, "rtpkeepalive")) {
+				if ((sscanf(v->value, "%30d", &peer->rtpkeepalive) != 1) || (peer->rtpkeepalive < 0)) {
+					ast_log(LOG_WARNING, "'%s' is not a valid RTP keepalive time at line %d.  Using default.\n", v->value, v->lineno);
+					peer->rtpkeepalive = global_rtpkeepalive;
+				}
+			} else if (!strcasecmp(v->name, "timert1")) {
+				if ((sscanf(v->value, "%30d", &peer->timer_t1) != 1) || (peer->timer_t1 < 0)) {
+					ast_log(LOG_WARNING, "'%s' is not a valid T1 time at line %d.  Using default.\n", v->value, v->lineno);
+					peer->timer_t1 = global_t1;
+				}
+				/* Note that Timer B is dependent upon T1 and MUST NOT be lower
+				 * than T1 * 64, according to RFC 3261, Section 17.1.1.2 */
+				if (peer->timer_b < peer->timer_t1 * 64) {
+					peer->timer_b = peer->timer_t1 * 64;
+				}
+			} else if (!strcasecmp(v->name, "timerb")) {
+				if ((sscanf(v->value, "%30d", &peer->timer_b) != 1) || (peer->timer_b < 0)) {
+					ast_log(LOG_WARNING, "'%s' is not a valid Timer B time at line %d.  Using default.\n", v->value, v->lineno);
+					peer->timer_b = global_timer_b;
+				}
+				if (peer->timer_b < peer->timer_t1 * 64) {
+					static int warning = 0;
+					if (warning++ % 20 == 0) {
+						ast_log(LOG_WARNING, "Timer B has been set lower than recommended. (RFC 3261, 17.1.1.2)\n");
+					}
+				}
+			} else if (!strcasecmp(v->name, "rtpkeepalive")) {
+				if ((sscanf(v->value, "%30d", &peer->rtpkeepalive) != 1) || (peer->rtpkeepalive < 0)) {
+					ast_log(LOG_WARNING, "'%s' is not a valid RTP keepalive time at line %d.  Using default.\n", v->value, v->lineno);
+					peer->rtpkeepalive = global_rtpkeepalive;
+				}
+			} else if (!strcasecmp(v->name, "setvar")) {
+				peer->chanvars = add_var(v->value, peer->chanvars);
+			} else if (!strcasecmp(v->name, "qualifyfreq")) {
+				int i;
+				if (sscanf(v->value, "%30d", &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) {
+					peer->maxcallbitrate = default_maxcallbitrate;
+				}
+			} else if (!strcasecmp(v->name, "session-timers")) {
+				int i = (int) str2stmode(v->value);
+				if (i < 0) {
+					ast_log(LOG_WARNING, "Invalid session-timers '%s' at line %d of %s\n", v->value, v->lineno, config);
+					peer->stimer.st_mode_oper = global_st_mode;
+				} else {
+					peer->stimer.st_mode_oper = i;
+				}
+			} else if (!strcasecmp(v->name, "session-expires")) {
+				if (sscanf(v->value, "%30d", &peer->stimer.st_max_se) != 1) {
+					ast_log(LOG_WARNING, "Invalid session-expires '%s' at line %d of %s\n", v->value, v->lineno, config);
+					peer->stimer.st_max_se = global_max_se;
+				}
+			} else if (!strcasecmp(v->name, "session-minse")) {
+				if (sscanf(v->value, "%30d", &peer->stimer.st_min_se) != 1) {
+					ast_log(LOG_WARNING, "Invalid session-minse '%s' at line %d of %s\n", v->value, v->lineno, config);
+					peer->stimer.st_min_se = global_min_se;
+				}
+				if (peer->stimer.st_min_se < 90) {
+					ast_log(LOG_WARNING, "session-minse '%s' at line %d of %s is not allowed to be < 90 secs\n", v->value, v->lineno, config);
+					peer->stimer.st_min_se = global_min_se;
+				}
+			} else if (!strcasecmp(v->name, "session-refresher")) {
+				int i = (int) str2strefresher(v->value);
+				if (i < 0) {
+					ast_log(LOG_WARNING, "Invalid session-refresher '%s' at line %d of %s\n", v->value, v->lineno, config);
+					peer->stimer.st_ref = global_st_refresher;
+				} else {
+					peer->stimer.st_ref = i;
 				}
 			}
-		} else if (realtime && !strcasecmp(v->name, "regseconds")) {
-			ast_get_time_t(v->value, &regseconds, 0, NULL);
-		} else if (realtime && !strcasecmp(v->name, "lastms")) {
+		}
+
+		/* These apply to devstate lookups */
+		if (realtime && !strcasecmp(v->name, "lastms")) {
 			sscanf(v->value, "%30d", &peer->lastms);
 		} else if (realtime && !strcasecmp(v->name, "ipaddr") && !ast_strlen_zero(v->value) ) {
 			inet_aton(v->value, &(peer->addr.sin_addr));
-		} else if (realtime && !strcasecmp(v->name, "name"))
-			ast_copy_string(peer->name, v->value, sizeof(peer->name));
-		else if (realtime && !strcasecmp(v->name, "fullcontact")) {
-			if (alt_fullcontact && !alt) {
-				/* Reset, because the alternate also has a fullcontact and we
-				 * do NOT want the field value to be doubled. It might be
-				 * tempting to skip this, but the first table might not have
-				 * fullcontact and since we're here, we know that the alternate
-				 * absolutely does. */
-				alt_fullcontact = 0;
-				ast_str_reset(fullcontact);
-			}
-			/* Reconstruct field, because realtime separates our value at the ';' */
-			if (fullcontact->used > 0) {
-				ast_str_append(&fullcontact, 0, ";%s", v->value);
-			} else {
-				ast_str_set(&fullcontact, 0, "%s", v->value);
-			}
-		} else if (!strcasecmp(v->name, "type")) {
-			if (!strcasecmp(v->value, "peer")) {
-				peer->type |= SIP_TYPE_PEER;
-			} else if (!strcasecmp(v->value, "user")) {
-				peer->type |= SIP_TYPE_USER;
-			} else if (!strcasecmp(v->value, "friend")) {
-				peer->type = SIP_TYPE_USER | SIP_TYPE_PEER;
-			}
-		} else if (!strcasecmp(v->name, "remotesecret")) {
-			ast_string_field_set(peer, remotesecret, v->value);
-		} else if (!strcasecmp(v->name, "secret")) {
-			ast_string_field_set(peer, secret, v->value);
-		} else if (!strcasecmp(v->name, "md5secret")) 
-			ast_string_field_set(peer, md5secret, v->value);
-		else if (!strcasecmp(v->name, "auth"))
-			peer->auth = add_realm_authentication(peer->auth, v->value, v->lineno);
-		else if (!strcasecmp(v->name, "callerid")) {
-			char cid_name[80] = { '\0' }, cid_num[80] = { '\0' };
-
-			ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
-			ast_string_field_set(peer, cid_name, cid_name);
-			ast_string_field_set(peer, cid_num, cid_num);
-		} else if (!strcasecmp(v->name, "fullname")) {
-			ast_string_field_set(peer, cid_name, v->value);
-		} else if (!strcasecmp(v->name, "cid_number")) {
-			ast_string_field_set(peer, cid_num, v->value);
-		} else if (!strcasecmp(v->name, "context")) {
-			ast_string_field_set(peer, context, v->value);
-		} else if (!strcasecmp(v->name, "subscribecontext")) {
-			ast_string_field_set(peer, subscribecontext, v->value);
-		} else if (!strcasecmp(v->name, "fromdomain")) {
-			ast_string_field_set(peer, fromdomain, v->value);
-		} else if (!strcasecmp(v->name, "usereqphone")) {
-			ast_set2_flag(&peer->flags[0], ast_true(v->value), SIP_USEREQPHONE);
-		} else if (!strcasecmp(v->name, "fromuser")) {
-			ast_string_field_set(peer, fromuser, v->value);
-		} else if (!strcasecmp(v->name, "outboundproxy")) {
-			char *port, *next, *force, *proxyname;
-			int forceopt = FALSE;
-			/* Set peer channel variable */
-			next = proxyname = ast_strdupa(v->value);
-			if ((port = strchr(proxyname, ':'))) {
-				*port++ = '\0';
-				next = port;
-			}
-			if ((force = strchr(next, ','))) {
-				*force++ = '\0';
-				forceopt = strcmp(force, "force");
-			}
-			/* Allocate proxy object */
-			peer->outboundproxy = proxy_allocate(proxyname, port, forceopt);
-		} else if (!strcasecmp(v->name, "host")) {
-			if (!strcasecmp(v->value, "dynamic")) {
-				/* They'll register with us */
-				if (!found || !peer->host_dynamic) {
-					/* Initialize stuff if this is a new peer, or if it used to
-					 * not be dynamic before the reload. */
-					memset(&peer->addr.sin_addr, 0, 4);
-					if (peer->addr.sin_port) {
-						/* If we've already got a port, make it the default rather than absolute */
-						peer->defaddr.sin_port = peer->addr.sin_port;
-						peer->addr.sin_port = 0;
-					}
-				}
-				peer->host_dynamic = TRUE;
-			} else {
-				/* Non-dynamic.  Make sure we become that way if we're not */
-				AST_SCHED_DEL_UNREF(sched, peer->expire,
-						unref_peer(peer, "removing register expire ref"));
-				peer->host_dynamic = FALSE;
-				srvlookup = v->value;
-				if (global_dynamic_exclude_static) {
-					int err = 0;
-					global_contact_ha = ast_append_ha("deny", (char *)ast_inet_ntoa(peer->addr.sin_addr), global_contact_ha, &err);
-					if (err) {
-						ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
-					}
-				}
-			}
-		} else if (!strcasecmp(v->name, "defaultip")) {
-			if (ast_get_ip(&peer->defaddr, v->value)) {
-				unref_peer(peer, "unref_peer: from build_peer defaultip");
-				return NULL;
-			}
-		} else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) {
-			int ha_error = 0;
-
-			peer->ha = ast_append_ha(v->name, v->value, peer->ha, &ha_error);
-			if (ha_error)
-				ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
-		} else if (!strcasecmp(v->name, "contactpermit") || !strcasecmp(v->name, "contactdeny")) {
-			int ha_error = 0;
-			peer->contactha = ast_append_ha(v->name + 7, v->value, peer->contactha, &ha_error);
-			if (ha_error) {
-				ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
-			}
-		} else if (!strcasecmp(v->name, "port")) {
-			if (!realtime && peer->host_dynamic)
-				peer->defaddr.sin_port = htons(atoi(v->value));
-			else
-				peer->addr.sin_port = htons(atoi(v->value));
-		} else if (!strcasecmp(v->name, "callingpres")) {
-			peer->callingpres = ast_parse_caller_presentation(v->value);
-			if (peer->callingpres == -1)
-				peer->callingpres = atoi(v->value);
-		} else if (!strcasecmp(v->name, "username") || !strcmp(v->name, "defaultuser")) {	/* "username" is deprecated */
-			ast_string_field_set(peer, username, v->value);
-			if (!strcasecmp(v->name, "username")) {
-				if (deprecation_warning) {
-					ast_log(LOG_NOTICE, "The 'username' field for sip peers has been deprecated in favor of the term 'defaultuser'\n");
-					deprecation_warning = 0;
-				}
-				peer->deprecated_username = 1;
-			}
-		} else if (!strcasecmp(v->name, "language")) {
-			ast_string_field_set(peer, language, v->value);
-		} else if (!strcasecmp(v->name, "regexten")) {
-			ast_string_field_set(peer, regexten, v->value);
-		} else if (!strcasecmp(v->name, "callbackextension")) {
-			ast_copy_string(callback, v->value, sizeof(callback));
-		} else if (!strcasecmp(v->name, "callcounter")) {
-			peer->call_limit = ast_true(v->value) ? INT_MAX : 0;
-		} else if (!strcasecmp(v->name, "call-limit")) {
-			peer->call_limit = atoi(v->value);
-			if (peer->call_limit < 0)
-				peer->call_limit = 0;
-		} else if (!strcasecmp(v->name, "busylevel")) {
-			peer->busy_level = atoi(v->value);
-			if (peer->busy_level < 0)
-				peer->busy_level = 0;
-		} else if (!strcasecmp(v->name, "amaflags")) {
-			format = ast_cdr_amaflags2int(v->value);
-			if (format < 0) {
-				ast_log(LOG_WARNING, "Invalid AMA Flags for peer: %s at line %d\n", v->value, v->lineno);
-			} else {
-				peer->amaflags = format;
-			}
-		} else if (!strcasecmp(v->name, "accountcode")) {
-			ast_string_field_set(peer, accountcode, v->value);
-		} else if (!strcasecmp(v->name, "mohinterpret")) {
-			ast_string_field_set(peer, mohinterpret, v->value);
-		} else if (!strcasecmp(v->name, "mohsuggest")) {
-			ast_string_field_set(peer, mohsuggest, v->value);
-		} else if (!strcasecmp(v->name, "parkinglot")) {
-			ast_string_field_set(peer, parkinglot, v->value);
-		} else if (!strcasecmp(v->name, "mailbox")) {
-			add_peer_mailboxes(peer, v->value);
-		} else if (!strcasecmp(v->name, "hasvoicemail")) {
-			/* People expect that if 'hasvoicemail' is set, that the mailbox will
-			 * be also set, even if not explicitly specified. */
-			if (ast_true(v->value) && AST_LIST_EMPTY(&peer->mailboxes)) {
-				add_peer_mailboxes(peer, name);
-			}
-		} else if (!strcasecmp(v->name, "subscribemwi")) {
-			ast_set2_flag(&peer->flags[1], ast_true(v->value), SIP_PAGE2_SUBSCRIBEMWIONLY);
-		} else if (!strcasecmp(v->name, "vmexten")) {
-			ast_string_field_set(peer, vmexten, v->value);
-		} else if (!strcasecmp(v->name, "callgroup")) {
-			peer->callgroup = ast_get_group(v->value);
-		} else if (!strcasecmp(v->name, "allowtransfer")) {
-			peer->allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED;
-		} else if (!strcasecmp(v->name, "pickupgroup")) {
-			peer->pickupgroup = ast_get_group(v->value);
-		} else if (!strcasecmp(v->name, "allow")) {
-			int error =  ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, TRUE);
-			if (error)
-				ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
-		} else if (!strcasecmp(v->name, "disallow")) {
-			int error =  ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, FALSE);
-			if (error)
-				ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
-		} else if (!strcasecmp(v->name, "registertrying")) {
-			ast_set2_flag(&peer->flags[1], ast_true(v->value), SIP_PAGE2_REGISTERTRYING);
-		} else if (!strcasecmp(v->name, "autoframing")) {
-			peer->autoframing = ast_true(v->value);
-		} else if (!strcasecmp(v->name, "rtptimeout")) {
-			if ((sscanf(v->value, "%30d", &peer->rtptimeout) != 1) || (peer->rtptimeout < 0)) {
-				ast_log(LOG_WARNING, "'%s' is not a valid RTP hold time at line %d.  Using default.\n", v->value, v->lineno);
-				peer->rtptimeout = global_rtptimeout;
-			}
-		} else if (!strcasecmp(v->name, "rtpholdtimeout")) {
-			if ((sscanf(v->value, "%30d", &peer->rtpholdtimeout) != 1) || (peer->rtpholdtimeout < 0)) {
-				ast_log(LOG_WARNING, "'%s' is not a valid RTP hold time at line %d.  Using default.\n", v->value, v->lineno);
-				peer->rtpholdtimeout = global_rtpholdtimeout;
-			}
-		} else if (!strcasecmp(v->name, "rtpkeepalive")) {
-			if ((sscanf(v->value, "%30d", &peer->rtpkeepalive) != 1) || (peer->rtpkeepalive < 0)) {
-				ast_log(LOG_WARNING, "'%s' is not a valid RTP keepalive time at line %d.  Using default.\n", v->value, v->lineno);

[... 352 lines stripped ...]



More information about the asterisk-commits mailing list