asterisk/res
Matthew Jordan bb87796f67 ARI: Fix endpoint/channel subscription issues; allow for subscriptions to tech
This patch serves two purposes:
(1) It fixes some bugs with endpoint subscriptions not reporting all of the
    channel events
(2) It serves as the preliminary work needed for ASTERISK-23692, which allows
    for sending/receiving arbitrary out of call text messages through ARI in a
    technology agnostic fashion.

The messaging functionality described on ASTERISK-23692 requires two things:
(1) The ability to send/receive messages associated with an endpoint. This is
    relatively straight forwards with the endpoint core in Asterisk now.
(2) The ability to send/receive messages associated with a technology and an
    arbitrary technology defined URI. This is less straight forward, as
    endpoints are formed from a tech + resource pair. We don't have a
    mechanism to note that a technology that *may* have endpoints exists.

This patch provides such a mechanism, and fixes a few bugs along the way.

The first major bug this patch fixes is the forwarding of channel messages
to their respective endpoints. Prior to this patch, there were two problems:
(1) Channel caching messages weren't forwarded. Thus, the endpoints missed
    most of the interesting bits (such as channel creation, destruction, state
    changes, etc.)
(2) Channels weren't associated with their endpoint until after creation.
    This resulted in endpoints missing the channel creation message, which
    limited the usefulness of the subscription in the first place (a major use
    case being 'tell me when this endpoint has a channel'). Unfortunately,
    this meant another parameter to ast_channel_alloc. Since not all channel
    technologies support an ast_endpoint, this patch makes such a call
    optional and opts for a new function, ast_channel_alloc_with_endpoint.

When endpoints are created, they will implicitly create a technology endpoint
for their technology (if one does not already exist). A technology endpoint is
special in that it has no state, cannot have channels created for it, cannot
be created explicitly, and cannot be destroyed except on shutdown. It does,
however, have all messages from other endpoints in its technology forwarded to
it.

Combined with the bug fixes, we now have Stasis messages being properly
forwarded. Consider the following scenario: two PJSIP endpoints (foo and bar),
where bar has a single channel associated with it and foo has two channels
associated with it. The messages would be forwarded as follows:

channel PJSIP/foo-1 --
                      \
                       --> endpoint PJSIP/foo --
                      /                         \
channel PJSIP/foo-2 --                           \
                                                  ---- > endpoint PJSIP
                                                /
channel PJSIP/bar-1 -----> endpoint PJSIP/bar --

ARI, through the applications resource, can:
 - subscribe to endpoint:PJSIP/foo and get notifications for channels
   PJSIP/foo-1,PJSIP/foo-2 and endpoint PJSIP/foo
 - subscribe to endpoint:PJSIP/bar and get notifications for channels
   PJSIP/bar-1 and endpoint PJSIP/bar
 - subscribe to endpoint:PJSIP and get notifications for channels
   PJSIP/foo-1,PJSIP/foo-2,PJSIP/bar-1 and endpoints PJSIP/foo,PJSIP/bar

Note that since endpoint PJSIP never changes, it never has events itself. It
merely provides an aggregation point for all other endpoints in its technology
(which in turn aggregate all channel messages associated with that endpoint).

This patch also adds endpoints to res_xmpp and chan_motif, because the actual
messaging work will need it (messaging without XMPP is just sad).

Review: https://reviewboard.asterisk.org/r/3760/

ASTERISK-23692
........

Merged revisions 419196 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419203 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-22 16:20:58 +00:00
..
ael Remove many deprecated modules 2014-07-04 13:26:37 +00:00
ari ARI: Fix endpoint/channel subscription issues; allow for subscriptions to tech 2014-07-22 16:20:58 +00:00
parking media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_pjsip media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
snmp Get the SNMP code to compile. 2013-08-02 15:01:37 +00:00
stasis ARI: Make mixing bridges propagate linkedids and accountcodes. 2014-07-09 16:34:51 +00:00
stasis_recording ari: Add a copy operation for stored recordings 2014-07-18 21:48:46 +00:00
Makefile ARI: Implement /recordings/stored API's 2013-08-30 13:28:50 +00:00
ari.make ARI: Add mailboxes resource for controlling and polling external MWI 2014-01-14 23:44:57 +00:00
res_adsi.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_ael_share.c Merged revisions 328247 via svnmerge from 2011-07-14 20:28:54 +00:00
res_ael_share.exports.in Allow symbol export filtering to work properly on platforms that have symbol prefixes. 2010-04-02 18:57:58 +00:00
res_agi.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_agi.exports.in Allow symbol export filtering to work properly on platforms that have symbol prefixes. 2010-04-02 18:57:58 +00:00
res_ari.c res_ari: Fix some off-nominal paths just dropping the HTTP connection. 2014-07-03 19:06:12 +00:00
res_ari.exports.in Rename everything Stasis-HTTP to ARI 2013-07-27 23:11:02 +00:00
res_ari_applications.c ARI: Support channel variables in originate 2014-01-21 14:27:21 +00:00
res_ari_asterisk.c ARI: Support channel variables in originate 2014-01-21 14:27:21 +00:00
res_ari_bridges.c ARI: Make bridges/{bridgeID}/play queue sound files 2014-04-18 20:09:24 +00:00
res_ari_channels.c uniqueid: channel linkedid, ami, ari object creation with id's 2014-03-07 15:47:55 +00:00
res_ari_device_states.c ARI: Support channel variables in originate 2014-01-21 14:27:21 +00:00
res_ari_endpoints.c ari:Add application/json parameter support 2013-11-27 15:48:39 +00:00
res_ari_events.c ARI: Add ability to raise arbitrary User Events 2014-05-22 16:09:51 +00:00
res_ari_mailboxes.c ARI: Support channel variables in originate 2014-01-21 14:27:21 +00:00
res_ari_model.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_ari_model.exports.in Rename everything Stasis-HTTP to ARI 2013-07-27 23:11:02 +00:00
res_ari_playbacks.c ARI: Support channel variables in originate 2014-01-21 14:27:21 +00:00
res_ari_recordings.c ari: Add a copy operation for stored recordings 2014-07-18 21:48:46 +00:00
res_ari_sounds.c ARI: Support channel variables in originate 2014-01-21 14:27:21 +00:00
res_calendar.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_calendar.exports.in Allow symbol export filtering to work properly on platforms that have symbol prefixes. 2010-04-02 18:57:58 +00:00
res_calendar_caldav.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_calendar_ews.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_calendar_exchange.c uniqueid: channel linkedid, ami, ari object creation with id's 2014-03-07 15:47:55 +00:00
res_calendar_icalendar.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_chan_stats.c Multiple revisions 399887,400138,400178,400180-400181 2013-09-30 18:55:27 +00:00
res_clialiases.c res_clialiases: Fix crash when reloading and re-aliasing an alias that is in use. 2014-02-04 02:22:28 +00:00
res_clioriginate.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_config_curl.c Logger/CLI/etc.: Fix some aesthetic issues; reduce chatty verbose messages 2014-05-28 22:54:12 +00:00
res_config_ldap.c Add support for a realtime sorcery module. 2013-04-27 12:01:29 +00:00
res_config_odbc.c Logger/CLI/etc.: Fix some aesthetic issues; reduce chatty verbose messages 2014-05-28 22:54:12 +00:00
res_config_pgsql.c cel_pgsql, cdr_pgsql, res_config_pgsql: Add PostgreSQL application_name support 2014-07-16 13:55:36 +00:00
res_config_sqlite.c res_config_sqlite: Check for CDR unregistration failures 2013-12-08 05:59:46 +00:00
res_config_sqlite3.c We have faced situation when using CDR and CEL by sqlite3 modules. With system having high load (~100 concurrent calls created by sipp) we found many cdr and cel records missed. There is special finction in sqlite3, that make able to fix this situation - sqlite3_wait_timeout, that also can replace awful code cdr_sqlite3 ad cel_sqlite3 modules. Also this function can be used for aastdb and res_config_sqlite3 to avoid missed writes to sqlite db. 2014-06-16 09:04:05 +00:00
res_convert.c Merged revisions 328247 via svnmerge from 2011-07-14 20:28:54 +00:00
res_corosync.c Fix more dev-mode build issues 2014-07-22 14:22:00 +00:00
res_crypto.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_crypto.exports.in Remove built-in AES code and use optional_api instead 2010-07-21 19:11:32 +00:00
res_curl.c Doxygen Updates - Title update 2012-10-14 21:44:27 +00:00
res_fax.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_fax.exports.in res_fax: Provide AMI equivalents for fax CLI commands 2014-07-18 15:49:46 +00:00
res_fax_spandsp.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_format_attr_celt.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_format_attr_h263.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_format_attr_h264.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_format_attr_opus.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_format_attr_silk.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_hep.c res_hep: Fix crash when hep.conf not available 2014-04-03 11:47:03 +00:00
res_hep.exports.in res_hep/res_hep_pjsip: Add a HEPv3 capture agent module and a logger for PJSIP 2014-03-28 18:32:50 +00:00
res_hep_pjsip.c res_hep_pjsip: Use the channel name instead of the call ID when it is available 2014-04-10 21:28:08 +00:00
res_http_post.c HTTP: Add persistent connection support. 2014-07-03 17:16:55 +00:00
res_http_websocket.c HTTP: Add persistent connection support. 2014-07-03 17:16:55 +00:00
res_http_websocket.exports.in res_http_websocket: Export symbol for ast_websocket_set_timeout 2014-06-26 18:27:53 +00:00
res_jabber.exports.in Fix chan_jingle/gtalk load regression introduced in r346087 2011-12-05 14:47:11 +00:00
res_limit.c Doxygen Updates - Title update 2012-10-14 21:44:27 +00:00
res_manager_devicestate.c res_manager_devicestate and res_manager_presencestate missing support level 2014-06-14 19:26:16 +00:00
res_manager_presencestate.c res_manager_devicestate and res_manager_presencestate missing support level 2014-06-14 19:26:16 +00:00
res_monitor.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_monitor.exports.in Allow symbol export filtering to work properly on platforms that have symbol prefixes. 2010-04-02 18:57:58 +00:00
res_musiconhold.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_mutestream.c Fix dialplan function NULL channel safety issues 2014-03-27 19:21:44 +00:00
res_mwi_external.c Prevent duplicate sorcery wizards from being applied to sorcery object types. 2014-04-02 18:57:29 +00:00
res_mwi_external.exports.in External MWI core support. 2014-01-06 17:45:25 +00:00
res_mwi_external_ami.c Fix more dev-mode build issues 2014-07-22 14:22:00 +00:00
res_odbc.c Logger/CLI/etc.: Fix some aesthetic issues; reduce chatty verbose messages 2014-05-28 22:54:12 +00:00
res_odbc.exports.in Allow symbol export filtering to work properly on platforms that have symbol prefixes. 2010-04-02 18:57:58 +00:00
res_parking.c Eliminate some more unnecessary RAII_VAR() uses. 2014-04-15 18:30:24 +00:00
res_phoneprov.c HTTP: Add persistent connection support. 2014-07-03 17:16:55 +00:00
res_pjsip.c res_pjsip: Support setting a default accountcode on endpoints 2014-07-16 14:03:51 +00:00
res_pjsip.exports.in res_pjsip: AMI commands and events. 2013-11-23 17:26:57 +00:00
res_pjsip_acl.c sorcery: Create AST_SORCERY dialplan function. 2014-03-06 22:39:54 +00:00
res_pjsip_authenticator_digest.c res_pjsip_authenticator_digest: Fix md5 hash buffer 2014-01-03 21:13:30 +00:00
res_pjsip_caller_id.c PJSIP: Add Path header support 2014-01-15 13:16:10 +00:00
res_pjsip_dialog_info_body_generator.c res_pjsip_dialog_info_body_generator: Add dialog-info+xml support for presence. 2014-07-07 16:08:47 +00:00
res_pjsip_diversion.c PJSIP: Add Path header support 2014-01-15 13:16:10 +00:00
res_pjsip_dtmf_info.c Prevent a crash in res_pjsip_dtmf_info.c 2013-09-03 18:09:02 +00:00
res_pjsip_endpoint_identifier_anonymous.c The large GULP->PJSIP renaming effort. 2013-07-30 18:14:50 +00:00
res_pjsip_endpoint_identifier_ip.c pjsip cli: Change Identify to show CIDR notation instead of netmasks. 2014-06-19 20:13:20 +00:00
res_pjsip_endpoint_identifier_user.c PJSIP: Add log messages when requests are received for non-existent endpoints 2013-10-25 17:41:38 +00:00
res_pjsip_exten_state.c res_pjsip_dialog_info_body_generator: Add dialog-info+xml support for presence. 2014-07-07 16:08:47 +00:00
res_pjsip_exten_state.exports.in The large GULP->PJSIP renaming effort. 2013-07-30 18:14:50 +00:00
res_pjsip_header_funcs.c chan_pjsip: Fix bug where custom SIP headers could be duplicated on outgoing INVITEs. 2014-06-09 20:21:42 +00:00
res_pjsip_log_forwarder.c res_pjsip: Forward PJSIP logging to Asterisk logging 2013-09-13 14:22:07 +00:00
res_pjsip_logger.c res_pjsip: Updates and adds more PJSIP CLI commands. 2014-02-06 17:55:45 +00:00
res_pjsip_messaging.c chan_sip.c: Fixed off-nominal message iterator ref count and alloc fail issues. 2014-04-30 21:03:29 +00:00
res_pjsip_multihomed.c res_pjsip_multihomed: Make address replacement less aggressive. 2014-03-17 22:46:56 +00:00
res_pjsip_mwi.c Abstract PJSIP-specific elements from the pubsub API. 2014-06-25 20:57:28 +00:00
res_pjsip_mwi_body_generator.c Decouple subscription handling from NOTIFY/PUBLISH body generation. 2014-01-31 22:27:07 +00:00
res_pjsip_nat.c PJSIP: Fix address for ACK in NAT situations 2014-01-31 15:08:49 +00:00
res_pjsip_notify.c PJSIP: PJSIPNotify - Strip content-length headers and add documentation 2014-06-10 16:06:12 +00:00
res_pjsip_one_touch_record_info.c The large GULP->PJSIP renaming effort. 2013-07-30 18:14:50 +00:00
res_pjsip_outbound_authenticator_digest.c Switch PJSIP auth to use a vector. 2013-12-09 16:10:05 +00:00
res_pjsip_outbound_registration.c res_pjsip: Add ActionID to events created as a result of PJSIP AMI actions 2014-06-27 13:50:02 +00:00
res_pjsip_path.c PJSIP: Add Path header support 2014-01-15 13:16:10 +00:00
res_pjsip_pidf_body_generator.c Abstract PJSIP-specific elements from the pubsub API. 2014-06-25 20:57:28 +00:00
res_pjsip_pidf_digium_body_supplement.c Improve XML sanitization in NOTIFYs, especially for presence subtypes and messages. 2014-05-07 15:29:18 +00:00
res_pjsip_pidf_eyebeam_body_supplement.c Decouple subscription handling from NOTIFY/PUBLISH body generation. 2014-01-31 22:27:07 +00:00
res_pjsip_pubsub.c astobj2: assert on invalid ref and backtrace cleanup 2014-07-18 17:55:38 +00:00
res_pjsip_pubsub.exports.in Abstract PJSIP-specific elements from the pubsub API. 2014-06-25 20:57:28 +00:00
res_pjsip_refer.c Channels: Masquerades to automatically move frame/audio hooks 2014-07-18 16:28:10 +00:00
res_pjsip_registrar.c res_pjsip: Add ActionID to events created as a result of PJSIP AMI actions 2014-06-27 13:50:02 +00:00
res_pjsip_registrar_expire.c sorcery, bucket: Change observer remove calls to take const callbacks struct. 2013-12-03 17:35:54 +00:00
res_pjsip_rfc3326.c The large GULP->PJSIP renaming effort. 2013-07-30 18:14:50 +00:00
res_pjsip_sdp_rtp.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_pjsip_send_to_voicemail.c res_pjsip_send_to_voicemail: transferring to voicemail for digium phones 2014-02-25 17:47:06 +00:00
res_pjsip_session.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_pjsip_session.exports.in The large GULP->PJSIP renaming effort. 2013-07-30 18:14:50 +00:00
res_pjsip_t38.c res_pjsip_session: Fix leaked video RTP ports. 2014-05-28 16:56:07 +00:00
res_pjsip_transport_websocket.c res_http_websocket: Close websocket correctly and use careful fwrite 2014-06-26 12:21:14 +00:00
res_pjsip_xpidf_body_generator.c Abstract PJSIP-specific elements from the pubsub API. 2014-06-25 20:57:28 +00:00
res_pktccops.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_pktccops.exports.in Allow symbol export filtering to work properly on platforms that have symbol prefixes. 2010-04-02 18:57:58 +00:00
res_realtime.c Cleanup references to sipusers and sipfriends dynamic realtime families 2011-11-01 19:53:26 +00:00
res_rtp_asterisk.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_rtp_multicast.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_security_log.c Multiple revisions 399887,400138,400178,400180-400181 2013-09-30 18:55:27 +00:00
res_smdi.c res_smdi: convert to astobj2 2014-07-21 08:41:29 +00:00
res_smdi.exports.in Allow symbol export filtering to work properly on platforms that have symbol prefixes. 2010-04-02 18:57:58 +00:00
res_snmp.c Doxygen Updates - Title update 2012-10-14 21:44:27 +00:00
res_sorcery_astdb.c json: Fix off-nominal json ref counting issues. 2014-02-21 18:04:54 +00:00
res_sorcery_config.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_sorcery_memory.c Pass the sorcery instance to wizards for CUD operations as well as retrieve. 2013-03-20 14:52:23 +00:00
res_sorcery_realtime.c Handle the return values of realtime updates and stores more accurately. 2014-03-14 18:11:55 +00:00
res_speech.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_speech.exports.in app_speech_utils: Fix unresolved symbol ast_speech_get_setting(). 2013-09-16 18:00:32 +00:00
res_srtp.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_srtp.exports.in Add SRTP support for Asterisk 2010-06-08 05:29:08 +00:00
res_stasis.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_stasis.exports.in Moved core logic from app_stasis to res_stasis 2013-04-15 16:43:47 +00:00
res_stasis_answer.c Replace __ast_answer with ast_raw_answer in app_control_answer 2014-05-19 19:52:34 +00:00
res_stasis_answer.exports.in Add missing exports file 2013-05-20 14:21:39 +00:00
res_stasis_device_state.c ARI: Make double subscribe respond with success 2014-01-28 19:19:08 +00:00
res_stasis_device_state.exports.in ARI: Implement device state API 2013-11-23 17:48:28 +00:00
res_stasis_mailbox.c ARI: Add mailboxes resource for controlling and polling external MWI 2014-01-14 23:44:57 +00:00
res_stasis_mailbox.exports.in ARI: Add mailboxes resource for controlling and polling external MWI 2014-01-14 23:44:57 +00:00
res_stasis_playback.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_stasis_playback.exports.in This patch implements the REST API's for POST /channels/{channelId}/play 2013-05-23 20:11:35 +00:00
res_stasis_recording.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_stasis_recording.exports.in ARI - channel recording support 2013-07-03 17:58:45 +00:00
res_stasis_snoop.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
res_stasis_snoop.exports.in ari: Add Snoop operation for spying/whispering on channels. 2013-11-23 12:40:46 +00:00
res_stasis_test.c Multiple revisions 399887,400138,400178,400180-400181 2013-09-30 18:55:27 +00:00
res_stasis_test.exports.in Initial support for endpoints. 2013-05-08 13:39:08 +00:00
res_statsd.c Rename everything Stasis-HTTP to ARI 2013-07-27 23:11:02 +00:00
res_statsd.exports.in Example of how to use the Stasis message bus 2013-04-26 20:05:15 +00:00
res_stun_monitor.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_timing_dahdi.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
res_timing_kqueue.c timing: Improve performance for most timing implementations. 2014-02-07 20:01:45 +00:00
res_timing_pthread.c timing: Improve performance for most timing implementations. 2014-02-07 20:01:45 +00:00
res_timing_timerfd.c timing: Improve performance for most timing implementations. 2014-02-07 20:01:45 +00:00
res_xmpp.c ARI: Fix endpoint/channel subscription issues; allow for subscriptions to tech 2014-07-22 16:20:58 +00:00
res_xmpp.exports.in Add a new unified Jingle, Google Jingle, and Google Talk channel driver written from scratch called chan_motif. 2012-07-07 17:06:51 +00:00