Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 29/11/2001 14:02:39
Showing 2 changed files
... ...
@@ -272,7 +272,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
272 272
    T->outbound_request[branch]->timeout         = RETR_T1;
273 273
    /* send the request */
274 274
    udp_send( T->outbound_request[branch]->buffer , T->outbound_request[branch]->bufflen , 
275
-		&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );
275
+		(struct sockaddr*)&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );
276 276
 }
277 277
 
278 278
 
... ...
@@ -506,19 +506,19 @@ int t_reply_matching( struct s_table *hash_table , struct sip_msg *p_msg , struc
506 506
    /* getting the hash_index from the brach param , via header*/
507 507
    begin = p_msg->via1->branch->value.s;
508 508
    for(  ; *begin!='.' ; begin++ );
509
-   hash_index = strtol( ++begin , &end , 10 );
509
+   hash_index = strtol( ++begin , &end , 16 );
510 510
    /*if the hash index is corect */
511 511
    if  ( *end=='.' && hash_index>=0 && hash_index<TABLE_ENTRIES-1 )
512 512
    {
513 513
       /* getting the entry label value */
514 514
       begin=end++ ;
515
-      entry_label = strtol( ++begin , &end , 10 );
515
+      entry_label = strtol( ++begin , &end , 16 );
516 516
       /* if the entry label also is corect */
517 517
       if  ( *end=='.' && entry_label>=0 )
518 518
       {
519 519
          /* getting the branch_id value */
520 520
          begin=end++ ;
521
-         branch_id = strtol( ++begin , &end , 10 );
521
+         branch_id = strtol( ++begin , &end , 16 );
522 522
          /* if the entry label also is corect */
523 523
           if  ( branch_id>=0 )
524 524
           {
... ...
@@ -503,8 +503,56 @@ error:
503 503
 
504 504
 
505 505
 
506
-char * build_res_buf_from_sip_req(struct sip_msg* msg, unsigned int *returned_len)
506
+char * build_res_buf_from_sip_req(unsigned int code , char *text , struct sip_msg* msg, unsigned int *returned_len)
507 507
 {
508
+	char                    *buf=0, *p;
509
+	unsigned int       len,foo,i;
510
+	struct hdr_field  *hdr;
511
+
512
+	/*computes the lenght of the new response buffer*/
513
+	len = 0;
514
+	/* first line */
515
+	len += 3/*code*/ + 1/*space*/ + strlen(text) + 1/*new line*/;
516
+	/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/
517
+	for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
518
+		if ( hdr->type==HDR_VIA || hdr->type==HDR_FROM || hdr->type==HDR_CALLID || hdr->type==HDR_TO || hdr->type==HDR_CSEQ )
519
+			len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) +1;
520
+	/* end of message */
521
+	len += 1; /*new line*/
522
+
523
+	/*allocating mem*/
524
+	buf = (char*) malloc( len );
525
+	if (!buf)
526
+	{
527
+		LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: out of memory\n");
528
+		goto error;
529
+	}
530
+
531
+	/* filling the buffer*/
532
+	/* first line */
533
+	for ( i=2 , foo = code  ;  i>=0  ;  i-- , foo=foo/10 )
534
+		*(p+i) = '0' + foo - ( foo/10 )*10;
535
+	p += 3;
536
+	*(p++) = ' ' ;
537
+	memcpy( p , text , strlen(text) );
538
+	p += strlen(text);
539
+	*(p++) = '\n';
540
+	/* headers*/
541
+	for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
542
+		if ( hdr->type==HDR_VIA || hdr->type==HDR_FROM || hdr->type==HDR_CALLID || hdr->type==HDR_TO || hdr->type==HDR_CSEQ )
543
+		{
544
+			memcpy( p , hdr->name.s ,  ((hdr->body.s+hdr->body.len ) - hdr->name.s ) );
545
+			len += ((hdr->body.s+hdr->body.len ) - hdr->name.s );
546
+			*(p++) = '\n';
547
+		}
548
+
549
+	*(p++) = '\n';
550
+	*returned_len=len;
551
+	return buf;
552
+error:
553
+	if (buf) free(buf);
554
+	*returned_len=0;
555
+	return 0;
508 556
 }
509 557
 
510 558