RE: Problem with siproxd not rewriting request URI

"Michael Procter" <[email protected]> Thu, 2 Feb 2006 11:08:11 -0000
Newsgroups gmane.network.siproxd
Message-ID <[email protected]>
Thomas Ries wrote:
> 
> I'd really like to have more details to see what is going on exactly.
> Especially the whole SIP communication in front and after siproxd.
> 
> Don't you have the chance to ask the admin of the machine to 
> assist you
> to record a debug log? Do you have the chance to reproduce this effect
> on a machine that you have under control? You should also try with the
> latest snapshot of siproxd.
> 

I am the admin of the machine in question.  I updated to the 02Feb2006
snapshot this morning, and the problem remained.  I've looked a little
further and come up with a fix.  The problem seemed to be in the
function
proxy_rewrite_request_uri, in that it only rewrote 2 of the 4 components
of the uri.  Rewriting the 'username' component made it work, but I
added
rewriting of the scheme too, just for completeness.

Regards,

Michael Procter



*** siproxd-0.5.12-snapshot-02Feb20006-orig/src/proxy.c  2006-01-01
20:31:54.000000000 +0000
--- siproxd-0.5.12-snapshot-02Feb2006/src/proxy.c       2006-02-02
10:34:02.000000000 +0000
***************
*** 1122,1127 ****
--- 1122,1129 ----
   *    STS_SUCCESS on success
   */
  int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){
+    char *scheme;
+    char *username;
     char *host;
     char *port;
     osip_uri_t *url;
***************
*** 1134,1139 ****
--- 1136,1163 ----
     DEBUGC(DBCLASS_PROXY,"rewriting incoming Request URI");
     url=osip_message_get_uri(mymsg);

+    /* set the true scheme */
+    if (url->scheme) osip_free(url->scheme);url->scheme=NULL;
+    if (urlmap[idx].true_url->scheme) {
+       DEBUGC(DBCLASS_BABBLE,"proxy_rewrite_request_uri: scheme=%s",
+              urlmap[idx].true_url->scheme);
+       scheme = (char *)malloc(strlen(urlmap[idx].true_url->scheme)+1);
+       memcpy(scheme, urlmap[idx].true_url->scheme,
strlen(urlmap[idx].true_url->scheme));
+       scheme[strlen(urlmap[idx].true_url->scheme)]='\0';
+       osip_uri_set_scheme(url, scheme);
+    }
+
+    /* set the true username */
+    if (url->username) osip_free(url->username);url->username=NULL;
+    if (urlmap[idx].true_url->username) {
+       DEBUGC(DBCLASS_BABBLE,"proxy_rewrite_request_uri: username=%s",
+              urlmap[idx].true_url->username);
+       username = (char
*)malloc(strlen(urlmap[idx].true_url->scheme)+1);
+       memcpy(username, urlmap[idx].true_url->username,
strlen(urlmap[idx].true_url->username));
+       username[strlen(urlmap[idx].true_url->username)]='\0';
+       osip_uri_set_username(url, username);
+    }
+
     /* set the true host */
     if (url->host) osip_free(url->host);url->host=NULL;
     if (urlmap[idx].true_url->host) {


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642