Module: sip-router
Branch: andrei/path
Commit: c43dc0cd35eff000a2eb7e40c65d85367c58e412
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c43dc0c…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Sep 4 15:09:08 2009 +0200
core: append_branch & next_branch api changes
- added path, branch flags support and switched the parameters to
str for append_branch and next_branch. append_branch is now
exactly the same as km_append_branch.
- added ser_append_branch for compatibility with ser modules which
don't need the extra parameters.
- updated core code to use the modified api.
---
action.c | 2 +-
dset.c | 152 ++++++++++++++++-----------------------------------------
dset.h | 46 +++++++++++++----
select_core.c | 6 +-
4 files changed, 83 insertions(+), 123 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=c43…
Revision: 5924
http://openser.svn.sourceforge.net/openser/?rev=5924&view=rev
Author: henningw
Date: 2009-09-07 10:36:27 +0000 (Mon, 07 Sep 2009)
Log Message:
-----------
- bug fix: protect against user error when backup is the same as initial host
- patch from Marius Zbihlei
Modified Paths:
--------------
branches/1.5/modules/carrierroute/cr_fifo.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Module: sip-router
Branch: master
Commit: 3b70140725f180026e30d327a0fb81b3e8902905
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3b70140…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Mon Sep 7 10:19:38 2009 +0200
cr: add random distribution function
- add a random distribution function to cr
- patch from Marius Zbihlei, marius dot zbihlei at 1and1 dot ro
---
modules/carrierroute/README | 6 +++---
modules/carrierroute/cr_fixup.c | 2 ++
modules/carrierroute/doc/carrierroute_admin.xml | 6 +++---
modules/carrierroute/prime_hash.c | 19 +++++++++++++++++++
modules/carrierroute/prime_hash.h | 2 ++
5 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/modules/carrierroute/README b/modules/carrierroute/README
index 7192926..0ab8268 100644
--- a/modules/carrierroute/README
+++ b/modules/carrierroute/README
@@ -493,7 +493,7 @@ hash_source, descavp)
be a contiguous range starting at 1, limited by the
configuration parameter max_targets. Possible values for
hash_source are: call_id, from_uri, from_user, to_uri and
- to_user.
+ to_user and rand.
* decsavp - Name of the AVP where to store the description.
This parameter is optional.
@@ -537,8 +537,8 @@ rewrite_user, hash_source, descavp)
* hash_source - The hash values of the destination set must
be a contiguous range starting at 1, limited by the
configuration parameter max_targets. Possible values for
- hash_source are: call_id, from_uri, from_user, to_uri and
- to_user.
+ hash_source are: call_id, from_uri, from_user, to_uri ,
+ to_user and rand
* descavp - Name of the AVP where to store the description.
This parameter is optional.
diff --git a/modules/carrierroute/cr_fixup.c b/modules/carrierroute/cr_fixup.c
index f832af4..94632f6 100644
--- a/modules/carrierroute/cr_fixup.c
+++ b/modules/carrierroute/cr_fixup.c
@@ -103,6 +103,8 @@ static enum hash_source hash_fixup(const char * my_hash_source) {
return shs_to_uri;
} else if (strcasecmp("to_user", my_hash_source) == 0) {
return shs_to_user;
+ } else if (strcasecmp("rand", my_hash_source) == 0) {
+ return shs_rand;
} else {
return shs_error;
}
diff --git a/modules/carrierroute/doc/carrierroute_admin.xml b/modules/carrierroute/doc/carrierroute_admin.xml
index 7814d83..656ff04 100644
--- a/modules/carrierroute/doc/carrierroute_admin.xml
+++ b/modules/carrierroute/doc/carrierroute_admin.xml
@@ -480,8 +480,8 @@ cr_tree_rewrite_uri(tree, domain)
<para><emphasis>hash_source</emphasis> - The hash values of the destination set must
be a contiguous range starting at 1, limited by the
configuration parameter max_targets. Possible values for
- hash_source are: call_id, from_uri, from_user, to_uri
- and to_user.
+ hash_source are: call_id, from_uri, from_user, to_uri,
+ to_user and rand
</para>
</listitem>
<listitem>
@@ -551,7 +551,7 @@ cr_tree_rewrite_uri(tree, domain)
be a contiguous range starting at 1, limited by the
configuration parameter max_targets. Possible values for
hash_source are: call_id, from_uri, from_user, to_uri
- and to_user.
+ to_user and rand
</para>
</listitem>
<listitem>
diff --git a/modules/carrierroute/prime_hash.c b/modules/carrierroute/prime_hash.c
index 8bb9579..25819c5 100644
--- a/modules/carrierroute/prime_hash.c
+++ b/modules/carrierroute/prime_hash.c
@@ -34,9 +34,13 @@
#include "../../lib/kcore/km_crc.h"
#include <ctype.h>
+#include <stdio.h> /* for snprintf */
+#include <stdlib.h> /* for rand */
#include "prime_hash.h"
+#define CR_RANDBUF_S 20
+static char cr_randbuf[CR_RANDBUF_S];
static int determine_source(struct sip_msg *msg, enum hash_source source,
str *source_string);
@@ -44,6 +48,7 @@ static int validate_msg(struct sip_msg * msg);
static int determine_call_id (struct sip_msg *msg, str *source_string);
static int determine_fromto_uri (struct to_body *fromto, str *source_string);
static int determine_fromto_user (struct to_body *fromto, str *source_string);
+static int determine_fromrand(str* source_string);
static int first_token (str *source_string);
@@ -56,6 +61,7 @@ int hash_func (struct sip_msg * msg,
if(determine_source (msg, source, &source_string) == -1) {
return -1;
}
+
crc32_uint(&source_string, &hash);
ret = hash % denominator;
@@ -128,6 +134,8 @@ static int determine_source (struct sip_msg *msg, enum hash_source source,
return determine_fromto_uri (get_to(msg), source_string);
case shs_to_user:
return determine_fromto_user (get_to(msg), source_string);
+ case shs_rand:
+ return determine_fromrand(source_string); /* msg is not needed */
default:
LM_ERR("unknown hash source %i.\n",
(int) source);
@@ -190,6 +198,17 @@ static int determine_fromto_user (struct to_body *fromto, str *source_string) {
return 0;
}
+static int determine_fromrand(str* source_string){
+
+ snprintf(&cr_randbuf[0], CR_RANDBUF_S , "%d", rand());
+
+ LM_NOTICE("randbuf is %s\n", cr_randbuf);
+ source_string->s = cr_randbuf;
+ source_string->len = strlen(source_string->s);
+
+ return 0;
+}
+
static int first_token (str *source_string) {
size_t len;
diff --git a/modules/carrierroute/prime_hash.h b/modules/carrierroute/prime_hash.h
index b059742..b383046 100644
--- a/modules/carrierroute/prime_hash.h
+++ b/modules/carrierroute/prime_hash.h
@@ -45,6 +45,7 @@
* - \b shs_from_user the username part of the URI in the From header field
* - \b shs_to_uri the entire URI in the To header field
* - \b shs_to_user the username part of the URI in the To header field
+ * - \b shs_rand some random data which is not related to any header field
* - \b shs_error no hash specified
*/
enum hash_source {
@@ -53,6 +54,7 @@ enum hash_source {
shs_from_user,
shs_to_uri,
shs_to_user,
+ shs_rand,
shs_error
};
Module: sip-router
Branch: master
Commit: 8dc53feb5a6b72d9f3ebf934fed9564d4e884ed5
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8dc53fe…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Mon Sep 7 10:34:58 2009 +0200
cr: new function 'cr_nofallback_route'
- add new function 'cr_nofallback_route' which behaves exactly like
the existing 'cr_prime_route' function but uses the standard CRC32
hash instead of this prime function to provide an path away from
this function
- mark 'cr_prime_route' function as obselete in docs
- patch from Carsten Gross, carsten dot gross at 1und1 dot de
---
modules/carrierroute/README | 1211 +++++++++++++----------
modules/carrierroute/carrierroute.c | 14 +-
modules/carrierroute/cr_func.c | 47 +-
modules/carrierroute/cr_func.h | 22 +
modules/carrierroute/doc/carrierroute_admin.xml | 75 ++
5 files changed, 812 insertions(+), 557 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=8dc…