[sr-dev] git:hpw/branch_failure_route: core: Update get_branch() to return instance from appended branches
Hugh Waite
hugh.waite at crocodile-rcs.com
Wed Mar 27 15:41:14 CET 2013
Module: sip-router
Branch: hpw/branch_failure_route
Commit: 42a1548a57ec8e3a8779f1644347340c25aa1bdd
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=42a1548a57ec8e3a8779f1644347340c25aa1bdd
Author: Hugh Waite <hugh.waite at crocodile-rcs.com>
Committer: Hugh Waite <hugh.waite at crocodile-rcs.com>
Date: Wed Mar 27 11:44:08 2013 +0000
core: Update get_branch() to return instance from appended branches
- get_branch() and next_branch() updated
- modified select_core.c to use new function definition
---
dset.c | 18 +++++++++++++-----
dset.h | 4 ++--
select_core.c | 6 +++---
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/dset.c b/dset.c
index 5421d0a..296f7c4 100644
--- a/dset.c
+++ b/dset.c
@@ -216,7 +216,7 @@ void set_branch_iterator(int n)
char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri,
str* path, unsigned int *flags,
struct socket_info** force_socket,
- str *ruid)
+ str *ruid, str *instance)
{
if (i < nr_branches) {
*len = branches[i].len;
@@ -237,6 +237,10 @@ char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri,
ruid->len = branches[i].ruid_len;
ruid->s = (ruid->len)?branches[i].ruid:0;
}
+ if (instance) {
+ instance->len = branches[i].instance_len;
+ instance->s = (instance->len)?branches[i].instance:0;
+ }
return branches[i].uri;
} else {
*len = 0;
@@ -257,6 +261,10 @@ char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri,
ruid->s = 0;
ruid->len = 0;
}
+ if (instance) {
+ instance->s = 0;
+ instance->len = 0;
+ }
return 0;
}
}
@@ -268,12 +276,12 @@ char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri,
*/
char* next_branch(int* len, qvalue_t* q, str* dst_uri, str* path,
unsigned int* flags, struct socket_info** force_socket,
- str* ruid)
+ str* ruid, str *instance)
{
char* ret;
ret=get_branch(branch_iterator, len, q, dst_uri, path, flags,
- force_socket, ruid);
+ force_socket, ruid, instance);
if (likely(ret))
branch_iterator++;
return ret;
@@ -442,7 +450,7 @@ char* print_dset(struct sip_msg* msg, int* len)
crt_branch = get_branch_iterator();
init_branch_iterator();
- while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0, 0, 0))) {
+ while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0, 0, 0, 0))) {
cnt++;
*len += uri.len;
if (q != Q_UNSPECIFIED) {
@@ -483,7 +491,7 @@ char* print_dset(struct sip_msg* msg, int* len)
}
init_branch_iterator();
- while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0, 0, 0))) {
+ while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0, 0, 0, 0))) {
if (i) {
memcpy(p, CONTACT_DELIM, CONTACT_DELIM_LEN);
p += CONTACT_DELIM_LEN;
diff --git a/dset.h b/dset.h
index 2eca07f..3741fcb 100644
--- a/dset.h
+++ b/dset.h
@@ -140,12 +140,12 @@ void set_branch_iterator(int n);
*/
char* next_branch(int* len, qvalue_t* q, str* dst_uri, str* path,
unsigned int* flags, struct socket_info** force_socket,
- str *ruid);
+ str *ruid, str *instance);
char* get_branch( unsigned int i, int* len, qvalue_t* q, str* dst_uri,
str* path, unsigned int *flags,
struct socket_info** force_socket,
- str* ruid);
+ str* ruid, str *instance);
/*! \brief
* Empty the array of branches
diff --git a/select_core.c b/select_core.c
index 68fa5ba..130a9fd 100644
--- a/select_core.c
+++ b/select_core.c
@@ -1621,7 +1621,7 @@ int select_branch_uri(str* res, select_t* s, struct sip_msg* msg) {
char *c;
init_branch_iterator();
len = 0;
- while ((c = next_branch(&l, &q, &dst_uri, 0, 0, 0, 0))) {
+ while ((c = next_branch(&l, &q, &dst_uri, 0, 0, 0, 0, 0))) {
if (s->params[SEL_POS].v.i & SEL_BRANCH_DST_URI) {
l = dst_uri.len;
@@ -1645,7 +1645,7 @@ int select_branch_uri(str* res, select_t* s, struct sip_msg* msg) {
init_branch_iterator();
res->len = 0;
n = 0;
- while ((c = next_branch(&l, &q, &dst_uri, 0, 0, 0, 0))) {
+ while ((c = next_branch(&l, &q, &dst_uri, 0, 0, 0, 0, 0))) {
if (s->params[SEL_POS].v.i & SEL_BRANCH_DST_URI) {
l = dst_uri.len;
c = dst_uri.s;
@@ -1687,7 +1687,7 @@ int select_branch_uri(str* res, select_t* s, struct sip_msg* msg) {
if (n < 0 || n >= nr_branches)
return -1;
init_branch_iterator();
- for (; (c = next_branch(&l, &q, &dst_uri, 0, 0, 0, 0)) && n; n--);
+ for (; (c = next_branch(&l, &q, &dst_uri, 0, 0, 0, 0, 0)) && n; n--);
if (!c) return 1;
if (s->params[SEL_POS].v.i & SEL_BRANCH_DST_URI) {
More information about the sr-dev
mailing list