Add missing OPTIONAL_API and ARI dependences.
authorCorey Farrell <git@cfware.com>
Thu, 18 Jan 2018 15:01:26 +0000 (10:01 -0500)
committerCorey Farrell <git@cfware.com>
Mon, 22 Jan 2018 17:16:58 +0000 (12:16 -0500)
I've audited all modules that include any header which includes
asterisk/optional_api.h.  All modules which use OPTIONAL_API now declare
those dependencies in AST_MODULE_INFO using requires or optional_modules
as appropriate.

In addition ARI dependency declarations have been reworked.  Instead of
declaring additional required modules in res/ari/resource_*.c we now add
them to an optional array "requiresModules" in api-docs for each module.
This allows the AST_MODULE_INFO dependencies to include those missing
modules.

Change-Id: Ia0c70571f5566784f63605e78e1ceccb4f79c606

33 files changed:
apps/app_mixmonitor.c
apps/app_statsd.c
bridges/bridge_builtin_features.c
res/ari/resource_bridges.c
res/ari/resource_channels.c
res/ari/resource_device_states.c
res/ari/resource_events.c
res/ari/resource_mailboxes.c
res/ari/resource_playbacks.c
res/ari/resource_recordings.c
res/res_ari_bridges.c
res/res_ari_channels.c
res/res_ari_device_states.c
res/res_ari_events.c
res/res_ari_mailboxes.c
res/res_ari_playbacks.c
res/res_ari_recordings.c
res/res_monitor.c
res/res_pjsip.c
res/res_pjsip/config_transport.c
res/res_pjsip_outbound_registration.c
res/res_statsd.c
rest-api-templates/res_ari_resource.c.mustache
rest-api-templates/swagger_model.py
rest-api/api-docs/bridges.json
rest-api/api-docs/channels.json
rest-api/api-docs/deviceStates.json
rest-api/api-docs/events.json
rest-api/api-docs/mailboxes.json
rest-api/api-docs/playbacks.json
rest-api/api-docs/recordings.json
tests/test_utils.c
tests/test_websocket_client.c

index bb47cfc..af29492 100644 (file)
@@ -1556,4 +1556,9 @@ static int load_module(void)
        return res;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Mixed Audio Monitoring Application");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Mixed Audio Monitoring Application",
+       .support_level = AST_MODULE_SUPPORT_CORE,
+       .load = load_module,
+       .unload = unload_module,
+       .optional_modules = "func_periodic_hook",
+);
index 54f9511..a4ca233 100644 (file)
@@ -420,4 +420,9 @@ static int load_module(void)
        return ast_register_application_xml(app, statsd_exec);
 }
 
-AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "StatsD Dialplan Application");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "StatsD Dialplan Application",
+       .support_level = AST_MODULE_SUPPORT_EXTENDED,
+       .load = load_module,
+       .unload = unload_module,
+       .requires = "res_statsd",
+);
index e6cacbf..e9efb91 100644 (file)
@@ -519,4 +519,9 @@ static int load_module(void)
        return AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Built in bridging features");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Built in bridging features",
+       .support_level = AST_MODULE_SUPPORT_CORE,
+       .load = load_module,
+       .unload = unload_module,
+       .optional_modules = "res_monitor",
+);
index a320c29..9808288 100644 (file)
@@ -24,8 +24,6 @@
  */
 
 /*** MODULEINFO
-       <depend type="module">res_stasis_recording</depend>
-       <depend type="module">res_stasis_playback</depend>
        <support_level>core</support_level>
  ***/
 
index 6b4f26c..cdf0f88 100644 (file)
  */
 
 /*** MODULEINFO
-       <depend type="module">res_stasis_answer</depend>
-       <depend type="module">res_stasis_playback</depend>
-       <depend type="module">res_stasis_recording</depend>
-       <depend type="module">res_stasis_snoop</depend>
        <support_level>core</support_level>
  ***/
 
index 020d930..c442fa5 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 /*** MODULEINFO
-       <depend type="module">res_stasis_device_state</depend>
        <support_level>core</support_level>
  ***/
 
index d81067f..5a8e898 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 /*** MODULEINFO
-       <depend type="module">res_http_websocket</depend>
        <support_level>core</support_level>
  ***/
 
index 3577e65..ae0f249 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 /*** MODULEINFO
-       <depend type="module">res_stasis_mailbox</depend>
        <support_level>core</support_level>
  ***/
 
index 57f424c..fc05a8d 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 /*** MODULEINFO
-       <depend type="module">res_stasis_playback</depend>
        <support_level>core</support_level>
  ***/
 
index 39ef65c..090f263 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 /*** MODULEINFO
-       <depend type="module">res_stasis_recording</depend>
        <support_level>core</support_level>
  ***/
 
index 34b9d89..93cf7c4 100644 (file)
@@ -35,6 +35,8 @@
        <depend type="module">res_ari</depend>
        <depend type="module">res_ari_model</depend>
        <depend type="module">res_stasis</depend>
+       <depend type="module">res_stasis_recording</depend>
+       <depend type="module">res_stasis_playback</depend>
        <support_level>core</support_level>
  ***/
 
@@ -1579,5 +1581,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Bri
        .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
-       .requires = "res_ari,res_ari_model,res_stasis",
+       .requires = "res_ari,res_ari_model,res_stasis,res_stasis_recording,res_stasis_playback",
 );
index 7862c10..7ca7e2e 100644 (file)
        <depend type="module">res_ari</depend>
        <depend type="module">res_ari_model</depend>
        <depend type="module">res_stasis</depend>
+       <depend type="module">res_stasis_answer</depend>
+       <depend type="module">res_stasis_playback</depend>
+       <depend type="module">res_stasis_recording</depend>
+       <depend type="module">res_stasis_snoop</depend>
        <support_level>core</support_level>
  ***/
 
@@ -2869,5 +2873,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Cha
        .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
-       .requires = "res_ari,res_ari_model,res_stasis",
+       .requires = "res_ari,res_ari_model,res_stasis,res_stasis_answer,res_stasis_playback,res_stasis_recording,res_stasis_snoop",
 );
index ec8890b..04479e6 100644 (file)
@@ -35,6 +35,7 @@
        <depend type="module">res_ari</depend>
        <depend type="module">res_ari_model</depend>
        <depend type="module">res_stasis</depend>
+       <depend type="module">res_stasis_device_state</depend>
        <support_level>core</support_level>
  ***/
 
@@ -349,5 +350,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Dev
        .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
-       .requires = "res_ari,res_ari_model,res_stasis",
+       .requires = "res_ari,res_ari_model,res_stasis,res_stasis_device_state",
 );
index f750a54..06eb77a 100644 (file)
@@ -35,6 +35,7 @@
        <depend type="module">res_ari</depend>
        <depend type="module">res_ari_model</depend>
        <depend type="module">res_stasis</depend>
+       <depend type="module">res_http_websocket</depend>
        <support_level>core</support_level>
  ***/
 
@@ -473,5 +474,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Web
        .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
-       .requires = "res_ari,res_ari_model,res_stasis",
+       .requires = "res_ari,res_ari_model,res_stasis,res_http_websocket",
 );
index 6469f93..123664e 100644 (file)
@@ -35,6 +35,7 @@
        <depend type="module">res_ari</depend>
        <depend type="module">res_ari_model</depend>
        <depend type="module">res_stasis</depend>
+       <depend type="module">res_stasis_mailbox</depend>
        <support_level>core</support_level>
  ***/
 
@@ -355,5 +356,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Mai
        .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
-       .requires = "res_ari,res_ari_model,res_stasis",
+       .requires = "res_ari,res_ari_model,res_stasis,res_stasis_mailbox",
 );
index 0148a74..547b39e 100644 (file)
@@ -35,6 +35,7 @@
        <depend type="module">res_ari</depend>
        <depend type="module">res_ari_model</depend>
        <depend type="module">res_stasis</depend>
+       <depend type="module">res_stasis_playback</depend>
        <support_level>core</support_level>
  ***/
 
@@ -307,5 +308,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Pla
        .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
-       .requires = "res_ari,res_ari_model,res_stasis",
+       .requires = "res_ari,res_ari_model,res_stasis,res_stasis_playback",
 );
index 531ff65..45c789c 100644 (file)
@@ -35,6 +35,7 @@
        <depend type="module">res_ari</depend>
        <depend type="module">res_ari_model</depend>
        <depend type="module">res_stasis</depend>
+       <depend type="module">res_stasis_recording</depend>
        <support_level>core</support_level>
  ***/
 
@@ -891,5 +892,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Rec
        .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
-       .requires = "res_ari,res_ari_model,res_stasis",
+       .requires = "res_ari,res_ari_model,res_stasis,res_stasis_recording",
 );
index 9dcbdbe..e2b5fb2 100644 (file)
@@ -1013,4 +1013,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_
        .load = load_module,
        .unload = unload_module,
        .load_pri = AST_MODPRI_CHANNEL_DEPEND,
+       .optional_modules = "func_periodic_hook",
 );
index ff262c9..6a6ba0f 100644 (file)
@@ -5139,4 +5139,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_
        .reload = reload_module,
        .load_pri = AST_MODPRI_CHANNEL_DEPEND - 5,
        .requires = "res_pjproject",
+       .optional_modules = "res_statsd",
 );
index 63bf118..713ab02 100644 (file)
@@ -30,6 +30,7 @@
 #include "asterisk/acl.h"
 #include "asterisk/utils.h"
 #include "include/res_pjsip_private.h"
+/* We're only using a #define from http_websocket.h, no OPTIONAL_API symbols are used. */
 #include "asterisk/http_websocket.h"
 
 #define MAX_POINTER_STRING 33
index 79bea48..80b885f 100644 (file)
@@ -2290,4 +2290,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Outbound Regist
        .unload = unload_module,
        .load_pri = AST_MODPRI_APP_DEPEND,
        .requires = "res_pjsip",
+       .optional_modules = "res_statsd",
 );
index 221b359..8565e41 100644 (file)
@@ -381,13 +381,13 @@ static int reload_module(void)
        }
 }
 
-/* The priority of this module is set to be as low as possible, since it could
- * be used by any other sort of module.
+/* The priority of this module is set just after realtime, since it loads
+ * configuration and could be used by any other sort of module.
  */
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Statsd client support",
        .support_level = AST_MODULE_SUPPORT_EXTENDED,
        .load = load_module,
        .unload = unload_module,
        .reload = reload_module,
-       .load_pri = 0,
+       .load_pri = AST_MODPRI_REALTIME_DRIVER + 5,
 );
index c1f680f..c697345 100644 (file)
@@ -40,6 +40,9 @@
        <depend type="module">res_ari</depend>
        <depend type="module">res_ari_model</depend>
        <depend type="module">res_stasis</depend>
+{{#requires_modules}}
+       <depend type="module">{{.}}</depend>
+{{/requires_modules}}
        <support_level>core</support_level>
  ***/
 
@@ -324,6 +327,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - {{{
        .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
-       .requires = "res_ari,res_ari_model,res_stasis",
+       .requires = "res_ari,res_ari_model,res_stasis{{#requires_modules}},{{.}}{{/requires_modules}}",
 );
 {{/api_declaration}}
index 0885241..3f729d8 100644 (file)
@@ -647,6 +647,7 @@ class ApiDeclaration(Stringify):
         self.api_version = api_decl_json.get('apiVersion')
         self.base_path = api_decl_json.get('basePath')
         self.resource_path = api_decl_json.get('resourcePath')
+        self.requires_modules = api_decl_json.get('requiresModules') or []
         api_json = api_decl_json.get('apis') or []
         self.apis = [
             Api().load(j, processor, context) for j in api_json]
index cf8ee31..04416c1 100644 (file)
@@ -6,6 +6,10 @@
        "swaggerVersion": "1.1",
        "basePath": "http://localhost:8088/ari",
        "resourcePath": "/api-docs/bridges.{format}",
+       "requiresModules": [
+               "res_stasis_recording",
+               "res_stasis_playback"
+       ],
        "apis": [
                {
                        "path": "/bridges",
index 602606c..ec8bae2 100644 (file)
@@ -6,6 +6,12 @@
        "swaggerVersion": "1.1",
        "basePath": "http://localhost:8088/ari",
        "resourcePath": "/api-docs/channels.{format}",
+       "requiresModules": [
+               "res_stasis_answer",
+               "res_stasis_playback",
+               "res_stasis_recording",
+               "res_stasis_snoop"
+       ],
        "apis": [
                {
                        "path": "/channels",
index 94d5b93..bd38935 100644 (file)
@@ -6,6 +6,9 @@
        "swaggerVersion": "1.1",
        "basePath": "http://localhost:8088/ari",
        "resourcePath": "/api-docs/deviceStates.{format}",
+       "requiresModules": [
+               "res_stasis_device_state"
+       ],
        "apis": [
                {
                        "path": "/deviceStates",
index e1b31bb..d85d8d9 100644 (file)
@@ -6,6 +6,9 @@
        "swaggerVersion": "1.2",
        "basePath": "http://localhost:8088/ari",
        "resourcePath": "/api-docs/events.{format}",
+       "requiresModules": [
+               "res_http_websocket"
+       ],
        "apis": [
                {
                        "path": "/events",
index ed50019..8f5941b 100644 (file)
@@ -6,6 +6,9 @@
        "swaggerVersion": "1.1",
        "basePath": "http://localhost:8088/ari",
        "resourcePath": "/api-docs/mailboxes.{format}",
+       "requiresModules": [
+               "res_stasis_mailbox"
+       ],
        "apis": [
                {
                        "path": "/mailboxes",
index 3dc4e1d..a78dcae 100644 (file)
@@ -6,6 +6,9 @@
        "swaggerVersion": "1.1",
        "basePath": "http://localhost:8088/ari",
        "resourcePath": "/api-docs/playbacks.{format}",
+       "requiresModules": [
+               "res_stasis_playback"
+       ],
        "apis": [
                {
                        "path": "/playbacks/{playbackId}",
index d0b9630..6ffd6d8 100644 (file)
@@ -6,6 +6,9 @@
        "swaggerVersion": "1.1",
        "basePath": "http://localhost:8088/ari",
        "resourcePath": "/api-docs/recordings.{format}",
+       "requiresModules": [
+               "res_stasis_recording"
+       ],
        "apis": [
                {
                        "path": "/recordings/stored",
index 68a2857..bcb2df3 100644 (file)
@@ -646,4 +646,9 @@ static int load_module(void)
        return AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Utils test module");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Utils test module",
+       .support_level = AST_MODULE_SUPPORT_CORE,
+       .load = load_module,
+       .unload = unload_module,
+       .requires = "res_agi,res_crypto",
+);
index 6743b53..e33f3f9 100644 (file)
@@ -156,4 +156,9 @@ static int unload_module(void)
        return 0;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Websocket client test module");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Websocket client test module",
+       .support_level = AST_MODULE_SUPPORT_CORE,
+       .load = load_module,
+       .unload = unload_module,
+       .requires = "res_http_websocket",
+);