Browse code

- Module interface extended, each module can specify list of management functions in a common fashion - added rpc lookup function

Jan Janak authored on 13/12/2005 00:02:03
Showing 2 changed files
... ...
@@ -40,6 +40,7 @@
40 40
 #include "dprint.h"
41 41
 #include "error.h"
42 42
 #include "mem/mem.h"
43
+#include "core_cmd.h"
43 44
 #include "ut.h"
44 45
 
45 46
 #include <regex.h>
... ...
@@ -272,6 +273,34 @@ cmd_function find_export(char* name, int param_no, int flags)
272 272
 }
273 273
 
274 274
 
275
+rpc_export_t* find_rpc_export(char* name, int flags)
276
+{
277
+	struct sr_module* t;
278
+	rpc_export_t* rpc;
279
+
280
+	     /* Scan the list of core methods first, they are always
281
+	      * present
282
+	      */
283
+	for(rpc = core_rpc_methods; rpc && rpc->name; rpc++) {
284
+		if ((strcmp(name, rpc->name) == 0) &&
285
+		    ((rpc->flags & flags) == flags)
286
+		    ) {
287
+			return rpc;
288
+		}
289
+	}
290
+	     /* Continue with modules if not found */
291
+	for(t = modules; t; t = t->next) {
292
+		for(rpc = t->exports->rpc_methods; rpc && rpc->name; rpc++) {
293
+			if ((strcmp(name, rpc->name) == 0) &&
294
+			    ((rpc->flags & flags) == flags)
295
+			   ) {
296
+				return rpc;
297
+			}
298
+		}
299
+	}
300
+	return 0;
301
+}
302
+
275 303
 
276 304
 /*
277 305
  * searches the module list and returns pointer to "name" function in module "mod"
... ...
@@ -46,6 +46,7 @@
46 46
 
47 47
 #include "parser/msg_parser.h" /* for sip_msg */
48 48
 #include "version.h"
49
+#include "rpc.h"
49 50
 
50 51
 typedef  struct module_exports* (*module_register)();
51 52
 typedef  int (*cmd_function)(struct sip_msg*, char*, char*);
... ...
@@ -77,7 +78,7 @@ typedef int (*param_func_t)( modparam_t type, void* val);
77 77
 #define PROC_TIMER    -1  /* Timer attendant process */
78 78
 #define PROC_FIFO     -2  /* FIFO attendant process */
79 79
 #define PROC_TCP_MAIN -4  /* TCP main process */
80
-#define PROC_UNIXSOCK -5  /* Unix domain socket server processes */
80
+#define PROC_UNIXSOCK -5  /* Unix socket server */
81 81
 
82 82
 #define MODULE_VERSION \
83 83
 	char *module_version=SER_FULL_VERSION; \
... ...
@@ -108,6 +109,7 @@ struct module_exports{
108 108
 	
109 109
 	cmd_export_t* cmds;             /* null terminated array of the exported
110 110
 									   commands */
111
+	rpc_export_t* rpc_methods;      /* null terminated array of exported rpc methods */
111 112
 	param_export_t* params;         /* null terminated array of the exported
112 113
 									   module parameters */
113 114
 
... ...
@@ -141,6 +143,7 @@ int register_module(struct module_exports*, char*,  void*);
141 141
 int load_module(char* path);
142 142
 cmd_function find_export(char* name, int param_no, int flags);
143 143
 cmd_function find_mod_export(char* mod, char* name, int param_no, int flags);
144
+rpc_export_t* find_rpc_export(char* name, int flags);
144 145
 struct sr_module* find_module(void *f, cmd_export_t** cmd);
145 146
 void destroy_modules();
146 147
 int init_child(int rank);