Browse code

dispatcher: removed mi commands

- rpc commands have to be used instead

Daniel-Constantin Mierla authored on 23/12/2016 18:07:01
Showing 3 changed files
... ...
@@ -14,6 +14,5 @@ LIBS=
14 14
 DEFS+=-DKAMAILIO_MOD_INTERFACE
15 15
 
16 16
 SERLIBPATH=../../lib
17
-SER_LIBS+=$(SERLIBPATH)/kmi/kmi
18 17
 SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
19 18
 include ../../Makefile.modules
... ...
@@ -41,7 +41,6 @@
41 41
 #include <sys/types.h>
42 42
 #include <unistd.h>
43 43
 
44
-#include "../../lib/kmi/mi.h"
45 44
 #include "../../core/sr_module.h"
46 45
 #include "../../core/dprint.h"
47 46
 #include "../../core/error.h"
... ...
@@ -170,11 +169,6 @@ static void destroy(void);
170 170
 
171 171
 static int ds_warn_fixup(void** param, int param_no);
172 172
 
173
-static struct mi_root* ds_mi_set(struct mi_root* cmd, void* param);
174
-static struct mi_root* ds_mi_list(struct mi_root* cmd, void* param);
175
-static struct mi_root* ds_mi_reload(struct mi_root* cmd_tree, void* param);
176
-static int mi_child_init(void);
177
-
178 173
 static cmd_export_t cmds[]={
179 174
 	{"ds_select",    (cmd_function)w_ds_select,            2,
180 175
 		fixup_igp_igp, 0, ANY_ROUTE},
... ...
@@ -257,14 +251,6 @@ static param_export_t params[]={
257 257
 };
258 258
 
259 259
 
260
-static mi_export_t mi_cmds[] = {
261
-	{ "ds_set_state",   ds_mi_set,     0,                 0,  0            },
262
-	{ "ds_list",        ds_mi_list,    MI_NO_INPUT_FLAG,  0,  0            },
263
-	{ "ds_reload",      ds_mi_reload,  0,                 0,  mi_child_init},
264
-	{ 0, 0, 0, 0, 0}
265
-};
266
-
267
-
268 260
 /** module exports */
269 261
 struct module_exports exports= {
270 262
 	"dispatcher",
... ...
@@ -272,7 +258,7 @@ struct module_exports exports= {
272 272
 	cmds,
273 273
 	params,
274 274
 	0,          /* exported statistics */
275
-	mi_cmds,    /* exported MI functions */
275
+	0,          /* exported MI functions */
276 276
 	0,          /* exported pseudo-variables */
277 277
 	0,          /* extra processes */
278 278
 	mod_init,   /* module initialization function */
... ...
@@ -290,11 +276,6 @@ static int mod_init(void)
290 290
 	str host;
291 291
 	int port, proto;
292 292
 
293
-	if(register_mi_mod(exports.name, mi_cmds)!=0)
294
-	{
295
-		LM_ERR("failed to register MI commands\n");
296
-		return -1;
297
-	}
298 293
 	if(ds_ping_active_init()<0) {
299 294
 		return -1;
300 295
 	}
... ...
@@ -576,15 +557,6 @@ static int child_init(int rank)
576 576
 	return 0;
577 577
 }
578 578
 
579
-static int mi_child_init(void)
580
-{
581
-
582
-	if(ds_db_url.s)
583
-		return ds_connect_db();
584
-	return 0;
585
-
586
-}
587
-
588 579
 /*! \brief
589 580
  * destroy function
590 581
  */
... ...
@@ -841,107 +813,6 @@ static int w_ds_reload(struct sip_msg* msg)
841 841
 	return 1;
842 842
 }
843 843
 
844
-/************************** MI STUFF ************************/
845
-
846
-static struct mi_root* ds_mi_set(struct mi_root* cmd_tree, void* param)
847
-{
848
-	str sp;
849
-	int ret;
850
-	unsigned int group;
851
-	int state;
852
-	struct mi_node* node;
853
-
854
-	node = cmd_tree->node.kids;
855
-	if(node == NULL)
856
-		return init_mi_tree(400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
857
-	sp = node->value;
858
-	if(sp.len<=0 || !sp.s)
859
-	{
860
-		LM_ERR("bad state value\n");
861
-		return init_mi_tree(500, "bad state value", 15);
862
-	}
863
-
864
-	state = ds_parse_flags(sp.s, sp.len);
865
-	if( state < 0 )
866
-	{
867
-		LM_ERR("unknown state value\n");
868
-		return init_mi_tree(500, "unknown state value", 19);
869
-	}
870
-	node = node->next;
871
-	if(node == NULL)
872
-		return init_mi_tree(400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
873
-	sp = node->value;
874
-	if(sp.s == NULL)
875
-	{
876
-		return init_mi_tree(500, "group not found", 15);
877
-	}
878
-
879
-	if(str2int(&sp, &group))
880
-	{
881
-		LM_ERR("bad group value\n");
882
-		return init_mi_tree( 500, "bad group value", 16);
883
-	}
884
-
885
-	node= node->next;
886
-	if(node == NULL)
887
-		return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
888
-
889
-	sp = node->value;
890
-	if(sp.s == NULL)
891
-	{
892
-		return init_mi_tree(500,"address not found", 18 );
893
-	}
894
-
895
-	ret = ds_reinit_state(group, &sp, state);
896
-
897
-	if(ret!=0)
898
-	{
899
-		return init_mi_tree(404, "destination not found", 21);
900
-	}
901
-
902
-	return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
903
-}
904
-
905
-
906
-
907
-
908
-static struct mi_root* ds_mi_list(struct mi_root* cmd_tree, void* param)
909
-{
910
-	struct mi_root* rpl_tree;
911
-
912
-	rpl_tree = init_mi_tree(200, MI_OK_S, MI_OK_LEN);
913
-	if (rpl_tree==NULL)
914
-		return 0;
915
-
916
-	if( ds_print_mi_list(&rpl_tree->node)< 0 )
917
-	{
918
-		LM_ERR("failed to add node\n");
919
-		free_mi_tree(rpl_tree);
920
-		return 0;
921
-	}
922
-
923
-	return rpl_tree;
924
-}
925
-
926
-#define MI_ERR_RELOAD 			"ERROR Reloading data"
927
-#define MI_ERR_RELOAD_LEN 		(sizeof(MI_ERR_RELOAD)-1)
928
-#define MI_NOT_SUPPORTED		"DB mode not configured"
929
-#define MI_NOT_SUPPORTED_LEN 	(sizeof(MI_NOT_SUPPORTED)-1)
930
-#define MI_ERR_DSLOAD			"No reload support for call load dispatching"
931
-#define MI_ERR_DSLOAD_LEN		(sizeof(MI_ERR_DSLOAD)-1)
932
-
933
-static struct mi_root* ds_mi_reload(struct mi_root* cmd_tree, void* param)
934
-{
935
-	if(!ds_db_url.s) {
936
-		if (ds_load_list(dslistfile)!=0)
937
-			return init_mi_tree(500, MI_ERR_RELOAD, MI_ERR_RELOAD_LEN);
938
-	} else {
939
-		if(ds_reload_db()<0)
940
-			return init_mi_tree(500, MI_ERR_RELOAD, MI_ERR_RELOAD_LEN);
941
-	}
942
-	return init_mi_tree(200, MI_OK_S, MI_OK_LEN);
943
-}
944
-
945 844
 
946 845
 static int w_ds_is_from_list0(struct sip_msg *msg, char *str1, char *str2)
947 846
 {
... ...
@@ -1368,92 +1368,6 @@ onreply_route {
1368 1368
 	</section>
1369 1369
 
1370 1370
 	<section>
1371
-	<title>MI Commands</title>
1372
-	<section id="dispatcher.mi.ds_set_state">
1373
-		<title>
1374
-		<function moreinfo="none">ds_set_state</function>
1375
-		</title>
1376
-		<para>
1377
-        Sets the status for a destination address (can be use to mark the destination
1378
-		as active or inactive).
1379
-		</para>
1380
-		<para>
1381
-		Name: <emphasis>ds_set_state</emphasis>
1382
-		</para>
1383
-		<para>Parameters:</para>
1384
-		<itemizedlist>
1385
-			<listitem><para>_state_ : state of the destination address</para>
1386
-			      <itemizedlist>
1387
-	                 <listitem><para> <quote>a</quote>: active</para></listitem> 
1388
-			         <listitem><para> <quote>i</quote>: inactive</para></listitem>
1389
-			         <listitem><para> <quote>t</quote>: trying</para></listitem>
1390
-			         <listitem><para> <quote>d</quote>: disabled</para></listitem>
1391
-				  </itemizedlist>
1392
-				  <para>The states <quote>a</quote>, <quote>i</quote> or
1393
-					  <quote>t</quote> can be followed by <quote>p</quote>
1394
-					  to set probing mode (e.g. 'ap', 'ip' or 'tp').</para>
1395
-			</listitem>
1396
-
1397
-			<listitem><para>_group_: destination group id</para></listitem>
1398
-
1399
-			<listitem><para>_address_: address of the destination in the _group_</para></listitem>
1400
-		</itemizedlist>
1401
-		<para>
1402
-		MI FIFO Command Format:
1403
-		</para>
1404
-        <programlisting  format="linespecific">
1405
-		:ds_set_state:_reply_fifo_file_
1406
-		_state_
1407
-		_group_
1408
-		_address_
1409
-		_empty_line_
1410
-		</programlisting>
1411
-    </section>
1412
-	<section id="dispatcher.mi.ds_list">
1413
-		<title>
1414
-		<function moreinfo="none">ds_list</function>
1415
-		</title>
1416
-		<para>
1417
-		It lists the groups and included destinations.
1418
-		</para>
1419
-		<para>
1420
-		Name: <emphasis>ds_list</emphasis>
1421
-		</para>
1422
-		<para>Parameters: <emphasis>none</emphasis></para>
1423
- 		<para>
1424
-		MI FIFO Command Format:
1425
-		</para>
1426
-        <programlisting  format="linespecific">
1427
-		:ds_list:_reply_fifo_file_
1428
-		_empty_line_
1429
-		</programlisting>
1430
-    </section>
1431
-	<section id="dispatcher.mi.ds_reload">
1432
-		<title>
1433
-		<function moreinfo="none">ds_reload</function>
1434
-		</title>
1435
-		<para>
1436
-		It reloads the groups and included destinations. For algorithm 10
1437
-		(call load distribution), old internal list of active calls is
1438
-		destroyed (because it is bould to the previous list of gateways),
1439
-		meaning that the module is starting to count active calls again
1440
-		from 0.
1441
-		</para>
1442
-		<para>
1443
-		Name: <emphasis>ds_reload</emphasis>
1444
-		</para>
1445
-		<para>Parameters: <emphasis>none</emphasis></para>
1446
- 		<para>
1447
-		MI DATAGRAM Command Format:
1448
-		</para>
1449
-        <programlisting  format="linespecific">
1450
-		":ds_reload:\n."
1451
-		</programlisting>
1452
-    </section>
1453
-
1454
-    </section>
1455
-
1456
-	<section>
1457 1371
 	<title>RPC Commands</title>
1458 1372
 	<section id="dispatcher.rpc.set_state">
1459 1373
 		<title>