[Asterisk-Dev] SIP Registration with outbound Proxy

Ginés Gómez gines at voztele.com
Thu Oct 23 17:47:22 MST 2003


Hi all,

    I've found the following problem when registering Asterisk against a SIP
provider via outbound proxy. Syntax of register is very flexible
user[:secret[:authuser]]@host[:port][/contact] and allows you to do things
like

register =>
gines at provider.com:ginessecret:ginesauthuser at proxy.provider.com:5065/305 in
this example the user gines registers at domain provider.com with
authorizationuser ginesauthuser and pass ginessecret sending registration
packets to proxy.provider.com port 5065 and mapping this account to internal
305 extension.

The problem comes when the request line of the packet instead of being

REGISTER sip:voztele.com SIP/2.0

becomes

REGISTER sip:proxy.voztele.com SIP/2.0

which causes the registration to fail in many cases. Changing in chan_sip.c
the method transmit_register


........
       if (strchr(r->username, '@')) {
                snprintf(from, sizeof(from), "<sip:%s>;tag=as%08x",
r->username, p->tag);
                snprintf(to, sizeof(to),     "<sip:%s>", r->username);
        } else {
                snprintf(from, sizeof(from), "<sip:%s@%s>;tag=as%08x",
r->username, r->hostname, p->tag);
                snprintf(to, sizeof(to),     "<sip:%s@%s>", r->username,
r->hostname);
        }

HERE IS THE REQUEST HEADER -->   snprintf(addr, sizeof(addr), "sip:%s",
r->hostname);
.......

        this last line per


       /* If username is of the type user at domain we should use the domain */
        if(strchr(r->username, '@')){
                snprintf(addr,sizeof(addr),"sip:%s",strchr(r->username,
'@')+1);
        }else{
                snprintf(addr, sizeof(addr), "sip:%s", r->hostname);
        }

solves the problem. Basically, what we do is make test wether the username
contains '@' if so, it means that this is the domain that we should use for
this REGISTER

Don't know if it's 100% legal, that's why I wanted to discuss in that list.
If so, and the solution seems appropriate feel free to add it to the source
code.

Thanks for your time

Gines
Voz Telecom





-- 
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.193 / Virus Database: 260.2.0 - Release Date: 16/10/2003




More information about the asterisk-dev mailing list