- another bug fixed (wrong new_len in forward_reply)
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Thu, 6 Sep 2001 19:14:19 +0000 (19:14 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Thu, 6 Sep 2001 19:14:19 +0000 (19:14 +0000)
forward.c
sip_router.cfg

index bc1cbdb..d353746 100644 (file)
--- a/forward.c
+++ b/forward.c
@@ -196,23 +196,32 @@ int forward_reply(char * orig, char* buf,
        /* we must remove the first via */
        via_len=msg->via1.size;
        size=msg->via1.hdr-buf;
+       printf("via len: %d, initial size: %d\n", via_len, size);
        if (msg->via1.next){
                /* keep hdr =substract hdr size +1 (hdr':') and add
                 */
                via_len-=strlen(msg->via1.hdr)+1;
                size+=strlen(msg->via1.hdr)+1;
+           printf(" adjusted via len: %d, initial size: %d\n",
+                               via_len, size);
        }
-       new_len=len-size;
-       new_buf=(char*)malloc(new_len);
+       new_len=len-via_len;
+       
+       printf(" old size: %d, new size: %d\n", len, new_len);
+       new_buf=(char*)malloc(new_len+1);/* +1 is for debugging (\0 to print it )*/
        if (new_buf==0){
                DPrint("ERROR: forward_reply: out of memory\n");
                goto error;
        }
+       new_buf[new_len]=0; /* debug: print the message */
        memcpy(new_buf, orig, size);
        offset=size;
        s_offset=size+via_len;
        memcpy(new_buf+offset,orig+s_offset, len-s_offset);
         /* send it! */
+       printf(" copied size: orig:%d, new: %d, rest: %d\n",
+                       s_offset, offset, 
+                       len-s_offset );
        printf("Sending: to %s:%d, \n%s.\n",
                        msg->via2.host, 
                        (unsigned short)msg->via2.port,
index 1b4d167..d1af83d 100644 (file)
@@ -5,7 +5,7 @@
 # (warning: re cannot contain space)
 
 #.                     .                                  centauri
-#.*                    .*                                 mobile50 
+.*                     .*                                 mobile50 
 .                      .                                  fox.iptel.org
 ^R.*        ^sip:.*@dorian.*   ekina.fokus.gmd.de        
 ^INVITE     .*                 ape:5061             # my laptop