[asterisk-commits] jrose: branch 1.8 r415359 - in /branches/1.8: channels/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 6 16:14:01 CDT 2014


Author: jrose
Date: Fri Jun  6 16:13:51 2014
New Revision: 415359

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=415359
Log:
chan_sip: Fix order of variables specified in SIPNotify action

Prior to this patch, sequential variables would be ordered in reverse
from the order specified in the manager action.

Review: https://reviewboard.asterisk.org/r/3588/

Modified:
    branches/1.8/channels/chan_sip.c
    branches/1.8/include/asterisk/config.h
    branches/1.8/include/asterisk/manager.h
    branches/1.8/main/config.c
    branches/1.8/main/manager.c

Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=415359&r1=415358&r2=415359
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Fri Jun  6 16:13:51 2014
@@ -13543,7 +13543,7 @@
 static int manager_sipnotify(struct mansession *s, const struct message *m)
 {
 	const char *channame = astman_get_header(m, "Channel");
-	struct ast_variable *vars = astman_get_variables(m);
+	struct ast_variable *vars = astman_get_variables_order(m, ORDER_NATURAL);
 	struct sip_pvt *p;
 	struct ast_variable *header, *var;
 

Modified: branches/1.8/include/asterisk/config.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/config.h?view=diff&rev=415359&r1=415358&r2=415359
==============================================================================
--- branches/1.8/include/asterisk/config.h (original)
+++ branches/1.8/include/asterisk/config.h Fri Jun  6 16:13:51 2014
@@ -459,6 +459,16 @@
  * (the arguments to ast_variables_new).
  */
 struct ast_variable *ast_variables_dup(struct ast_variable *var);
+
+/*!
+ * \brief Reverse a variable list
+ * \param var the linked list of variables to reverse
+ * \return The head of the reversed variable list
+ *
+ * \note The variable list var is not preserved in this function and should
+ * not be used after reversing it.
+ */
+struct ast_variable *ast_variables_reverse(struct ast_variable *var);
 
 /*!
  * \brief Free variable list

Modified: branches/1.8/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/manager.h?view=diff&rev=415359&r1=415358&r2=415359
==============================================================================
--- branches/1.8/include/asterisk/manager.h (original)
+++ branches/1.8/include/asterisk/manager.h Fri Jun  6 16:13:51 2014
@@ -241,8 +241,20 @@
 /*! \brief Get header from mananger transaction */
 const char *astman_get_header(const struct message *m, char *var);
 
-/*! \brief Get a linked list of the Variable: headers */
+/*! \brief Get a linked list of the Variable: headers
+ *
+ *  \note Order of variables is reversed from the order they are specified in
+ *        the manager message
+ */
 struct ast_variable *astman_get_variables(const struct message *m);
+
+enum variable_orders {
+	ORDER_NATURAL,
+	ORDER_REVERSE
+};
+
+/*! \brief Get a linked list of the Variable: headers with order specified */
+struct ast_variable *astman_get_variables_order(const struct message *m, enum variable_orders order);
 
 /*! \brief Send error in manager transaction */
 void astman_send_error(struct mansession *s, const struct message *m, char *error);

Modified: branches/1.8/main/config.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/config.c?view=diff&rev=415359&r1=415358&r2=415359
==============================================================================
--- branches/1.8/main/config.c (original)
+++ branches/1.8/main/config.c Fri Jun  6 16:13:51 2014
@@ -557,6 +557,30 @@
 	}
 
 	return cloned;
+}
+
+struct ast_variable *ast_variables_reverse(struct ast_variable *var)
+{
+	struct ast_variable *var1, *var2;
+
+	var1 = var;
+
+	if (!var1 || !var1->next) {
+		return var1;
+	}
+
+	var2 = var1->next;
+	var1->next = NULL;
+
+	while (var2) {
+		struct ast_variable *next = var2->next;
+
+		var2->next = var1;
+		var1 = var2;
+		var2 = next;
+	}
+
+	return var1;
 }
 
 void ast_variables_destroy(struct ast_variable *v)

Modified: branches/1.8/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/manager.c?view=diff&rev=415359&r1=415358&r2=415359
==============================================================================
--- branches/1.8/main/manager.c (original)
+++ branches/1.8/main/manager.c Fri Jun  6 16:13:51 2014
@@ -1924,6 +1924,12 @@
 
 struct ast_variable *astman_get_variables(const struct message *m)
 {
+	return astman_get_variables_order(m, ORDER_REVERSE);
+}
+
+struct ast_variable *astman_get_variables_order(const struct message *m,
+	enum variable_orders order)
+{
 	int varlen;
 	int x;
 	struct ast_variable *head = NULL;
@@ -1937,6 +1943,10 @@
 			continue;
 		}
 		head = man_do_variable_value(head, m->headers[x] + varlen);
+	}
+
+	if (order == ORDER_NATURAL) {
+		head = ast_variables_reverse(head);
 	}
 
 	return head;




More information about the asterisk-commits mailing list