- removed 2 warnings on Solaris
[sip-router] / receive.c
index 51fc621..ca5d394 100644 (file)
--- a/receive.c
+++ b/receive.c
@@ -11,7 +11,7 @@
 #include "forward.h"
 
 
-int receive_msg(char* buf, unsigned int len)
+int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
 {
        struct sip_msg msg;
        struct route_elem *re;
@@ -21,7 +21,7 @@ int receive_msg(char* buf, unsigned int len)
        orig=(char*) malloc(len);
        if (orig==0){
                DPrint("ERROR: memory allocation failure\n");
-               goto error;
+               goto error1;
        }
        memcpy(orig, buf, len);
        
@@ -49,8 +49,8 @@ int receive_msg(char* buf, unsigned int len)
                }
                re->tx++;
                /* send msg */
-               forward_request(orig, buf, len, &msg, re);
                DPrint(" found route to: %s\n", re->host.h_name);
+               forward_request(orig, buf, len, &msg, re, src_ip);
        }else if (msg.first_line.type==SIP_REPLY){
                /* sanity checks */
                if (msg.via1.error!=VIA_PARSE_OK){
@@ -64,17 +64,18 @@ int receive_msg(char* buf, unsigned int len)
                /* check if via1 == us */
                
                /* send the msg */
-               forward_reply(orig, buf, len, &msg);
-               DPrint(" reply forwarded to %s:%d\n", 
-                                       msg.via2.host,
-                                       (unsigned short) msg.via2.port
-                               );
+               if (forward_reply(orig, buf, len, &msg)==0){
+                       DPrint(" reply forwarded to %s:%d\n", 
+                                               msg.via2.host,
+                                               (unsigned short) msg.via2.port);
+               }
        }
 skip:
        free(orig);
        return 0;
 error:
+       free(orig);
+error1:
        return -1;
-
 }