asterisk/res/res_pjsip
George Joseph cbc1136704 res_pjsip_nat: Restore original contact for REGISTER responses
RFC3261 Section 10 "Registrations", specifically paragraph
"10.2.4: Refreshing Bindings", states that a user agent compares
each contact address (in a 200 REGISTER response) to see if it
created the contact.  If the Asterisk endpoint has the
rewrite_contact option set however, the contact host and port sent
back in the 200 response will be the rewritten one and not the
one sent by the user agent.  This prevents the user agent from
matching its own contact.  Some user agents get very upset when
this happens and will not consider the registration successful.
While this is rare, it is acceptable behavior especially if more
than 1 user agent is allowed to register to a single endpoint/aor.

This commit updates res_pjsip_nat (where rewrite_contact is
implemented) to store the original incoming Contact header in
a new "x-ast-orig-host" URI parameter before rewriting it, and to
restore the original host and port to the Contact headers in the
outgoing response.

This is only done if the request is a REGISTER and rewrite_contact
is enabled.

pjsip_message_filter was also updated to ensure that if a request
comes in with any existing x-ast-* URI parameters, we remove them
so they don't conflict.  Asterisk will never send a request
with those headers in it but someone might just decide to add them
to a request they craft and send to Asterisk.

NOTE: If a device changes its contact address and registers again,
it's a NEW registration.  If the device didn't unregister the
original registration then all existing behavior based
on aor/remove_existing and aor/max_contacts apply.

ASTERISK-28502
Reported-by: Ross Beer

Change-Id: Idc263ad2d2d7bd8faa047e5804d96a5fe1cd282e
2019-12-06 12:48:08 -06:00
..
include taskprocessor: Enable subsystems and overload by subsystem 2019-02-20 11:51:08 -06:00
config_auth.c res_pjsip: Implement additional SIP RFCs for Google Voice trunk compatability 2018-10-24 07:51:25 -05:00
config_domain_aliases.c res_pjsip: Make pjlib.h consistently included. 2018-08-03 16:07:22 -05:00
config_global.c res_pjsip: Added a norefersub configuration setting 2019-04-17 10:18:40 -05:00
config_system.c various files - fix some alerts raised by lgtm code analysis 2019-11-18 08:30:45 -06:00
config_transport.c various files - fix some alerts raised by lgtm code analysis 2019-11-18 08:30:45 -06:00
location.c res_pjsip: Fix multiple of the same contact in "pjsip show contacts". 2019-08-01 04:12:00 -06:00
pjsip_cli.c pjsip: Improve CLI completion performance 2017-12-10 12:57:24 -06:00
pjsip_configuration.c channels: Allow updating variable value 2019-09-12 16:00:07 -05:00
pjsip_distributor.c taskprocessor: Enable subsystems and overload by subsystem 2019-02-20 11:51:08 -06:00
pjsip_global_headers.c Remove redundant module checks and references. 2018-01-24 13:37:29 -05:00
pjsip_message_filter.c res_pjsip_nat: Restore original contact for REGISTER responses 2019-12-06 12:48:08 -06:00
pjsip_options.c pjsip_options.c: Allow immediate qualifies for new contacts. 2019-05-07 10:26:19 -06:00
pjsip_resolver.c various files - fix some alerts raised by lgtm code analysis 2019-11-18 08:30:45 -06:00
pjsip_scheduler.c Merge "pjsip_scheduler.c: Add ability to trace scheduled tasks." 2018-04-16 07:11:26 -05:00
pjsip_session.c res_pjsip: Patch for res_pjsip_* module load/reload crash 2018-12-03 08:44:59 -06:00
pjsip_transport_events.c res_pjsip_registrar: blocked threads on reliable transport shutdown take 3 2019-02-27 17:02:43 -06:00
pjsip_transport_management.c pjsip_transport_management: Shutdown transport immediately on disconnect 2019-01-21 07:57:12 -06:00
presence_xml.c res_pjsip_pidf_eyebeam_body_supplement: Correct status presentation 2017-08-01 15:42:38 -06:00
security_events.c security-events: Fix SuccessfulAuth using_password declaration. 2017-12-04 17:21:27 -06:00