summaryrefslogtreecommitdiff
path: root/channels
AgeCommit message (Collapse)Author
2016-02-05chan_misdn: Fix a few issues causing compile errorsGeorge Joseph
Change-Id: I54b48c24d7ca88ed80496fdfd142d08772a7ab98
2016-02-03AST-2016-002 chan_sip.c: Fix retransmission timeout integer overflow.Richard Mudgett
Setting the sip.conf timert1 value to a value higher than 1245 can cause an integer overflow and result in large retransmit timeout times. These large timeout times hold system file descriptors hostage and can cause the system to run out of file descriptors. NOTE: The default sip.conf timert1 value is 500 which does not expose the vulnerability. * The overflow is now detected and the previous timeout time is calculated. ASTERISK-25397 #close Reported by: Alexander Traud Change-Id: Ia7231f2f415af1cbf90b923e001b9219cff46290
2016-02-02Merge "chan_sip.c: AMI & CLI notify methods get different values of ↵Mark Michelson
asterisk's own ip."
2016-02-01build_system: Fix some warnings highlighted by clangGeorge Joseph
Fix some warnings found with clang. Change-Id: I5195b6189b148c2ee3ed4a19d015a6d4ef3e77bd
2016-01-31chan_sip.c: AMI & CLI notify methods get different values of asterisk's own ip.StefanEng86
When I ask asterisk to send a SIP NOTIFY message to a sip peer using either a) AMI action: SIPnotify or b) cli command: sip notify <cmd> <peer>, I expect asterisk to include the same value for its own ip in both cases a) and b), but it seems a) produces a contact header like Contact: <sip:asterisk@192.168.1.227:8060> whereas b) produces a contact header like <sip:asterisk@127.0.0.1:8060>. 0.0.0.0:8060 is my udpbindaddr in sip.conf My guess is that manager_sipnotify should call ast_sip_ouraddrfor(&p->sa, &p->ourip, p) the same way sip_cli_notify does, because after applying this patch, both cases a) and b) produce the contact header that I expect: <sip:asterisk@192.168.1.227:8060> Reported by: Stefan Engström Tested by: Stefan Engström Change-Id: I86af5e209db64aab82c25417de6c768fb645f476
2016-01-25chan_sip: Fix buffer overrun in sip_sipredirect.Corey Farrell
sip_sipredirect uses sscanf to copy up to 256 characters to a stacked buffer of 256 characters. This patch reduces the copy to 255 characters to leave room for the string null terminator. ASTERISK-25722 #close Change-Id: Id6c3a629a609e94153287512c59aa1923e8a03ab
2016-01-21Merge "chan_sip: option 'notifyringing' change and doc fix"Mark Michelson
2015-12-26chan_sip: option 'notifyringing' change and doc fixWard van Wanrooij
In the sample sip.conf this is written with regard to notifyringing: ;notifyringing = no ; Control whether subscriptions already INUSE get sent RINGING when another call is sent (default: yes) However, this setting changes whether or not any RINGING indications are sent to subscriptions. There is no separate configurable setting that allows to control whether INUSE subscriptions also get sent RINGING. This is however a useful option, to see (using BLF) if somebody else is able to handle an incoming call or if everybody is busy. This patch corrects the documentation for notifyringing (so the documentation matches the functionality) and make notifyringing a tri-state option, by adding the value 'notinuse' (in addition to 'yes' and 'no'). When notifyringing = notinuse, only subscriptions that are not INUSE are sent the RINGING signal. The default setting for notifyringing remains set to yes, so the default behaviour is not affected. ASTERISK-25558 Change-Id: I88f7036ee084bb3f43b74f15612695c6708f74aa
2015-12-25chan_sip.c: fix websocket_write_timeout default valueDade Brandon
websocket_write_timeout was not being set to its default value during sip config reload, which meant that prior to this commit, 1) the default value of 100 was not used, unless an invalid value (or 1) was specified in sip.conf for websocket_write_timeout, and 2) if the websocket_write_timeout directive was removed from sip.conf without a full restart of asterisk, then the previous value would continue to be used indefinitely. This essentially lead to a 0ms write timeout (the first write attempt in ast_careful_fwrite must have succeeded) in websocket write requests from chan_sip, unless websocket_write_timeout was explicitely set in sip.conf. Changes to websocket_write_timeout still only apply to new websocket sessions, after the sip reload -- timeouts on existing sessions are not adjusted during sip reload. Change-Id: Ibed3816ed29cc354af6564c5ab3e75eab72cb953
2015-12-17chan_sip: Enable WebSocket support by default.Joshua Colp
Per the documentation the WebSocket support in chan_sip is supposed to be enabled by default but is not. This change corrects that. Change-Id: Icb02bbcad47b11a795c14ce20a9bf29649a54423
2015-12-10chan_sip: Add TCP/TLS keepalive to TCP/TLS serverJonathan Rose
Adds the TCP Keep Alive option to TCP and TLS server sockets. Previously this option was only being set on session sockets. http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/ According to the link above, the SO_KEEPALIVE option is useful for knowing when a TCP connected endpoint has severed communication without indicating it or has become unreachable for some reason. Without this patch, keep alive is not set on the socket listening for incoming TCP sessions and in Komatsu's report this resulted in the thread listening for TCP becoming stuck in a waiting state. ASTERISK-25364 #close Reported by: Hiroaki Komatsu Change-Id: I7ed7bcfa982b367dc64b4b73fbd962da49b9af36
2015-12-09Merge "chan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)"Matt Jordan
2015-12-08chan_sip.c: Start ICE negotiation when response is sent or received.Eugene Voityuk
The current logic for ICE negotiation starts it when receiving an SDP with ICE candidates. This is incorrect as ICE negotiation can only start when each call party have at least one pair of local and remote candidate. Starting ICE negotiation early would result in negotiation failure and ultimately no audio. This change makes it so ICE negotiation is only started when a response with SDP is received or when a response with SDP is sent. ASTERISK-24146 Change-Id: I55a632bde9e9827871b09141d82747e08379a8ca
2015-12-08chan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)Filip Jenicek
Asterisk may crash when calling ast_channel_get_t38_state(c) on a locked channel which is being hung up. ASTERISK-25609 #close Change-Id: Ifaa707c04b865a290ffab719bd2e5c48ff667c7b
2015-12-07chan_sip: Fix crash involving the bogus peer during sip reload.Richard Mudgett
A crash happens sometimes when performing a CLI "sip reload". The bogus peer gets refreshed while it is in use by a new call which can cause the crash. * Protected the global bogus peer object with an ao2 global object container. ASTERISK-25610 #close Change-Id: I5b528c742195681abcf713c6e1011ea65354eeed
2015-12-07chan_sip: Support parsing of Q.850 reason header in SIP BYE and CANCEL requests.Christof Lauber
Current support for reason header did work only in SIP responses. According to RFC3336 the reason header might appear in any SIP request. But it seems to make most sence in BYE and CANCEL so parasing is done there too (if use_q850_reason=yes). Change-Id: Ib6be7b34c23a76d0e98dfd0816c89931000ac790
2015-12-01Audit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)Richard Mudgett
chan_sip.c: * Initialize mwi subscription scheduler ids earlier because of ASTOBJ to ao2 conversion. * Initialize register scheduler ids earlier because of ASTOBJ to ao2 conversion. chan_skinny.c: * Fix more scheduler usage for the valid 0 id value. ASTERISK-25476 Change-Id: If9f0e5d99638b2f9d102d1ebc9c5a14b2d706e95
2015-12-01Audit improper usage of scheduler exposed by 5c713fdf18f.Richard Mudgett
channels/chan_iax2.c: * Initialize struct chan_iax2_pvt scheduler ids earlier because of iax2_destroy_helper(). channels/chan_sip.c: channels/sip/config_parser.c: * Fix initialization of scheduler id struct members. Some off nominal paths had 0 as a scheduler id to be destroyed when it was never started. chan_skinny.c: * Fix some scheduler id comparisons that excluded the valid 0 id. channel.c: * Fix channel initialization of the video stream scheduler id. pbx_dundi.c: * Fix channel initialization of the packet retransmission scheduler id. ASTERISK-25476 Change-Id: I07a3449f728f671d326a22fcbd071f150ba2e8c8
2015-11-22chan_pjsip: Handle T.38 faxes with direct media bridgesMatt Jordan
When a channel is in a direct media bridge, a re-INVITE may arrive that forces Asterisk to re-negotiate the media to a T.38 fax. When this occurs, the bridge must change its technology to a simple bridge, and re-INVITE the media back to Asterisk. Generally, this logic mostly already exists in Asterisk. However, prior to this patch, there were a few bugs: (1) The T.38 framehook currently prevents a channel capable of T.38 faxes from ever entering into a direct media bridge. This applies even when the only media being passed over the channel is audio. This patch fixes this bug by having the framehook specify that it defers caring about any frame type. This allows the channels to enter into a direct media bridge, which will be broken when a re-INVITE is received. (2) When a re-INVITE is received, nothing instructed the bridging layer to re-inspect the allowed bridging technology. This now occurs when either a re-INVITE is received from a peer, or when a response is received from the far end (that is, when the T.38 state changes to either T38_PEER_REINVITE or T38_LOCAL_REINVITE). (3) chan_pjsip needs to do a small amount of work to prevent a direct media bridge from being chosen when a T.38 session is in progress. When a T.38 session supplement has a t38 datastore - which is added when we detect we should start thinking about T.38 on a channel - we now refuse a native RTP bridge. (4) When a BYE request is received, we don't terminate the T.38 session. If the other side of a T.38 fax survives the hangup (due to the 'g' flag in Dial, for example), we don't currently re-INVITE the media on the other channel back to audio. This patch now has res_pjsip_t38 intercept BYE requests and inform the far side that the T.38 session is terminated. This naturally causes the correct re-INVITEs to be sent. ASTERISK-25582 Change-Id: Iabd6aa578e633d16e6b9f342091264e4324a79eb
2015-11-12Further fixes to improper usage of schedulerSteve Davies
When ASTERISK-25449 was closed, a number of scheduler issues mentioned in the comments were missed. These have since beed raised in ASTERISK-25476 and elsewhere. This patch attempts to collect all of the scheduler issues discovered so far and address them sensibly. ASTERISK-25476 #close Change-Id: I87a77d581e2e0d91d33b4b2fbff80f64a566d05b
2015-11-09ast_format_cap_get_names: To display all formats, the buffer was increased.Alexander Traud
ASTERISK-25533 #close Change-Id: Ie1a9d1a6511b3f1a56b93d04475fbf8a4e40010a
2015-11-03chan_sip: Allow websockets to be disabled.Corey Farrell
This patch adds a new setting "websockets_enabled" to sip.conf. Setting this to false allows chan_sip to be used without causing conflicts with res_pjsip_transport_websocket. ASTERISK-24106 #close Reported by: Andrew Nagy Change-Id: I04fe8c4f2d57b2d7375e0e25826c91a72e93bea7
2015-10-29Merge "chan_sip: Do not send all codecs on INVITE."Matt Jordan
2015-10-26chan_sip: Do not send all codecs on INVITE.Alexander Traud
Since version 13, Asterisk sent all allowed codecs as callee, even when the caller did not request/support them. In case of dynamic RTP payloads, this led to the same ID for different codecs, which is not allowed by SIP/SDP. Now, the intersection between the requested and the supported codecs is send again. ASTERISK-24543 #close Change-Id: Ie90cb8bf893b0895f8d505e77343de3ba152a287
2015-10-24build: GCC 5.1.x catches some new const, array bounds and missing paren issuesGeorge Joseph
Fixed 1 issue in each of the affected files. ASTERISK-25494 #close Reported-by: George Joseph Tested-by: George Joseph Change-Id: I818f149cd66a93b062df421e1c73c7942f5a4a77
2015-10-21chan_sip: Fix autoframing=yes.Alexander Traud
With Asterisk 13, the structures ast_format and ast_codec changed. Because of that, the paketization timing (framing) of the RTP channel moved away from the formats/codecs. In the course of that change, the ptime of the callee was not honored anymore, when the optional autoframing was enabled. ASTERISK-25484 #close Change-Id: Ic600ccaa125e705922f89c72212c698215d239b4
2015-10-13channels/chan_sip: Set cause code to 44 on RTP timeoutMatt Jordan
To quote Olle: "When issuing a hangup due to RTP timeouts the cause code is not set. I have selected 44 based on Cisco's implementation..." ASTERISK-25135 #close Reported by: Olle Johansson patches: rtp-timeout-cause-1.8.diff uploaded by Olle Johansson (License 5267) Change-Id: Ia62100c55077d77901caee0bcae299f8dc7375fc
2015-10-08Merge "chan_pjsip: Fix crash on reINVITE before initial INVITE completes."Joshua Colp
2015-10-06chan_sip: Fix port parsing for IPv6 addresses in SIP Via headers.Florian Sauerteig
If a Via header containes an IPv6 address and a port number is ommitted, as it is the standard port, we now leave the port empty and to not set it to the value after the first colon of the IPv6 address. ASTERISK-25443 #close Change-Id: Ie3c2f05471cd006bf04ed15598589c09577b1e70
2015-10-06chan_pjsip: Fix crash on reINVITE before initial INVITE completes.Richard Mudgett
Apparently some endpoints attempt to send a reINVITE before completing the initial INVITE transaction. In this case PJSIP responds appropriately to the reINVITE with a 491 INVITE request pending. Unfortunately chan_pjsip is using the initial INVITE transaction state to determine if an INVITE is the initial INVITE or a reINVITE. Since the initial INVITE transaction has not been confirmed yet chan_pjsip thinks the reINVITE is an initial INVITE and starts another PBX thread on the channel. The extra PBX thread ensures that hilarity ensues. * Fix checks for a reINVITE on incoming requests to look for the presence of a to-tag instead of the initial INVITE transaction state. * Made caller_id_incoming_request() determine what to do if there is a channel on the session or not. After a channel is created it is too late to just store the new party id on the session because the session's party id has already been copied to the channel's caller id. ASTERISK-25404 #close Reported by: Chet Stevens Change-Id: Ie78201c304a2b13226f3a4ce59908beecc2c68be
2015-10-06Merge "Fix improper usage of scheduler exposed by 5c713fdf18f"Matt Jordan
2015-10-06Fix improper usage of scheduler exposed by 5c713fdf18fMatt Jordan
When 5c713fdf18f was merged, it allowed for scheduled items to have an ID of '0' returned. While this was valid per the documentation for the API, it was apparently never returned previously. As a result, several users of the scheduler API viewed the result as being invalid, causing them to reschedule already scheduled items or otherwise fail in interesting ways. This patch corrects the users such that they view '0' as valid, and a returned ID of -1 as being invalid. Note that the failing HEP RTCP tests now pass with this patch. These tests failed due to a duplicate scheduling of the RTCP transmissions. ASTERISK-25449 #close Change-Id: I019a9aa8b6997584f66876331675981ac9e07e39
2015-10-05chan_pjsip: Add Referred-By header to the PJSIP REFER packet.Debian Amtelco
Some systems require the REFER packet to include a Referred-By header. If the channel variable SIPREFERREDBYHDR is set, it passes that value as the Referred-By header value. Otherwise, it adds the current dialog’s local info. Reported by: Dan Cropp Tested by: Dan Cropp Change-Id: I3d17912ce548667edf53cb549e88a25475eda245
2015-09-19Merge "chan_sip: Fix From header truncation for extremely long CALLERID(name)."Joshua Colp
2015-09-18chan_sip: Fix From header truncation for extremely long CALLERID(name).Walter Doekes
The CALLERID(num) and CALLERID(name) and other info are placed into the `char from[256]` in initreqprep. If the name was too long, the addr-spec and params wouldn't fit. Code is moved around so the addr-spec with params is placed there first, and then fitting in as much of the display-name as possible. ASTERISK-25396 #close Change-Id: I33632baf024f01b6a00f8c7f35c91e5f68c40260
2015-09-17PJSIP: avoid crash when getting rtp peerScott Griepentrog
Although unlikely, if the tech private is returned as a NULL, chan_pjsip_get_rtp_peer() would crash. ASTERISK-25323 Change-Id: Ie231369bfa7da926fb2b9fdaac228261a3152e6a
2015-09-11Merge "chan_sip.c: Validation on module reload"Matt Jordan
2015-09-10chan_sip.c: Validation on module reloadRodrigo Ramírez Norambuena
Change validation on reload module because now used the cli function for reload. The sip_reload() function never fail and ever return NULL for this reason on reload() now use the call the sip_reload() and return AST_MODULE_LOAD_SUCCESS. This problem is dectected on reload by PUT method on ARI, getting always 404 http code when the module is reloaded. ASTERISK-25325 #close Reporte by: Rodrigo Ramírez Norambuena Change-Id: I41215877fb2cfc589e0d4d464000cf6825f4d7fb
2015-09-05Merge "channels/pjsip/dialplan_functions: Add an option for extracting the ↵Matt Jordan
SIP call-id"
2015-09-05channels/pjsip/dialplan_functions: Add an option for extracting the SIP call-idMatt Jordan
This patch adds a new option to the CHANNEL function that allows for the extraction of the SIP call-id. It is used in conjunction with the 'pjsip' option, and will return the Call-ID of the INVITE request that established the PJSIP channel. ASTERISK-25352 Change-Id: I278d1f8bcfe3a53c5aa1dadebc14e92b0abd476a
2015-08-27Merge "Chaos: make hangup NULL tolerant"Mark Michelson
2015-08-26Chaos: make hangup NULL tolerantScott Griepentrog
In chan_pjsip_new, if allocation of the pvt structure fails, ast_hangup is called. But it was written to assume pvt was valid, and this change corrects that. ASTERISK-25323 Reported by: Scott Griepentrog Change-Id: I5f47860fe9cee4cd56abd3f79b108678ab72cc87
2015-08-26chan_sip: Allow call pickup to set the hangup cause.Joshua Colp
The call pickup implementation in chan_sip currently sets the channel hangup cause to "normal clearing" if call pickup is successfully performed. This action overwrites the "answered elsewhere" hangup cause set by the call pickup code and can result in the SIP device in question showing a missed call when it should not. This change sets the hangup cause to "normal clearing" as a default initially but allows the call pickup to change it as needed. ASTERISK-25346 #close Change-Id: I00ac2c269cee9e29586ee2c65e83c70e52a02cff
2015-08-20chan_sip.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: I7f04d5c8bee1126fee5fe6afbc39e45104469f4e
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-13chan_sip.c: wrong peer searched in sip_report_security_eventKevin Harwell
In chan_sip, after handling an incoming invite a security event is raised describing authorization (success, failure, etc...). However, it was doing a lookup of the peer by extension. This is fine for register messages, but in the case of an invite it may search and find the wrong peer, or a non existent one (for instance, in the case of call pickup). Also, if the peers are configured through realtime this may cause an unnecessary database lookup when caching is enabled. This patch makes it so that sip_report_security_event searches by IP address when looking for a peer instead of by extension after an invite is processed. ASTERISK-25320 #close Change-Id: I9b3f11549efb475b6561c64f0e6da1a481d98bc4
2015-08-12Merge "chan_dahdi.c: Lock private struct for ast_write()."Mark Michelson
2015-08-12Merge "chan_dahdi.c: Flush the DAHDI write buffer after starting DTMF."Mark Michelson
2015-08-11chan_dahdi.c: Flush the DAHDI write buffer after starting DTMF.Richard Mudgett
Pressing DTMF digits on a phone to go out on a DAHDI channel can result in the digit not being recognized or even heard by the peer. Phone -> Asterisk -> DAHDI/channel Turns out the DAHDI behavior with DTMF generation (and any other generated tones) is exposed by the "buffers=" setting in chan_dahdi.conf. When Asterisk requests to start sending DTMF then DAHDI waits until its write buffer is empty before generating any samples for the DTMF tones. When Asterisk subsequently requests DAHDI to stop sending DTMF then DAHDI immediately stops generating the DTMF samples. As a result, the more samples there are in the DAHDI write buffer the shorter the time DTMF actually gets sent on the wire. If there are more samples in the write buffer than the time DTMF is supposed to be sent then no DTMF gets sent on the wire. With the "buffers=12,half" setting and each buffer representing 20 ms of samples then the DAHDI write buffer is going to contain around 120 ms of samples. For DTMF to be recognized by the peer the actual sent DTMF duration needs to be a minimum of 40 ms. Therefore, the intended duration needs to be a minimum of 160 ms for the peer to receive the minimum DTMF digit duration to recognize it. A simple and effective solution to work around the DAHDI behavior is for Asterisk to flush the DAHDI write buffer when sending DTMF so the full duration of DTMF is actually sent on the wire. When someone is going to send DTMF they are not likely to be talking before sending the tones so the flushed write samples are expected to just contain silence. * Made dahdi_digit_begin() flush the DAHDI write buffer after requesting to send a DTMF digit. ASTERISK-25315 #close Reported by John Hardin Change-Id: Ib56262c708cb7858082156bfc70ebd0a220efa6a
2015-08-11chan_dahdi.c: Lock private struct for ast_write().Richard Mudgett
There is a window of opportunity for DTMF to not go out if an audio frame is in the process of being written to DAHDI while another thread starts sending DTMF. The thread sending the audio frame could be past the currently dialing check before being preempted by another thread starting a DTMF generation request. When the thread sending the audio frame resumes it will then cause DAHDI to stop the DTMF tone generation. The result is no DTMF goes out. * Made dahdi_write() lock the private struct before writing to the DAHDI file descriptor. ASTERISK-25315 Reported by John Hardin Change-Id: Ib4e0264cf63305ed5da701188447668e72ec9abb