summaryrefslogtreecommitdiff
path: root/res/res_pjsip/location.c
AgeCommit message (Collapse)Author
2017-11-16res_pjsip: Use sorcery prefix operation for contact lookupSean Bright
This improves performance for registrations assuming that res_config_astdb is not in use. Change-Id: I86f37aa9ef07a4fe63448cb881bbadd996834bb1
2017-11-07res_pjsip: Avoid crash when contact uri is empty stringAaron An
Asterisk will crash if contact uri is invalid, so contact_apply_handler should check if the uri is NULL or empty. ASTERISK-27393 #close Reported-by: Aaron An Tested-by: AaronAn Change-Id: Ia0309bdc6b697c73c9c736e1caec910b77ca69f5
2017-09-14res_pjsip: Filter out non SIP(S) requestsGeorge Joseph
Incoming requests with non sip(s) URIs in the Request, To, From or Contact URIs are now rejected with PJSIP_SC_UNSUPPORTED_URI_SCHEME (416). This is performed in pjsip_message_filter (formerly pjsip_message_ip_updater) and is done at pjproject's "TRANSPORT" layer before a request can even reach the distributor. URIs read by res_pjsip_outbound_publish from pjsip.conf are now also checked for both length and sip(s) scheme. Those URIs read by outbound registration and aor were already being checked for scheme but their error messages needed to be updated to include scheme failure as well as length failure. Change-Id: Ibb2f9f1d2dc7549da562af4cbd9156c44ffdd460
2017-08-15res_pjsip: Fix prune_on_boot to remove only contacts for the host.Richard Mudgett
* Check that the contact's reg_server matches the host's name before deleting any prune_on_boot contacts. We don't want to delete reliable transport contacts made with other servers if the ps_contacts database table is shared with other servers. Thanks to Ross Beer for pointing out that the original prune logic would delete reliable transport contacts from other servers. ASTERISK-27147 Change-Id: I8e439d0d1c266ffdfd7b73d1e5e466180a689bd0
2017-08-10res_pjsip: Remove ephemeral registered contacts on transport shutdown.Richard Mudgett
The fix for the issue is broken up into three parts. This is part two which handles the server side of REGISTER requests when rewrite_contact is enabled. Any registered reliable transport contact becomes invalid when the transport connection becomes disconnected. * Monitor the rewrite_contact's reliable transport REGISTER contact for shutdown. If it is shutdown then the contact must be removed because it is no longer valid. Otherwise, when the client attempts to re-REGISTER it may be blocked because the invalid contact is there. Also if we try to send a call to the endpoint using the invalid contact then the endpoint is not likely to see the request. The endpoint either won't be listening on that port for new connections or a NAT/firewall will block it. * Prune any rewrite_contact's registered reliable transport contacts on boot. The reliable transport no longer exists so the contact is invalid. * Websockets always rewrite the REGISTER contact address and the transport needs to be monitored for shutdown. * Made the websocket transport set a unique name since that is what we use as the ao2 container key. Otherwise, we would not know which transport we find when one of them shuts down. The names are also used for PJPROJECT debug logging. * Made the websocket transport post the PJSIP_TP_STATE_CONNECTED state event. Now the global keep_alive_interval option, initially idle shutdown timer, and the server REGISTER contact monitor can work on wetsocket transports. * Made the websocket transport set the PJSIP_TP_DIR_INCOMING direction. Now initially idle websockets will automatically shutdown. ASTERISK-27147 Change-Id: I397a5e7d18476830f7ffe1726adf9ee6c15964f4
2017-06-06res_pjsip: Add support for returning only reachable contacts and use it.Joshua Colp
This introduces the ability for PJSIP code to specify filtering flags when retrieving PJSIP contacts. The first flag for use causes the query code to only retrieve contacts that are not unreachable. This change has been leveraged by both the Dial() process and the PJSIP_DIAL_CONTACTS dialplan function so they will now only attempt calls to contacts which are not unreachable. ASTERISK-26281 Change-Id: I8233b4faa21ba3db114f5a42e946e4b191446f6c
2017-02-08Revert "Update qualifies when AOR configuration changes."Mark Michelson
This reverts commit 6492e91392b8fd394193e411c6eb64b45486093f. The change in question was intended to prevent the need to reload in order to update qualifies on contacts when an AOR changes. However, this ended up causing a deadlock instead. Change-Id: I1a835c90a5bb65b6dc3a1e94cddc12a4afc3d71e
2017-02-01Update qualifies when AOR configuration changes.Mark Michelson
Prior to this change, qualifies would only update in the following cases: * A reload of res_pjsip.so was issued. * A dynamic contact was re-registered after its AOR's qualify_frequency had been changed This does not work well if you are using realtime for your AORs. You can update your database to have a new qualify_frequency, but the permanent contacts on that AOR will not have their qualifies updated. And the dynamic contacts on that AOR will not have their qualifies updated until the next registration, which could be a long time. This change seeks to fix this problem by making it so that whenever AOR configuration is applied, the contacts pertaining to that AOR have their qualifies updated. Additions from this patch: * AOR sorcery objects now have an apply handler that calls into a newly added function in the OPTIONS code. This causes all contacts associated with that AOR to re-schedule qualifies. * When it is time to qualify a contact, the OPTIONS code checks to see if the AOR can still be retrieved. If not, then qualification is canceled on the contact. Alterations from this patch: * The registrar code no longer updates contact's qualify_frequence and qualify_timeout. There is no point to this since those values already get updated when the AOR changes. * Reloading res_pjsip.so no longer calls the OPTIONS initialization function. Reloading res_pjsip.so results in re-loading AORs, which results in re-scheduling qualifies. Change-Id: I2e7c3316da28f389c45954f24c4e9389abac1121
2016-09-02sorcery: Create function ast_sorcery_lockable_alloc.Corey Farrell
Create an alternative to ast_sorcery_generic_alloc which uses astobj2 shared locking. Use this new method for the 'struct ast_sip_aor' allocator. Change-Id: I3f62f2ada64b622571950278fbb6ad57395b5d6f
2016-08-12Merge "location.c: Misc fixes and cleanups."Joshua Colp
2016-08-11location.c: Misc fixes and cleanups.Richard Mudgett
* Eliminated most RAII_VAR() usage. * Added several missing allocation failure checks. * Made ast_sip_for_each_contact() allocate the wrapper ao2 object without a lock as it is not needed. Change-Id: Ie20913365156c95dd79e5d471cfd25e99ae880bc
2016-08-11res_pjsip: Make aor named lock a mutex.Richard Mudgett
The named aor lock was always being locked for writes so a rwlock adds no benefit and may be slower because rwlocks are biased toward read locking. Change-Id: I8c5c2c780eb30ce5441832257beeb3506fd12b28
2016-06-30Merge "res_pjsip: improve realtime performance #2"Joshua Colp
2016-06-22res_pjsip: improve realtime performance #2Alexei Gradinari
The patch removes updating all Endpoints' status on startup. Instead, only non-qualified aors with static contact and non-qualified non-expired contacts are retrieved from the realtime to update the endpoint status to ONLINE. The endpoint name was added to the contact object to simply find the endpoint that created this contact. The status of endpoints with qualified aors will be updated by 'qualify' functions. ASTERISK-26061 #close Change-Id: Id324c1776fa55d3741e0c5457ecac0304cb1a0df
2016-06-22Fix Alembic upgrades.Mark Michelson
A non-existent constraint was being referenced in the upgrade script. This patch corrects the problem by removing the reference. In addition, the head of the alembic branch referred to a non-existent revision. This has been fixed by referring to the proper revision. This patch fixes another realtime problem as well. Our Alembic scripts store booleans as yes or no values. However, Sorcery tries to insert "true" or "false" instead. This patch introduces a new boolean type that translates to "yes" or "no" instead. ASTERISK-26128 #close Change-Id: I51574736a881189de695a824883a18d66a52dcef
2016-06-09sorcery: Add setting object type congestion levels.Richard Mudgett
Sorcery creates taskprocessors for object types to process object observer callbacks. An API call is needed to be able to set the congestion levels of these taskprocessors for selected object types. * Updated PJSIP's contact and contact_status sorcery object type observer default congestion levels based upon stress testing. Increased the congestion levels to reduce the potential for bursty register/unregister and subscribe/unsubscribe activity from triggering the taskprocessor overload alert. ASTERISK-26088 Reported by: Richard Mudgett Change-Id: I4542e83b556f0714009bfeff89505c801f1218c6
2016-05-26res_pjsip: add "via_addr", "via_port", "call_id" to contactAlexei Gradinari
As res_pjsip_nat rewrites contact's address, only the last Via header can contain the source address of registered endpoint. Also Call-Id header may contain the source address of registered endpoint. Added "via_addr", "via_port", "call_id" to contact. Added new fields ViaAddress, CallID to AMI event ContactStatus. ASTERISK-26011 Change-Id: I36bcc0bf422b3e0623680152d80486aeafe4c576
2016-05-05res_pjsip: improve realtime performanceAlexei Gradinari
This patch modified pjsip_options to retrieve only permament contacts for aor if the qualify_frequency is > 0 and persisted contacts if the qualify_frequency is > 0. This patch also fixed a bug in res_sorcery_astdb. res_sorcery_astdb doesn't save object data retrived from astdb. ASTERISK-25826 Change-Id: I1831fa46c4578eae5a3e574ee3362fddf08a1f05
2016-05-02pjsip: Added "reg_server" to contacts.Alexei Gradinari
If the Asterisk system name is set in asterisk.conf, it will be stored into the "reg_server" field in the ps_contacts table to facilitate multi-server setups. ASTERISK-25931 Change-Id: Ia8f6bd2267809c78753b52bcf21835b9b59f4cb8
2016-04-19PJSIP: Remove PJSIP parsing functions from uri length validation.Mark Michelson
The PJSIP parsing functions provide a nice concise way to check the length of a hostname in a SIP URI. The problem is that in order to use those parsing functions, it's required to use them from a thread that has registered with PJLib. On startup, when parsing AOR configuration, the permanent URI handler may not be run from a PJLib-registered thread. Specifically, this could happen when Asterisk was started in daemon mode rather than console-mode. If PJProject were compiled with assertions enabled, then this would cause Asterisk to crash on startup. The solution presented here is to do our own parsing of the contact URI in order to ensure that the hostname in the URI is not too long. The parsing does not attempt to perform a full SIP URI parse/validation, since the hostname in the URI is what is important. ASTERISK-25928 #close Reported by Joshua Colp Change-Id: Ic3d6c20ff3502507c17244a8b7e2ca761dc7fb60
2016-04-14AST-2016-004: Fix crash on REGISTER with long URI.Mark Michelson
Due to some ignored return values, Asterisk could crash if processing an incoming REGISTER whose contact URI was above a certain length. ASTERISK-25707 #close Reported by George Joseph Patches: 0001-res_pjsip-Validate-that-URIs-don-t-exceed-pjproject-.patch AST-2016-004 Change-Id: I3ea7cee16f29c8088794de3085ca7523c1c4833d
2016-04-11res_pjsip contact: Lock expiration/addition of contactsGeorge Joseph
Contact expiration can occur in several places: res_pjsip_registrar, res_pjsip_registrar_expire, and automatically when anyone calls ast_sip_location_retrieve_aor_contact. At the same time, res_pjsip_registrar may also be attempting to renew or add a contact. Since none of this was locked it was possible for one thread to be renewing a contact and another thread to expire it immediately because it was working off of stale data. This was the casue of intermittent registration/inbound/nominal/multiple_contacts test failures. Now, the new named lock functionality is used to lock the aor during contact expire and add operations and res_pjsip_registrar_expire now checks the expiration with the lock held before deleting the contact. ASTERISK-25885 #close Reported-by: Josh Colp Change-Id: I83d413c46a47796f3ab052ca3b349f21cca47059
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-07res_pjsip: Strip spaces from items parsed from comma-separated listsGeorge Joseph
Configurations like "aors = a, b, c" were either ignoring everything after "a" or trying to look up " b". Same for mailboxes, ciphers, contacts and a few others. To fix, all the strsep(&copy, ",") calls have been wrapped in ast_strip. To facilitate this, ast_strip, ast_skip_blanks and ast_skip_nonblanks were updated to handle null pointers. In some cases, an ast_strlen_zero() test was added to skip consecutive commas. There was also an attempt to ast_free an ast_strdupa'd string in ast_sip_for_each_aor which was causing a SEGV. I removed it. Although this issue was reported for realtime, the issue was in the res_pjsip modules so all config mechanisms were affected. ASTERISK-25829 #close Reported-by: Mateusz Kowalski Change-Id: I0b22a2cf22a7c1c50d4ecacbfa540155bec0e7a2
2016-01-09Revert "pjsip_location: Delete contact_status object when contact is deleted"George Joseph
This reverts commit 0a9941de9d24093b5ff44096d1d7406f29d11e45. Matt, This patch causes another problem and should not have been needed. Before this patch, persistent_endpoint_contact_deleted_observer WAS deleting the contact_status when ast_sip_location_delete_contact was called. By deleting it yourself in ast_sip_location_delete_contact it was gone before the observer could run and the observer therefore was throwing an error and not sending stasis/AMI/statsd messages. So, I don't think this was the cause of your original issue. I also had verified the contact AMI and statsd lifecycle and it was working. I'll double check now though. ASTERISK-25675 Reported-by: Daniel Journo Change-Id: Ib586a6b7f90acb641b0c410f659743ab90e84f1a
2015-12-24res/res_pjsip_location: Delete contact_status object when contact is deletedMatt Jordan
In 450579e908, a change was made that removed the deletion of the 'contact_status' object when a 'contact' object is deleted in sorcery. This unfortunately means that the 'contact_status' object persists, even when something has explicitly removed a contact. The result is that the state of the contact will not be regenerated if that contact is re-created, and the stale state will be reported/used for that contact. It also results in no ContactStatusChanged events being generated for either ARI or AMI. This patch restores the deletion logic that was removed. Doing so now results in the expected events being generated again. Change-Id: I28789a112e845072308b5b34522690e3faf58f07
2015-12-04res_pjsip/contacts/statsd: Make contact lifecycle events more consistentGeorge Joseph
It will never be perfect or even pretty, mostly because of the differences between static and dynamic contacts. Created: Can't use the contact or contact_status alloc functions because the objects come and go regardless of the actual state. Can't use the contact_apply_handler, ast_sip_location_add_contact or a sorcery created handler because they only get called for dynamic contacts. Similarly, permanent_uri_handler only gets called for static contacts. So, Matt had it right. :) ast_res_pjsip_find_or_create_contact_status is the only place it can go and not have duplicated code. Both permanent_uri_handler and contact_apply_handler call find_or_create. Removed: Can't use the destructors for the same reason as above. The only place to put this is in persistent_endpoint_contact_deleted_observer which I believe is the "correct" place but even that will handle only dynamic contacts. This doesn't called on shutdown however. There is no hook to use for static contacts that may be removed because of a config change while asterisk is in operation. I moved the cleanup of contact_status from ast_sip_location_delete_contact to the handler as well. Status Change and RTT: Although they worked fine where they were (in update_contact_status) I moved them to persistent_endpoint_contact_status_observer to make it more consistent with removed. There was logic there already to detect a state change. Finally, fixed a nit in permanent_uri_handler rmudgett reported eralier. ASTERISK-25608 #close Change-Id: I4b56e7dfc3be3baaaf6f1eac5b2068a0b79e357d Reported-by: George Joseph Tested-by: George Joseph
2015-12-03res_pjsip: Use a MD5 hash for static Contact IDsGeorge Joseph
When 90d9a70789 was merged, it mostly tested dynamic contacts created as a result of registering a PJSIP endpoint. Contacts generated in this fashion typically have a long alphanumeric string as their object identifier, which maps reasonably well for StatsD. Unfortunately, this doesn't work in the general case. StatsD treats both '.' and ':' characters as special characters. In particular, having a ':' appear in the middle of a StatsD metric will result in the metric being rejected. This causes some obvious issues with SIP URIs. The StatsD API should not be responsible for escaping the metric name passed to it. The metric is treated as a single long string, and it would be challenging to know what to escape in the string passed to the function. Likewise, we don't want to escape the metric in PJSIP, as that involves overhead that is wasted when either res_statsd isn't loaded or enabled. This patch takes an alternative approach. The Contact ID has been changed to be "aor@@uri_hash" instead of "aor@@uri". This (a) won't contain any of the aforementioned special characters, (b) can be done on Contact creation, which has minimal impact on run-time performance, and (c) also conforms to an earlier commit that changed the ID for dynamic contacts. The downside of this is that StatsD users will have to map SHA1 hashes back to the Contacts that are emitting the statistics. To that end, the CLI commands have been updated to include the first 10 characters of the MD5 hash, which should be enough to match what is shown in Graphite (or some other StatsD backend). ASTERISK-25595 #close Change-Id: Ic674a3307280365b4a45864a3571c295b48a01e2 Reported-by: Matt Jordan Tested-by: George Joseph
2015-12-02res_pjsip: Update logging to show contact->uri in messagesGeorge Joseph
An earlier commit changed the id of dynamic contacts to contain a hash instead of the uri. This patch updates status change logging to show the aor/uri instead of the id. This required adding the aor id to contact and contact_status and adding uri to contact_status. The aor id gets added to contact and contact_status in their allocators and the uri gets added to contact_status in pjsip_options when the contact_status is created or updated. ASTERISK-25598 #close Reported-by: George Joseph Tested-by: George Joseph Change-Id: I56cbec1d2ddbe8461367dd8b6da8a6f47f6fe511
2015-11-24Fixed some typosDavid M. Lee
Fixes some minor typos in the CHANGES file, plus an embarrasing typo in the StatsD API. Change-Id: I9ca4858c64a4a07d2643b81baa64baebb27a4eb7
2015-11-23res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contactsMatt Jordan
This patch adds the ability to send StatsD statistics related to the state of PJSIP contacts. This includes: * A GUAGE statistic measuring the count of contacts in a particular state. This measures how many contacts are reachable, unreachable, etc. * The RTT time for each contact, if those contacts are qualified. This provides StatsD engines useful time-based data about each contact. ASTERISK-25571 Change-Id: Ib8378d73afedfc622be0643b87c542557e0b332c
2015-11-03res_pjsip/location: Destroy contact_status objects on contact deletionMatt Jordan
The contact_status Sorcery objects are currently not destroyed when a contact is deleted. This causes the contact's last known RTT/status to be 'sticky' when the contact itself may no longer exist. This patch causes the contact_status objects associated with both dynamic and static contacts to be destroyed if the AoR holding those contacts is also destroyed (or via other paths where a contact may be deleted.) Change-Id: I7feec8b9278cac3c5263a4c0483f4a0f3b62426e
2015-10-24res_pjsip: Add "like" processing to pjsip list and show commandsGeorge Joseph
Add the ability to filter output from pjsip list and show commands using the "like" predicate like chan_sip. For endpoints, aors, auths, registrations, identifyies and transports, the modification was a simple change of an ast_sorcery_retrieve_by_fields call to ast_sorcery_retrieve_by_regex. For channels and contacts a little more work had to be done because neither of those objects are true sorcery objects. That was just removing the non-matching object from the final container. Of course, a little extra plumbing in the common pjsip_cli code was needed to parse the "like" and pass the regex to the get_container callbacks. Some of the get_container code in res_pjsip_endpoint_identifier was also refactored for simplicity. ASTERISK-25477 #close Reported by: Bryant Zimmerman Tested by: George Joseph Change-Id: I646d9326b778aac26bb3e2bcd7fa1346d24434f1
2015-10-21res_pjsip: Move URI validation to use time.Joshua Colp
In a realtime based system with a limited number of threadpool threads it is possible for a deadlock to occur. This happens when permanent endpoint state is updated, which will cause database queries to be done. These queries may result in URI validation being done which is done synchronously using a PJSIP thread. If all PJSIP threads are in use processing traffic they themselves may be blocked waiting to get the permanent endpoint container lock when identifying an endpoint. This change moves URI validation to occur at use time instead of configuration time. While this comes at a cost of not seeing a problem until you use it it does solve the underlying deadlock problem. ASTERISK-25486 #close Change-Id: I2d7d167af987d23b3e8199e4a68f3359eba4c76a
2015-09-10res_pjsip/location.c: Use the builtin ao2_callback() match function instead.Richard Mudgett
Change-Id: I364906d6d2bad3472929986704a0286b9a2cbe3f
2015-09-09Merge "res_pjsip: Use hash for contact object identity instead of Contact URI."Joshua Colp
2015-09-08res_pjsip: Use hash for contact object identity instead of Contact URI.Joshua Colp
In the wild it is possible for Contact URIs to be quite long as parameters can exist on them. This can present a problem when storing them in the AstDB as the URI is used as part of the object name and there is a fixed length limit for the AstDB. This will cause the contact to not get stored. This change uses the MD5 hash of the Contact URI as part of the object name instead. This has a fixed length which is guaranteed to not exceed the AstDB length limit. ASTERISK-25295 #close Change-Id: Ie8252a75331ca00b41b9f308f42cc1fbdf701a02
2015-09-07res/res_pjsip: Purge contacts when an AoR is deletedMatt Jordan
When an AoR is deleted by an external mechanism, such as through ARI, we currently do not remove dynamic contacts that were created for that AoR as a result of a received REGISTER request. As a result, re-creating the AoR will cause the dynamic contact to be interpreted as a persistent contact, leading to some rather strange state being created for the contacts/endpoints. This patch adds a sorcery observer for the 'aor' object. When a delete is issued on the underlying sorcery object, the observer is called, and all contacts created and persisted in sorcery for that AoR are also removed. Note that we don't want to perform this action when an AO2 object that is an AoR is destroyed, as the AoR can still exist in the backing storage (and we would thus be removing valid contacts from an AoR that still "exists".) ASTERISK-25381 #close Change-Id: I6697e51ef6b2858b5d63401f35dc378bb0f90328
2015-06-23res_pjsip_mwi: Set up unsolicited MWI upon registration.Joshua Colp
The res_pjsip_mwi previously required a reload to set up the proper subscriptions to allow unsolicited MWI to work. This change makes it so the act of registering will also cause this to occur. This is particularly useful if realtime is involved as no reload needs to occur within Asterisk to cause the MWI information to get sent. ASTERISK-25180 #close Change-Id: Id847b47de4b8b3ab8858455ccc2f07b0f915f252
2015-06-03res_pjsip/location: Fix ref leak in contact_apply_handlerGeorge Joseph
contact_apply_handler calls ast_res_pjsip_find_or_create_contact_status to force the creation of a contact_status object whenever a new contact is added but it didn't unref the returned object. Added an ao2_cleanup(status) to plug the leak. ASTERISK-25141 Change-Id: Icc1401cae142855a1abc86ab5179dfb3ee861c40 Reported-by: Corey Farrell
2015-05-29res_pjsip/location: Fix memory leak in permanent_uri_handlerGeorge Joseph
When permanent_uri_handler was creating the contact status object for each contact, it wasn't unreffing it at the end of the loop. ASTERISK-25141 #close Reported-by: Corey Farrell Change-Id: I7bb127994677bb3d459f87952f8425c9b9967b12
2015-04-27res_pjsip: Fix SEGV on pending-qualify contactsGeorge Joseph
Permanent contacts that hadn't been qualified yet were missing their contact_status entries causing SEGVs when running CLI commands. This patch makes sure that contact_statuses are created for both dynamic and permanent contacts when they are created. It also adds checks in the CLI code to make sure there's a contact_status, just in case. ASTERISK-25018 #close Reported-by: Ivan Poddubny Tested-by: Ivan Poddubny Tested-by: George Joseph Change-Id: I3cc13e5cedcafb24c400368b515b02d7fb81e029
2015-04-23res_pjsip: Validate that contact uris start with sip: or sips:George Joseph
Currently we use pjsip_parse_hdr to validate contact uris but it appears that it allows uris without a scheme if there's a port supplied. I.E myexample.com will fail but myexample.com:5060 will pass even though it has no scheme. This causes SEGVs later on whenever the uri is used. To prevent this, permanent_contact_validate has been updated to check that the scheme is either 'sip' or 'sips'. 2 uses of possibly-null endpoint have also been fixed in create_out_of_dialog_request. ASTERISK-24999 Change-Id: Ifc17d16a4923e1045d37fe51e43bbe29fa556ca2 Reported-by: Brad Latus
2015-04-19pjsip_options: Fix non-qualified contacts showing as unavailableGeorge Joseph
The "Add qualify_timeout processing and eventing" patch introduced an issue where contacts that had qualify_frequency set to 0 were showing Unavailable instead Unknown. This patch checks for qualify_frequency=0 and create an "Unknown" contact_status with an RTT = 0. Previously, the lack of contact_status implied Unknown but since we're now changing endpoint state based on contact_status, I've had to add new UNKNOWN status so that changes could trigger the appropriate contact_status observers. ASTERISK-24977: #close Change-Id: Ifcbc01533ce57f0e4e584b89a395326e098b8fe7
2015-04-16pjsip_options: Add qualify_timeout processing and eventingGeorge Joseph
This is the second follow-on to https://reviewboard.asterisk.org/r/4572/ and the discussion at http://lists.digium.com/pipermail/asterisk-dev/2015-March/073921.html The basic issues are that changes in contact status don't cause events to be emitted for the associated endpoint. Only dynamic contact add/delete actions update the endpoint. Also, the qualify timeout is fixed by pjsip at 32 seconds which is a long time. This patch makes use of the new transaction timeout feature in r4585 and provides the following capabilities... 1. A new aor/contact variable 'qualify_timeout' has been added that allows the user to specify the maximum time in milliseconds to wait for a response to an OPTIONS message. The default is 3000ms. When the timer expires, the contact is marked unavailable. 2. Contact status changes are now propagated up to the endpoint as follows... When any contact is 'Available', the endpoint is marked as 'Reachable'. When all contacts are 'Unavailable', the endpoint is marked as 'Unreachable'. The existing endpoint events are generated appropriately. ASTERISK-24863 #close Change-Id: Id0ce0528e58014da1324856ea537e7765466044a Tested-by: Dmitriy Serov Tested-by: George Joseph <george.joseph@fairview5.com>
2015-01-27res_pjsip: make it unloadable (take 2)Kevin Harwell
Due to the original patch causing memory corruptions it was removed until the problem could be resolved. This patch is the original patch plus some added locking around stasis router subcription that was needed to avoid the memory corruption. Description of the original problem and patch (still applicable): The res_pjsip module was previously unloadable. With this patch it can now be unloaded. This patch is based off the original patch on the issue (listed below) by Corey Farrell with a few modifications. Namely, removed a few changes not required to make the module unloadable and also fixed a bug that would cause asterisk to crash on unloading. This patch is the first step (should hopefully be followed by another/others at some point) in allowing res_pjsip and the modules that depend on it to be unloadable. At this time, res_pjsip and some of the modules that depend on res_pjsip cannot be unloaded without causing problems of some sort. The goal of this patch is to get res_pjsip and only res_pjsip to be able to unload successfully and/or shutdown without incident (crashes, leaks, etc...). Other dependent modules may still cause problems on unload. Basically made sure, with the patch applied, that res_pjsip (with no other dependent modules loaded) could be succesfully unloaded and Asterisk could shutdown without any leaks or crashes that pertained directly to res_pjsip. ASTERISK-24485 #close Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4363/ patches: pjsip_unload-broken-r1.patch submitted by Corey Farrell (license 5909) ........ Merged revisions 431179 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431180 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-17REVERTING res_pjsip: make it unloadableKevin Harwell
Due to the original patch causing memory corruptions the patch is being removed until the problem can be resolved. ........ Merged revisions 430734 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430735 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-14res_pjsip: make it unloadableKevin Harwell
The res_pjsip module was previously unloadable. With this patch it can now be unloaded. This patch is based off the original patch on the issue (listed below) by Corey Farrell with a few modifications. Namely, removed a few changes not required to make the module unloadable and also fixed a bug that would cause asterisk to crash on unloading. This patch is the first step (should hopefully be followed by another/others at some point) in allowing res_pjsip and the modules that depend on it to be unloadable. At this time, res_pjsip and some of the modules that depend on res_pjsip cannot be unloaded without causing problems of some sort. The goal of this patch is to get res_pjsip and only res_pjsip to be able to unload successfully and/or shutdown without incident (crashes, leaks, etc...). Other dependent modules may still cause problems on unload. Basically made sure, with the patch applied, that res_pjsip (with no other dependent modules loaded) could be succesfully unloaded and Asterisk could shutdown without any leaks or crashes that pertained directly to res_pjsip. ASTERISK-24485 #close Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4311/ patches: pjsip_unload-broken-r1.patch submitted by Corey Farrell (license 5909) ........ Merged revisions 430628 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430629 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-06pjsip cli: Fix sorting of contacts for 'pjsip list contacts'George Joseph
For some reason I was using a hash container instead of a list to gather the contacts for 'pjsip list/show contacts' so even though I had a sort function, the output wasn't sorted. This patch just changes the hash container to a list container and the contacts now appear sorted in the CLI. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4305/ ........ Merged revisions 430221 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430222 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-05pjsip: Add 'PJSIP_AOR' and 'PJSIP_CONTACT' dialplan functions.Joshua Colp
The PJSIP_AOR dialplan function allows inspection of configured AORs including what contacts are currently bound to them. The PJSIP_CONTACT dialplan function allows inspection of contacts in existence. These can include both externally added (by way of registration) or permanent ones. ASTERISK-24341 Reported by: xrobau Review: https://reviewboard.asterisk.org/r/4308/ ........ Merged revisions 430179 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430180 65c4cc65-6c06-0410-ace0-fbb531ad65f3