[Asterisk-Dev] help needed - SIP register response contact
Michael Procter
michael.procter at citel.com
Mon Dec 1 08:59:06 MST 2003
> From: Conroy, Lawrence (SMTP) [mailto:lwc at roke.co.uk]
> Sent: 29 November 2003 13:16
> Hi Folks,
> suitably nudged, I would like to fix a latent bug that has been
> hanging around in chan_sip for ages.
[Creation of Contact header in 200 response to REGISTER]
> I believe that this is WRONG - it certainly causes the mediatrix stack
> (and Siemens phones) to ignore the register response, as they don't
> think it's for them. They expect to see their OWN contact address in
> the register response, not that of the proxy (or any other machine).
I believe you are correct - that this is the wrong behaviour. I recently
came up against this problem, and listed it as bug ID 510 on
bugs.digium.com.
> As a quick hack, I replace the last line (2257) with the following:
> /* lwc add_header(resp, "Contact", contact); */ copy_header(resp,
req,
> "Contact");
Whilst this is more correct, in the sense that the Contact header now
contains
the correct bound address, there are still problems. Firstly, this change
appears to copy throught the 'expires' parameter from the REGISTER message.
Whilst the UA may provide a suggested 'expires', the registrar should pick
the
final value. If Asterisk wishes to use a different value, this change would
prevent that (expires value in Contact header takes precedence over value in
Expires header).
Secondly, I think it still misses one of the main points of performing a
registration.
Suppose I send a REGISTER containing 'To: sip:me at asterisk.example.com', and
'Contact: sip:myphone at mydesk.example.com'. Any call to
me at asterisk.example.com through Asterisk should arrive at
myphone at mydesk (no argument there, I think), but with the Request-URI
rewritten to be 'sip:myphone at mydesk.example.com', i.e. the value I
specified in the Contact of the REGISTER message. [RFC3261 Sec 16.12.1.1,
specifically the rewriting of the Request-URI that P2 performs].
So, by not caching the true Contact details, I'm not sure how future calls
routed via Asterisk can be received by a SIP phone. Just stashing the IP
address/port information is a start, but a Request-URI can contain various
parameters as well. [RFC3261 Table 1 in section 19.1.2].
> The real issue is line 2254, where p->our_contact is used. Nope, it
> should be THEIR contact address (as in the req Contact header).
Exactly. And Asterisk should cache the contact address (parameters and
all) to use in the Request-URI of future calls.
> Some phones don't check the Contact header address in the register
> response, so the current
> stuff doesn't break them. This is why it has worked for most folk -
> their phones aren't strictly compliant. However...
I thought this was true, when I found out that my Cisco 7960 can register
with Asterisk. But I did a few more tests. If the 7960 can't find it's
Contact-URI in the response to the register, it defaults the expiry time
to be the value specified in the Expires: header. Since Asterisk sends
an Expires: header correctly, the 7960 is happy, even though the Contact:
header is incorrect.
> I don't have any Cisco phones (or pingtel, grandstream, Snom ones)
> available, so could
> someone put in my proposed hack to check whether it breaks their setup,
> please?
I would suggest that at a minimum, you ensure you don't copy any 'expires'
parameter from the Contact in the REGISTER. Ideally, I think the entire
URI should be cached, but that may be a larger change than you were
planning!
Regards,
Michael
More information about the asterisk-dev
mailing list