[sr-dev] git:master:1121ee05: core: added rpc command core.modules

Daniel-Constantin Mierla miconda at gmail.com
Fri Aug 18 07:25:05 CEST 2017


Module: kamailio
Branch: master
Commit: 1121ee05e982625e31045416473b00be1caf481c
URL: https://github.com/kamailio/kamailio/commit/1121ee05e982625e31045416473b00be1caf481c

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-08-18T07:24:20+02:00

core: added rpc command core.modules

- list the names of loaded modules

---

Modified: src/core/core_cmd.c
Modified: src/core/sr_module.c
Modified: src/core/sr_module.h

---

Diff:  https://github.com/kamailio/kamailio/commit/1121ee05e982625e31045416473b00be1caf481c.diff
Patch: https://github.com/kamailio/kamailio/commit/1121ee05e982625e31045416473b00be1caf481c.patch

---

diff --git a/src/core/core_cmd.c b/src/core/core_cmd.c
index ed8d71749e..a489a8975d 100644
--- a/src/core/core_cmd.c
+++ b/src/core/core_cmd.c
@@ -959,6 +959,26 @@ static void core_sockets_list(rpc_t* rpc, void* c)
 /**
  *
  */
+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;
+	}
+}
+
+/**
+ *
+ */
 static const char* core_ppdefines_doc[] = {
 	"List preprocessor defines",    /* Documentation string */
 	0                               /* Method signature(s) */
@@ -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	},
diff --git a/src/core/sr_module.c b/src/core/sr_module.c
index fe545378eb..489ae55593 100644
--- a/src/core/sr_module.c
+++ b/src/core/sr_module.c
@@ -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
diff --git a/src/core/sr_module.h b/src/core/sr_module.h
index e2bef74950..4dd6523f3b 100644
--- a/src/core/sr_module.h
+++ b/src/core/sr_module.h
@@ -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*/
@@ -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)




More information about the sr-dev mailing list