Merge "core: Remove 'Data Retrieval API'"
authorJenkins2 <jenkins2@gerrit.asterisk.org>
Fri, 7 Jul 2017 20:42:56 +0000 (15:42 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Fri, 7 Jul 2017 20:42:56 +0000 (15:42 -0500)
1  2 
channels/chan_sip.c
main/channel.c

diff --combined channels/chan_sip.c
  #include "asterisk/threadstorage.h"
  #include "asterisk/translate.h"
  #include "asterisk/ast_version.h"
- #include "asterisk/data.h"
  #include "asterisk/aoc.h"
  #include "asterisk/message.h"
  #include "sip/include/sip.h"
@@@ -33278,17 -33277,17 +33277,17 @@@ static int reload_config(enum channelre
  
                /* If TCP is running on a different IP than UDP, then add it too */
                if (!ast_sockaddr_isnull(&sip_tcp_desc.local_address) &&
 -                  !ast_sockaddr_cmp(&bindaddr, &sip_tcp_desc.local_address)) {
 +                  ast_sockaddr_cmp_addr(&bindaddr, &sip_tcp_desc.local_address)) {
                        add_sip_domain(ast_sockaddr_stringify_addr(&sip_tcp_desc.local_address),
                                       SIP_DOMAIN_AUTO, NULL);
                }
  
                /* If TLS is running on a different IP than UDP and TCP, then add that too */
                if (!ast_sockaddr_isnull(&sip_tls_desc.local_address) &&
 -                  !ast_sockaddr_cmp(&bindaddr, &sip_tls_desc.local_address) &&
 -                  !ast_sockaddr_cmp(&sip_tcp_desc.local_address,
 +                  ast_sockaddr_cmp_addr(&bindaddr, &sip_tls_desc.local_address) &&
 +                  ast_sockaddr_cmp_addr(&sip_tcp_desc.local_address,
                                      &sip_tls_desc.local_address)) {
 -                      add_sip_domain(ast_sockaddr_stringify_addr(&sip_tcp_desc.local_address),
 +                      add_sip_domain(ast_sockaddr_stringify_addr(&sip_tls_desc.local_address),
                                       SIP_DOMAIN_AUTO, NULL);
                }
  
@@@ -34530,75 -34529,6 +34529,6 @@@ AST_TEST_DEFINE(test_sip_mwi_subscribe_
        return res;
  }
  
- AST_TEST_DEFINE(test_sip_peers_get)
- {
-       struct sip_peer *peer;
-       struct ast_data *node;
-       struct ast_data_query query = {
-               .path = "/asterisk/channel/sip/peers",
-               .search = "peers/peer/name=test_peer_data_provider"
-       };
-       switch (cmd) {
-               case TEST_INIT:
-                       info->name = "sip_peers_get_data_test";
-                       info->category = "/main/data/sip/peers/";
-                       info->summary = "SIP peers data providers unit test";
-                       info->description =
-                               "Tests whether the SIP peers data provider implementation works as expected.";
-                       return AST_TEST_NOT_RUN;
-               case TEST_EXECUTE:
-                       break;
-       }
-       /* Create the peer that we will retrieve. */
-       peer = build_peer("test_peer_data_provider", NULL, NULL, 0, 0);
-       if (!peer) {
-               return AST_TEST_FAIL;
-       }
-       peer->type = SIP_TYPE_USER;
-       peer->call_limit = 10;
-       ao2_link(peers, peer);
-       /* retrieve the chan_sip/peers tree and check the created peer. */
-       node = ast_data_get(&query);
-       if (!node) {
-               ao2_unlink(peers, peer);
-               ao2_ref(peer, -1);
-               return AST_TEST_FAIL;
-       }
-       /* compare item. */
-       if (strcmp(ast_data_retrieve_string(node, "peer/name"), "test_peer_data_provider")) {
-               ao2_unlink(peers, peer);
-               ao2_ref(peer, -1);
-               ast_data_free(node);
-               return AST_TEST_FAIL;
-       }
-       if (strcmp(ast_data_retrieve_string(node, "peer/type"), "user")) {
-               ao2_unlink(peers, peer);
-               ao2_ref(peer, -1);
-               ast_data_free(node);
-               return AST_TEST_FAIL;
-       }
-       if (ast_data_retrieve_int(node, "peer/call_limit") != 10) {
-               ao2_unlink(peers, peer);
-               ao2_ref(peer, -1);
-               ast_data_free(node);
-               return AST_TEST_FAIL;
-       }
-       /* release resources */
-       ast_data_free(node);
-       ao2_unlink(peers, peer);
-       ao2_ref(peer, -1);
-       return AST_TEST_PASS;
- }
  /*!
   * \brief Imitation TCP reception loop
   *
@@@ -35130,170 -35060,6 +35060,6 @@@ AST_TEST_DEFINE(get_in_brackets_const_t
  
  #endif
  
- #define DATA_EXPORT_SIP_PEER(MEMBER)                          \
-       MEMBER(sip_peer, name, AST_DATA_STRING)                 \
-       MEMBER(sip_peer, secret, AST_DATA_PASSWORD)             \
-       MEMBER(sip_peer, md5secret, AST_DATA_PASSWORD)          \
-       MEMBER(sip_peer, remotesecret, AST_DATA_PASSWORD)       \
-       MEMBER(sip_peer, context, AST_DATA_STRING)              \
-       MEMBER(sip_peer, subscribecontext, AST_DATA_STRING)     \
-       MEMBER(sip_peer, username, AST_DATA_STRING)             \
-       MEMBER(sip_peer, accountcode, AST_DATA_STRING)          \
-       MEMBER(sip_peer, tohost, AST_DATA_STRING)               \
-       MEMBER(sip_peer, regexten, AST_DATA_STRING)             \
-       MEMBER(sip_peer, fromuser, AST_DATA_STRING)             \
-       MEMBER(sip_peer, fromdomain, AST_DATA_STRING)           \
-       MEMBER(sip_peer, fullcontact, AST_DATA_STRING)          \
-       MEMBER(sip_peer, cid_num, AST_DATA_STRING)              \
-       MEMBER(sip_peer, cid_name, AST_DATA_STRING)             \
-       MEMBER(sip_peer, vmexten, AST_DATA_STRING)              \
-       MEMBER(sip_peer, language, AST_DATA_STRING)             \
-       MEMBER(sip_peer, mohinterpret, AST_DATA_STRING)         \
-       MEMBER(sip_peer, mohsuggest, AST_DATA_STRING)           \
-       MEMBER(sip_peer, parkinglot, AST_DATA_STRING)           \
-       MEMBER(sip_peer, useragent, AST_DATA_STRING)            \
-       MEMBER(sip_peer, mwi_from, AST_DATA_STRING)             \
-       MEMBER(sip_peer, engine, AST_DATA_STRING)               \
-       MEMBER(sip_peer, unsolicited_mailbox, AST_DATA_STRING)  \
-       MEMBER(sip_peer, is_realtime, AST_DATA_BOOLEAN)         \
-       MEMBER(sip_peer, host_dynamic, AST_DATA_BOOLEAN)        \
-       MEMBER(sip_peer, autoframing, AST_DATA_BOOLEAN)         \
-       MEMBER(sip_peer, inuse, AST_DATA_INTEGER)               \
-       MEMBER(sip_peer, ringing, AST_DATA_INTEGER)             \
-       MEMBER(sip_peer, onhold, AST_DATA_INTEGER)              \
-       MEMBER(sip_peer, call_limit, AST_DATA_INTEGER)          \
-       MEMBER(sip_peer, t38_maxdatagram, AST_DATA_INTEGER)     \
-       MEMBER(sip_peer, maxcallbitrate, AST_DATA_INTEGER)      \
-       MEMBER(sip_peer, rtptimeout, AST_DATA_SECONDS)          \
-       MEMBER(sip_peer, rtpholdtimeout, AST_DATA_SECONDS)      \
-       MEMBER(sip_peer, rtpkeepalive, AST_DATA_SECONDS)        \
-       MEMBER(sip_peer, lastms, AST_DATA_MILLISECONDS)         \
-       MEMBER(sip_peer, maxms, AST_DATA_MILLISECONDS)          \
-       MEMBER(sip_peer, qualifyfreq, AST_DATA_MILLISECONDS)    \
-       MEMBER(sip_peer, timer_t1, AST_DATA_MILLISECONDS)       \
-       MEMBER(sip_peer, timer_b, AST_DATA_MILLISECONDS)        \
-       MEMBER(sip_peer, description, AST_DATA_STRING)
- AST_DATA_STRUCTURE(sip_peer, DATA_EXPORT_SIP_PEER);
- static int peers_data_provider_get(const struct ast_data_search *search,
-       struct ast_data *data_root)
- {
-       struct sip_peer *peer;
-       struct ao2_iterator i;
-       struct ast_data *data_peer, *data_peer_mailboxes = NULL, *data_peer_mailbox, *enum_node;
-       struct ast_data *data_sip_options;
-       int total_mailboxes, x;
-       struct sip_mailbox *mailbox;
-       i = ao2_iterator_init(peers, 0);
-       while ((peer = ao2_iterator_next(&i))) {
-               ao2_lock(peer);
-               data_peer = ast_data_add_node(data_root, "peer");
-               if (!data_peer) {
-                       ao2_unlock(peer);
-                       ao2_ref(peer, -1);
-                       continue;
-               }
-               ast_data_add_structure(sip_peer, data_peer, peer);
-               /* transfer mode */
-               enum_node = ast_data_add_node(data_peer, "allowtransfer");
-               if (!enum_node) {
-                       ao2_unlock(peer);
-                       ao2_ref(peer, -1);
-                       continue;
-               }
-               ast_data_add_str(enum_node, "text", transfermode2str(peer->allowtransfer));
-               ast_data_add_int(enum_node, "value", peer->allowtransfer);
-               /* transports */
-               ast_data_add_str(data_peer, "transports", get_transport_list(peer->transports));
-               /* peer type */
-               if ((peer->type & SIP_TYPE_USER) && (peer->type & SIP_TYPE_PEER)) {
-                       ast_data_add_str(data_peer, "type", "friend");
-               } else if (peer->type & SIP_TYPE_PEER) {
-                       ast_data_add_str(data_peer, "type", "peer");
-               } else if (peer->type & SIP_TYPE_USER) {
-                       ast_data_add_str(data_peer, "type", "user");
-               }
-               /* mailboxes */
-               total_mailboxes = 0;
-               AST_LIST_TRAVERSE(&peer->mailboxes, mailbox, entry) {
-                       if (!total_mailboxes) {
-                               data_peer_mailboxes = ast_data_add_node(data_peer, "mailboxes");
-                               if (!data_peer_mailboxes) {
-                                       break;
-                               }
-                               total_mailboxes++;
-                       }
-                       data_peer_mailbox = ast_data_add_node(data_peer_mailboxes, "mailbox");
-                       if (!data_peer_mailbox) {
-                               continue;
-                       }
-                       ast_data_add_str(data_peer_mailbox, "id", mailbox->id);
-               }
-               /* amaflags */
-               enum_node = ast_data_add_node(data_peer, "amaflags");
-               if (!enum_node) {
-                       ao2_unlock(peer);
-                       ao2_ref(peer, -1);
-                       continue;
-               }
-               ast_data_add_int(enum_node, "value", peer->amaflags);
-               ast_data_add_str(enum_node, "text", ast_channel_amaflags2string(peer->amaflags));
-               /* sip options */
-               data_sip_options = ast_data_add_node(data_peer, "sipoptions");
-               if (!data_sip_options) {
-                       ao2_unlock(peer);
-                       ao2_ref(peer, -1);
-                       continue;
-               }
-               for (x = 0 ; x < ARRAY_LEN(sip_options); x++) {
-                       ast_data_add_bool(data_sip_options, sip_options[x].text, peer->sipoptions & sip_options[x].id);
-               }
-               /* callingpres */
-               enum_node = ast_data_add_node(data_peer, "callingpres");
-               if (!enum_node) {
-                       ao2_unlock(peer);
-                       ao2_ref(peer, -1);
-                       continue;
-               }
-               ast_data_add_int(enum_node, "value", peer->callingpres);
-               ast_data_add_str(enum_node, "text", ast_describe_caller_presentation(peer->callingpres));
-               /* codecs */
-               ast_data_add_codecs(data_peer, "codecs", peer->caps);
-               if (!ast_data_search_match(search, data_peer)) {
-                       ast_data_remove_node(data_root, data_peer);
-               }
-               ao2_unlock(peer);
-               ao2_ref(peer, -1);
-       }
-       ao2_iterator_destroy(&i);
-       return 0;
- }
- static const struct ast_data_handler peers_data_provider = {
-       .version = AST_DATA_HANDLER_VERSION,
-       .get = peers_data_provider_get
- };
- static const struct ast_data_entry sip_data_providers[] = {
-       AST_DATA_ENTRY("asterisk/channel/sip/peers", &peers_data_provider),
- };
  static const struct ast_sip_api_tech chan_sip_api_provider = {
        .version = AST_SIP_API_VERSION,
        .name = "chan_sip",
@@@ -35414,15 -35180,11 +35180,11 @@@ static int load_module(void
        }
  
  #ifdef TEST_FRAMEWORK
-       AST_TEST_REGISTER(test_sip_peers_get);
        AST_TEST_REGISTER(test_sip_mwi_subscribe_parse);
        AST_TEST_REGISTER(test_tcp_message_fragmentation);
        AST_TEST_REGISTER(get_in_brackets_const_test);
  #endif
  
-       /* Register AstData providers */
-       ast_data_register_multiple(sip_data_providers, ARRAY_LEN(sip_data_providers));
        /* Register all CLI functions for SIP */
        ast_cli_register_multiple(cli_sip, ARRAY_LEN(cli_sip));
  
@@@ -35549,14 -35311,10 +35311,10 @@@ static int unload_module(void
  #ifdef TEST_FRAMEWORK
        ast_unregister_application(app_sipsendcustominfo);
  
-       AST_TEST_UNREGISTER(test_sip_peers_get);
        AST_TEST_UNREGISTER(test_sip_mwi_subscribe_parse);
        AST_TEST_UNREGISTER(test_tcp_message_fragmentation);
        AST_TEST_UNREGISTER(get_in_brackets_const_test);
  #endif
-       /* Unregister all the AstData providers */
-       ast_data_unregister(NULL);
        /* Unregister CLI commands */
        ast_cli_unregister_multiple(cli_sip, ARRAY_LEN(cli_sip));
  
diff --combined main/channel.c
@@@ -66,7 -66,6 +66,6 @@@
  #include "asterisk/autochan.h"
  #include "asterisk/stringfields.h"
  #include "asterisk/global_datastores.h"
- #include "asterisk/data.h"
  #include "asterisk/channel_internal.h"
  #include "asterisk/features.h"
  #include "asterisk/bridge.h"
@@@ -3262,12 -3261,8 +3261,12 @@@ int ast_waitfordigit_full(struct ast_ch
                } else if (rchan) {
                        int res;
                        struct ast_frame *f = ast_read(c);
 -                      if (!f)
 +
 +                      if (!f) {
 +                              ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
 +
                                return -1;
 +                      }
  
                        switch (f->frametype) {
                        case AST_FRAME_DTMF_BEGIN:
@@@ -7570,122 -7565,6 +7569,6 @@@ int ast_plc_reload(void
  
  /*!
   * \internal
-  * \brief Implements the channels provider.
-  */
- static int data_channels_provider_handler(const struct ast_data_search *search,
-       struct ast_data *root)
- {
-       struct ast_channel *c;
-       struct ast_channel_iterator *iter = NULL;
-       struct ast_data *data_channel;
-       for (iter = ast_channel_iterator_all_new();
-               iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {
-               ast_channel_lock(c);
-               data_channel = ast_data_add_node(root, "channel");
-               if (!data_channel) {
-                       ast_channel_unlock(c);
-                       continue;
-               }
-               if (ast_channel_data_add_structure(data_channel, c, 1) < 0) {
-                       ast_log(LOG_ERROR, "Unable to add channel structure for channel: %s\n", ast_channel_name(c));
-               }
-               ast_channel_unlock(c);
-               if (!ast_data_search_match(search, data_channel)) {
-                       ast_data_remove_node(root, data_channel);
-               }
-       }
-       if (iter) {
-               ast_channel_iterator_destroy(iter);
-       }
-       return 0;
- }
- /*!
-  * \internal
-  * \brief Implements the channeltypes provider.
-  */
- static int data_channeltypes_provider_handler(const struct ast_data_search *search,
-       struct ast_data *data_root)
- {
-       struct chanlist *cl;
-       struct ast_data *data_type;
-       AST_RWLIST_RDLOCK(&backends);
-       AST_RWLIST_TRAVERSE(&backends, cl, list) {
-               data_type = ast_data_add_node(data_root, "type");
-               if (!data_type) {
-                       continue;
-               }
-               ast_data_add_str(data_type, "name", cl->tech->type);
-               ast_data_add_str(data_type, "description", cl->tech->description);
-               ast_data_add_bool(data_type, "devicestate", cl->tech->devicestate ? 1 : 0);
-               ast_data_add_bool(data_type, "presencestate", cl->tech->presencestate ? 1 : 0);
-               ast_data_add_bool(data_type, "indications", cl->tech->indicate ? 1 : 0);
-               ast_data_add_bool(data_type, "transfer", cl->tech->transfer ? 1 : 0);
-               ast_data_add_bool(data_type, "send_digit_begin", cl->tech->send_digit_begin ? 1 : 0);
-               ast_data_add_bool(data_type, "send_digit_end", cl->tech->send_digit_end ? 1 : 0);
-               ast_data_add_bool(data_type, "call", cl->tech->call ? 1 : 0);
-               ast_data_add_bool(data_type, "hangup", cl->tech->hangup ? 1 : 0);
-               ast_data_add_bool(data_type, "answer", cl->tech->answer ? 1 : 0);
-               ast_data_add_bool(data_type, "read", cl->tech->read ? 1 : 0);
-               ast_data_add_bool(data_type, "write", cl->tech->write ? 1 : 0);
-               ast_data_add_bool(data_type, "send_text", cl->tech->send_text ? 1 : 0);
-               ast_data_add_bool(data_type, "send_image", cl->tech->send_image ? 1 : 0);
-               ast_data_add_bool(data_type, "send_html", cl->tech->send_html ? 1 : 0);
-               ast_data_add_bool(data_type, "exception", cl->tech->exception ? 1 : 0);
-               ast_data_add_bool(data_type, "early_bridge", cl->tech->early_bridge ? 1 : 0);
-               ast_data_add_bool(data_type, "fixup", cl->tech->fixup ? 1 : 0);
-               ast_data_add_bool(data_type, "setoption", cl->tech->setoption ? 1 : 0);
-               ast_data_add_bool(data_type, "queryoption", cl->tech->queryoption ? 1 : 0);
-               ast_data_add_bool(data_type, "write_video", cl->tech->write_video ? 1 : 0);
-               ast_data_add_bool(data_type, "write_text", cl->tech->write_text ? 1 : 0);
-               ast_data_add_bool(data_type, "func_channel_read", cl->tech->func_channel_read ? 1 : 0);
-               ast_data_add_bool(data_type, "func_channel_write", cl->tech->func_channel_write ? 1 : 0);
-               ast_data_add_bool(data_type, "get_pvt_uniqueid", cl->tech->get_pvt_uniqueid ? 1 : 0);
-               ast_data_add_bool(data_type, "cc_callback", cl->tech->cc_callback ? 1 : 0);
-               ast_data_add_codecs(data_type, "capabilities", cl->tech->capabilities);
-               if (!ast_data_search_match(search, data_type)) {
-                       ast_data_remove_node(data_root, data_type);
-               }
-       }
-       AST_RWLIST_UNLOCK(&backends);
-       return 0;
- }
- /*!
-  * \internal
-  * \brief /asterisk/core/channels provider.
-  */
- static const struct ast_data_handler channels_provider = {
-       .version = AST_DATA_HANDLER_VERSION,
-       .get = data_channels_provider_handler
- };
- /*!
-  * \internal
-  * \brief /asterisk/core/channeltypes provider.
-  */
- static const struct ast_data_handler channeltypes_provider = {
-       .version = AST_DATA_HANDLER_VERSION,
-       .get = data_channeltypes_provider_handler
- };
- static const struct ast_data_entry channel_providers[] = {
-       AST_DATA_ENTRY("/asterisk/core/channels", &channels_provider),
-       AST_DATA_ENTRY("/asterisk/core/channeltypes", &channeltypes_provider),
- };
- /*!
-  * \internal
   * \brief Print channel object key (name).
   * \since 12.0.0
   *
@@@ -7883,7 -7762,6 +7766,6 @@@ static void channels_shutdown(void
        free_external_channelvars(&ami_vars);
        free_external_channelvars(&ari_vars);
  
-       ast_data_unregister(NULL);
        ast_cli_unregister_multiple(cli_channel, ARRAY_LEN(cli_channel));
        if (channels) {
                ao2_container_unregister("channels");
@@@ -7908,8 -7786,6 +7790,6 @@@ int ast_channels_init(void
  
        ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel));
  
-       ast_data_register_multiple_core(channel_providers, ARRAY_LEN(channel_providers));
        ast_plc_reload();
  
        ast_register_cleanup(channels_shutdown);