Module: sip-router
Branch: master
Commit: 8cf72b2de1ca86cafe7203433ff411e837d26dfa
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8cf72b2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Apr 28 19:23:23 2009 +0200
kex: added km_append_branch
- K compatible append_branch() function
---
modules_k/kex/kex_mod.c | 5 +++
modules_k/kex/km_core.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++
modules_k/kex/km_core.h | 30 +++++++++++++++++++++
3 files changed, 102 insertions(+), 0 deletions(-)
diff --git a/modules_k/kex/kex_mod.c b/modules_k/kex/kex_mod.c
index e4960c0..9baa48d 100644
--- a/modules_k/kex/kex_mod.c
+++ b/modules_k/kex/kex_mod.c
@@ -31,6 +31,7 @@
#include "../../mod_fix.h"
#include "flags.h"
+#include "km_core.h"
#include "mi_core.h"
#include "core_stats.h"
@@ -63,6 +64,10 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE },
{"isbflagset", (cmd_function)w_isbflagset, 2,fixup_igp_igp,
0, ANY_ROUTE },
+ {"km_append_branch", (cmd_function)w_km_append_branch, 0, 0,
+ 0, REQUEST_ROUTE | FAILURE_ROUTE },
+ {"km_append_branch", (cmd_function)w_km_append_branch, 1, fixup_spve_null,
+ 0, REQUEST_ROUTE | FAILURE_ROUTE },
{0,0,0,0,0,0}
};
diff --git a/modules_k/kex/km_core.c b/modules_k/kex/km_core.c
new file mode 100644
index 0000000..beebb35
--- /dev/null
+++ b/modules_k/kex/km_core.c
@@ -0,0 +1,67 @@
+/**
+ * $Id$
+ *
+ * Copyright (C) 2009
+ *
+ * This file is part of SIP-Router.org, a free SIP server.
+ *
+ * SIP-Router is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "../../dprint.h"
+#include "../../dset.h"
+#include "../../flags.h"
+#include "../../mod_fix.h"
+#include "km_core.h"
+
+int w_km_append_branch(struct sip_msg *msg, char *uri, str *sq)
+{
+ str suri;
+ int ret;
+ int q = Q_UNSPECIFIED;
+ flag_t branch_flags = 0;
+
+ getbflagsval(0, &branch_flags);
+ if (uri==NULL) {
+ ret = km_append_branch(msg, 0, &msg->dst_uri, &msg->path_vec,
+ q, branch_flags, msg->force_send_socket);
+ /* reset all branch info */
+ msg->force_send_socket = 0;
+ setbflagsval(0, 0);
+ if(msg->dst_uri.s!=0)
+ pkg_free(msg->dst_uri.s);
+ msg->dst_uri.s = 0;
+ msg->dst_uri.len = 0;
+ if(msg->path_vec.s!=0)
+ pkg_free(msg->path_vec.s);
+ msg->path_vec.s = 0;
+ msg->path_vec.len = 0;
+ } else {
+ if(fixup_get_svalue(msg, (gparam_p)uri, &suri)!=0)
+ {
+ LM_ERR("cannot get the URI parameter\n");
+ return -1;
+ }
+ ret = km_append_branch(msg, &suri, &msg->dst_uri,
+ &msg->path_vec, q, branch_flags,
+ msg->force_send_socket);
+ }
+ return ret;
+}
+
diff --git a/modules_k/kex/km_core.h b/modules_k/kex/km_core.h
new file mode 100644
index 0000000..a668c71
--- /dev/null
+++ b/modules_k/kex/km_core.h
@@ -0,0 +1,30 @@
+/**
+ * $Id$
+ *
+ * Copyright (C) 2009
+ *
+ * This file is part of SIP-Router.org, a free SIP server.
+ *
+ * SIP-Router is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _KEX_CORE_H_
+#define _KEX_CORE_H_
+
+#include "../../sr_module.h"
+
+int w_km_append_branch(struct sip_msg *msg, char *uri, str *s2);
+
+#endif
Module: sip-router
Branch: master
Commit: d02a166db83db71b587cd1252db0b4d4954e8c93
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d02a166…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Apr 28 19:21:04 2009 +0200
core: renamed getbflsgs to getblagsval
- match the template of counterpart setblagsval
- swapped the parameters
---
dset.c | 2 +-
dset.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dset.c b/dset.c
index cbc636b..9409557 100644
--- a/dset.c
+++ b/dset.c
@@ -126,7 +126,7 @@ int resetbflag(unsigned int branch, flag_t flag)
}
-int getbflags(flag_t* res, unsigned int branch)
+int getbflagsval(unsigned int branch, flag_t* res)
{
flag_t* flags;
if (res == NULL) return -1;
diff --git a/dset.h b/dset.h
index e350238..adba10e 100644
--- a/dset.h
+++ b/dset.h
@@ -126,11 +126,11 @@ int isbflagset(unsigned int branch, flag_t flag);
*
* This function returns the value of all branch flags
* combined in a single variable.
- * @param res A pointer to a variable to store the result
* @param branch Number of the branch (0 for the main Request-URI branch)
+ * @param res A pointer to a variable to store the result
* @return 1 on success, -1 on failure
*/
-int getbflags(flag_t* res, unsigned int branch);
+int getbflagsval(unsigned int branch, flag_t* res);
/**
* Set the value of all branch flags at once for a given branch.
Module: sip-router
Branch: andrei/type_conversion
Commit: bb4d414574c35b1ba2c0497e19313b4cd000f775
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bb4d414…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Apr 28 19:54:03 2009 +0200
news: update (new operators, expr. eval behaviour a.s.o.)
---
NEWS | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/NEWS b/NEWS
index fade123..ed1ab96 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,33 @@ $Id$
sip-router changes
core:
+ - new operators eq, ne for string compares and ieq, ine for interger
+ compares. The names are not yet final (use them at your own risk).
+ Future version might use ==/!= only for ints (ieq/ine) and eq/ne for
+ strings (under debate).
+ They are almost equivalent to == or !=, but they force the conversion
+ of their operands (eq to string and ieq to int), allowing among other
+ things better type checking on startup and more optimizations.
+ Non equiv. examples: 0 == "" (true) is not equivalent to 0 eq ""
+ (false: it evaluates to "0" eq ""). "a" ieq "b" (true: (int)"a" is 0
+ and (int)"b" is 0) is not equivalent to "a" == "b" (false).
+ Note: internally == and != are converted on startup to eq/ne/ieq/ine
+ whenever possible (both operand types can be safely determined at
+ start time and they are the same).
+ - try to guess what the user wanted when operators that support multiple
+ types are used on different typed operands. In general convert the
+ the right operand to the type of the left operand and then perform the
+ operation. Exception: the left operand is undef.
+ This applies to the following operators: +, == and !=.
+ Special case: undef as left operand:
+ For +: undef + expr -> undef is converted to string => "" + expr.
+ For == and !=: undef == expr -> undef is converted to type_of expr.
+ If expr is undef, then undef == undef is true (internally is converted
+ to string).
+ - expression evaluation changes: auto-convert to interger or string
+ in function of the operators:
+ int(undef)==0, int("")==0, int("123")==123, int("abc")==0
+ str(undef)=="", str(123)=="123".
- new script operators: defined, strlen, strempty
defined expr - returns true if expr is defined, and false if not.
Note: only a standalone avp or pvar can be