[sr-dev] git:pd/outbound: modules/tm: updated t_serial to store/retrieve ruid

Peter Dunkley peter.dunkley at crocodile-rcs.com
Fri Mar 15 00:17:08 CET 2013


Module: sip-router
Branch: pd/outbound
Commit: 87e624ffe1e66104b04d34bd2102f458f5785bf0
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=87e624ffe1e66104b04d34bd2102f458f5785bf0

Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date:   Thu Mar 14 23:16:27 2013 +0000

modules/tm: updated t_serial to store/retrieve ruid

---

 modules/tm/t_serial.c |   56 ++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/modules/tm/t_serial.c b/modules/tm/t_serial.c
index 1eb722a..570d02c 100644
--- a/modules/tm/t_serial.c
+++ b/modules/tm/t_serial.c
@@ -50,6 +50,7 @@ struct contact {
     str path;
     struct socket_info* sock;
     str instance;
+    str ruid;
     unsigned int flags;
     unsigned short q_flag;
     struct contact *next;
@@ -92,9 +93,11 @@ static str sock_name = {"sock", 4};
 static str instance_name = {"instance", 8};
 static str flags_name = {"flags", 5};
 static str q_flag_name = {"q_flag", 6};
+static str ruid_name = {"ruid", 4};
 
 void add_contacts_avp(str *uri, str *dst_uri, str *path, str *sock_str,
-		      unsigned int flags, unsigned int q_flag, str *instance)
+		      unsigned int flags, unsigned int q_flag, str *instance,
+		      str *ruid)
 {
     sr_xavp_t *record;
     sr_xval_t val;
@@ -136,6 +139,12 @@ void add_contacts_avp(str *uri, str *dst_uri, str *path, str *sock_str,
 	xavp_add_value(&instance_name, &val, &record);
     }
 
+    if (ruid->len > 0) {
+	val.type = SR_XTYPE_STR;
+	val.v.s = *ruid;
+	xavp_add_value(&ruid_name, &val, &record);
+    }
+
     val.type = SR_XTYPE_XAVP;
     val.v.xavp = record;
     xavp_add_value(&contacts_avp, &val, NULL);
@@ -192,6 +201,7 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
 	contacts->path = msg->path_vec;
 	contacts->q = get_ruri_q();
 	contacts->instance = msg->instance;
+        contacts->ruid = msg->ruid;
 	first_idx = 0;
     } else {
 	/* Insert first branch to first contact */
@@ -207,6 +217,8 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
 	contacts->q = branch->q;
 	contacts->instance.s = branch->instance;
 	contacts->instance.len = branch->instance_len;
+        contacts->ruid.s = branch->ruid;
+        contacts->ruid.len = branch->ruid_len;
 	first_idx = 1;
     }
 
@@ -233,6 +245,8 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
 	next->q = branch->q;
 	next->instance.s = branch->instance;
 	next->instance.len = branch->instance_len;
+	next->ruid.s = branch->ruid;
+	next->ruid.len = branch->ruid_len;
 	next->next = (struct contact *)0;
 
 	prev = (struct contact *)0;
@@ -283,7 +297,7 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
 
 	add_contacts_avp(&(curr->uri), &(curr->dst_uri), &(curr->path),
 			 &sock_str, curr->flags, curr->q_flag,
-			 &(curr->instance));
+			 &(curr->instance), &(curr->ruid));
 
 	curr = curr->next;
     }
@@ -298,7 +312,7 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
 }
 
 void add_contact_flows_avp(str *uri, str *dst_uri, str *path, str *sock_str,
-			   unsigned int flags, str *instance)
+			   unsigned int flags, str *instance, str *ruid)
 {
     sr_xavp_t *record;
     sr_xval_t val;
@@ -332,6 +346,12 @@ void add_contact_flows_avp(str *uri, str *dst_uri, str *path, str *sock_str,
 	xavp_add_value(&instance_name, &val, &record);
     }
 
+    if (ruid->len > 0) {
+	val.type = SR_XTYPE_STR;
+	val.v.s = *ruid;
+	xavp_add_value(&ruid_name, &val, &record);
+    }
+
     val.type = SR_XTYPE_INT;
     val.v.i = flags;
     xavp_add_value(&flags_name, &val, &record);
@@ -354,7 +374,7 @@ void add_contact_flows_avp(str *uri, str *dst_uri, str *path, str *sock_str,
  * there was nothing to do. Returns -1 in case of an error. */
 int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 {
-    str uri, dst_uri, path, instance, host, sock_str;
+    str uri, dst_uri, path, instance, host, sock_str, ruid;
     struct socket_info *sock;
     unsigned int flags, q_flag;
     sr_xavp_t *xavp_list, *xavp, *prev_xavp, *vavp;
@@ -443,6 +463,9 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 	il->next = (struct instance_list *)0;
     }
 
+    vavp = xavp_get(&ruid_name, xavp->val.v.xavp);
+    ruid = vavp->val.v.s;
+
     /* Rewrite Request-URI */
     rewrite_uri(msg, &uri);
 
@@ -462,6 +485,8 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 
     setbflagsval(0, flags);
 
+    set_ruid(msg, &ruid);
+
     /* Check if there was only one contact at this priority */
     if (q_flag) {
 	xavp_rm(xavp, NULL);
@@ -535,7 +560,7 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 	    }
 	    if (ilp) {
 		add_contact_flows_avp(&uri, &dst_uri, &path, &sock_str,
-				      flags, &instance);
+				      flags, &instance, &ruid);
 		goto check_q_flag;
 	    }
 	    if (!q_flag) {
@@ -560,8 +585,11 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 	    }
 	}
 
-	if (append_branch(msg, &uri, &dst_uri, &path, 0, flags, sock, 0, 0)
-	    != 1) {
+        vavp = xavp_get(&ruid_name, xavp->val.v.xavp);
+        ruid = vavp->val.v.s;
+
+	if (append_branch(msg, &uri, &dst_uri, &path, 0, flags, sock, 0, 0,
+			  &ruid) != 1) {
 	    LM_ERR("appending branch failed\n");
 	    free_instance_list(il);
 	    xavp_destroy_list(&xavp_list);
@@ -596,7 +624,7 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
  * there was nothing to do. Returns -1 in case of an error. */
 int t_next_contact_flows(struct sip_msg* msg, char* key, char* value)
 {
-    str uri, dst_uri, path, instance, host;
+    str uri, dst_uri, path, instance, host, ruid;
     struct socket_info *sock;
     unsigned int flags;
     sr_xavp_t *xavp_list, *xavp, *next_xavp, *vavp;
@@ -683,6 +711,9 @@ int t_next_contact_flows(struct sip_msg* msg, char* key, char* value)
 	il->next = (struct instance_list *)0;
     }
 
+    vavp = xavp_get(&ruid_name, xavp->val.v.xavp);
+    ruid = vavp->val.v.s;
+
     /* Rewrite Request-URI */
     rewrite_uri(msg, &uri);
 
@@ -700,6 +731,8 @@ int t_next_contact_flows(struct sip_msg* msg, char* key, char* value)
 
     set_force_socket(msg, sock);
 
+    set_ruid(msg, &ruid);
+
     setbflagsval(0, flags);
 
     /* Append branches until out of branches. */
@@ -793,8 +826,11 @@ int t_next_contact_flows(struct sip_msg* msg, char* key, char* value)
 	vavp = xavp_get(&flags_name, xavp->val.v.xavp);
 	flags = vavp->val.v.i;
 
-	if (append_branch(msg, &uri, &dst_uri, &path, 0, flags, sock, 0, 0)
-	    != 1) {
+        vavp = xavp_get(&ruid_name, xavp->val.v.xavp);
+        ruid = vavp->val.v.s;
+
+	if (append_branch(msg, &uri, &dst_uri, &path, 0, flags, sock, 0, 0,
+			  &ruid) != 1) {
 	    LM_ERR("appending branch failed\n");
 	    free_instance_list(il);
 	    xavp_destroy_list(&xavp_list);




More information about the sr-dev mailing list