summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2014-06-06 21:44:16 +0000
committerJonathan Rose <jrose@digium.com>2014-06-06 21:44:16 +0000
commit5ca495ed2f60fe8907503196ae50a2cfba9ff1fd (patch)
treeb711478b90599d2457f905c3d4d444864a4e6d13 /main
parent4308aa5648ef4d7332dd14f920b944b0806ec8fb (diff)
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/ ........ Merged revisions 415359 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 415390 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 415410 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415411 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/config.c24
-rw-r--r--main/manager.c10
2 files changed, 34 insertions, 0 deletions
diff --git a/main/config.c b/main/config.c
index aee81e3ff..d9bef2e1b 100644
--- a/main/config.c
+++ b/main/config.c
@@ -562,6 +562,30 @@ struct ast_variable *ast_variables_dup(struct ast_variable *var)
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)
{
struct ast_variable *vn;
diff --git a/main/manager.c b/main/manager.c
index cb2b0bbe2..09d49f002 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -2390,6 +2390,12 @@ static struct ast_variable *man_do_variable_value(struct ast_variable *head, con
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;
@@ -2405,6 +2411,10 @@ struct ast_variable *astman_get_variables(const struct message *m)
head = man_do_variable_value(head, m->headers[x] + varlen);
}
+ if (order == ORDER_NATURAL) {
+ head = ast_variables_reverse(head);
+ }
+
return head;
}