[asterisk-commits] oej: trunk r172268 - in /trunk: channels/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 29 07:21:31 CST 2009


Author: oej
Date: Thu Jan 29 07:21:31 2009
New Revision: 172268

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=172268
Log:
- Make sure we set setvar= variables on outbound calls too, not only inbound calls.
- Also, change a function in app.c to return a userful value instead of always returning 0.

Patch by fnordian, changed by Corydon76 and myself.

This does not close the bug report, as fnordian had an additional change we're still discussing.

(related to issue #14059)
Reported by: fnordian
Patches: 
      chan_sip_hfield.patch uploaded by fnordian (license 110)
      20090116__bug14059.diff.txt uploaded by Corydon76 (license 14)
Tested by: fnordian, Corydon76, oej


Modified:
    trunk/channels/chan_sip.c
    trunk/include/asterisk/app.h
    trunk/main/app.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=172268&r1=172267&r2=172268
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Jan 29 07:21:31 2009
@@ -2317,6 +2317,7 @@
 static void *do_monitor(void *data);
 static int restart_monitor(void);
 static void peer_mailboxes_to_str(struct ast_str **mailbox_str, struct sip_peer *peer);
+static struct ast_variable *copy_vars(struct ast_variable *src);
 /* static int sip_addrcmp(char *name, struct sockaddr_in *sin);	Support for peer matching */
 static int sip_refer_allocate(struct sip_pvt *p);
 static void ast_quiet_chan(struct ast_channel *chan);
@@ -2692,6 +2693,21 @@
 	.get_codec = sip_get_codec,
 };
 
+/*!
+ * duplicate a list of channel variables, \return the copy.
+ */
+static struct ast_variable *copy_vars(struct ast_variable *src)
+{
+	struct ast_variable *res = NULL, *tmp, *v = NULL;
+
+	for (v = src ; v ; v = v->next) {
+		if ((tmp = ast_variable_new(v->name, v->value, v->file))) {
+			tmp->next = res;
+			res = tmp;
+		}
+	}
+	return res;
+}
 
 /*! \brief SIP TCP connection handler */
 static void *sip_tcp_worker_fn(void *data)
@@ -4650,6 +4666,7 @@
  */
 static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
 {
+
 	/* this checks that the dialog is contacting the peer on a valid
 	 * transport type based on the peers transport configuration,
 	 * otherwise, this function bails out */
@@ -4778,6 +4795,8 @@
 	if (peer->call_limit)
 		ast_set_flag(&dialog->flags[0], SIP_CALL_LIMIT);
 	
+	dialog->chanvars = copy_vars(peer->chanvars);
+
 	return 0;
 }
 
@@ -6222,8 +6241,10 @@
 		pbx_builtin_setvar_helper(tmp, "_T38CALL", "1");
 
 	/* Set channel variables for this call from configuration */
-	for (v = i->chanvars ; v ; v = v->next)
-		pbx_builtin_setvar_helper(tmp, v->name, v->value);
+	for (v = i->chanvars ; v ; v = v->next) {
+		char valuebuf[1024];
+		pbx_builtin_setvar_helper(tmp, v->name, ast_get_encoded_str(v->value, valuebuf, sizeof(valuebuf)));
+	}
 
 	if (state != AST_STATE_DOWN && ast_pbx_start(tmp)) {
 		ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
@@ -12688,21 +12709,6 @@
 	return 0;
 }
 
-/*!
- * duplicate a list of channel variables, \return the copy.
- */
-static struct ast_variable *copy_vars(struct ast_variable *src)
-{
-	struct ast_variable *res = NULL, *tmp, *v = NULL;
-
-	for (v = src ; v ; v = v->next) {
-		if ((tmp = ast_variable_new(v->name, v->value, v->file))) {
-			tmp->next = res;
-			res = tmp;
-		}
-	}
-	return res;
-}
 
 /*! \brief helper function for check_{user|peer}_ok() */
 static void replace_cid(struct sip_pvt *p, const char *rpid_num, const char *calleridname)
@@ -16109,9 +16115,11 @@
 		struct ast_variable *v;
 	
 		chanvar = strsep(&chanvar, "]");
-		for (v = peer->chanvars ; v ; v = v->next)
-			if (!strcasecmp(v->name, chanvar))
+		for (v = peer->chanvars ; v ; v = v->next) {
+			if (!strcasecmp(v->name, chanvar)) {
 				ast_copy_string(buf, v->value, len);
+			}
+		}
 	} else  if (!strncasecmp(colname, "codec[", 6)) {
 		char *codecnum;
 		int codec = 0;

Modified: trunk/include/asterisk/app.h
URL: http://svn.digium.com/svn-view/asterisk/trunk/include/asterisk/app.h?view=diff&rev=172268&r1=172267&r2=172268
==============================================================================
--- trunk/include/asterisk/app.h (original)
+++ trunk/include/asterisk/app.h Thu Jan 29 07:21:31 2009
@@ -490,11 +490,13 @@
 /*! \brief Allow to record message and have a review option */
 int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path);
 
-/*! \brief Decode an encoded control or extended ASCII character */
+/*! \brief Decode an encoded control or extended ASCII character 
+    \return Returns a pointer to the result string
+*/
 int ast_get_encoded_char(const char *stream, char *result, size_t *consumed);
 
 /*! \brief Decode a stream of encoded control or extended ASCII characters */
-int ast_get_encoded_str(const char *stream, char *result, size_t result_len);
+char *ast_get_encoded_str(const char *stream, char *result, size_t result_len);
 
 /*! \brief Common routine for child processes, to close all fds prior to exec(2) */
 void ast_close_fds_above_n(int n);

Modified: trunk/main/app.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/app.c?view=diff&rev=172268&r1=172267&r2=172268
==============================================================================
--- trunk/main/app.c (original)
+++ trunk/main/app.c Thu Jan 29 07:21:31 2009
@@ -1827,7 +1827,7 @@
 	return 0;
 }
 
-int ast_get_encoded_str(const char *stream, char *result, size_t result_size)
+char *ast_get_encoded_str(const char *stream, char *result, size_t result_size)
 {
 	char *cur = result;
 	size_t consumed;
@@ -1837,7 +1837,7 @@
 		stream += consumed;
 	}
 	*cur = '\0';
-	return 0;
+	return result;
 }
 
 void ast_close_fds_above_n(int n)




More information about the asterisk-commits mailing list