[OpenSIPS-Devel] [ opensips-Bugs-3519665 ] drouting: improper handling for address in dr_gateways

SourceForge.net noreply at sourceforge.net
Sat May 5 07:00:57 CEST 2012


Bugs item #3519665, was opened at 2012-04-19 15:35
Message generated for change (Comment added) made by osas
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=3519665&group_id=232389

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: 1.8.x
Status: Open
Resolution: Fixed
Priority: 7
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Bogdan-Andrei Iancu (bogdan_iancu)
Summary: drouting: improper handling for address in dr_gateways

Initial Comment:
The documentation specify that the address field in dr_gateways table is a SIP URI.
When a SIP URI is populated into the table, drouting fails to load.

The first thing that needs to be fixed is creating the URI that needs to be parsed in routing.c:add_dst():
@@ -491,8 +491,9 @@
        pgw->type = type;

        /* add address in the list */
-       if(pgw->ip_str.len<5 || (strncasecmp("sip:", ip, 4)
-                       && strncasecmp("sips:", ip, 5)))
+       if(pgw->ip_str.len<5 ||
+               (strncasecmp("sip:",ip,4) != 0 &&
+               strncasecmp("sips:",ip,5) != 0))
        {
                if(pgw->ip_str.len+4>=GWABUF_MAX_SIZE) {
                        LM_ERR("GW address (%d) longer "


But after that, the code still expects an IP:port in pgw->ip_str (but we have a SIP URI).
When the new destination URI is created, the resulting SIP URI is bogus because the host part of the new URI is startin with "sip:"

drouting:push_gw_for_usage: adding gw [blah] as "sip:username at sip:host" in order 0

Regards,
Ovidiu Sas

----------------------------------------------------------------------

Comment By: Ovidiu Sas (osas)
Date: 2012-05-04 22:00

Message:
It is working ok now, the username is properly ignored.
This issue can be closed.

Regards,
Ovidiu Sas

----------------------------------------------------------------------

Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2012-05-04 07:58

Message:
An extra fix is available on SVN - please test and confirm.

Regards,
Bogdan

----------------------------------------------------------------------

Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2012-05-04 00:44

Message:
OK, I see your point. I will fix this.

Regards,
Bogdan

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2012-04-24 08:13

Message:
It is working ok now (but there are some other issues - see bellow).  I
would like to propose to make the URI validation as the preferred method of
populating the address field.  We should keep for now the old style, but we
should mark it as deprecated.

Also, if I populate the address field with a URI with params, those params
are taken into consideration (which is good).

Now, since we have a SIP URI, a user is allowed.  If I populate a user in
the URI, the user will be used to send out the call, resulting an invalid
URI:
Example:
set gw address to "sip:blah at 192.168.2.30;transport=tcp"
The mi interface reports:
ID:: gw_t1_id30 IP=blah at 192.168.2.30;transport=tcp Enabled=yes
and the call goes out to:
sip:[orig_uri]@blah at 192.168.2.30;transport=tcp
We have two '@' inside destination URI.

A quick fix would be to reject/ignore URIs with a username.

Also, the URI can have sip or sips URI scheme.  Is this information taken
into consideration when the request is constructed and sent out?
I didn't get a chance to validate this.

Regards,
Ovidiu Sas

----------------------------------------------------------------------

Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2012-04-24 03:34

Message:
Hi Ovidiu,

Forget what I said, I made the fix in such a way that is works now
correctly as before : the GW address can be with or without the "sip"
prefix.

The fix is on SVN (trunk, 1.8, 1.7), please test it and confirm.

Regards,
Bogdan

----------------------------------------------------------------------

Comment By: Ovidiu Sas (osas)
Date: 2012-04-20 06:16

Message:
In this case proper validation of the address field should be imposed.
Maybe socket_info.h:parse_phostport() should be broken in two by creating a
parse_hostport() to validate only host[:port] strings and integrate
parse_hostport() into parse_phostport().

Regards,
Ovidiu Sas

----------------------------------------------------------------------

Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2012-04-20 03:55

Message:
Hi Ovidiu,

Actually the docs should be updated - the GWs are to be defined only as
IP:port format, to be consistent in the entire code.

Regards,
Bogdan

----------------------------------------------------------------------

Comment By: Ovidiu Sas (osas)
Date: 2012-04-19 15:47

Message:
The URI parsing part is fine (the patch is a noop).
The only issue is storing the full SIP URI as a host:port in the structure
pointed by pgw .

Regards,
Ovidiu Sas

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=3519665&group_id=232389



More information about the Devel mailing list