summaryrefslogtreecommitdiff
path: root/res/res_pjsip/config_global.c
AgeCommit message (Collapse)Author
2016-09-09res_pjsip: Add ignore_uri_user_options option.Richard Mudgett
This implements the chan_sip legacy_useroption_parsing option but with a better name. * Made the caller-id number and redirecting number strings obtained from incoming SIP URI user fields always truncated at the first semicolon. People don't care about anything after the semicolon showing up on their displays even though the RFC allows the semicolon. ASTERISK-26316 #close Reported by: Kevin Harwell Change-Id: Ib42b0e940dd34d84c7b14bc2e90d1ba392624f62
2016-09-02config_global.c: Comments and a default expression adjustment.Richard Mudgett
Change-Id: Ia6a58f8c73a30da6874b3f94364dce162d6f1ad3
2016-08-25res_pjsip: Cache global config options.Richard Mudgett
We may check a global config option hundreds of times a second or more. Asking sorcery for the global configuration from the config files backend involves several allocations and container traversals. Using realtime without a memory cache is a lot worse because you have to lookup in the realtime database each time to reconstitute the sorcery object. With a memory cache for realtime, there is about the same amount of overhead as for config files. Either way, it is still fairly expensive to access the sorcery object that much. * Cache the global config options so we can access them faster. You must now always perform a res_pjsip reload to change the global options. Change-Id: Ice16c7a4cbca4614da344aaea21a072b86263ef7
2016-08-11res_pjsip: Fail global load if debug or default_from_user are emptyGeorge Joseph
If debug was specified in the global configuration but left blank, the logger would treat it as a wildcard and log all hosts. If default_from_user was empty, a crash would result. The global apply handler now checks for empty strings. ASTERISK-26239 #close ASTERISK-26238 #close Change-Id: Ie75727f5cd5808845d92cc81f5713842fb203336
2016-08-08res_pjsip_mwi: fix unsolicited mwi blocks PJSIP stackAlexei Gradinari
The PJSIP taskprocessors could be overflowed on startup if there are many (thousands) realtime endpoints configured with unsolicited mwi. The PJSIP stack could be totally unresponsive for a few minutes after boot completed. This patch creates a separate PJSIP serializers pool for mwi and makes unsolicited mwi use serializers from this pool. This patch also adds 2 new global options to tune taskprocessor alert levels: 'mwi_tps_queue_high' and 'mwi_tps_queue_low'. This patch also adds new global option 'mwi_disable_initial_unsolicited' to disable sending unsolicited mwi to all endpoints on startup. If disabled then unsolicited mwi will start processing on next endpoint's contact update. ASTERISK-26230 #close Change-Id: I4c8ecb82c249eb887930980a800c9f87f28f861a
2016-04-27res_pjsip: Add ability to identify by Authorization usernameGeorge Joseph
A feature of chan_sip that service providers relied upon was the ability to identify by the Authorization username. This is most often used when customers have a PBX that needs to register rather than identify by IP address. From my own experiance, this is pretty common with small businesses who otherwise don't need a static IP. In this scenario, a register from the customer's PBX may succeed because From will usually contain the PBXs account id but an INVITE will contain the caller id. With nothing recognizable in From, the service provider's Asterisk can never match to an endpoint and the INVITE just stays unauthorized. The fixes: A new value "auth_username" has been added to endpoint/identify_by that will use the username and digest fields in the Authorization header instead of username and domain in the the From header to match an endpoint, or the To header to match an aor. This code as added to res_pjsip_endpoint_identifier_user rather than creating a new module. Although identify_by was always a comma-separated list, there was only 1 choice so order wasn't preserved. So to keep the order, a vector was added to the end of ast_sip_endpoint. This is only used by res_pjsip_registrar to find the aor. The res_pjsip_endpoint_identifier_* modules are called in globals/endpoint_identifier_order. Along the way, the logic in res_pjsip_registrar was corrected to match most-specific to least-specific as res_pjsip_endpoint_identifier_user does. The order is: username@domain username@domain_alias username Auth by username does present 1 problem however, the first INVITE won't have an Authorization header so the distributor, not finding a match on anything, sends a securty_alert. It still sends a 401 with a challenge so the next INVITE will have the Authorization header and presumably succeed. As a result though, that first security alert is actually a false alarm. To address this, a new feature has been added to pjsip_distributor that keeps track of unidentified requests and only sends the security alert if a configurable number of unidentified requests come from the same IP in a configurable amout of time. Those configuration options have been added to the global config object. This feature is only used when auth_username is enabled. Finally, default_realm was added to the globals object to replace the hard coded "asterisk" used when an endpoint is not yet identified. The testsuite tests all pass but new tests are forthcoming for this new feature. ASTERISK-25835 #close Reported-by: Ross Beer Change-Id: I30ba62d208e6f63439600916fcd1c08a365ed69d
2016-04-27res_pjsip: disable multi domain to improve realtime performaceAlexei Gradinari
This patch added new global pjsip option 'disable_multi_domain'. Disabling Multi Domain can improve Realtime performance by reducing number of database requests. ASTERISK-25930 #close Change-Id: I2e7160f3aae68475d52742107949a799aa2c7dc7
2016-04-06res_pjsip: Fix configuration setting of "regcontext".Joshua Colp
Due to a merge problem two options were swapped causing the regcontext setting to not get set. Change-Id: Icb33edc668e7357bacbaec2861a6b5ac64edaff1
2016-03-30res_pjsip_mwi: Add voicemail extension and mwi_subscribe_replaces_unsolicitedGeorge Joseph
res_pjsip_mwi was missing the chan_sip "vmexten" functionality which adds the Message-Account header to the MWI NOTIFY. Also, specifying mailboxes on endpoints for unsolicited mwi and on aors for subscriptions required that the admin know in advance which the client wanted. If you specified mailboxes on the endpoint, subscriptions were rejected even if you also specified mailboxes on the aor. Voicemail extension: * Added a global default_voicemail_extension which defaults to "". * Added voicemail_extension to both endpoint and aor. * Added ast_sip_subscription_get_dialog for support. * Added ast_sip_subscription_get_sip_uri for support. When an unsolicited NOTIFY is constructed, the From header is parsed, the voicemail extension from the endpoint is substituted for the user, and the result placed in the Message-Account field in the body. When a subscribed NOTIFY is constructed, the subscription dialog local uri is parsed, the voicemail_extension from the aor (looked up from the subscription resource name) is substituted for the user, and the result placed in the Message-Account field in the body. If no voicemail extension was defined, the Message-Account field is not added to the NOTIFY body. mwi_subscribe_replaces_unsolicited: * Added mwi_subscribe_replaces_unsolicited to endpoint. The previous behavior was to reject a subscribe if a previous internal subscription for unsolicited MWI was found for the mailbox. That remains the default. However, if there are mailboxes also set on the aor and the client subscribes and mwi_subscribe_replaces_unsolicited is set, the existing internal subscription is removed and replaced with the external subscription. This allows an admin to configure mailboxes on both the endpoint and aor and allows the client to select which to use. ASTERISK-25865 #close Reported-by: Ross Beer Change-Id: Ic15a9415091760539c7134a5ba3dc4a6a1217cea
2016-03-27sorcery/res_pjsip: Refactor for realtime performanceGeorge Joseph
There were a number of places in the res_pjsip stack that were getting all endpoints or all aors, and then filtering them locally. A good example is pjsip_options which, on startup, retrieves all endpoints, then the aors for those endpoints, then tests the aors to see if the qualify_frequency is > 0. One issue was that it never did anything with the endpoints other than retrieve the aors so we probably could have skipped a step and just retrieved all aors. But nevermind. This worked reasonably well with local config files but with a realtime backend and thousands of objects, this was a nightmare. The issue really boiled down to the fact that while realtime supports predicates that are passed to the database engine, the non-realtime sorcery backends didn't. They do now. The realtime engines have a scheme for doing simple comparisons. They take in an ast_variable (or list) for matching, and the name of each variable can contain an operator. For instance, a name of "qualify_frequency >" and a value of "0" would create a SQL predicate that looks like "where qualify_frequency > '0'". If there's no operator after the name, the engines add an '=' so a simple name of "qualify_frequency" and a value of "10" would return exact matches. The non-realtime backends decide whether to include an object in a result set by calling ast_sorcery_changeset_create on every object in the internal container. However, ast_sorcery_changeset_create only does exact string matches though so a name of "qualify_frequency >" and a value of "0" returns nothing because the literal "qualify_frequency >" doesn't match any name in the objset set. So, the real task was to create a generic string matcher that can take a left value, operator and a right value and perform the match. To that end, strings.c has a new ast_strings_match(left, operator, right) function. Left and right are the strings to operate on and the operator can be a string containing any of the following: = (or NULL or ""), !=, >, >=, <, <=, like or regex. If the operator is like or regex, the right string should be a %-pattern or a regex expression. If both left and right can be converted to float, then a numeric comparison is performed, otherwise a string comparison is performed. To use this new function on ast_variables, 2 new functions were added to config.c. One that compares 2 ast_variables, and one that compares 2 ast_variable lists. The former is useful when you want to compare 2 ast_variables that happen to be in a list but don't want to traverse the list. The latter will traverse the right list and return true if all the variables in it match the left list. Now, the backends' fields_cmp functions call ast_variable_lists_match instead of ast_sorcery_changeset_create and they can now process the same syntax as the realtime engines. The realtime backend just passes the variable list unaltered to the engine. The only gotcha is that there's no common realtime engine support for regex so that's been noted in the api docs for ast_sorcery_retrieve_by_fields. Only one more change to sorcery was done... A new config flag "allow_unqualified_fetch" was added to reg_sorcery_realtime. "no": ignore fetches if no predicate fields were supplied. "error": same as no but emit an error. (good for testing) "yes": allow (the default); "warn": allow but emit a warning. (good for testing) Now on to res_pjsip... pjsip_options was modified to retrieve aors with qualify_frequency > 0 rather than all endpoints then all aors. Not only was this a big improvement in realtime retrieval but even for config files there's an improvement because we're not going through endpoints anymore. res_pjsip_mwi was modified to retieve only endpoints with something in the mailboxes field instead of all endpoints then testing mailboxes. res_pjsip_registrar_expire was completely refactored. It was retrieving all contacts then setting up scheduler entries to check for expiration. Now, it's a single thread (like keepalive) that periodically retrieves only contacts whose expiration time is < now and deletes them. A new contact_expiration_check_interval was added to global with a default of 30 seconds. Ross Beer reports that with this patch, his Asterisk startup time dropped from around an hour to under 30 seconds. There are still objects that can't be filtered at the database like identifies, transports, and registrations. These are not going to be anywhere near as numerous as endpoints, aors, auths, contacts however. Back to allow_unqualified_fetch. If this is set to yes and you have a very large number of objects in the database, the pjsip CLI commands will attempt to retrive ALL of them if not qualified with a LIKE. Worse, if you type "pjsip show endpoint <tab>" guess what's going to happen? :) Having a cache helps but all the objects will have to be retrieved at least once to fill the cache. Setting allow_unqualified_fetch=no prevents the mass retrieve and should be used on endpoints, auths, aors, and contacts. It should NOT be used for identifies, registrations and transports since these MUST be retrieved in bulk. Example sorcery.conf: [res_pjsip] endpoint=config,pjsip.conf,criteria=type=endpoint endpoint=realtime,ps_endpoints,allow_unqualified_fetch=error ASTERISK-25826 #close Reported-by: Ross Beer Tested-by: Ross Beer Change-Id: Id2691e447db90892890036e663aaf907b2dc1c67
2016-01-13pjsip: Add option global/regcontextDaniel Journo
Added new global option (regcontext) to pjsip. When set, Asterisk will dynamically create and destroy a NoOp priority 1 extension for a given endpoint who registers or unregisters with us. ASTERISK-25670 #close Reported-by: Daniel Journo Change-Id: Ib1530c5b45340625805c057f8ff1fb240a43ea62
2015-09-10res_pjsip: Copy default_from_user to avoid crash.Mark Michelson
The default_from_user retrieval function was pulling the default_from_user from the global configuration struct in an unsafe way. If using a database as a backend configuration store, the global configuration struct is short-lived, so grabbing a pointer from it results in referencing freed memory. The fix here is to copy the default_from_user value out of the global configuration struct. Thanks go to John Hardin for discovering this problem and proposing the patch on which this fix is based. ASTERISK-25390 #close Reported by Mark Michelson Change-Id: I6b96067a495c1259da768f4012d44e03e7c6148c
2015-09-04res_pjsip: Change default from user value.Mark Michelson
When Asterisk sends an outbound SIP request, if there is no direct reason to place a specific value for the username in the From header, Asterisk would generate a UUID. For example, this would happen when sending outbound OPTIONS requests when qualifying or when sending outbound INVITE requests when originating (if no explicit caller ID were provided). The issue is that some SIP providers reject these sorts of requests with a "Name too long" error response. This patch aims to fix this by changing the default outbound username in From headers to "asterisk". This value can be overridden by changing the default_from_user option in the global options if desired. ASTERISK-25377 #close Reported by Mark Michelson Change-Id: I6a4d34a56ff73ff4f661b0075aeba5461b7f3190
2015-04-16res_pjsip: Add global option to limit the maximum time for initial qualifiesGeorge Joseph
Currently when Asterisk starts initial qualifies of contacts are spread out randomly between 0 and qualify_timeout to prevent network and system overload. If a contact's qualify_frequency is 5 minutes however, that contact may be unavailable to accept calls for the entire 5 minutes after startup. So while staggering the initial qualifies is a good idea, basing the time on qualify_timeout could leave contacts unavailable for too long. This patch adds a new global parameter "max_initial_qualify_time" that sets the maximum time for the initial qualifies. This way you could make sure that all your contacts are initialy, randomly qualified within say 30 seconds but still have the contact's ongoing qualifies at a 5 minute interval. If max_initial_qualify_time is > 0, the formula is initial_interval = min(max_initial_interval, qualify_timeout * random(). If not set, qualify_timeout is used. The default is "0" (disabled). ASTERISK-24863 #close Change-Id: Ib80498aa1ea9923277bef51d6a9015c9c79740f4 Tested-by: George Joseph <george.joseph@fairview5.com>
2015-04-09res_pjsip: add CLI command to show global and system configurationKevin Harwell
Added a new CLI command for res_pjsip that shows both global and system configuration settings: pjsip show settings ASTERISK-24918 #close Reported by: Scott Griepentrog Review: https://reviewboard.asterisk.org/r/4597/ ........ Merged revisions 434527 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434528 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-17res_pjsip: Allow configuration of endpoint identifier query orderKevin Harwell
This patch fixes previously reverted code that caused binary incompatibility problems with some modules. And like the original patch it makes sure that no matter what order the endpoint identifier modules were loaded, priority is given based on the ones specified in the new global 'endpoint_identifier_order' option. ASTERISK-24840 Reported by: Mark Michelson Review: https://reviewboard.asterisk.org/r/4489/ ........ Merged revisions 433028 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433029 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-13Revert - res_pjsip: Allow configuration of endpoint identifier query orderKevin Harwell
Due to a break in binary compatibility with some other modules these changes are being reverted until the issue can be resolved. ASTERISK-24840 Reported by: Mark Michelson ........ Merged revisions 432868 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432869 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-11res_pjsip: Fix pjsip.conf type=global object default value handling.Richard Mudgett
When a type=global section is not defined in pjsip.conf the global defaults are not applied. As a result the mandatory Max-Forwards header is not added to SIP messages for res_pjsip/chan_pjsip. The handling of pjsip.conf type=global objects has several problems: 1) If the global object is missing the defaults are not applied. 2) If the global object is missing the default_outbound_endpoint's default value is not returned by ast_sip_global_default_outbound_endpoint(). 3) Defines are needed so default values only need to be changed in one place. * Added a sorcery instance observer callback to check if there were any type=global sections loaded. If there were more than one then issue an error message. If there were none then apply the global defaults. * Fixed ast_sip_global_default_outbound_endpoint() to return the documented default when no type=global object is defined. * Made defines for the global default values. * Increased the default_useragent[] size because SVN version strings can get lengthy and 128 characters may not be enough. * Fixed an off-nominal code path ref leak in global_alloc() if the string fields fail to initialize. * Eliminated RAII_VAR in get_global_cfg() and ast_sip_global_default_outbound_endpoint(). ASTERISK-24807 #close Reported by: Anatoli Review: https://reviewboard.asterisk.org/r/4467/ ........ Merged revisions 432766 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432767 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-09res_pjsip: allow configuration of endpoint identifier query orderKevin Harwell
It's possible to have a scenario that will create a conflict between endpoint identifiers. For instance an incoming call could be identified by two different endpoint identifiers and the one chosen depended upon which identifier module loaded first. This of course causes problems when, for example, the incoming call is expected to be identified by username, but instead is identified by ip. This patch adds a new 'global' option to res_pjsip called 'endpoint_identifier_order'. It is a comma separated list of endpoint identifier names that specifies the order by which identifiers are processed and checked. ASTERISK-24840 #close Reported by: Mark Michelson Review: https://reviewboard.asterisk.org/r/4455/ ........ Merged revisions 432638 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432639 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-17res_pjsip_keepalive: Add runtime configurable keepalive module for ↵Joshua Colp
connection-oriented transports. This change adds a module which is configurable using the keep_alive_interval setting in the global section that will send a CRLF keep alive to all active connection-oriented transports at the provided interval. This is useful because it can help keep connections open through NATs. This functionality also exists within PJSIP but can not be controlled at runtime and requires recompiling it. Review: https://reviewboard.asterisk.org/r/4084/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425825 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-06res_pjsip: Updates and adds more PJSIP CLI commands.Richard Mudgett
* Adds identify, transport, and registration support to the PJSIP CLI. * Creates three additional callbacks, one for an iterator, one for a comparator, and one for a container. This eliminates the link dependency from higher level modules to lower level ones. * Eliminates duplicate sorting in PJSIP CLI commands. * Cleans up PJSIP CLI output formatting. * Pushes CLI command registration down to the implementing source file. * Adds several ast_sip_destroy_sorcery functions to complement existing ast_sip_sorcery_initialize functions. The destroy functions unregister PJSIP CLI commands and PJSIP CLI formatters. Reported by: George Joseph Review: https://reviewboard.asterisk.org/r/3104/ ........ Merged revisions 407568 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407573 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-05res_pjsip: When no global type the debug option defaults to "yes"Kevin Harwell
If the global section was not specified in pjsip.conf then the configuration object does not exist in sorcery so when retrieving "debug" option it would return NULL. Then the NULL result was passed to ast_false utils function which would return false because it wasn't set to some representation of false, thus enabling sip debug logging. Made it so if the global config object does not exist then it will return a default of "no" for sip debugging. (issue ASTERISK-23038) Reported by: Rusty Newton ........ Merged revisions 407442 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407443 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31res_pjsip: Config option to enable PJSIP logger at load time.Kevin Harwell
Added a "debug" configuration option for res_pjsip that when set to "yes" enables SIP messages to be logged. It is specified under the "system" type. Also added an alembic script to add the option to realtime. (closes issue ASTERISK-23038) Reported by: Rusty Newton Review: https://reviewboard.asterisk.org/r/3148/ ........ Merged revisions 407036 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407037 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-11res_pjsip_messaging: send message to a default outbound endpointKevin Harwell
In some cases messages need to be sent to a direct URI (sip:<ip address>). This patch adds in that support by using a default outbound endpoint. When sending messages, if no endpoint can be found then the default one is used. To facilitate this a new default_outbound_endpoint option was added to the globals section for pjsip.conf. Review: https://reviewboard.asterisk.org/r/2944/ ........ Merged revisions 403680 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403687 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-11-22res_pjsip: convert configuration settings names to snake caseKevin Harwell
Renamed, where appropriate, the configuration options for chan/res_pjsip to use snake case (compound words separated by an underscore). For example, faxdetect will become fax_detect, recordofffeature will become record_off_feature, etc... Review: https://reviewboard.asterisk.org/r/3002/ ........ Merged revisions 403022 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403051 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-30The large GULP->PJSIP renaming effort.Mark Michelson
The general gist is to have a clear boundary between old SIP stuff and new SIP stuff by having the word "SIP" for old stuff and "PJSIP" for new stuff. Here's a brief rundown of the changes: * The word "Gulp" in dialstrings, functions, and CLI commands is now "PJSIP" * chan_gulp.c is now chan_pjsip.c * Function names in chan_gulp.c that were "gulp_*" are now "chan_pjsip_*" * All files that were "res_sip*" are now "res_pjsip*" * The "res_sip" directory is now "res_pjsip" * Files in the "res_pjsip" directory that began with "sip_*" are now "pjsip_*" * The configuration file is now "pjsip.conf" instead of "res_sip.conf" * The module info for all PJSIP-related files now uses "PJSIP" instead of "SIP" * CLI and AMI commands created by Asterisk's PJSIP modules now have "pjsip" as the starting word instead of "sip" git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395764 65c4cc65-6c06-0410-ace0-fbb531ad65f3