summaryrefslogtreecommitdiff
path: root/main
AgeCommit message (Collapse)Author
2015-09-02pbx: Fix crash when issuing "core show hints" with long pattern match.Joshua Colp
When issuing the "core show hints" CLI command a combination of both the hint extension and context is created. This uses a fixed size buffer expecting that the extension will not exceed maximum extension length. When the extension is actually a pattern match this constraint does not hold true, and the extension may exceed the maximum extension length. In this case extra characters are written past the end of the fixed size buffer. This change makes it so the construction of the combined hint extension and context can not exceed the size of the buffer. ASTERISK-25367 #close Change-Id: Idfa1b95d0d4dc38e675be7c1de8900b3f981f499
2015-08-29taskprocessor: Fix race condition between unreferencing and finding.Joshua Colp
When unreferencing a taskprocessor its reference count is checked to determine if it should be unlinked from the taskprocessors container and its listener shut down. In between the time when the reference count is checked and unlinking it is possible for another thread to jump in, find it, and get a reference to it. If the thread then uses the taskprocessor it may find that it is not in the state it expects. This change locks the taskprocessors container during almost the entire unreference operation to ensure that any other thread which may attempt to find the taskprocessor has to wait. ASTERISK-25295 Change-Id: Icb842db82fe1cf238da55df92e95938a4419377c
2015-08-28sched: ast_sched_del may return prematurely due to spurious wakeupJoshua Colp
When deleting a scheduled item if the item in question is currently executing the ast_sched_del function waits until it has completed. This is accomplished using ast_cond_wait. Unfortunately the ast_cond_wait function can suffer from spurious wakeups so the predicate needs to be checked after it returns to make sure it has really woken up as a result of being signaled. This change adds a loop around the ast_cond_wait to make sure that it only exits when the executing task has really completed. ASTERISK-25355 #close Change-Id: I51198270eb0b637c956c61aa409f46283432be61
2015-08-24bridge: Kick channel from bridge if hung up during action.Joshua Colp
When executing an action in a bridge it is possible for the channel to be hung up without the bridge becoming aware of it. This is most easily reproducible by hanging up when the bridge is streaming DTMF due to a feature timeout. This change makes it so after action execution the channel is checked to determine if it has been hung up and if it has it is kicked from the bridge. ASTERISK-25341 #close Change-Id: I6dd8b0c3f5888da1c57afed9e8a802ae0a053062
2015-08-20rtp_engine.c: Get current or create a needed rx payload type mapping.Richard Mudgett
* Make ast_rtp_codecs_payload_code() get the current mapping or create a rx payload type mapping. ASTERISK-25166 Reported by: Kevin Harwell ASTERISK-17410 Reported by: Boris Fox Change-Id: Ia4b2d45877a8f004f6ce3840e3d8afe533384e56
2015-08-19rtp_engine.c: Extract rtp_codecs_payload_replace_rx().Richard Mudgett
ASTERISK-25166 Reported by: Kevin Harwell ASTERISK-17410 Reported by: Boris Fox Change-Id: I34e23bf5b084c8570f9c3e6ccd19b95fe85af239
2015-08-19rtp_engine.c: Initial split of payload types into rx and tx mappings.Richard Mudgett
There are numerous problems with the current implementation of the RTP payload type mapping in Asterisk. It uses only one mapping structure to associate payload types to codecs. The single mapping is overkill if all of the payload type values are well known values. Dynamic payload type mappings do not work as well with the single mapping because RFC3264 allows each side of the link to negotiate different dynamic mappings for what they want to receive. Not only could you have the same codec mapped for sending and receiving on different payload types you could wind up with the same payload type mapped to different codecs for each direction. 1) An independent payload type mapping is needed for sending and receiving. 2) The receive mapping needs to keep track of previous mappings because of the slack to when negotiation happens and current packets in flight using the old mapping arrive. 3) The transmit mapping only needs to keep track of the current negotiated values since we are sending the packets and know when the switchover takes place. * Needed to create ast_rtp_codecs_payload_code_tx() and make some callers use the new function because ast_rtp_codecs_payload_code() was used for mappings in both directions. * Needed to create ast_rtp_codecs_payloads_xover() for cases where we need to pass preferred codec mappings to the peer channel for early media bridging or when we need to prefer the offered mapping that RFC3264 says we SHOULD use. * ast_rtp_codecs_payloads_xover() and ast_rtp_codecs_payload_code_tx() are the only new public functions created. All the others were only used for the tx or rx mapping direction so the function doxygen now reflects which direction the function operates. * chan_mgcp.c: Removed call to ast_rtp_codecs_payloads_clear() as doing that makes no sense when processing an incoming SDP. We would be wiping out any mappings that we set for the possible outgoing SDP we sent earlier. ASTERISK-25166 Reported by: Kevin Harwell ASTERISK-17410 Reported by: Boris Fox Change-Id: Iaf6c227bca68cb7c414cf2fd4108a8ac98bd45ac
2015-08-17CHAOS: prevent sorcery object with null idScott Griepentrog
When allocating a sorcery object, fail if the id value was not allocated. ASTERISK-25323 Reported by: Scott Griepentrog Change-Id: I152133fb7545a4efcf7a0080ada77332d038669e
2015-08-13audiohook.c: Simplify variable usage in audiohook_read_frame_both().Richard Mudgett
Change-Id: I58bed58631a94295b267991c5b61a3a93c167f0c
2015-08-13audiohook.c: Fix MixMonitor crash when using the r() or t() options.Richard Mudgett
The built frame format in audiohook_read_frame_both() is now set to a signed linear format before the rx and tx frames are duplicated instead of only for the mixed audio frame duplication. ASTERISK-25322 #close Reported by Sean Pimental Change-Id: I86f85b5c48c49e4e2d3b770797b9d484250a1538
2015-08-10main/format: Add an API call for retrieving format attributesMatt Jordan
Some codecs that may be a third party library to Asterisk need to have knowledge of the format attributes that were negotiated. Unfortunately, when the great format migration of Asterisk 13 occurred, that ability was lost. This patch adds an API call, ast_format_attribute_get, to the core format API, along with updates to the unit test to check the new API call. A new callback is also now available for format attribute modules, such that they can provide the format attribute values they manage. Note that the API returns a void *. This is done as the format attribute modules themselves may store format attributes in any particular manner they like. Care should be taken by consumers of the API to check the return value before casting and dereferencing. Consumers will obviously need to have a priori knowledge of the type of the format attribute as well. Change-Id: Ieec76883dfb46ecd7aff3dc81a52c81f4dc1b9e3
2015-08-10Merge "Replaces clock_gettime() with ast_tsnow()"Joshua Colp
2015-08-08Merge "rtp_engine.c: Fix performance issue with several channel drivers that ↵Matt Jordan
use RTP."
2015-08-07Replaces clock_gettime() with ast_tsnow()David M. Lee
clock_gettime() is, unfortunately, not portable. But I did like that over our usual `ts.tv_nsec = tv.tv_usec * 1000` copy/paste code we usually do when we want a timespec and all we have is ast_tvnow(). This patch adds ast_tsnow(), which mimics ast_tvnow(), but returns a timespec. If clock_gettime() is available, it will use that. Otherwise ast_tsnow() falls back to using ast_tvnow(). Change-Id: Ibb1ee67ccf4826b9b76d5a5eb62e90b29b6c456e
2015-08-07ARI: Retrieve existing log channelsScott Emidy
An http request can be sent to get the existing Asterisk logs. The command "curl -v -u user:pass -X GET 'http://localhost:8088 /ari/asterisk/logging'" can be run in the terminal to access the newly implemented functionality. * Retrieve all existing log channels ASTERISK-25252 Change-Id: I7bb08b93e3b938c991f3f56cc5d188654768a808
2015-08-07ARI: Creating log channelsScott Emidy
An http request can be sent to create a log channel in Asterisk. The command "curl -v -u user:pass -X POST 'http://localhost:088/ari/asterisk/logging/mylog? configuration=notice,warning'" can be run in the terminal to access the newly implemented functionality for ARI. * Ability to create log channels using ARI ASTERISK-25252 Change-Id: I9a20e5c75716dfbb6b62fd3474faf55be20bd782
2015-08-06ARI: Deleting log channelsScott Emidy
An http request can be sent to delete a log channel in Asterisk. The command "curl -v -u user:pass -X DELETE 'http://localhost:8088 /ari/asterisk/logging/mylog'" can be run in the terminal to access the newly implemented functionally for ARI. * Able to delete log channels using ARI ASTERISK-25252 Change-Id: Id6eeb54ebcc511595f0418d586ff55914bc3aae6
2015-08-06Merge "rtp_engine.c: Must protect mime_types_len with mime_types_lock."Joshua Colp
2015-08-03Merge topic 'misc_rtp_tweaks'Joshua Colp
* changes: rtp_engine.h: No sense allowing payload types larger than RFC allows. rtp_engine.c: Minor tweaks. rtp_engine.h: Misc comment fixes.
2015-07-31ARI: Rotate log channels.Benjamin Ford
An http request can be sent to rotate a specified log channel. If the channel does not exist, an error response will be returned. The command "curl -v -u user:pass -X PUT 'http://localhost:8088 /ari/asterisk/logging/logChannelName/rotate'" can be run in the terminal to access this new functionality. * Added the ability to rotate log files through ARI ASTERISK-25252 Change-Id: Iaefa21cbbc1b29effb33004ee3d89c977e76ab01
2015-07-31Merge "dns_core: Allow zero-length DNS responses."Joshua Colp
2015-07-31dns_core: Allow zero-length DNS responses.Mark Michelson
A testsuite test recently failed due to a crash that occurred in the DNS core. The problem was that the test could not resolve an address, did not set a result on the DNS query, and then indicated the query was completed. The DNS core does not handle the case of a query with no result gracefully, and so there is a crash. This changeset makes the DNS system resolver set a result with a zero-length answer in the case that a DNS resolution failure occurs early. The DNS core now also will accept such a response without treating it as invalid input. A unit test was updated to no longer treat setting a zero-length response as off-nominal. Change-Id: Ie56641e22debdaa61459e1c9a042e23b78affbf6
2015-07-30rtp_engine.c: Fix performance issue with several channel drivers that use RTP.Richard Mudgett
ast_rtp_codecs_get_payload() gets called once or twice for every received RTP frame so it would be nice to not allocate an ao2 object to then have it destroyed shortly thereafter. The ao2 object gets allocated only if the payload type is not set by the channel driver as a negotiated value. The issue affects chan_skinny, chan_unistim, chan_rtp, and chan_ooh323. * Made static_RTP_PT[] an array of ao2 objects that ast_rtp_codecs_get_payload() can return instead of an array of structs that must be copied into a created ao2 object. ASTERISK-25296 #close Reported by: Richard Mudgett Change-Id: Icb6de5cd90bfae07d44403a1352963db9109dac0
2015-07-30rtp_engine.c: Must protect mime_types_len with mime_types_lock.Richard Mudgett
Change-Id: I44220dd369cc151ebf5281d5119d84bb9e54d54e
2015-07-30rtp_engine.h: No sense allowing payload types larger than RFC allows.Richard Mudgett
* Tweaked add_static_payload() to not use magic numbers. Change-Id: I1719ff0f6d3ce537a91572501eae5bcd912a420b
2015-07-30rtp_engine.c: Minor tweaks.Richard Mudgett
* Fix off nominial ref leak of new_type in ast_rtp_codecs_payloads_set_m_type(). * No need to lock static_RTP_PT_lock in ast_rtp_codecs_payloads_set_m_type() and ast_rtp_codecs_payloads_set_rtpmap_type_rate() before the payload type parameter sanity check. * No need to create ast_rtp_payload_type ao2 objects with a lock since the lock is not used. Change-Id: I64dd1bb4dfabdc7e981e3f61448beac9bb7504d4
2015-07-29Add a test event for inband ringing.Mark Michelson
This event is necessary for the bridge_wait_e_options test to be able to confirm that ringing is being played on the local channel that runs the BridgeWait() application with the e(r) option. ASTERISK-25292 #close Reported by Kevin Harwell Change-Id: Ifd3d3d2bebc73344d4b5310d0d55c7675359d72e
2015-07-28holding_bridge: ensure moh participants get framesJonathan Rose
Currently, if a blank musiconhold.conf is used, musiconhold will fail to start for a channel going into a holding bridge with an anticipation of getting music on hold. That being the case, no frames will be written to the channel and that can pose a problem for blind transfers in PJSIP which may rely on frames being written to get past the REFER framehook. This patch makes holding bridges start a silence generator if starting music on hold fails and makes it so that if no music on hold functions are installed that the ast_moh_start function will report a failure so that consumers of that function will be able to respond appropriately. ASTERISK-25271 #close Change-Id: I06f066728604943cba0bb0b39fa7cf658a21cd99 (cherry picked from commit 8458b8d441c2f4143ff135163ff3da4f88fe14c8)
2015-07-24pjsip: Add rtp_timeout and rtp_timeout_hold endpoint options.Joshua Colp
This change adds support for the 'rtp_timeout' and 'rtp_timeout_hold' endpoint options. These allow the channel to be hung up if RTP is not received from the remote endpoint for a specified number of seconds. ASTERISK-25259 #close Change-Id: I3f39daaa7da2596b5022737b77799d16204175b9
2015-07-24Local channels: Alternate solution to ringback problem.Mark Michelson
Commit 54b25c80c8387aea9eb20f9f4f077486cbdf3e5d solved an issue where a specific scenario involving local channels and a native local RTP bridge could result in ringback still being heard on a calling channel even after the call is bridged. That commit caused many tests in the testsuite to fail with alarming consequences, such as not sending DialBegin and DialEnd events, and giving incorrect hangup causes during calls. This commit reverts the previous commit and implements and alternate solution. This new solution involves only passing AST_CONTROL_RINGING frames across local channels if the local channel is in AST_STATE_RING. Otherwise, the frame does not traverse the local channels. By doing this, we can ensure that a playtones generator does not get started on the calling channel but rather is started on the local channel on which the ringing frame was initially indicated. ASTERISK-25250 #close Reported by Etienne Lessard Change-Id: I3bc87a18a38eb2b68064f732d098edceb5c19f39
2015-07-22Merge "audiohook: Use manipulated frame instead of dropping it."Matt Jordan
2015-07-22Merge "audiohook: Read the correct number of samples based on audiohook format."Mark Michelson
2015-07-22audiohook: Use manipulated frame instead of dropping it.Joshua Colp
Previous changes to sample rate support in audiohooks accidentally removed code responsible for allowing the manipulate audiohooks to work. Without this code the manipulated frame would be dropped and not used. This change restores it. ASTERISK-25253 #close Change-Id: I3ff50664cd82faac8941f976fcdcb3918a50fe13
2015-07-22Local channels: Do not block control -1 payloads.Mark Michelson
Control frames with a -1 payload are used as a special signal to stop playtones generators on channels. This indication is sent both by app_dial as well as by ast_answer() when a call is answered in case any tones were being generated on a calling channel. This control frame type was made to stop traversing local channel pairs as an optimization, because it was thought that it was unnecessary to send these indications, and allowing such unnecessary control frames to traverse the local channels would cause the local channels to optimize away less quickly. As it turns out, through some special magic dialplan code, it is possible to have a tones being played on a non-local channel, and it is important for the local channel to convey that the tones should be stopped. The result of having tones continue to be played on the non-local channel is that the tones play even once the channel has been bridged. By not blocking the -1 control frame type, we can ensure that this situation does not happen. ASTERISK-25250 #close Reported by Etienne Lessard Change-Id: I0bcaac3d70b619afdbd0ca8a8dd708f33fd2f815
2015-07-22audiohook: Read the correct number of samples based on audiohook format.Joshua Colp
Due to changes in audiohooks to support different sample rates the underlying storage of samples is in the format of the audiohook itself and not of the format being requested. This means that if a channel is using G722 the samples stored will be at 16kHz. If something subsequently reads from the audiohook at a format which is not the same sample rate as the audiohook the number of samples needs to be adjusted. Given the following example: 1. Channel writing into audiohook at 16kHz (as it is using G722). 2. Chanspy reading from audiohook at 8kHz. The original code would read 160 samples from the audiohook for each 20ms of audio. This is incorrect. Since the audio in the audiohook is at 16kHz the actual number needing to be read is 320. Failure to read this much would cause the audiohook to reset itself constantly as the buffer became full. This change adjusts the requested number of samples by determining the duration of audio requested and then calculating how many samples that would be in the audiohook format. ASTERISK-25247 #close Change-Id: Ia91ce516121882387a315fd8ee116b118b90653d
2015-07-20Merge "res_pjsip: Add rtp_keepalive endpoint option."Joshua Colp
2015-07-20res_pjsip: Add rtp_keepalive endpoint option.Mark Michelson
This adds an "rtp_keepalive" option for PJSIP endpoints. Similar to the chan_sip option, this specifies an interval, in seconds, at which we will send RTP comfort noise frames. This can be useful for keeping RTP sessions alive as well as keeping NAT associations alive during lulls. ASTERISK-25242 #close Reported by Mark Michelson Change-Id: I3b9903d99e35fe5d0b53ecc46df82c750776bc8d
2015-07-17pbx.c: Post AMI VarSet event if delete a non-empty dialplan variable.Richard Mudgett
ASTERISK-25256 #close Reported by: Richard Mudgett Change-Id: I0b6be720b66fa956f6a798cd22ef8934eb0c0ff3
2015-07-17Merge "strings.h: Fix issues with escape string functions."Matt Jordan
2015-07-16Merge "media cache: Add CLI commands"Matt Jordan
2015-07-16Merge "media cache: Add a core API and facade for a backend agnostic media ↵Matthew Jordan
cache"
2015-07-16strings.h: Fix issues with escape string functions.Richard Mudgett
Fixes for issues with the ASTERISK-24934 patch. * Fixed ast_escape_alloc() and ast_escape_c_alloc() if the s parameter is an empty string. If it were an empty string the functions returned NULL as if there were a memory allocation failure. This failure caused the AMI VarSet event to not get posted if the new value was an empty string. * Fixed dest buffer overwrite potential in ast_escape() and ast_escape_c(). If the dest buffer size is smaller than the space needed by the escaped s parameter string then the dest buffer would be written beyond the end by the nul string terminator. The num parameter was really the dest buffer size parameter so I renamed it to size. * Made nul terminate the dest buffer if the source string parameter s was an empty string in ast_escape() and ast_escape_c(). * Updated ast_escape() and ast_escape_c() doxygen function description comments to reflect reality. * Added some more unit test cases to /main/strings/escape to cover the empty source string issues. ASTERISK-25255 #close Reported by: Richard Mudgett Change-Id: Id77fc704600ebcce81615c1200296f74de254104
2015-07-14Merge "main/bucket: Add a callback function for ast_bucket_file objects"Matt Jordan
2015-07-13Merge "ARI: Added new functionality to get information on a single module."Mark Michelson
2015-07-13ARI: Added new functionality to get information on a single module.Benjamin Ford
An http request can be sent to retrieve information on a single module, including the resource name, description, use count, status, and support level. The command "curl -v -u user:pass -X GET 'http://localhost:8088/ari /asterisk/modules/{moduleName}'" (or something similar, depending on configuration) can be run in the terminal to access this new functionality. For more information, see: https://wiki.asterisk.org/wiki.display/~bford/Asterisk+ARI+Resource * Added new ARI functionality * Information on a single module can now be retrieved ASTERISK-25173 Change-Id: Ibce5a94e70ecdf4e90329cf0ba66c33a62d37463
2015-07-13bridge.c: Fixed race condition during attended transferKevin Harwell
During an attended transfer a thread is started that handles imparting the bridge channel. From the start of the thread to when the bridge channel is ready exists a gap that can potentially cause problems (for instance, the channel being swapped is hung up before the replacement channel enters the bridge thus stopping the transfer). This patch adds a condition that waits for the impart thread to get to a point of acceptable readiness before allowing the initiating thread to continue. ASTERISK-24782 Reported by: John Bigelow Change-Id: I08fe33a2560da924e676df55b181e46fca604577
2015-07-13Merge "main/format_cap: Parse capabilities generated by ↵Matt Jordan
ast_format_cap_get_names"
2015-07-12media cache: Add CLI commandsMatt Jordan
This patch adds five CLI commands for the media cache: * 'media cache show all' - display a summary of all items in the media cache. * 'media cache show <uri>' - display detailed information about a single item in the media cache. * 'media cache delete <uri>' - remove an item from the media cache, and inform the bucket backend for the URI scheme to remove the item as well. * 'media cache refresh <uri>' - refresh a URI. If the item does not exist in the media cache, the bucket backend will pull down the media associated with the URI and create the item in the cache. * 'media cache create <uri>' - create an item in the media cache from some local media storage. Note that the bucket backend for the URI scheme must still permit the item creation. Change-Id: Id1c5707a3b8e2d96b56e4691a46a936cd171f4ae
2015-07-12media cache: Add a core API and facade for a backend agnostic media cacheMatthew Jordan
This patch adds a new API to the Asterisk core that acts as a media cache. The core API itself is mostly a thin wrapper around some bucket API provided implementation that itself acts as the mechanism of retrieval for media. The media cache API in the core provides the following: * A very thin in-memory cache of the active bucket_file items. Unlike a more traditional cache, it provides no expiration mechanisms. Most queries that hit the in-memory cache will also call into the bucket implementations as well. The bucket implementations are responsible for determining whether or not the active record is active and valid. This makes sense for the most likely implementation of a media cache backend, i.e., HTTP. The HTTP layer itself is the actual arbiter of whether or not a record is truly active; as such, the in-memory cache in the core has to defer to it. * The ability to create new items in the media cache from local resources. This allows for re-creation of items in the cache on restart. * Synchronization of items in the media cache to the AstDB. This also includes various pieces of important metadata. The API provides sufficient access that higher level APIs, such as the file or app APIs, do not have to worry about the semantics of the bucket APIs when needing to playback a resource. In addition, this patch provides unit tests for the media cache API. The unit tests use a fake bucket backend to verify correctness. Change-Id: I11227abbf14d8929eeb140ddd101dd5c3820391e
2015-07-12main/bucket: Add a callback function for ast_bucket_file objectsMatt Jordan
This patch adds a new function to the bucket API for ast_bucket_file objects, ast_bucket_file_metadata_callback. It will call ao2_callback on the ast_bucket_file's ao2_container of metadata, calling the provided ao2_callback_fn callback on each piece of metadata associated with the file. This is particularly useful when a bucket backend has added metadata, and a higher level API wants to be aware of/access said metadata, without knowing for sure what the key is. Change-Id: I96f6757717f47b650df91a437f7df16406227466