Browse Source

bug_fix: empty to_tags & msg_builder uses now socket for via

Jiri Kuthan 22 years ago
parent
commit
f7576304a2
3 changed files with 16 additions and 9 deletions
  1. 10 7
      modules/tm/t_msgbuilder.c
  2. 4 1
      modules/tm/t_msgbuilder.h
  3. 2 1
      modules/tm/uac.c

+ 10 - 7
modules/tm/t_msgbuilder.c

@@ -332,7 +332,9 @@ char *build_uac_request_dlg(str* msg,           /* Method */
 			    str* body,          /* Body of the message */
 			    int branch,         /* Branch */
 			    struct cell *t,     
-			    unsigned int *len)
+			    unsigned int *len,
+				struct socket_info* send_sock
+				)
 {
 	char *via, *buf, *w, content_len[10], cseq_str[10], branch_buf[MAX_BRANCH_PARAM_LEN];
 	int content_len_len, cseq_str_len, branch_len;
@@ -368,8 +370,8 @@ char *build_uac_request_dlg(str* msg,           /* Method */
 		goto error;
 	}
 
-	via = via_builder(&via_len, t->uac[branch].request.send_sock, 
-			branch_buf, branch_len, t->uac[branch].request.send_sock->proto);
+	via = via_builder(&via_len, send_sock,
+			branch_buf, branch_len, send_sock->proto);
 	if (!via) {
 		LOG(L_ERR, "ERROR: build_uac_request_dlg: via building failed\n");
 		goto error;
@@ -387,7 +389,8 @@ char *build_uac_request_dlg(str* msg,           /* Method */
 		+ CRLF_LEN; /* EoM */
 	
 	     /* header field value and body length */
-	*len +=   to->len + ((totag) ? (TOTAG_LEN + totag->len) : 0) /* To */
+	*len +=   to->len + 
+			((totag && totag->len) ? (TOTAG_LEN + totag->len) : 0) /* To */
 		+ from->len + FROMTAG_LEN + fromtag->len             /* From */
 		+ cseq_str_len + 1 + msg->len                        /* CSeq */
 		+ callid->len                                        /* Call-ID */
@@ -418,11 +421,11 @@ char *build_uac_request_dlg(str* msg,           /* Method */
 
 	     /* To */
 	t->to.s = w;
-	t->to.len = TO_LEN + to->len + ((totag) ? (TOTAG_LEN + totag->len) : 0);
-
+	t->to.len= TO_LEN+to->len;
 	memapp(w, TO, TO_LEN);
 	memapp(w, to->s, to->len);
-	if (totag) {
+	if (totag && totag->len ) {
+		t->to.len += TOTAG_LEN + totag->len ;
 		memapp(w, TOTAG, TOTAG_LEN);
 		memapp(w, totag->s, totag->len);
 	}

+ 4 - 1
modules/tm/t_msgbuilder.h

@@ -30,6 +30,8 @@
 #ifndef _MSGBUILDER_H
 #define _MSGBUILDER_H
 
+#include "../../ip_addr.h"
+
 #include "defs.h"
 
 
@@ -96,7 +98,8 @@ char *build_uac_request_dlg(str* msg,            /* Method */
 	                    str* body,           /* Body of the message */
 	                    int branch,         /* Branch */
 	                    struct cell *t,
-	                    unsigned int *len
+	                    unsigned int *len,
+						struct socket_info *send_sock
 	                   );
 
 

+ 2 - 1
modules/tm/uac.c

@@ -498,7 +498,8 @@ int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OP
 				    body, 
 				    branch,
 				    new_cell,
-				    &req_len);
+				    &req_len,
+					send_sock);
 	if (!buf) {
 		ret = E_OUT_OF_MEM;
 		LOG(L_ERR, "ERROR: t_uac: short of req shmem\n");