summaryrefslogtreecommitdiff
path: root/main
AgeCommit message (Collapse)Author
2017-05-26Merge "asterisk: Audit locking of channel when manipulating flags."Jenkins2
2017-05-24unittests: Add a unit test that causes a SEGV and...George Joseph
...that can only be run by explicitly calling it with 'test execute category /DO_NOT_RUN/ name RAISE_SEGV' This allows us to more easily test CI and debugging tools that should do certain things when asterisk coredumps. To allow this a new member was added to the ast_test_info structure named 'explicit_only'. If set by a test, the test will be skipped during a 'test execute all' or 'test execute category ...'. Change-Id: Ia3a11856aae4887df9a02b6b081cc777b36eb6ed
2017-05-17core/conversions: Added string to unsigned integer and long conversionsKevin Harwell
Added functions that convert a string to an unsigned integer or unsigned long. A couple of unit test were also created to test the routines. The reasons for adding these conversion utilities (and hopefully eventually more) are as follows: * Conversion routines are functionally contained with consistent and better error checking * The function names offer a better description of what is happening * It encourages code reuse for easier bug fixing at a single source * It's simpler to use * It's unit testable For instance, currently in a lot of places when converting to an integer or similar the "sscanf" function is used. When using "sscanf" it may not be immediately clear what's happening as it lacks semantic naming. Limited error checking is usually done as well. For example, most of the time a check is done to make sure the value converted, but does not check for overflows or negative valued conversions when converting unsigned numbers. Why use/wrap "strtoul" and not "sscanf" then? Primarily, it lacks some of the built in error handling that "strtoul" has. For instance "strtoul" contains overflow checks. Less so, but can still factor as reasons, "sscanf" is slightly more complex in its use. And maybe a bit controversial, but it may be ("big if") potentially slower than "strtoul" in some cases. Change-Id: If7eaca4a48f8c7b89cc8b5a1f4bed2852fca82bb
2017-05-16asterisk: Audit locking of channel when manipulating flags.Joshua Colp
When manipulating flags on a channel the channel has to be locked to guarantee that nothing else is also manipulating the flags. This change introduces locking where necessary to guarantee this. It also adds helper functions that manipulate channel flags and lock to reduce repeated code. ASTERISK-26789 Change-Id: I489280662dba0f4c50981bfc5b5a7073fef2db10
2017-05-12Merge changes from topic 'sdp_api_adjustments'George Joseph
* changes: SDP: Make process possible multiple fmtp attributes per rtpmap. SDP: Explicitly stop a RTP instance before destoying it. SDP: Rework merge_capabilities(). SDP: Update ast_get_topology_from_sdp() to keep RTP map.
2017-05-12Merge "SDP: Remove sdp_state.remote_capabilities"George Joseph
2017-05-12Merge "SDP: Add interface_address to specify our address to use."Jenkins2
2017-05-11Merge "logger: Added logger_queue_limit to the configuration options."Jenkins2
2017-05-11Merge "tcptls: Improve error messages for TLS connections."Jenkins2
2017-05-09SDP: Make process possible multiple fmtp attributes per rtpmap.Richard Mudgett
Change-Id: Ie7511008d82b59590e0eb520a21b5e1da4bd7349
2017-05-09SDP: Remove sdp_state.remote_capabilitiesRichard Mudgett
The sdp_state.remote_capabilities was only used inside merge_sdps() and subsequent calls to merge_sdps() by re-INVITE's would leak them. Change-Id: I0ceb7838ea044cc913e8ad4a255c39c9740ae0ce
2017-05-09SDP: Add interface_address to specify our address to use.Richard Mudgett
When we optionally set the interface_address we are forcing the media to go out a specific interface address. This allows us to optionally have the media go out the interface that SIP signalling came in on or if we are configured to have the media always go out a specific address. Change-Id: I160d9fac322a075bd2557b430632544178196189
2017-05-09SDP: Explicitly stop a RTP instance before destoying it.Richard Mudgett
* Made sdp_add_m_from_rtp_stream() and sdp_add_m_from_udptl_stream() handle generating disabled/declined streams. * Added /main/sdp/sdp_merge_asymmetric unit test. It currently does not check the offerer side negotiated SDP because that isn't the purpose of this patch and there is much to be done to handle declined/dummy streams. * Added T.38 image streams to the /main/sdp/sdp_merge_symmetric and /main/sdp/sdp_merge_crisscross unit tests. Change-Id: Ib4dcb3ca4f9a9133b376f4e3302f9a1f963f2b31
2017-05-09SDP: Rework merge_capabilities().Richard Mudgett
* Tried to give better variable names. * Made our SDP answer use the offer's RTP payload types as the SDP RFC says we SHOULD. * Updating the local topology now takes the stream format caps. We are likely preparing to send an offer. Change-Id: I34d3be8e3036402a8575ffcae3eebc5ce348d7c0
2017-05-09SDP: Update ast_get_topology_from_sdp() to keep RTP map.Richard Mudgett
* Add failure exits to ast_get_topology_from_sdp(). Change-Id: I4cc85c1ede8d712766ed20f544dbcef04c8c1049
2017-05-09tcptls: Improve error messages for TLS connections.Joshua Colp
This change uses the functions provided by OpenSSL to query and better construct error messages for situations where the connection encounters a problem. ASTERISK-26606 Change-Id: I7ae40ce88c0dc4e185c4df1ceb3a6ccc198f075b
2017-05-09Prevent Undefined Capath CrashJoshua Elson
It is possible to initialize a valid config without a capath or cafile definition. This will cause a crash on a reload. This fix ensures capath is always allocated. ASTERISK-26983 #close Change-Id: I63ff715d9d9023427543a5b8a4ba7b0d82533c12
2017-05-08Merge "stream: ast_stream_clone() cannot copy the opaque user data."Joshua Colp
2017-05-08logger: Added logger_queue_limit to the configuration options.George Joseph
All log messages go to a queue serviced by a single thread which does all the IO. This setting controls how big that queue can get (and therefore how much memory is allocated) before new messages are discarded. The default is 1000. Should something go bezerk and log tons of messages in a tight loop, this will prevent memory escalation. When the limit is reached, a WARNING is logged to that effect and messages are discarded until the queue is empty again. At that time another WARNING will be logged with the count of discarded messages. There's no "low water mark" for this queue because the logger thread empties the entire queue and processes it in 1 batch before going back and waiting on the queue again. Implementing a low water mark would mean additional locking as the thread processes each message and it's not worth it. A "test" was added to test_logger.c but since the outcome is non-deterministic, it's really just a cli command, not a unit test. Change-Id: Ib4520c95e1ca5325dbf584c7989ce391649836d1
2017-05-08Merge "netsock2.c: Made get/set addr port avoid potential uninitialized memory."Joshua Colp
2017-05-08Merge "bridge: Fix returning to dialplan when executing Bridge() from AMI."Joshua Colp
2017-05-05stream: ast_stream_clone() cannot copy the opaque user data.Richard Mudgett
ast_stream_clone() cannot copy the opaque user data stored on a stream. We don't know how to clone the data so it isn't copied into the clone. Change-Id: Ia51321bf38ecbfdcc53787ca77ea5fd2cabdf367
2017-05-05netsock2.c: Made get/set addr port avoid potential uninitialized memory.Richard Mudgett
Change-Id: I532052bd7cd95a4b3565485fc01e2a1ea07ee647
2017-05-04app_confbridge: Fix reference to cfg in menu_template_handlerGeorge Joseph
menu_template_handler wasn't properly accounting for the fact that it might be called both during a load/reload (which isn't really valid but not prevented) and by a dialplan function. In both cases it was attempting to use the "pending" config which wasn't valid in the latter case. aco_process_config is also partly to blame because it wasn't properly cleaning "pending" up when a reload was done and no changes were made. Both of these contributed to a crash if CONFBRIDGE(menu,template) was called in a dialplan after a reload. * aco_process_config now sets info->internal->pending to NULL after it unrefs it although this isn't strictly necessary in the context of this fix. * menu_template_handler now uses the "current" config and silently ignores any attempt to be called as a result of someone uses the "template" parameter in the conf file. Luckily there's no other place in the codebase where aco_pending_config is used outside of aco_process_config. ASTERISK-25506 #close Reported-by: Frederic LE FOLL Change-Id: Ib349a17d3d088f092480b19addd7122fcaac21a7
2017-05-04Merge "SDP: Replace SDP telephone_event option with dtmf option"Jenkins2
2017-05-04bridge: Fix returning to dialplan when executing Bridge() from AMI.Joshua Colp
When using the Bridge AMI action on the same channel multiple times it was possible for the channel to return to the wrong location in the dialplan if the other party hung up. This happened because the priority of the channel was not preserved across each action invocation and it would fail to move on to the next priority in other cases. This change makes it so that the priority of a channel is preserved when taking control of it from another thread and it is incremented as appropriate such that the priority reflects where the channel should next be executed in the dialplan, not where it may or may not currently be. The Bridge AMI action was also changed to ensure that it too starts the channels at the next location in the dialplan. ASTERISK-24529 Change-Id: I52406669cf64208aef7252a65b63ade31fbf7a5a
2017-05-03bridge_simple: Added support for streamsKevin Harwell
This patch is the first cut at adding stream support to the bridging framework. Changes were made to the framework that allows mapping of stream topologies to a bridge's supported media types. The first channel to enter a bridge initially defines the media types for a bridge (i.e. a one to one mapping is created between the bridge and the first channel). Subsequently added channels merge their media types into the bridge's adding to it when necessary. This allows channels with different sized topologies to map correctly to each other according to media type. The bridge drops any frame that does not have a matching index into a given write stream. For now though, bridge_simple will align its two channels according to size or first to join. Once both channels join the bridge the one with the most streams will indicate to the other channel to update its streams to be the same as that of the other. If both channels have the same number of streams then the first channel to join is chosen as the stream base. A topology change source was also added to a channel when a stream toplogy change request is made. This allows subsystems to know whether or not they initiated a change request. Thus avoiding potential recursive situations. ASTERISK-26966 #close Change-Id: I1eb5987921dd80c3cdcf52accc136393ca2d4163
2017-05-02SDP: Replace SDP telephone_event option with dtmf optionRichard Mudgett
The telephone_event option was used as a flag and a bit mapped value in different places when it is a boolean. It is also inadequate to configure the DTMF operation of the RTP instance created for the stream. Change-Id: Ib1addeaf0ce86f07039f2f979cab29405dc5239b
2017-05-02Merge "SDP: Make SDP translation to/from internal representation more const."Joshua Colp
2017-05-02Merge "stream: Make ast_stream_topology_create_from_format_cap() allow NULL ↵Joshua Colp
cap."
2017-05-01Merge "SDP: Make ast_sdp_state_set_remote_sdp() return error."Jenkins2
2017-05-01Merge "SDP: Misc cleanups (Mostly memory leaks)"Jenkins2
2017-05-01Merge "SDP API: Add SSRC-level attributes"Jenkins2
2017-04-27SDP: Make SDP translation to/from internal representation more const.Richard Mudgett
Change-Id: I473a174b869728604b37c60853896b0c458bc504
2017-04-27stream: Make ast_stream_topology_create_from_format_cap() allow NULL cap.Richard Mudgett
Change-Id: Ie29760c49c25d7022ba2124698283181a0dd5d08
2017-04-27SDP: Make ast_sdp_state_set_remote_sdp() return error.Richard Mudgett
Change-Id: I7707c9d872c476d897ff459008652b35142a35e1
2017-04-27SDP: Misc cleanups (Mostly memory leaks)Richard Mudgett
Change-Id: I74431b385da333f2c5f5a6d7c55e70b69a4f05d2
2017-04-27Merge "channel: Add ability to request an outgoing channel with stream ↵Jenkins2
topology."
2017-04-27Merge "frame: Better handle interpolated frames."Jenkins2
2017-04-27SDP API: Add SSRC-level attributesMark Michelson
RFC 5576 defines how SSRC-level attributes may be added to SDP media descriptions. In general, this is useful for grouping related SSRCes, indicating SSRC-level format attributes, and resolving collisions in RTP SSRC values. These attributes are used widely by browsers during WebRTC communications, including attributes defined by documents outside of RFC 5576. This commit introduces the addition of SSRC-level attributes into SDPs generated by Asterisk. Since Asterisk does not tend to use multiple SSRCs on a media stream, the initial support is minimal. Asterisk includes an SSRC-level CNAME attribute if configured to do so. This at least gives browsers (and possibly others) the ability to resolve SSRC collisions at offer-answer time. In order to facilitate this, the RTP engine API has been enhanced to be able to retrieve the SSRC and CNAME on a given RTP instance. res_rtp_asterisk currently does not provide meaningful CNAME values in its RTCP SDES items, and therefore it currently will always return an empty string as the CNAME value. A task in the near future will result in res_rtp_asterisk generating more meaningful CNAMEs. Change-Id: I29e7f23e7db77524f82a3b6e8531b1195ff57789
2017-04-27channel: Add ability to request an outgoing channel with stream topology.Joshua Colp
This change extends the ast_request functionality by adding another function and callback to create an outgoing channel with a requested stream topology. Fallback is provided by either converting the requested stream topology into a format capabilities structure if the channel driver does not support streams or by converting the requested format capabilities into a stream topology if the channel driver does support streams. The Dial application has also been updated to request an outgoing channel with the stream topology of the calling channel. ASTERISK-26959 Change-Id: Ifa9037a672ac21d42dd7125aa09816dc879a70e6
2017-04-27Merge "sdp: Add support for T.38"Joshua Colp
2017-04-27Merge "SDP: Ensure SDPs "merge" properly."Joshua Colp
2017-04-26frame: Better handle interpolated frames.Joshua Colp
Interpolated frames are frames which contain a number of samples but have no actual data. Audiohooks did not handle this case when translating an incoming frame into signed linear. It assumed that a frame would always contain media when it may not. If this occurs audiohooks will now immediately return and not act on the frame. As well for users of ast_trans_frameout the function has been changed to be a bit more sane and ensure that the data pointer on a frame is set to NULL if no data is actually on the frame. This allows the various spots in Asterisk that check for an interpolated frame based on the presence of a data pointer to work as expected. ASTERISK-26926 Change-Id: I7fa22f631fa28d540722ed789ce28e84c7f8662b
2017-04-26Merge "res_pjsip_sdp_rtp: No rtpmap for static RTP payload IDs in SDP."Jenkins2
2017-04-25sdp: Add support for T.38Joshua Colp
This change adds a T.38 format which can be used in a stream topology to specify that a UDPTL stream needs to be created. The SDP API has been changed to understand T.38 and create the UDPTL session, add the attributes, and parse the attributes. This change does not change the boundary of the T.38 state machine. It is still up to the channel driver to implement and act on it (such as queueing control frames or reacting to them). ASTERISK-26949 Change-Id: If28956762ccb8ead562ac6c03d162d3d6014f2c7
2017-04-25SDP: Ensure SDPs "merge" properly.Mark Michelson
The gist of this work ensures that when a remote SDP is received, it is merged properly with the local capabilities. The remote SDP is converted into a stream topology. That topology is then merged with the current local topology on the SDP state. That new merged topology is then used to create an SDP. Finally, adjustments are made to RTP instances based on knowledge gained from the remote SDP. There are also a battery of tests in this commit that ensure that some basic SDP merges work as expected. While this may not sound like a big change, it has the property that it caused lots of ancillary changes. * The remote SDP is no longer stored on the SDP state. Biggest reason: there's no need for it. The remote SDP is used at the time it is being set and nowhere else. * Some new SDP APIs were added in order to find attributes and convert generic SDP attributes into rtpmap structures. * Writing tests made me realize that retrieving a value from an SDP options structure, the SDP options needs to be made const. * The SDP state machine was essentially gutted by a previous commit. Initially, I attempted to reinstate it, but I found that as it had been defined, it was not all that useful. What was more useful was knowing the role we play in SDP negotiation, so the SDP state machine has been transformed into an indicator of role. * Rather than storing separate local and joint stream state capabilities, it makes more sense to keep track of current stream state and update it as things change. Change-Id: I5938c2be3c6f0a003aa88a39a59e0880f8b2df3d
2017-04-24core: Use eventfd for alert pipes on Linux when possibleSean Bright
The primary win of switching to eventfd when possible is that it only uses a single file descriptor while pipe() will use two. This means for each bridge channel we're reducing the number of required file descriptors by 1, and - if you're using timerfd - we also now have 1 less file descriptor per Asterisk channel. The API is not ideal (passing int arrays), but this is the cleanest approach I could come up with to maintain API/ABI. I've also removed what I believe to be an erroneous code block that checked the non-blocking flag on the pipe ends for each read. If the file descriptor is 'losing' its non-blocking mode, it is because of a bug somewhere else in our code. In my testing I haven't seen any measurable difference in performance. Change-Id: Iff0fb1573e7f7a187d5211ddc60aa8f3da3edb1d
2017-04-21Merge "pbx: Use same thread if AST_OUTGOING_WAIT_COMPLETE specified"George Joseph
2017-04-19pbx: Use same thread if AST_OUTGOING_WAIT_COMPLETE specifiedSean Bright
Both ast_pbx_outgoing_app() and ast_pbx_outgoing_exten() cause the core to spawn a new thread to perform the dial. When AST_OUTGOING_WAIT_COMPLETE is passed to these functions, the calling thread will be blocked until the newly created channel has been hung up. After this patch, we run the dial on the current thread rather than spawning a new one. The only in-tree code that passes AST_OUTGOING_WAIT_COMPLETE is pbx_spool, so you should see reduced thread usage if you are using .call files. Change-Id: I512735d243f0a9da2bcc128f7a96dece71f2d913