summaryrefslogtreecommitdiff
path: root/res
AgeCommit message (Collapse)Author
2015-08-20res_pjsip_sdp_rtp.c: Set preferred rx payload type mapping on incoming offers.Richard Mudgett
ASTERISK-25166 Reported by: Kevin Harwell ASTERISK-17410 Reported by: Boris Fox Change-Id: I97ecebc1ab9b5654fb918bf1f4c98c956b852369
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-19Merge "res_ari_events: Fix shutdown ref leak."Mark Michelson
2015-08-19Merge "res_http_websocket.c: Add missing unref on an off nominal path."Mark Michelson
2015-08-19ari/ari_websockets.c: Fix ast_debug parameter type mismatch.Richard Mudgett
This is a type mismatch fix of the debugging commit c63316eec10e1990a88bf4712238d6deb375bfa9 made to find out why a testsuite test was failing only on one of the continuous integration build agents. Change-Id: Iba34f6e87cec331f6ac80e4daff6476ea6f00a75
2015-08-18res_ari_events: Fix shutdown ref leak.Richard Mudgett
ASTERISK-25308 #close Reported by: Joshua Colp Change-Id: I592785bf70ff4b63d00e535b482f40da8e82a082
2015-08-18res_http_websocket.c: Add missing unref on an off nominal path.Richard Mudgett
Change-Id: I228df6adecd4cb450d03e09e9a38c86bb566e811
2015-08-18res_http_websocket.c: Fix some off nominal path cleanup.Richard Mudgett
* Remove extraneous unlock on off-nominal path. * Add missing HTTP error reply. Change-Id: I1f402bfe448fba8696b507477cab5f060ccd9b2b
2015-08-18res_ari.c: Add missing off nominal unlock and remove a RAII_VAR().Richard Mudgett
Change-Id: I0c5e7b34057f26dadb39489c4dac3015c52f5dbf
2015-08-14res_pjsip_sdp_rtp: Restore removed NULL check.Mark Michelson
When sending an RTP keepalive, we need to be sure we're not dealing with a NULL RTP instance. There had been a NULL check, but the commit that added the rtp_timeout and rtp_hold_timeout options removed the NULL check. Change-Id: I2d7dcd5022697cfc6bf3d9e19245419078e79b64
2015-08-13res_http_websocket: When shutting down a session don't close closed socketJoshua Colp
Due to the use of ast_websocket_close in session termination it is possible for the underlying socket to already be closed when the session is terminated. This occurs when the close frame is attempted to be written out but fails. Change-Id: I7572583529a42a7dc911ea77a974d8307d5c0c8b
2015-08-12Merge "res_http_websocket: Forcefully terminate on write errors."Joshua Colp
2015-08-12Merge "res_pjsip.c: Fix crash from corrupt saved SUBSCRIBE message."Mark Michelson
2015-08-12res_http_websocket: Forcefully terminate on write errors.Joshua Colp
The res_http_websocket module will currently attempt to close the WebSocket connection if fatal cases occur, such as when attempting to write out data and being unable to. When the fatal cases occur the code attempts to write a WebSocket close frame out to have the remote side close the connection. If writing this fails then the connection is not terminated. This change forcefully terminates the connection if the WebSocket is to be closed but is unable to send the close frame. ASTERISK-25312 #close Change-Id: I10973086671cc192a76424060d9ec8e688602845
2015-08-11res/res_format_attr_silk: Expose format attributes to other modulesMatt Jordan
This patch adds the .get callback to the format attribute module, such that the Asterisk core or other third party modules can query for the negotiated format attributes. Change-Id: Ia24f55cf9b661d651ce89b4f4b023d921380f19c
2015-08-11res_pjsip.c: Fix crash from corrupt saved SUBSCRIBE message.Richard Mudgett
If the saved SUBSCRIBE message is not parseable for whatever reason then Asterisk could crash when libpjsip tries to parse the message and adds an error message to the parse error list. * Made ast_sip_create_rdata() initialize the parse error rdata list. The list is checked after parsing to see that it remains empty for the function to return successful. ASTERISK-25306 Reported by Mark Michelson Change-Id: Ie0677f69f707503b1a37df18723bd59418085256
2015-08-07Replace htobe64 with htonllDavid M. Lee
We don't have a compatability function to fill in a missing htobe64; but we already have one for the identical htonll. Change-Id: Ic0a95db1c5b0041e14e6b127432fb533b97e4cac
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-07Merge "ARI: Deleting log channels"Joshua Colp
2015-08-07Merge "res_pjsip: Ensure sanitized XML is NULL terminated."Joshua Colp
2015-08-07Merge "res_pjsip_pubsub: More accurately persist packet."Joshua Colp
2015-08-07Merge "res_rtp_asterisk.c: Fix off-nominal crash potential."Joshua Colp
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-06res_pjsip_pubsub: More accurately persist packet.Mark Michelson
The pjsip_rx_data structure has a pkt_info.packet field on it that is the packet that was read from the transport. For datagram transports, the packet read from the transport will correspond to the SIP message that arrived. For streamed transports, however, it is possible to read multiple SIP messages in one packet. In a recent case, Asterisk crashed on a system where TCP was being used. This is because at some point, a read from the TCP socket resulted in a 200 OK response as well as an incoming SUBSCRIBE request being stored in rdata->pkt_info.packet. When the SUBSCRIBE was processed, the combination 200 OK and SUBSCRIBE was saved in persistent storage. Later, a restart of Asterisk resulted in the crash because the persistent subscription recreation code ended up building the 200 OK response instead of a SUBSCRIBE request, and we attempted to access request-specific data. The fix here is to use the pjsip_msg_print() function in order to persist SUBSCRIBE requests. This way, rather than using the raw socket data, we use the parsed SIP message that PJSIP has given us. If we receive multiple SIP messages from a single read, we will be sure only to save off the relevant SIP message. There also is a safeguard put in place to make sure that if we do end up reconstructing a SIP response, it will not cause a crash. ASTERISK-25306 #close Reported by Mark Michelson Change-Id: I4bf16f7b76a2541d10b55de82bcd14c6e542afb2
2015-08-06Merge "res_pjsip_sdp_rtp.c: Fixup some whitespace."Joshua Colp
2015-08-06res_pjsip: Ensure sanitized XML is NULL terminated.Joshua Colp
The ast_sip_sanitize_xml function is used to sanitize a string for placement into XML. This is done by examining an input string and then appending values to an output buffer. The function used by its implementation, strncat, has specific behavior that was not taken into account. If the size of the input string exceeded the available output buffer size it was possible for the sanitization function to write past the output buffer itself causing a crash. The crash would either occur because it was writing into memory it shouldn't be or because the resulting string was not NULL terminated. This change keeps count of how much remaining space is available in the output buffer for text and only allows strncat to use that amount. Since this was exposed by the res_pjsip_pidf_digium_body_supplement module attempting to send a large message the maximum allowed message size has also been increased in it. A unit test has also been added which confirms that the ast_sip_sanitize_xml function is providing NULL terminated output even when the input length exceeds the output buffer size. ASTERISK-25304 #close Change-Id: I743dd9809d3e13d722df1b0509dfe34621398302
2015-08-06Merge "res_pjsip_sdp_rtp.c: Fix processing wrong SDP media list."Joshua Colp
2015-08-06Merge "res_http_websocket: Debug write lengths."Joshua Colp
2015-08-05res_rtp_asterisk: Don't leak temporary key when enabling PFS.Joshua Colp
A change recently went in which enabled perfect forward secrecy for DTLS in res_rtp_asterisk. This was accomplished two different ways depending on the availability of a feature in OpenSSL. The fallback method created a temporary instance of a key but did not free it. This change fixes that. ASTERISK-25265 Change-Id: Iadc031b67a91410bbefb17ffb4218d615d051396
2015-08-04res_http_websocket: Debug write lengths.Mark Michelson
Commit 39cc28f6ea2140ad6d561fd4c9e9a66f065cecee attempted to fix a test failure observed on 32 bit test agents by ensuring that a cast from a 32 bit unsigned integer to a 64 bit unsigned integer was happening in a predictable place. As it turns out, this did not cause test runs to succeed. This commit adds several redundant debug messages that print the payload lengths of websocket frames. The idea here is that this commit will not cause tests to succeed for the faulty test agent, but we might deduce where the fault lies more easily this way by observing at what point the expected value (537) changes to some ungangly huge number. If you are wondering why something like this is being committed to the branch, keep in mind that in commit 39cc28f6ea2140ad6d561fd4c9e9a66f065cecee I noted that the observed test failures only happen when automated tests are run. Attempts to run the tests by hand manually on the test agent result in the tests passing. Change-Id: I14a65c19d8af40dadcdbd52348de3b0016e1ae8d
2015-08-03Merge "res_http_websocket: Avoid passing strlen() to ast_websocket_write()."Matt Jordan
2015-08-03Merge "res/res_rtp_asterisk: Add ECDH support"Matt Jordan
2015-08-03res_http_websocket: Avoid passing strlen() to ast_websocket_write().Mark Michelson
We have seen a rash of test failures on a 32-bit build agent. Commit 48698a5e21d7307f61b5fb2bd39fd593bc1423ca solved an obvious problem where we were not encoding a 64-bit value correctly over the wire. This commit, however, did not solve the test failures. In the failing tests, ARI is attempting to send a 537 byte text frame over a websocket. When sending a frame this small, 16 bits are all that is required in order to encode the payload length on the websocket frame. However, ast_websocket_write() thinks that the payload length is greater than 65535 and therefore writes out a 64 bit payload length. Inspecting this payload length, the lower 32 bits are exactly what we would expect it to be, 537 in hex. The upper 32 bits, are junk values that are not expected to be there. In the failure, we are passing the result of strlen() to a function that expects a uint64_t parameter to be passed in. strlen() returns a size_t, which on this 32-bit machine is 32 bits wide. Normally, passing a 32-bit unsigned value to somewhere where a 64-bit unsigned value is expected would cause no problems. In fact, in manual runs of failing tests, this works just fine. However, ast_websocket_write() uses the Asterisk optional API, which means that rather than a simple function call, there are a series of macros that are used for its declaration and implementation. These macros may be causing some sort of error to occur when converting from a 32 bit quantity to a 64 bit quantity. This commit changes the logic by making existing ast_websocket_write() calls use ast_websocket_write_string() instead. Within ast_websocket_write_string(), the 64-bit converted strlen is saved in a local variable, and that variable is passed to ast_websocket_write() instead. Note that this commit message is full of speculation rather than certainty. This is because the observed test failures, while always present in automated test runs, never occur when tests are manually attempted on the same test agent. The idea behind this commit is to fix a theoretical issue by performing changes that should, at the least, cause no harm. If it turns out that this change does not fix the failing tests, then this commit should be reverted. Change-Id: I4458dd87d785ca322b89c152b223a540a3d23e67
2015-07-31Merge "ARI: Channels added to Stasis application during WebSocket creation ..."Mark Michelson
2015-07-31Merge "ARI: Rotate log channels."Mark Michelson
2015-07-31Merge "res_pjsip_session.c: Fix crashes seen when call cancelled."Joshua Colp
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-31ARI: Channels added to Stasis application during WebSocket creation ...Ashley Sanders
Prior to ASTERISK-24988, the WebSocket handshake was resolved before Stasis applications were registered. This was done such that the WebSocket would be ready when an application is registered. However, by creating the WebSocket first, the client had the ability to make requests for the Stasis application it thought had been created with the initial handshake request. The inevitable conclusion of this scenario was the cart being put before the horse. ASTERISK-24988 resolved half of the problem by ensuring that the applications were created and registered with Stasis prior to completing the handshake with the client. While this meant that Stasis was ready when the client received the green-light from Asterisk, it also meant that the WebSocket was not yet ready for Stasis to dispatch messages. This patch introduces a message queuing mechanism for delaying messages from Stasis applications while the WebSocket is being constructed. When the ARI event processor receives the message from the WebSocket that it is being created, the event processor instantiates an event session which contains a message queue. It then tries to create and register the requested applications with Stasis. Messages that are dispatched from Stasis between this point and the point at which the event processor is notified the WebSocket is ready, are stashed in the queue. Once the WebSocket has been built, the queue's messages are dispatched in the order in which they were originally received and the queue is concurrently cleared. ASTERISK-25181 #close Reported By: Matt Jordan Change-Id: Iafef7b85a2e0bf78c114db4c87ffc3d16d671a17
2015-07-30res_rtp_asterisk.c: Fix off-nominal crash potential.Richard Mudgett
ASTERISK-25296 Reported by: Richard Mudgett Change-Id: I08549fb7c3ab40a559f41a3940f3732a4059b55b
2015-07-30res_pjsip_sdp_rtp.c: Fixup some whitespace.Richard Mudgett
Change-Id: Ib4eb7ef7dcaf93ddc26538f0a498aaf110d7a973
2015-07-30res_pjsip_sdp_rtp.c: Fix processing wrong SDP media list.Richard Mudgett
Change-Id: I7c076826c2d3c6ae8c923ca73b7a71980cca11f2
2015-07-30res_pjsip_session.c: Fix crashes seen when call cancelled.Richard Mudgett
Two testsuite tests crashed in the same place as a result of an INVITE being CANCELed. tests/channels/pjsip/resolver/srv/failover/in_dialog/transport_unspecified tests/channels/pjsip/resolver/srv/failover/in_dialog/transport_tcp The session pointer is no longer in the inv->mod_data[session_module.id] location because the INVITE transaction has reached the terminated state. ASTERISK-25297 #close Reported by: Richard Mudgett Change-Id: Idb75fdca0321f5447d5dac737a632a5f03614427
2015-07-29res_http_websocket: Properly encode 64 bit payloadMark Michelson
A test agent was continuously failing all ARI tests when run against Asterisk 13. As it turns out, the reason for this is that on those test runs, for some reason we decided to use the super extended 64 bit payload length for websocket text frames instead of the extended 16 bit payload length. For 64-bit payloads, the expected byte order over the network is 7, 6, 5, 4, 3, 2, 1, 0 However, we were sending the payload as 3, 2, 1, 0, 7, 6, 5, 4 This meant that we were saying to expect an absolutely MASSIVE payload to arrive. Since we did not follow through on this expected payload size, the client would sit patiently waiting for the rest of the payload to arrive until the test would time out. With this change, we use the htobe64() function instead of htonl() so that a 64-bit byte-swap is performed instead of a 32 bit byte-swap. Change-Id: Ibcd8552392845fbcdd017a8c8c1043b7fe35964a
2015-07-29res/res_rtp_asterisk: Add ECDH supportMark Duncan
This will add ECDH support to Asterisk. It will detect auto ECDH support in OpenSSL (1.0.2b and above) during ./configure. If this is available, it will use it, otherwise it will fall back to prime256v1 (this behavior is consistent with other projects such as Apache and nginx). This fixes WebRTC being broken in Firefox 38+ due to Firefox now only supporting ciphers with perfect forward secrecy. ASTERISK-25265 #close Change-Id: I8c13b33a2a79c0bde2e69e4ba6afa5ab9351465b
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-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-19Merge "res/res_musiconhold: Add a warning when MOH does not exist"Matt Jordan
2015-07-19res/res_musiconhold: Add a warning when MOH does not existMichael Cargile
Change-Id: Ifdfbd0b97cf31478d29923ec30aabce28d01740b