Browse Source

core and several modules: instance and reg_id in branch_t

- added instance and reg_id fields to branch_t
- added instance and reg_id arguments to append_branch function
- modified append_branch calls in core and several modules
- did not touch obsolete or modules_s modules (which are to be
  removed from next release)
Juha Heinanen 13 years ago
parent
commit
571e4e3fce

+ 3 - 2
action.c

@@ -507,8 +507,9 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
 			}
 			getbflagsval(0, (flag_t*)&flags);
 			ret=append_branch(msg, &a->val[0].u.str, &msg->dst_uri,
-								&msg->path_vec, a->val[1].u.number,
-								(flag_t)flags, msg->force_send_socket);
+					  &msg->path_vec, a->val[1].u.number,
+					  (flag_t)flags, msg->force_send_socket,
+					  0, 0);
 			/* if the uri is the ruri and q was also not changed, mark
 			   ruri as consumed, to avoid having an identical branch */
 			if ((a->val[0].u.str.s == 0 || a->val[0].u.str.len == 0) &&

+ 4 - 2
config.h

@@ -73,6 +73,8 @@
 
 #define MAX_PATH_SIZE 256 		/*!< Maximum length of path header buffer */
 
+#define MAX_INSTANCE_SIZE 256 		/*!< Maximum length of +sip.instance contact header param value buffer */
+
 #define MY_VIA "Via: SIP/2.0/UDP "
 #define MY_VIA_LEN (sizeof(MY_VIA) - 1)
 
@@ -85,11 +87,11 @@
 #define CONTENT_LENGTH "Content-Length: "
 #define CONTENT_LENGTH_LEN (sizeof(CONTENT_LENGTH)-1)
 
-#define USER_AGENT "User-Agent: " NAME \
+#define USER_AGENT "User-Agent: OpenXg SIP Proxy "\
 		" (" VERSION " (" ARCH "/" OS_QUOTED "))"
 #define USER_AGENT_LEN (sizeof(USER_AGENT)-1)
 
-#define SERVER_HDR "Server: " NAME \
+#define SERVER_HDR "Server: OpenXg SIP Proxy "\
 		" (" VERSION " (" ARCH "/" OS_QUOTED "))"
 #define SERVER_HDR_LEN (sizeof(SERVER_HDR)-1)
 

+ 26 - 5
dset.c

@@ -214,8 +214,8 @@ void set_branch_iterator(int n)
  * more branches
  */
 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* path, unsigned int *flags,
+		 struct socket_info** force_socket)
 {
 	if (i < nr_branches) {
 		*len = branches[i].len;
@@ -258,12 +258,12 @@ char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri,
  * 0 is returned if there are no more branches
  */
 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)
 {
 	char* ret;
 	
 	ret=get_branch(branch_iterator, len, q, dst_uri, path, flags,
-					force_socket);
+		       force_socket);
 	if (likely(ret))
 		branch_iterator++;
 	return ret;
@@ -295,7 +295,9 @@ void clear_branches(void)
  * @return  <0 (-1) on failure, 1 on success (script convention).
  */
 int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
-		qvalue_t q, unsigned int flags, struct socket_info* force_socket)
+		  qvalue_t q, unsigned int flags,
+		  struct socket_info* force_socket,
+		  str* instance, unsigned int reg_id)
 {
 	str luri;
 
@@ -360,6 +362,25 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
 	branches[nr_branches].force_send_socket = force_socket;
 	branches[nr_branches].flags = flags;
 
+	/* copy instance string */
+	if (unlikely(instance && instance->len && instance->s)) {
+		if (unlikely(instance->len > MAX_INSTANCE_SIZE - 1)) {
+			LOG(L_ERR, "too long instance: %.*s\n",
+			    instance->len, instance->s);
+			return -1;
+		}
+		memcpy(branches[nr_branches].instance, instance->s,
+		       instance->len);
+		branches[nr_branches].instance[instance->len] = 0;
+		branches[nr_branches].instance_len = instance->len;
+	} else {
+		branches[nr_branches].instance[0] = '\0';
+		branches[nr_branches].instance_len = 0;
+	}
+
+	/* copy reg_id */
+	branches[nr_branches].reg_id = reg_id;
+
 	nr_branches++;
 	return 1;
 }

+ 24 - 19
dset.h

@@ -59,6 +59,13 @@ struct branch
         * contact within the array */
     struct socket_info* force_send_socket;
 
+    /* +sip.instance contact header param value */
+    char instance[MAX_INSTANCE_SIZE];
+    unsigned int instance_len;
+
+    /* reg-id contact header param value */
+    unsigned int reg_id;
+
     /* Branch flags */
     flag_t flags;
 };
@@ -79,29 +86,30 @@ int drop_sip_branch(int idx);
  * Add a new branch to current transaction 
  */
 int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
-					 qvalue_t q, unsigned int flags,
-					 struct socket_info* force_socket);
+		  qvalue_t q, unsigned int flags,
+		  struct socket_info* force_socket,
+		  str* instance, unsigned int reg_id);
 
 /*! \brief kamailio compatible version */
 #define km_append_branch(msg, uri, dst_uri, path, q, flags, force_socket) \
-	append_branch(msg, uri, dst_uri, path, q, flags, force_socket)
+    append_branch(msg, uri, dst_uri, path, q, flags, force_socket, 0, 0);
 
 /*! \brief ser compatible append_branch version.
  *  append_branch version compatible with ser: no path or branch flags support
  *  and no str parameters.
  */
 static inline int ser_append_branch(struct sip_msg* msg,
-									char* uri, int uri_len,
-									char* dst_uri, int dst_uri_len,
-									qvalue_t q,
-									struct socket_info* force_socket)
+				    char* uri, int uri_len,
+				    char* dst_uri, int dst_uri_len,
+				    qvalue_t q,
+				    struct socket_info* force_socket)
 {
-	str s_uri, s_dst_uri;
-	s_uri.s=uri;
-	s_uri.len=uri_len;
-	s_dst_uri.s=dst_uri;
-	s_dst_uri.len=dst_uri_len;
-	return append_branch(msg, &s_uri, &s_dst_uri, 0, q, 0, force_socket);
+    str s_uri, s_dst_uri;
+    s_uri.s=uri;
+    s_uri.len=uri_len;
+    s_dst_uri.s=dst_uri;
+    s_dst_uri.len=dst_uri_len;
+    return append_branch(msg, &s_uri, &s_dst_uri, 0, q, 0, force_socket, 0, 0);
 }
 
 
@@ -126,14 +134,11 @@ void set_branch_iterator(int n);
  *  *len) or 0 if there are no more branches.
  */
 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);
 
 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* path, unsigned int *flags,
+		  struct socket_info** force_socket);
 
 /*! \brief
  * Empty the array of branches

+ 3 - 2
modules/avpops/avpops_impl.c

@@ -998,7 +998,8 @@ int ops_pushto_avp (struct sip_msg* msg, struct fis_param* dst,
 			{
 				/* if is not the first modification, push the current uri as
 				 * branch */
-				if (append_branch( msg, 0, 0, 0, Q_UNSPECIFIED, 0, 0)!=1 )
+			    if (append_branch( msg, 0, 0, 0, Q_UNSPECIFIED,
+					       0, 0, 0, 0) != 1)
 				{
 					LM_ERR("append_branch action failed\n");
 					goto error;
@@ -1025,7 +1026,7 @@ int ops_pushto_avp (struct sip_msg* msg, struct fis_param* dst,
 			ruri_mark_new(); /* re-use uri for serial forking */
 		} else if (dst->opd&AVPOPS_USE_BRANCH) {
 			if (append_branch( msg, &val, 0, 0, Q_UNSPECIFIED, 0,
-								msg->force_send_socket)!=1 )
+					   msg->force_send_socket, 0, 0) != 1)
 			{
 				LM_ERR("append_branch action failed\n");
 				goto error;

+ 2 - 2
modules/corex/corex_lib.c

@@ -70,8 +70,8 @@ int corex_append_branch(sip_msg_t *msg, gparam_t *pu, gparam_t *pq)
 
 	getbflagsval(0, &branch_flags);
 	ret = append_branch(msg, (uri.len>0)?&uri:0, &msg->dst_uri,
-			&msg->path_vec, q, branch_flags,
-			msg->force_send_socket);
+			    &msg->path_vec, q, branch_flags,
+			    msg->force_send_socket, 0, 0);
 
 
 	if(uri.len<=0)

+ 1 - 1
modules/dialplan/dialplan.c

@@ -295,7 +295,7 @@ static int dp_update(struct sip_msg * msg, pv_spec_t * src, pv_spec_t * dest,
 
 	if(is_route_type(FAILURE_ROUTE)
 			&& (dest->type==PVT_RURI || dest->type==PVT_RURI_USERNAME)) {
-		if (append_branch(msg, 0, 0, 0, Q_UNSPECIFIED, 0, 0)!=1 ){
+	    if (append_branch(msg, 0, 0, 0, Q_UNSPECIFIED, 0, 0, 0, 0) != 1) {
 			LM_ERR("append_branch action failed\n");
 			return -1;
 		}

+ 3 - 2
modules/enum/enum.c

@@ -687,7 +687,7 @@ int do_query(struct sip_msg* _msg, char *user, char *name, str *service) {
 		q = q - 10;
 		curr_prio = priority;
 	    }
-	    if (append_branch(_msg, &result, 0, 0, q, 0, 0) == -1) {
+	    if (append_branch(_msg, &result, 0, 0, q, 0, 0, 0, 0) == -1) {
 		goto done;
 	    }
 	}
@@ -1137,7 +1137,8 @@ int enum_pv_query_3(struct sip_msg* _msg, char* _sp, char* _suffix,
 				q = q - 10;
 				curr_prio = priority;
 			}
-			if (append_branch(_msg, &result, 0, 0, q, 0, 0) == -1) {
+			if (append_branch(_msg, &result, 0, 0, q, 0, 0, 0, 0)
+			    == -1) {
 				goto done;
 			}
 		}

+ 1 - 1
modules/tm/t_serial.c

@@ -444,7 +444,7 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 	    return -1;
 	}
 
-	if (append_branch(msg, &uri, &dst, &path, 0, flags, sock) != 1) {
+	if (append_branch(msg, &uri, &dst, &path, 0, flags, sock, 0, 0) != 1) {
 	    LM_ERR("appending branch failed\n");
 	    destroy_avp(avp);
 	    return -1;

+ 2 - 1
modules_k/alias_db/alookup.c

@@ -201,7 +201,8 @@ int alias_db_lookup(struct sip_msg* _msg, str table_s)
 				break;
 		} else {
 			user_s.s = useruri_buf;
-			if (append_branch(_msg, &user_s, 0, 0, MIN_Q, 0, 0) == -1)
+			if (append_branch(_msg, &user_s, 0, 0, MIN_Q, 0, 0,
+					  0, 0) == -1)
 			{
 				LM_ERR("error while appending branches\n");
 				goto err_server;

+ 5 - 3
modules_k/cpl-c/cpl_sig.c

@@ -90,9 +90,11 @@ int cpl_proxy_to_loc_set( struct sip_msg *msg, struct location **locs,
 		bflags = ((*locs)->flags&CPL_LOC_NATED) ? cpl_fct.ulb.nat_flag : 0 ;
 		LM_DBG("appending branch <%.*s>, flags %d\n",
 			(*locs)->addr.uri.len, (*locs)->addr.uri.s, bflags);
-		if(append_branch(msg, &(*locs)->addr.uri, &(*locs)->addr.received, 0,
-						 Q_UNSPECIFIED, bflags, 0)==-1){
-			LM_ERR("failed when appending branch <%s>\n",(*locs)->addr.uri.s);
+		if(append_branch(msg, &(*locs)->addr.uri,
+				 &(*locs)->addr.received, 0,
+				 Q_UNSPECIFIED, bflags, 0, 0, 0)==-1){
+			LM_ERR("failed when appending branch <%s>\n",
+			       (*locs)->addr.uri.s);
 			goto error;
 		}
 		/* free the location and point to the next one */

+ 2 - 1
modules_k/exec/exec.c

@@ -167,7 +167,8 @@ int exec_str(struct sip_msg *msg, char *cmd, char *param, int param_len) {
 				goto error02;
 			}
 		} else {
-			if (append_branch(msg, &uri, 0, 0, Q_UNSPECIFIED, 0, 0)==-1) {
+		    if (append_branch(msg, &uri, 0, 0, Q_UNSPECIFIED, 0, 0,
+				      0, 0) == -1) {
 				LM_ERR("append_branch failed; too many or too long URIs?\n");
 				goto error02;
 			}