Module: sip-router
Branch: master
Commit: 651603023f4fc46b25bc143d44415cd0acdf0a48
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6516030…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Feb 11 15:20:36 2010 +0100
dispatcher(k): weight based distribution
- new algorithm 9 for weight based distribution
- new column to hold attributes per destination
- for weight based distribution you have to set for each address in
destination set: weight=value, for example:
[setid address flags priority attributes]
2 sip:10.10.0.1:5080 0 2 weight=40
2 sip:10.10.0.2:5082 0 1 weight=60
- this will send 60% of the traffic to second address
- note that at startup the distribution is randomized, so traffic is
directed to first or second desintation alternatively but keeping
overall percentages
---
modules_k/dispatcher/dispatch.c | 248 ++++++++++++++++++++++++++++---------
modules_k/dispatcher/dispatch.h | 2 +
modules_k/dispatcher/dispatcher.c | 13 ++-
3 files changed, 203 insertions(+), 60 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=651…
Module: sip-router
Branch: master
Commit: 817b9c5cf1133cd9fe59624167b1af1da7461529
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=817b9c5…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Feb 10 21:30:11 2010 +0100
core: include only from/to tags when computing via branch value
- use only the to & from tags when computing the via branch value
in syn_branch==0 mode. This should improve interoperability with
broken implementations that don't keep the from & to headers
unchanged. Defining BRANCH_INCLUDE_FROMTO_BODY will revert to
the old behaviour.
- moved char_msg_val from parser/msg_parser.h to its own file
(it has nothing to do with parsing).
---
char_msg_val.h | 101 ++++++++++++++++++++++++++++++++++++++++++++++
forward.c | 1 +
modules/tm/h_table.c | 1 +
modules_k/exec/exec_hf.c | 1 +
modules_s/exec/exec_hf.c | 1 +
parser/msg_parser.h | 34 ---------------
6 files changed, 105 insertions(+), 34 deletions(-)
diff --git a/char_msg_val.h b/char_msg_val.h
new file mode 100644
index 0000000..9e20918
--- /dev/null
+++ b/char_msg_val.h
@@ -0,0 +1,101 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 iptelorg GmbH
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * char_msg_val.h
+ */
+/*
+ * History:
+ * --------
+ * 2010-02-10 moved from parser/msg_parser.h and added tag only mode
+ * by default (andrei)
+*/
+/** compute the characteristic value of a message.
+ * @file
+ * @ingroup core
+ */
+/* Defines:
+ * BRANCH_INCLUDE_FROMTO_BODY - if defined the old (pre 3.1) mode of
+ * including the full from & to bodies will be used (instead of only the
+ * tags).
+*/
+
+#ifndef __char_msg_val_h
+#define __char_msg_val_h
+
+#include "comp_defs.h"
+#include "compiler_opt.h"
+#include "str.h"
+#include "parser/msg_parser.h"
+#include "parser/parse_to.h"
+#include "parser/parse_from.h"
+#include "md5utils.h"
+
+/*! \brief calculate characteristic value of a message -- this value
+ is used to identify a transaction during the process of
+ reply matching
+ */
+inline static int char_msg_val( struct sip_msg *msg, char *cv )
+{
+ str src[8];
+
+ if (unlikely(!check_transaction_quadruple(msg))) {
+ LOG(L_ERR, "ERROR: can't calculate char_value due "
+ "to a parsing error\n");
+ memset( cv, '0', MD5_LEN );
+ return 0;
+ }
+
+#ifdef BRANCH_INCLUDE_FROMTO_BODY
+ /* use the from & to full bodies */
+ src[0]= msg->from->body;
+ src[1]= msg->to->body;
+#else
+ /* to body is automatically parsed (via check_transactionquadruple /
+ parse_header), but the from body has to be parsed manually */
+ if (msg->from->parsed==0){
+ /* parse from body */
+ if (unlikely(parse_from_header(msg) == -1)){
+ LOG(L_ERR, "error while parsing From header\n");
+ return 0;
+ }
+ }
+ /* use only the from & to tags */
+ src[0]=get_from(msg)->tag_value;
+ src[1]=get_to(msg)->tag_value;
+#endif
+ src[2]= msg->callid->body;
+ src[3]= msg->first_line.u.request.uri;
+ src[4]= get_cseq( msg )->number;
+
+ /* topmost Via is part of transaction key as well ! */
+ src[5]= msg->via1->host;
+ src[6]= msg->via1->port_str;
+ if (msg->via1->branch) {
+ src[7]= msg->via1->branch->value;
+ MD5StringArray ( cv, src, 8 );
+ } else {
+ MD5StringArray( cv, src, 7 );
+ }
+ return 1;
+}
+
+
+
+#endif /*__char_msg_val_h*/
+
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
diff --git a/forward.c b/forward.c
index 0971027..4b58f71 100644
--- a/forward.c
+++ b/forward.c
@@ -78,6 +78,7 @@
#include "hash_func.h"
#include "config.h"
#include "parser/msg_parser.h"
+#include "char_msg_val.h"
#include "route.h"
#include "events.h"
#include "dprint.h"
diff --git a/modules/tm/h_table.c b/modules/tm/h_table.c
index 2f18336..c860005 100644
--- a/modules/tm/h_table.c
+++ b/modules/tm/h_table.c
@@ -59,6 +59,7 @@
#include "../../ut.h"
#include "../../globals.h"
#include "../../error.h"
+#include "../../char_msg_val.h"
#include "defs.h"
#include "t_reply.h"
#include "t_cancel.h"
diff --git a/modules_k/exec/exec_hf.c b/modules_k/exec/exec_hf.c
index 58d10d5..37eaf27 100644
--- a/modules_k/exec/exec_hf.c
+++ b/modules_k/exec/exec_hf.c
@@ -49,6 +49,7 @@
#include "../../mem/mem.h"
#include "../../dprint.h"
#include "../../md5utils.h"
+#include "../../char_msg_val.h"
#include "exec_hf.h"
/* should be environment variables set by header fields ? */
diff --git a/modules_s/exec/exec_hf.c b/modules_s/exec/exec_hf.c
index f354190..b977834 100644
--- a/modules_s/exec/exec_hf.c
+++ b/modules_s/exec/exec_hf.c
@@ -57,6 +57,7 @@
#include "../../mem/mem.h"
#include "../../dprint.h"
#include "../../md5utils.h"
+#include "../../char_msg_val.h"
#include "exec_hf.h"
/* should be environment variables set by header fields ? */
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index c092f51..ca08284 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -398,40 +398,6 @@ inline static int check_transaction_quadruple( struct sip_msg* msg )
-/*! \brief calculate characteristic value of a message -- this value
- is used to identify a transaction during the process of
- reply matching
- */
-inline static int char_msg_val( struct sip_msg *msg, char *cv )
-{
- str src[8];
-
- if (!check_transaction_quadruple(msg)) {
- LOG(L_ERR, "ERROR: can't calculate char_value due "
- "to a parsing error\n");
- memset( cv, '0', MD5_LEN );
- return 0;
- }
-
- src[0]= msg->from->body;
- src[1]= msg->to->body;
- src[2]= msg->callid->body;
- src[3]= msg->first_line.u.request.uri;
- src[4]= get_cseq( msg )->number;
-
- /* topmost Via is part of transaction key as well ! */
- src[5]= msg->via1->host;
- src[6]= msg->via1->port_str;
- if (msg->via1->branch) {
- src[7]= msg->via1->branch->value;
- MD5StringArray ( cv, src, 8 );
- } else {
- MD5StringArray( cv, src, 7 );
- }
- return 1;
-}
-
-
/*! \brief returns a pointer to the begining of the msg's body
*/
inline static char* get_body(struct sip_msg *msg)
Module: sip-router
Branch: master
Commit: 54e17098b5efddf559e5b745e36a82f6027ffc91
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=54e1709…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Feb 10 21:48:00 2010 +0100
core: use the prev. via branch id if it's 3261
When computing the via branch value in syn_branch==0 mode, use the
previous via branch id and not the to_tag, from_tag, callid, ruri,
cseq number, via port and host, if the previous via branch id is
in rfc3261 format (begins with the magic cookie).
See rfc3261/16.11 P116 for more informations.
To revert to the old behaviour, define BRANCH_IGNORE_3261_VIA.
---
char_msg_val.h | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/char_msg_val.h b/char_msg_val.h
index 9e20918..e78bd9d 100644
--- a/char_msg_val.h
+++ b/char_msg_val.h
@@ -22,7 +22,7 @@
* History:
* --------
* 2010-02-10 moved from parser/msg_parser.h and added tag only mode
- * by default (andrei)
+ * by default (andrei)
*/
/** compute the characteristic value of a message.
* @file
@@ -32,6 +32,9 @@
* BRANCH_INCLUDE_FROMTO_BODY - if defined the old (pre 3.1) mode of
* including the full from & to bodies will be used (instead of only the
* tags).
+ * BRANCH_IGNORE_3261_VIA - if defined, no check and special/simpler handling
+ * of messages with 3261 cookies in the via branch will be made (same
+ * behaviour as in pre 3.1 versions).
*/
#ifndef __char_msg_val_h
@@ -59,7 +62,15 @@ inline static int char_msg_val( struct sip_msg *msg, char *cv )
memset( cv, '0', MD5_LEN );
return 0;
}
-
+#ifndef BRANCH_IGNORE_3261_VIA
+ if (likely(msg->via1->branch && msg->via1->branch->value.len>MCOOKIE_LEN &&
+ memcmp(msg->via1->branch->value.s, MCOOKIE, MCOOKIE_LEN)==0)){
+ /* 3261 branch cookie present => hash only the received branch ID */
+ src[0]=msg->via1->branch->value;
+ MD5StringArray ( cv, src, 1 );
+ return 1; /* success */
+ }
+#endif /* BRANCH_IGNORE_3261_VIA */
#ifdef BRANCH_INCLUDE_FROMTO_BODY
/* use the from & to full bodies */
src[0]= msg->from->body;
@@ -77,7 +88,7 @@ inline static int char_msg_val( struct sip_msg *msg, char *cv )
/* use only the from & to tags */
src[0]=get_from(msg)->tag_value;
src[1]=get_to(msg)->tag_value;
-#endif
+#endif /* BRANCH_INCLUDE_FROMTO_BODY */
src[2]= msg->callid->body;
src[3]= msg->first_line.u.request.uri;
src[4]= get_cseq( msg )->number;
@@ -85,7 +96,7 @@ inline static int char_msg_val( struct sip_msg *msg, char *cv )
/* topmost Via is part of transaction key as well ! */
src[5]= msg->via1->host;
src[6]= msg->via1->port_str;
- if (msg->via1->branch) {
+ if (likely(msg->via1->branch)) {
src[7]= msg->via1->branch->value;
MD5StringArray ( cv, src, 8 );
} else {
Hi, it would be great if TM implements RFC 3326 by adding a Reason header in
CANCEL. I explain the use cases:
1) Parallel forking:
- alice calls bob through Proxy.
- Proxy does parallel forking to two locations from which bob is registered
(bob1 and bob2).
- Both phones ring. After a while bob2 answers.
- Proxy generates a CANCEL for bob1 and includes a header:
Reason: SIP ;cause=200 ;text="Call completed elsewhere"
- By inspecting such header (cause=200) bob1 device decides not to include
this call in the list of "missed calls".
2) Propagating CANCEL + Reason from an application server or PBX.
- alice calls bob through PBX.
- The PBX "forkes" (no need to really fork as it's a B2BUA/UAC and could just
generate two different INVITE), and calls to bob's SIP phone and bob's mobile
(through a PSTN gateway).
- The INVITE to bob's SIP phone is sent to bob's inbound Proxy. The Proxy
routes the request to the location of bob.
- Bob human was out so answers the call in his mobile.
- The PBX sends a CANCEL to Proxy including the header:
Reason: SIP ;cause=200 ;text="Call completed elsewhere"
- Such CANCEL arrives to Proxy. As CANCEL is hop by hop the Proxy generates
its own CANCEL but due to local policy (i.e. the CANCEL comes from the trusted
PBX) it *propagates* the Reason header.
- Again bob's SIP phone receives the CANCEL with such Reason header and
decides not to include this call in the list of "missed calls".
This is very useful feature IMHO as bob won't waste time by calling to all of
those non real "missed" calls.
At implementation level I would consider the following:
- Case 1 doesn't require parameters or script decissions (IMHO) so it's safe
to add Reason header in a CANCEL when cancelling a branch (in parallel
forking).
- Case 2 requires a local policy as it wouldn't be safe to propagate any
Reason header coming in a CANCEL from any sender (imagine you receive a
malicius call at 5 o'clock in the night and the hacker added "Reason" header
to the CANCEL so you don't find that call in the missed calls list of the
phone).
- This local policy could be implemented as follows:
a) Enabling a flag in t_relay() that only makes sense for CANCEL rather than
INVITE, so:
if (is_method("CANCEL")) {
if ($si == MY_APPLICATION_SERVER_IP)
# Allow propagating "Reason" header.
t_relay(0x12);
else
t_relay();
}
or a explicit flag:
if (is_method("CANCEL")) {
if ($si == MY_APPLICATION_SERVER_IP)
setflag(FLAG_ALLOW_CANCEL_REASON);
t_relay();
}
As a side note, Asterisk does implement this Reason header when calls to
various phones for the same call. Also, this feature is implemented in
OpenSIPS TM module (case 1 is already implemented and case 2 will be
implemented soon).
Do you consider feasible implementing it? opinnions?
I would like to try it by myself, but being the serious TM module I would like
to know your opinnions first :)
Regards.
--
Iñaki Baz Castillo <ibc(a)aliax.net>
Module: sip-router
Branch: kamailio_3.0
Commit: 59907c49af12496af3d85e74ef52e67055cf610f
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=59907c4…
Author: Juha Heinanen <jh(a)tutpro.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Feb 10 07:15:24 2010 +0200
modules_k/permissions: group identifier must be positive integer
- Group Identifier in address permissions must have a positive integer
value.
(cherry picked from commit c67e72eb16f277eeae16182e15e0e8ebf319dce0)
---
modules_k/permissions/README | 4 ++--
modules_k/permissions/address.c | 1 +
modules_k/permissions/doc/permissions_admin.xml | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/modules_k/permissions/README b/modules_k/permissions/README
index a3406f2..ff0959f 100644
--- a/modules_k/permissions/README
+++ b/modules_k/permissions/README
@@ -276,8 +276,8 @@ Chapter 1. Admin Guide
(allow_source_address) or given as pvar arguments (allow_address).
Addresses stored in cached database table can be grouped together into
- one or more groups specified by a group identifier (unsigned integer).
- Group identifier is given as argument to allow_address and
+ one or more groups specified by a group identifier (positive integer
+ value). Group identifier is given as argument to allow_address and
allow_source_address functions.
1.5. Trusted Requests
diff --git a/modules_k/permissions/address.c b/modules_k/permissions/address.c
index e40e510..126c8d8 100644
--- a/modules_k/permissions/address.c
+++ b/modules_k/permissions/address.c
@@ -114,6 +114,7 @@ int reload_address_table(void)
val = ROW_VALUES(row + i);
if ((ROW_N(row + i) == 4) &&
(VAL_TYPE(val) == DB1_INT) && !VAL_NULL(val) &&
+ (VAL_INT(val) > 0) &&
(VAL_TYPE(val + 1) == DB1_STRING) && !VAL_NULL(val + 1) &&
inet_aton((char *)VAL_STRING(val + 1), &ip_addr) != 0 &&
(VAL_TYPE(val + 2) == DB1_INT) && !VAL_NULL(val + 2) &&
diff --git a/modules_k/permissions/doc/permissions_admin.xml b/modules_k/permissions/doc/permissions_admin.xml
index 4ad28b7..06512a9 100644
--- a/modules_k/permissions/doc/permissions_admin.xml
+++ b/modules_k/permissions/doc/permissions_admin.xml
@@ -179,7 +179,7 @@
<para>
Addresses stored in cached database table can be grouped
together into one or more groups specified by a group
- identifier (unsigned integer). Group
+ identifier (positive integer value). Group
identifier is given as argument to allow_address and
allow_source_address functions.
</para>