Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 07/12/2001 00:09:42
Showing 5 changed files
... ...
@@ -35,7 +35,8 @@ NAME=ser
35 35
 #                  twice, trying to free a pointer alloc'ed with a different
36 36
 #                  malloc etc.)
37 37
 DEFS=-DNOCR -DMACROEATER -DDNS_IP_HACK  -DSHM_MEM \
38
-	 -DPKG_MALLOC -DNO_DEBUG -DDBG_QM_MALLOC 
38
+	 -DPKG_MALLOC #-DDBG_QM_MALLOC
39
+>>>>>>> 1.50
39 40
 #-DEXTRA_DEBUG
40 41
 # -DUSE_SHM_MEM
41 42
 #-DNO_DEBUG 
... ...
@@ -115,6 +115,9 @@ struct sip_msg* sip_msg_cloner( struct sip_msg *org_msg )
115 115
 	    case HDR_FROM :
116 116
 		new_msg->from = new_hdr;
117 117
 		break;
118
+	    case HDR_TO :
119
+		new_msg->to = new_hdr;
120
+		break;
118 121
 	    case HDR_CSEQ :
119 122
 		if (header->parsed)
120 123
 		{
... ...
@@ -1156,14 +1156,15 @@ int t_cancel_branch(unsigned int branch)
1156 1156
 int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_msg* rpl)
1157 1157
 {
1158 1158
    struct sip_msg* p_msg , *r_msg;
1159
-    struct via_body *via;
1160
-    struct hdr_field *hdr;
1161
-    char *ack_buf, *p;
1162
-    unsigned int len;
1163
-    int n;
1159
+   struct hdr_field *hdr;
1160
+   char *ack_buf, *p, *via;
1161
+   unsigned int len, via_len;
1162
+   int n;
1164 1163
 
1164
+   ack_buf = 0;
1165
+   via =0;
1165 1166
 
1166
-   p_msg = T->inbound_request;
1167
+   p_msg = Trans->inbound_request;
1167 1168
    r_msg = rpl;
1168 1169
 
1169 1170
    if ( parse_headers(rpl,HDR_TO)==-1 || !rpl->to )
... ...
@@ -1176,7 +1177,13 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms
1176 1177
     /*first line's len */
1177 1178
     len += 4+p_msg->first_line.u.request.uri.len+1+p_msg->first_line.u.request.version.len+CRLF_LEN;
1178 1179
     /*via*/
1179
-    len+= MY_VIA_LEN + names_len[0] + 1+ port_no_str_len + MY_BRANCH_LEN + 3*sizeof(unsigned int) /*branch*/ + CRLF_LEN;
1180
+    via = via_builder( p_msg , &via_len );
1181
+    if (!via)
1182
+    {
1183
+	LOG(L_ERR, "ERROR: t_build_and_send_ACK: no via header got from builder\n");
1184
+	goto error;
1185
+    }
1186
+    len+= via_len;
1180 1187
     /*headers*/
1181 1188
    for ( hdr=p_msg->headers ; hdr ; hdr=hdr->next )
1182 1189
       if ( hdr->type==HDR_FROM || hdr->type==HDR_CALLID || hdr->type==HDR_CSEQ )
... ...
@@ -1215,31 +1222,10 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms
1215 1222
    p+=CRLF_LEN;
1216 1223
 
1217 1224
    /* insert our via */
1218
-   memcpy( p , MY_VIA , MY_VIA_LEN );
1219
-   p += MY_VIA_LEN;
1220
-
1221
-   memcpy( p , names[0] , names_len[0] );
1222
-   p += names_len[0];
1223
-
1224
-  // *(p++) = ':';
1225
-
1226
-   memcpy( p , port_no_str , port_no_str_len );
1227
-   p += port_no_str_len;
1228
-
1229
-   memcpy( p, MY_BRANCH, MY_BRANCH_LEN );
1230
-   p+=MY_BRANCH_LEN;
1231
-
1232
-   n=sprintf( p /*, ack_buf + MAX_ACK_LEN - p*/, ".%x.%x.%x%s",
1233
-                 Trans->hash_index, Trans->label, branch, CRLF );
1234
-
1235
-   if (n==-1) {
1236
-	LOG(L_ERR, "ERROR: t_build_and_send_ACK: unable to generate branch\n");
1237
-	goto error;
1238
-   }
1239
-   p+=n;
1240
-
1241
-
1225
+   memcpy( p , via , via_len );
1226
+   p += via_len;
1242 1227
 
1228
+   /*other headers*/
1243 1229
    for ( hdr=p_msg->headers ; hdr ; hdr=hdr->next )
1244 1230
    {
1245 1231
       if ( hdr->type==HDR_FROM || hdr->type==HDR_CALLID  )
... ...
@@ -1273,11 +1259,13 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms
1273 1259
 
1274 1260
    /* free mem*/
1275 1261
    if (ack_buf) free( ack_buf );
1262
+   if (via) free(via );
1276 1263
    return 0;
1277 1264
 
1278 1265
 error:
1279
-   	if (ack_buf) free( ack_buf );
1280
-	return -1;
1266
+   if (ack_buf) free( ack_buf );
1267
+   if (via) free(via );
1268
+   return -1;
1281 1269
 }
1282 1270
 
1283 1271
 
... ...
@@ -161,7 +161,11 @@ char* via_builder( struct sip_msg *msg , unsigned int *len )
161 161
 				src[2]= msg->callid->body;
162 162
 				src[3]= msg->first_line.u.request.uri;
163 163
 				src[4]= get_cseq( msg )->number;
164
-
164
+                                                             DBG("XXXXXXXXXXXXXXX <%s>\n",msg->from->body.s);
165
+                                                             DBG("XXXXXXXXXXXXXXX <%s>\n",msg->to->body.s);
166
+                                                             DBG("XXXXXXXXXXXXXXX <%s>\n",msg->callid->body.s);
167
+                                                             DBG("XXXXXXXXXXXXXXX <%s>\n",msg->first_line.u.request.uri.s);
168
+                                                             DBG("XXXXXXXXXXXXXXX <%s>\n",get_cseq( msg )->number.s);
165 169
 				MDStringArray ( line_buf+via_len-1, src, 5 );
166 170
 				/*DBG("DEBUG: build_req_buf_from_sip_req: branch loop "
167 171
 				/		"detection: %s, %s, %s, %s, %s -> %s32\n",
... ...
@@ -20,6 +20,8 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
20 20
 									char *text ,
21 21
 									struct sip_msg* msg,
22 22
 									unsigned int *returned_len);
23
+char* via_builder( struct sip_msg *msg ,
24
+									unsigned int *len );
23 25
 
24 26
 
25 27