Browse Source

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
Hugh Waite 12 years ago
parent
commit
42a1548a57
3 changed files with 18 additions and 10 deletions
  1. 13 5
      dset.c
  2. 2 2
      dset.h
  3. 3 3
      select_core.c

+ 13 - 5
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,
 char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri,
 		 str* path, unsigned int *flags,
 		 str* path, unsigned int *flags,
 		 struct socket_info** force_socket,
 		 struct socket_info** force_socket,
-		 str *ruid)
+		 str *ruid, str *instance)
 {
 {
 	if (i < nr_branches) {
 	if (i < nr_branches) {
 		*len = branches[i].len;
 		*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->len = branches[i].ruid_len;
 			ruid->s = (ruid->len)?branches[i].ruid:0;
 			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;
 		return branches[i].uri;
 	} else {
 	} else {
 		*len = 0;
 		*len = 0;
@@ -257,6 +261,10 @@ char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri,
 			ruid->s = 0;
 			ruid->s = 0;
 			ruid->len = 0;
 			ruid->len = 0;
 		}
 		}
+		if (instance) {
+			instance->s = 0;
+			instance->len = 0;
+		}
 		return 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,
 char* next_branch(int* len, qvalue_t* q, str* dst_uri, str* path,
 		  unsigned int* flags, struct socket_info** force_socket,
 		  unsigned int* flags, struct socket_info** force_socket,
-		  str* ruid)
+		  str* ruid, str *instance)
 {
 {
 	char* ret;
 	char* ret;
 	
 	
 	ret=get_branch(branch_iterator, len, q, dst_uri, path, flags,
 	ret=get_branch(branch_iterator, len, q, dst_uri, path, flags,
-		       force_socket, ruid);
+		       force_socket, ruid, instance);
 	if (likely(ret))
 	if (likely(ret))
 		branch_iterator++;
 		branch_iterator++;
 	return ret;
 	return ret;
@@ -442,7 +450,7 @@ char* print_dset(struct sip_msg* msg, int* len)
 	crt_branch = get_branch_iterator();
 	crt_branch = get_branch_iterator();
 
 
 	init_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++;
 		cnt++;
 		*len += uri.len;
 		*len += uri.len;
 		if (q != Q_UNSPECIFIED) {
 		if (q != Q_UNSPECIFIED) {
@@ -483,7 +491,7 @@ char* print_dset(struct sip_msg* msg, int* len)
 	}
 	}
 
 
 	init_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))) {
 		if (i) {
 		if (i) {
 			memcpy(p, CONTACT_DELIM, CONTACT_DELIM_LEN);
 			memcpy(p, CONTACT_DELIM, CONTACT_DELIM_LEN);
 			p += CONTACT_DELIM_LEN;
 			p += CONTACT_DELIM_LEN;

+ 2 - 2
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,
 char* next_branch(int* len, qvalue_t* q, str* dst_uri, str* path,
 		  unsigned int* flags, struct socket_info** force_socket,
 		  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,
 char* get_branch( unsigned int i, int* len, qvalue_t* q, str* dst_uri,
 		  str* path, unsigned int *flags,
 		  str* path, unsigned int *flags,
 		  struct socket_info** force_socket,
 		  struct socket_info** force_socket,
-		  str* ruid);
+		  str* ruid, str *instance);
 
 
 /*! \brief
 /*! \brief
  * Empty the array of branches
  * Empty the array of branches

+ 3 - 3
select_core.c

@@ -1621,7 +1621,7 @@ int select_branch_uri(str* res, select_t* s, struct sip_msg* msg) {
 		char *c;
 		char *c;
 		init_branch_iterator();
 		init_branch_iterator();
 		len = 0;
 		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) {
 			if (s->params[SEL_POS].v.i & SEL_BRANCH_DST_URI) {
 				l = dst_uri.len;
 				l = dst_uri.len;
@@ -1645,7 +1645,7 @@ int select_branch_uri(str* res, select_t* s, struct sip_msg* msg) {
 		init_branch_iterator();
 		init_branch_iterator();
 		res->len = 0;
 		res->len = 0;
 		n = 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) {
 			if (s->params[SEL_POS].v.i & SEL_BRANCH_DST_URI) {
 				l = dst_uri.len;
 				l = dst_uri.len;
 				c = dst_uri.s;
 				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) 
 		if (n < 0 || n >= nr_branches) 
 			return -1;
 			return -1;
 		init_branch_iterator();
 		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 (!c) return 1;
 		
 		
 		if (s->params[SEL_POS].v.i & SEL_BRANCH_DST_URI) {
 		if (s->params[SEL_POS].v.i & SEL_BRANCH_DST_URI) {