[Asterisk-code-review] res_pjsip_nat: Restore original contact for REGISTER responses (...asterisk[13])

Alexei Gradinari asteriskteam at digium.com
Mon Sep 16 09:33:14 CDT 2019


Alexei Gradinari has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/12824 )

Change subject: res_pjsip_nat: Restore original contact for REGISTER responses
......................................................................


Patch Set 4:

> Patch Set 4:
> 
> > Patch Set 4:
> > 
> > > Patch Set 4:
> > > 
> > > One more issue.
> > > I don't know why, but this patch is not working if the active contact record already exists in realtime table ps_contacts.
> > > 
> > > If contact exists in ps_contacts then debug only
> > > Saving contact
> > > got contact 
> > > So when "got contact" the x-ast-orig-host not found and it's not saved into realtime table ps_contacts,
> > > the uri field is 'sip:endpoint at endpoint-public-ip:endpoint-public-port'
> > > 
> > > If contact not  exists in ps_contacts then debug
> > > Saving contact
> > > got contact
> > > Found orig host:
> > > The x-ast-orig-host is found and it's saved into realtime table ps_contacts
> > > the uri field is 'sip:endpoint at endpoint-public-ip:endpoint-public-port;x-ast-orig-host=endpoint-private-ip:endpoint-private-port'
> > 
> > 
> > Could you, please, look at res_pjsip_registrar.c function register_aor_core
> > starting with line 804.
> > It seems if contact URI:PORT from request is found in sorcery then this sorcery's contact will be used in response (so we lost x-ast-orig-host)
> 
> I don't think so.  We get a copy of the existing contact object, which has the x-ast-orig-host parameter, the modify a few fields like expiration time, then put it back in the contacts container with the parameter preserved.  I just tested it and it works as expected.


Wrong.
The existing contact object doesn't have x-ast-orig-host parameter.
Please, look at 
contact_update = ast_sorcery_copy(ast_sip_get_sorcery(), contact);
The contact_update object doesn't have x-ast-orig-host.
Then we set some parameters (expiration_time,qualify_frequency,authenticate_qualify,path,user_agent and reg_server) on this object.
But doesn't set the uri (leave the old value) in this object.
Then we update sorcery (in my case record in DB table ps_contacts) with this object.
Then we use this object to form a response.
The response will not contain the x-ast-orig-host parameter because contact_update object does not contain. The sorcery object (in my case record in ps_contacts) will not contain too, so next time again we will get the contact from sorcery which doesn't have x-ast-orig-host parameter.

I tested it, without
ast_string_field_set(contact_update, uri, contact_uri);
the response Contact URI contains the wrong (rewritten) host/port.
With ast_string_field_set it contains original host/port.


-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/12824
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Idc263ad2d2d7bd8faa047e5804d96a5fe1cd282e
Gerrit-Change-Number: 12824
Gerrit-PatchSet: 4
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Comment-Date: Mon, 16 Sep 2019 14:33:14 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190916/1defda2b/attachment.html>


More information about the asterisk-code-review mailing list