res_pjsip_endpoint_identifier_ip.c: Added regex support to match_header

This patch adds regular expression support to make the identify section's
match_header option more useful when attempting to match complex headers
like the 'To' or 'From' headers.  The 'From' header has variable
components such as the tag parameter that you cannot predict.  To specify
a regular expression put slashes around the regular expression in place of
the header value.

[identify-alice]
type=identify
endpoint=alice
match_header=From: /<sip:alice@127\\.0\\.0\\.1>/

* Added regex support to match_header so you could match a 'To' header
among other complex headers.

Fixed reported crashes when trying to match special headers like 'Contact'.
The identify section's match_header method used code that assumed you were
matching a generic header.  Any other type of header could cause a crash
if the header structure variant did not match the generic header enough.

* Made use code that will work for any header type instead of code
specific to generic headers.

Other fixes while in the area:

* Made check all headers of the requested name.
* Added some more sanity checks to the configured identify matching
options when applying the configuration.

ASTERISK-27548

Change-Id: I27dfd4ff5e2259b906640e3c330681b76b4ed1f1
This commit is contained in:
Richard Mudgett
2018-07-24 13:44:41 -05:00
parent a31e877502
commit 32ce8e5cf3
2 changed files with 125 additions and 38 deletions

View File

@@ -143,6 +143,13 @@ res_pjsip
when both 'SIP' and 'Q.850' Reason headers are received. This option allows
the 'Q.850' Reason header to be suppressed. The default value is 'no'.
res_pjsip_endpoint_identifier_ip
------------------
* Added regex support to the identify section match_header option. You
specify a regex instead of an explicit string by surrounding the header
value with slashes:
match_header = SIPHeader: /regex/
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 15.4.0 to Asterisk 15.5.0 ------------
------------------------------------------------------------------------------