summaryrefslogtreecommitdiff
path: root/main
AgeCommit message (Collapse)Author
2015-11-04main/dial: Protect access to the format_cap structure of the requesting channelMatt Jordan
When a dial attempt is made that involves a requesting channel, we previously were not: a) Protecting access to the native format capabilities structure on the requesting channel. That is inherently unsafe. b) Reference bumping the lifetime of the format capabilities structure. In both cases, something else could sneak in, blow away the format capabilities, and we'd be holding onto an invalid format_cap structure. When the newly created channel attempts to construct its format capabilities, things go poorly. This patch: a) Ensures that we get a reference to the native format capabilities while the requesting channel is locked b) Holds a reference to the native format capabilities during the creation of the new channel. ASTERISK-25522 #close Change-Id: I0bfb7ba8b9711f4158cbeaae96edf9626e88a54f
2015-11-04Fix cli display of build options.Corey Farrell
A previous commit reduced the AST_BUILDOPTS compiler define to only include options that affected ABI. This included some options that were previously displayed by cli "core show settings". This change corrects the CLI display while still restricting buildopts.h to ABI effecting options only. ASTERISK-25434 #close Reported by: Rusty Newton Change-Id: Id07af6bedd1d7d325878023e403fbd9d3607e325
2015-11-03main/stasis_endpoints: Fix ContactStatusChange JSON for roundtrip_usec fieldMatt Jordan
The JSON packing for the ContactStatusChange event forgot to include the roundtrip_usec field. As a result, the field never showed up in any event, even when the data was available. This patch corrects that error by properly packing the JSON blob with the data. Change-Id: I8df80da659a44010afbd48f645967518ff5daa17
2015-10-26Merge "format: Update the maximum packetization time for iLBC 30."Matt Jordan
2015-10-23Merge topic 'fix_oom_crash'Joshua Colp
* changes: strings.c: Fix __ast_str_helper() to always return a terminated string. Add missing failure checks to ast_str_set_va() callers.
2015-10-22format_cap: Detect vector allocation failures.Mark Michelson
A crash was seen on a system that ran out of memory due to Asterisk not checking for vector allocation failures in format_cap.c. With this change, if either of the AST_VECTOR_INIT calls fail, we will return a value indicating failure. Change-Id: Ieb9c59f39dfde6d11797a92b45e0cf8ac5722bc8
2015-10-21strings.c: Fix __ast_str_helper() to always return a terminated string.Richard Mudgett
Users of functions which call __ast_str_helper() such as the ones listed below are likely to not check the return value for failure so ensuring that the string is always nil terminated is a good safety measure. ast_str_set_va() ast_str_append_va() ast_str_set() ast_str_append() Change-Id: I36ab2d14bb6015868b49329dda8639d70fbcae07
2015-10-21Add missing failure checks to ast_str_set_va() callers.Richard Mudgett
Change-Id: I0c2cdcd53727bdc6634095c61294807255bd278f
2015-10-21format: Update the maximum packetization time for iLBC 30.Alexander Traud
In September 2006, the maximum packetization time (ptime) were set to such a low value, packetization was disabled for many codecs actually. This was fixed for many codecs but not for iLBC 30. This enables packetization for iLBC which can be enabled for example via allow=ilbc:60,gsm,alaw,ulaw in the file sip.conf. ASTERISK-7803 Change-Id: I2ef90023d35efb7cb8fe96ed74f53f6846ffad12
2015-10-20main/cdr: Allow modules to modify CDR fields before dispatching themJonh Wendell
This patch adds the functions ast_cdr_modifier_register() ast_cdr_modifier_unregister() That work much like ast_cdr_register() and ast_cdr_unregister(). Modules registered will be given a chance to modify (or to do whatever they want) CDR fields just before they are passed to registered engines. Thus, for instance, if a module change the "userfield" field of a CDR, the modified value will be passed to every registered CDR backend for logging. ASTERISK-25479 #close Change-Id: If11d8fd19ef89b1a66ecacf1201e10fcf86ccd56
2015-10-12config.c: Fix off-nominal memory leak.Richard Mudgett
Change-Id: I06e346e9a5c63cc5071e7eda537310c4b43bffe0
2015-10-12config.c: Fix potential memory corruption after [section](+).Richard Mudgett
The memory corruption could happen if the [section](+) is the last section in the file with trailing comments. In this case process_text_line() has left *last_cat is set to newcat and newcat is destroyed. Change-Id: I0d1d999f553986f591becd000e7cc6ddfb978d93
2015-10-12config.c: Fix #include after [section](+).Richard Mudgett
An #include right after a [section](+) would associate any variable assignments before a new section in the #include with the wrong section. * Fix section association by setting the current section to the appended section. * Fix '+' and '!' section flag interaction corner case depending upon which flag came first. If the '!' came first then it would be ignored. If the '!' came after then it would affect the appended section. The '!' will now no longer be ignored. ASTERISK-25461 #close Reported by: Sean Pimental Change-Id: Ic9d3191c8758048e2cbce6432f854b32531731c3
2015-10-03manager: Fix GetConfigJSON returning invalid JSONIvan Poddubny
When GetConfigJSON was introduced back in 1.6, it returned each section as an array of strings: ["key=value", "key2=value2"]. Afterwards, it was changed a few times and became ["key": "value", "key2": "value2"], which is not a correct JSON. This patch fixes that by constructing a JSON object {} instead of an array []. Also, the keys "istemplate" and "tempates" that are used to indicate templates and their inherited categories are now wrapped in quotes. ASTERISK-25391 #close Reported by: Bojan Nemčić Change-Id: Ibbe93c6a227dff14d4a54b0d152341857bcf6ad8
2015-09-30sched.c: Add warning about negative time interval request.Richard Mudgett
Change-Id: Ib91435fb45b7f5f7c0fc83d0eec20b88098707bc
2015-09-29main/logger: Add log formatters and JSON structured logsMatt Jordan
When Asterisk is part of a larger distributed system, log files are often gathered using tools (such as logstash) that prefer to consume information and have it rendered using other tools (such as Kibana) that prefer a structured format, e.g., JSON. This patch adds support for JSON formatted logs by adding support for an optional log format specifier in Asterisk's logging subsystem. By adding a format specifier of '[json]': full => [json]debug,verbose,notice,warning,error Log messages will be output to the 'full' channel in the following format: { "hostname": Hostname or name specified in asterisk.conf "timestamp": Date/Time "identifiers": { "lwp": Thread ID, "callid": Call Identifier } "logmsg": { "location": { "filename": Name of the file that generated the log statement "function": Function that generated the log statement "line": Line number that called the logging function } "level": Log level, e.g., DEBUG, VERBOSE, etc. "message": Actual text of the log message } } ASTERISK-25425 #close Change-Id: I8649bfedf3fb7bf3138008cc11565553209cc238
2015-09-28Merge "translate: Fix transcoding while different in frame size."Matt Jordan
2015-09-25Merge "logger: Prevent duplicate dynamic channels from being added."Joshua Colp
2015-09-24logger: Prevent duplicate dynamic channels from being added.Mark Michelson
There was a problem observed where the "logger add channel" CLI command would allow for a channel with the same name to be added multiple times. This would result in each message being written out to the same file multiple times. The problem was due to the difference in how logger channel filenames are stored versus the format they are allowed to be presented when they are added. For instance, if adding the logger channel "foo" through the CLI, the result would be a logger channel with the file name /var/log/asterisk/foo being stored. So when trying to add another "foo" channel, "foo" would not match "/var/log/asterisk/foo" so we'd happily add the duplicate channel. The fix presented here is to introduce two new methods in the logger code: * make_filename(): given a logger channel name, this creates the filename for that logger channel. * find_logchannel(): given a logger channel name, this calls make_filename() and then traverses the list of logchannels in order to find a match. This change has made use of make_filename() and find_logchannel() throughout to more consistently behave. ASTERISK-25305 #close Reported by Mark Michelson Change-Id: I892d52954d6007d8bc453c3cbdd9235dec9c4a36
2015-09-24Do not swallow frames on channels leaving bridges.Mark Michelson
When leaving a bridge, indications on a channel could be swallowed by the internal indication logic because it appears that the channel is on its way to be hung up anyway. One such situation where this is detrimental is when channels on hold are redirected out of a bridge. The AST_CONTROL_UNHOLD indication from the bridging code is swallowed, leaving the channel in question to still appear to be on hold. The fix here is to modify the logic inside ast_indicate_data() to not drop the indication if the channel is simply leaving a bridge. This way, channels on hold redirected out of a bridge revert to their expected "in use" state after the redirection. ASTERISK-25418 #close Reported by Mark Michelson Change-Id: If6115204dfa0551c050974ee138fabd15f978949
2015-09-23Merge "ARI: Add events for Contact and Peer Status changes"Matt Jordan
2015-09-22app_page.c: Fix crash when forwarding with a predial handler.Richard Mudgett
Page uses the async method of dialing with the dial API. When a call gets forwarded there is no calling channel available. If the predial handler was set then the calling channel could not be put into auto-service for the forwarded call because it doesn't exist. A crash is the result. * Moved the callee predial parameter string processing to before the string is passed to the dial API rather than having the dial API do it. There are a few benefits do doing this. The first is the predial parameter string processing doesn't need to be done for each channel called by the dial API. The second is in async mode and the forwarded channel is to have the predial handler executed on it then the non-existent calling channel does not need to be present to process the predial parameter string. * Don't start auto-service on a non-existent calling channel to execute the predial handler when the dial API is in async mode and forwarding a call. ASTERISK-25384 #close Reported by: Chet Stevens Change-Id: If53892b286d29f6cf955e2545b03dcffa2610981
2015-09-22Merge "core/logging: Fix logging to more than one syslog channel"Matt Jordan
2015-09-22Merge "pbx: Update device and presence state when changing a hint extension."Joshua Colp
2015-09-21Merge "astfd: Adds a timestamp for each entry."Joshua Colp
2015-09-21core/logging: Fix logging to more than one syslog channelElazar Broad
Currently, Asterisk will log to the last configured syslog channel in logger.conf. This is due to the fact that the final call to openlog() supersedes all of the previous calls. This commit removes the call to openlog() and passes the facility to ast_log_vsyslog(), along with utilizing the LOG_MAKEPRI macro to ensure that the message is routed to the correct facility and with the correct priority. ASTERISK-25407 #close Reported by: Elazar Broad Tested by: Elazar Broad Change-Id: Ie2a2416bc00cce1b04e99ef40917c2011953ddd2
2015-09-21ARI: Add events for Contact and Peer Status changesMatt Jordan
This patch adds support for receiving events regarding Peer status changes and Contact status changes. This is particularly useful in scenarios where we are subscribed to all endpoints and channels, where we often want to know more about the state of channel technology specific items than a single endpoint's state. ASTERISK-24870 Change-Id: I6137459cdc25ce27efc134ad58abf065653da4e9
2015-09-21Merge "main/config_options: Check for existance of internal object before ↵Matt Jordan
derefing"
2015-09-19astfd: Adds a timestamp for each entry.Alexander Traud
Now with menuselect "DEBUG_FD_LEAKS" and CLI "core show fd", a timestamp is shown with each file descriptor. This helps to debug leaked UDP/TCP ports on long-lived servers, for example. ASTERISK-25405 #close Change-Id: I968339e5155a512eba1032a5263f1ec8b5e1f80b
2015-09-19pbx: Update device and presence state when changing a hint extension.Joshua Colp
When changing a hint extension without removing the hint first the device state and presence state is not updated. This causes the state of the hint to be that of the previous extension and not the current one. This state is kept until a state change occurs as a result of something (presence state change, device state change). This change updates the hint with the current device and presence state of the new extension when it is changed. Any state callbacks which may have been added before the hint extension is changed are also informed of the new device and presence state if either have changed. ASTERISK-25394 #close Change-Id: If268f1110290e502c73dd289c9e7e7b27bc8432f
2015-09-17translate: Fix transcoding while different in frame size.Alexander Traud
When Asterisk translates between codecs, each with a different frame size (for example between iLBC 30 and Speex-WB), too large frames were created by ast_trans_frameout. Now, ast_trans_frameout is called with the correct frame length, creating several frames when necessary. Affects all transcoding modules which used ast_trans_frameout: GSM, iLBC, LPC10, and Speex. ASTERISK-25353 #close Change-Id: I2e229569d73191d66a4e43fef35432db24000212
2015-09-15scheduler: Use queue for allocating sched IDs.Mark Michelson
It has been observed that on long-running busy systems, a scheduler context can eventually hit INT_MAX for its assigned IDs and end up overflowing into a very low negative number. When this occurs, this can result in odd behaviors, because a negative return is interpreted by callers as being a failure. However, the item actually was successfully scheduled. The result may be that a freed item remains in the scheduler, resulting in a crash at some point in the future. The scheduler can overflow because every time that an item is added to the scheduler, a counter is bumped and that counter's current value is assigned as the new item's ID. This patch introduces a new method for assigning scheduler IDs. Instead of assigning from a counter, a queue of available IDs is maintained. When assigning a new ID, an ID is pulled from the queue. When a scheduler item is released, its ID is pushed back onto the queue. This way, IDs may be reused when they become available, and the growth of ID numbers is directly related to concurrent activity within a scheduler context rather than the uptime of the system. Change-Id: I532708eef8f669d823457d7fefdad9a6078b99b2
2015-09-11main/config_options: Check for existance of internal object before derefingMatt Jordan
Asterisk can load and register an object type while still having an invalid sorcery mapping. This can cause an issue when a creation call is invoked. For example, mis-configuring PJSIP's endpoint identifier by IP address mapping in sorcery.conf will cause the sorcery mechanism to be invalidated; however, a subsequent ARI invocation to create the object will cause a crash, as the internal type may not be registered as sorcery expects. Merely checking for a NULL pointer here solves the issue. Change-Id: I54079fb94a1440992f4735a9a1bbf1abb1c601ac
2015-09-08Merge "Core/General: Add #ifdef needed on FreeBSD."Joshua Colp
2015-09-04endpoint snapshot: avoid second cleanup on alloc failureScott Griepentrog
In ast_endpoint_snapshot_create(), a failure to init the string fields results in two attempts to ao2_cleanup the same pointer. Removed RAII_VAR to eliminate problem. ASTERISK-25375 #close Reported by: Scott Griepentrog Change-Id: If4d9dfb1bbe3836b623642ec690b6d49b25e8979
2015-09-03Core/General: Add #ifdef needed on FreeBSD.Guido Falsi
pthread_attr_init() defaults to PTHREAD_EXPLICIT_SCHED on FreeBSD too. ASTERISK-25310 #close Reported by: Guido Falsi Change-Id: Iae6befac9028b5b9795f86986a4a08a1ae6ab7c4
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