[asterisk-bugs] [Asterisk 0011055]: [patch] Register to the SIP server with domain name

noreply at bugs.digium.com noreply at bugs.digium.com
Wed Nov 7 19:52:11 CST 2007


The following issue has been RESOLVED. 
====================================================================== 
http://bugs.digium.com/view.php?id=11055 
====================================================================== 
Reported By:                Adam Lee
Assigned To:                file
====================================================================== 
Project:                    Asterisk
Issue ID:                   11055
Category:                   Channels/chan_sip/Registration
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     resolved
Asterisk Version:           1.4.13  
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
Resolution:                 no change required
Fixed in Version:           
====================================================================== 
Date Submitted:             10-23-2007 01:18 CDT
Last Modified:              11-07-2007 19:52 CST
====================================================================== 
Summary:                    [patch] Register to the SIP server with domain name
Description: 
I tried to connect the the Nortel CS5200 Sip Server which is configured
with its local domain name, however, the asterisk could not register to the
server successfully.

I set the following descriptions in the sip.conf: 
[general]
.
.
maxexpiry=3600
defaultexpiry=1200
register=>390 at myproxy.domain:390:390 at 10.0.174.221:5060/390
registertimeout=30

The 10.0.174.221 is its actual ip address and "myproxy.domain" is its
local domain name which is not a real domain name and only can be regonized
in the local domain name server.

I captured the SIP REGISTER Request with "sip debug" as follows:
[Oct 23 14:03:58] NOTICE[15232]: chan_sip.c:7296 sip_reregister:    --
Re-registration for  390 at myproxy.domain@10.0.174.221
REGISTER 12 headers, 0 lines
Reliably Transmitting (no NAT) to 10.0.174.221:5060:
REGISTER sip:10.0.174.221 SIP/2.0     
Via: SIP/2.0/UDP 10.0.174.125:5060;branch=z9hG4bK24503299;rport
From: <sip:390 at myproxy.domain>;tag=as1a549b74
To: <sip:390 at myproxy.domain>
Call-ID: 6f2143e66db5fc393d8ffeb918a559bc at 127.0.0.1
CSeq: 102 REGISTER
User-Agent: SI-688 IPPBX
Max-Forwards: 70
Expires: 1200
Contact: <sip:390 at 10.0.174.125>
Event: registration
Content-Length: 0

I think the problem is that the SIP Request line of the REGISTER Request
is the ip address of the server instead of its domain name. Therefore, I
modified the source code of Asterisk v1.4.13 and captured the outgoing
REGISTER Request again as follows:
[Oct 23 14:10:11] NOTICE[19490]: chan_sip.c:7296 sip_reregister:    --
Re-registration for  390 at myproxy.domain@10.0.174.221
REGISTER 12 headers, 0 lines
Reliably Transmitting (no NAT) to 10.0.174.221:5060:
REGISTER sip:myproxy.domain SIP/2.0
Via: SIP/2.0/UDP 10.0.174.125:5060;branch=z9hG4bK0b0ab833;rport
From: <sip:390 at myproxy.domain>;tag=as03e91925
To: <sip:390 at myproxy.domain>
Call-ID: 1aaa5911374141993743c63a20e7d4f9 at 127.0.0.1
CSeq: 102 REGISTER
User-Agent: SI-688 IPPBX
Max-Forwards: 70
Expires: 1200
Contact: <sip:390 at 10.0.174.125>
Event: registration
Content-Length: 0

Now, Asterisk registers with the Nortel SIP Server successfully.

Here is my patch:
--- chan_sip.c  2007-10-10 22:42:00.000000000 +0800
+++ chan_sip_mod.c      2007-10-23 13:53:45.000000000 +0800
@@ -7477,10 +7477,14 @@
                else
                        snprintf(addr, sizeof(addr), "sip:%s",
p->fromdomain);
        } else {
-               if (r->portno && r->portno != STANDARD_SIP_PORT)
-                       snprintf(addr, sizeof(addr), "sip:%s:%d",
r->hostname, r->portno);
-               else
-                       snprintf(addr, sizeof(addr), "sip:%s",
r->hostname);
+               if (strchr(r->username, '@')) {
+                       snprintf(addr, sizeof(addr), "sip:%s",
strchr(r->username, '@') + 1);
+               } else {
+                       if (r->portno && r->portno != STANDARD_SIP_PORT)
+                               snprintf(addr, sizeof(addr), "sip:%s:%d",
r->hostname, r->portno);
+                       else
+                               snprintf(addr, sizeof(addr), "sip:%s",
r->hostname);
+               }
        }
        ast_string_field_set(p, uri, addr);

Thank you.
====================================================================== 

---------------------------------------------------------------------- 
 file - 11-07-07 19:52  
---------------------------------------------------------------------- 
Greetings!

This can be accomplished using a peer entry with fromuser and fromdomain
set. You would just specify the peer name instead of the IP address in the
register line.

As well in the future please attach patches and mark them as code so
licensing is verified on them.

Peace! 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
11-07-07 19:52  file           Status                   new => resolved     
11-07-07 19:52  file           Resolution               open => no change
required
11-07-07 19:52  file           Assigned To               => file            
11-07-07 19:52  file           Note Added: 0073352                          
======================================================================




More information about the asterisk-bugs mailing list