Skip to content

Commit

Permalink
core: added rpc command core.modules
Browse files Browse the repository at this point in the history
- list the names of loaded modules
  • Loading branch information
miconda committed Aug 18, 2017
1 parent 4072b0f commit 1121ee0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
23 changes: 22 additions & 1 deletion src/core/core_cmd.c
Expand Up @@ -956,6 +956,26 @@ static void core_sockets_list(rpc_t* rpc, void* c)
} while((proto=next_proto(proto)));
}

/**
*
*/
static const char* core_modules_doc[] = {
"List loaded modules", /* Documentation string */
0 /* Method signature(s) */
};

/**
* list listen sockets for SIP server
*/
static void core_modules(rpc_t* rpc, void* c)
{
sr_module_t* t;

for(t = get_loaded_modules(); t; t = t->next) {
if (rpc->add(c, "s", t->exports.name) < 0) return;
}
}

/**
*
*/
Expand Down Expand Up @@ -1014,7 +1034,8 @@ static rpc_export_t core_rpc_methods[] = {
0},
{"core.aliases_list", core_aliases_list, core_aliases_list_doc, 0},
{"core.sockets_list", core_sockets_list, core_sockets_list_doc, 0},
{"core.ppdefines", core_ppdefines, core_ppdefines_doc, RET_ARRAY},
{"core.modules", core_modules, core_modules_doc, RET_ARRAY},
{"core.ppdefines", core_ppdefines, core_ppdefines_doc, RET_ARRAY},
#ifdef USE_DNS_CACHE
{"dns.mem_info", dns_cache_mem_info, dns_cache_mem_info_doc,
0 },
Expand Down
3 changes: 3 additions & 0 deletions src/core/sr_module.c
Expand Up @@ -781,6 +781,9 @@ struct sr_module* find_module_by_name(char* mod) {
return 0;
}

sr_module_t* get_loaded_modules(void) {
return modules;
}

/*!
* \brief Find a parameter with given type
Expand Down
5 changes: 3 additions & 2 deletions src/core/sr_module.h
Expand Up @@ -435,13 +435,13 @@ union module_exports_u {
};


struct sr_module {
typedef struct sr_module {
char* path;
void* handle;
unsigned int orig_mod_interface_ver;
struct sr31_module_exports exports;
struct sr_module* next;
};
} sr_module_t;


extern struct sr_module* modules; /**< global module list*/
Expand All @@ -459,6 +459,7 @@ void destroy_modules(void);
int init_child(int rank);
int init_modules(void);
struct sr_module* find_module_by_name(char* mod);
sr_module_t* get_loaded_modules(void);

/**< true if the module with name 'mod_name' is loaded */
#define module_loaded(mod_name) (find_module_by_name(mod_name)!=0)
Expand Down

0 comments on commit 1121ee0

Please sign in to comment.