[OpenSIPS-Users] Via header interpretation with rport parameter being set

Thomas Gelf thomas at gelf.net
Mon Sep 14 16:59:10 CEST 2009


Hi All,

I stumbled over an intersting issue I'd like to share and to ask
feedback for. Grandstream phones offer an option called "use symmetric
RFC 3581 routing". If that option is enabled and STUN detection was
successful, it's REGISTER packets show a perfectly correct Contact
header and a Via header using it's private IP address and port.

IMO RFC 3581 is not clear about whether in such situations a client
shall nonetheless replace it's Via ip:port pair with what he has
learned by doing STUN. Please correct me if this assumption is wrong,
I'll open a ticket at Grandstream and forget about this.

Said so, I'd like to raise a few questions:

* is there something like a has_rport() function in OpenSIPS?
* would a new test checking whether Contact differs from the socket
  where the UAC's packet came from make sense?
* More and more clients are adding the rport parameter, and while most
  of them are setting Via as learned by STUN, this must not be always
  true. At least I didn't find anything in RFC 3581 stating so. Even if
  I definitively would never ever suggest using Grandstream as a refe-
  rence implementation, the fact that they are doing as told above
  means that different interpretations could definitively be possible
  here. As told before, I could be wrong here!
* Contact is as correct as possible in most cases, however just checking
  for private IPs doesn't suffice (for the very same reason there are
  multiple checks for Via headers), but one should also NOT consider the
  client being behind NAT just because Contact and client socket differ.

Instead of explaining wide and long the meaning of this, I'll show you
an example of how my "best-nat-check-ever"-config should look like,
assuming there was a client_nat_test("8") meaning that Contact differs
from client socket:

if (client_nat_test("8"))
{
    # Contact doesn't match client socket, apply all checks regardless
    # of rport being set or not:
    if (client_nat_test("7")) {
        setbflag(BF_NAT);
        AVP_RECEIVED = $source_uri;
    }
} else {
    # Contact is correct. If either rport is set or Via is also correct,
    # we have no NAT issue.
    if (! $(hdr(Via)[0]) =~ ";rport" && client_nat_test("6"))
    {
        setbflag(BF_NAT);
        AVP_RECEIVED = $source_uri;
    }
}

I'm pretty curious about your opinions!

Best regards,
Thomas Gelf

-- 
 mail: thomas at gelf.net
  web: http://thomas.gelf.net/




More information about the Users mailing list