diff --git a/src/modules/kex/Makefile b/src/modules/kex/Makefile index 8312ed5520e..7e376304fcc 100644 --- a/src/modules/kex/Makefile +++ b/src/modules/kex/Makefile @@ -12,6 +12,5 @@ LIBS= DEFS+=-DKAMAILIO_MOD_INTERFACE SERLIBPATH=../../lib -SER_LIBS+=$(SERLIBPATH)/kmi/kmi SER_LIBS+=$(SERLIBPATH)/srutils/srutils include ../../Makefile.modules diff --git a/src/modules/kex/core_stats.c b/src/modules/kex/core_stats.c index 811423f186b..89fcc5a96cd 100644 --- a/src/modules/kex/core_stats.c +++ b/src/modules/kex/core_stats.c @@ -29,7 +29,6 @@ #include #include "../../core/counters.h" -#include "../../lib/kmi/mi.h" #include "../../core/events.h" #include "../../core/dprint.h" #include "../../core/timer.h" @@ -142,30 +141,9 @@ stat_export_t shm_stats[] = { {0,0,0} }; -static struct mi_root *mi_get_stats(struct mi_root *cmd, void *param); -static struct mi_root *mi_reset_stats(struct mi_root *cmd, void *param); -static struct mi_root *mi_clear_stats(struct mi_root *cmd, void *param); - -static mi_export_t mi_stat_cmds[] = { - { "get_statistics", mi_get_stats, 0 , 0, 0 }, - { "reset_statistics", mi_reset_stats, 0 , 0, 0 }, - { "clear_statistics", mi_clear_stats, 0 , 0, 0 }, - { 0, 0, 0, 0, 0} -}; - int stats_proc_stats_init_rpc(void); -int register_mi_stats(void) -{ - /* register MI commands */ - if (register_mi_mod("core", mi_stat_cmds)<0) { - LM_ERR("unable to register MI cmds\n"); - return -1; - } - return 0; -} - static int km_cb_req_stats(struct sip_msg *msg, unsigned int flags, void *param) { @@ -628,304 +606,53 @@ int stats_proc_stats_init_rpc(void) return 0; } -/***************************** MI STUFF ********************************/ - -inline static int mi_add_stat(struct mi_node *rpl, stat_var *stat) -{ - struct mi_node *node; - - if (stats_support()==0) return -1; - - node = addf_mi_node_child(rpl, 0, 0, 0, "%s:%s = %lu", - ZSW(get_stat_module(stat)), - ZSW(get_stat_name(stat)), - get_stat_val(stat) ); - - if (node==0) - return -1; - return 0; -} - - - -/* callback for counter_iterate_grp_vars. */ -static void mi_add_grp_vars_cbk(void* r, str* g, str* n, counter_handle_t h) -{ - struct mi_node *rpl; - - rpl = r; - addf_mi_node_child(rpl, 0, 0, 0, "%.*s:%.*s = %lu", - g->len, g->s, n->len, n->s, counter_get_val(h)); -} - - -/* callback for counter_iterate_grp_names */ -static void mi_add_all_grps_cbk(void* p, str* g) -{ - counter_iterate_grp_vars(g->s, mi_add_grp_vars_cbk, p); -} - -static struct mi_root *mi_get_stats(struct mi_root *cmd, void *param) -{ - struct mi_root *rpl_tree; - struct mi_node *rpl; - struct mi_node *arg; - stat_var *stat; - str val; - - - if(stats_support()==0) - return init_mi_tree( 404, "Statistics Not Found", 20); - - if (cmd->node.kids==NULL) - return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); - - rpl_tree = init_mi_tree( 200, MI_OK_S, MI_OK_LEN); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - for( arg=cmd->node.kids ; arg ; arg=arg->next) { - if (arg->value.len==0) - continue; - - val = arg->value; - - if ( val.len==3 && memcmp(val.s,"all",3)==0) { - /* add all statistic variables */ - /* use direct counters access for that */ - counter_iterate_grp_names(mi_add_all_grps_cbk, rpl); - } else if ( val.len>1 && val.s[val.len-1]==':') { - /* add module statistics */ - val.len--; - val.s[val.len]=0; /* zero term. */ - /* use direct counters access for that */ - counter_iterate_grp_vars(val.s, mi_add_grp_vars_cbk, rpl); - val.s[val.len]=':' /* restore */; - } else { - /* add only one statistic */ - stat = get_stat( &val ); - if (stat==0) - continue; - if (mi_add_stat(rpl,stat)!=0) - goto error; - } - } - - if (rpl->kids==0) { - free_mi_tree(rpl_tree); - return init_mi_tree( 404, "Statistics Not Found", 20); - } - - return rpl_tree; -error: - free_mi_tree(rpl_tree); - return 0; -} - - - -static struct mi_root *mi_reset_stats(struct mi_root *cmd, void *param) -{ - struct mi_root *rpl_tree; - struct mi_node *arg; - stat_var *stat; - int found; - - if (cmd->node.kids==NULL) - return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); - - rpl_tree = init_mi_tree( 200, MI_OK_S, MI_OK_LEN); - if (rpl_tree==0) - return 0; - found = 0; - - for( arg=cmd->node.kids ; arg ; arg=arg->next) { - if (arg->value.len==0) - continue; - - stat = get_stat( &arg->value ); - if (stat==0) - continue; - - reset_stat( stat ); - found = 1; - } - - if (!found) { - free_mi_tree(rpl_tree); - return init_mi_tree( 404, "Statistics Not Found", 20); - } - - return rpl_tree; -} - - -inline static int mi_reset_and_add_stat(struct mi_node *rpl, stat_var *stat) -{ - struct mi_node *node; - long old_val, new_val; - - if (stats_support()==0) return -1; - - old_val=get_stat_val(stat); - reset_stat(stat); - new_val=get_stat_val(stat); - - if (old_val==new_val) - { - node = addf_mi_node_child(rpl, 0, 0, 0, "%s:%s = %lu", - ZSW(get_stat_module(stat)), - ZSW(get_stat_name(stat)), - new_val); - } else { - node = addf_mi_node_child(rpl, 0, 0, 0, "%s:%s = %lu (%lu)", - ZSW(get_stat_module(stat)), - ZSW(get_stat_name(stat)), - new_val, old_val ); - } - - if (node==0) - return -1; - return 0; -} - - -/* callback for counter_iterate_grp_vars to reset counters */ -static void mi_add_grp_vars_cbk2(void* r, str* g, str* n, counter_handle_t h) -{ - struct mi_node *rpl; - counter_val_t old_val, new_val; - - rpl = r; - old_val = counter_get_val(h); - counter_reset(h); - new_val = counter_get_val(h); - - if (old_val==new_val) - { - addf_mi_node_child(rpl, 0, 0, 0, "%.*s:%.*s = %lu", - g->len, g->s, n->len, n->s, new_val); - } else { - addf_mi_node_child(rpl, 0, 0, 0, "%.*s:%.*s = %lu (%lu)", - g->len, g->s, n->len, n->s, new_val, old_val); - } -} - - -/* callback for counter_iterate_grp_names to reset counters */ -static void mi_add_all_grps_cbk2(void* p, str* g) -{ - counter_iterate_grp_vars(g->s, mi_add_grp_vars_cbk2, p); -} - - -static struct mi_root *mi_clear_stats(struct mi_root *cmd, void *param) -{ - struct mi_root *rpl_tree; - struct mi_node *rpl; - struct mi_node *arg; - stat_var *stat; - str val; - - if(stats_support()==0) - return init_mi_tree( 404, "Statistics Not Found", 20); - - if (cmd->node.kids==NULL) - return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); - - rpl_tree = init_mi_tree( 200, MI_OK_S, MI_OK_LEN); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - for( arg=cmd->node.kids ; arg ; arg=arg->next) - { - if (arg->value.len==0) - continue; - - val = arg->value; - - if ( val.len==3 && memcmp(val.s,"all",3)==0) { - /* add all statistic variables */ - /* use direct counters access for that */ - counter_iterate_grp_names(mi_add_all_grps_cbk2, rpl); - } else if ( val.len>1 && val.s[val.len-1]==':') { - /* add module statistics */ - val.len--; - val.s[val.len]=0; /* zero term. */ - /* use direct counters access for that */ - counter_iterate_grp_vars(val.s, mi_add_grp_vars_cbk2, rpl); - val.s[val.len]=':' /* restore */; - } else { - /* reset & return only one statistic */ - stat = get_stat( &val ); - - if (stat==0) - continue; - if (mi_reset_and_add_stat(rpl,stat)!=0) - goto error; - } - } - - if (rpl->kids==0) { - free_mi_tree(rpl_tree); - return init_mi_tree( 404, "Statistics Not Found", 20); - } - - return rpl_tree; -error: - free_mi_tree(rpl_tree); - return 0; -} - /*** shm stats ***/ -static struct mem_info _stats_shm_mi; +static struct mem_info _stats_shm_rpc; static ticks_t _stats_shm_tm = 0; void stats_shm_update(void) { ticks_t t; t = get_ticks(); if(t!=_stats_shm_tm) { - shm_info(&_stats_shm_mi); + shm_info(&_stats_shm_rpc); _stats_shm_tm = t; } } unsigned long shm_stats_get_size(void) { stats_shm_update(); - return _stats_shm_mi.total_size; + return _stats_shm_rpc.total_size; } unsigned long shm_stats_get_used(void) { stats_shm_update(); - return _stats_shm_mi.used; + return _stats_shm_rpc.used; } unsigned long shm_stats_get_rused(void) { stats_shm_update(); - return _stats_shm_mi.real_used; + return _stats_shm_rpc.real_used; } unsigned long shm_stats_get_mused(void) { stats_shm_update(); - return _stats_shm_mi.max_used; + return _stats_shm_rpc.max_used; } unsigned long shm_stats_get_free(void) { stats_shm_update(); - return _stats_shm_mi.free; + return _stats_shm_rpc.free; } unsigned long shm_stats_get_frags(void) { stats_shm_update(); - return _stats_shm_mi.total_frags; + return _stats_shm_rpc.total_frags; } #endif diff --git a/src/modules/kex/core_stats.h b/src/modules/kex/core_stats.h index 2531ff856da..ae59e9463fb 100644 --- a/src/modules/kex/core_stats.h +++ b/src/modules/kex/core_stats.h @@ -97,7 +97,6 @@ extern stat_var* unsupported_methods; /*! \brief Set in get_hdr_field(). */ extern stat_var* bad_msg_hdr; -int register_mi_stats(void); int register_core_stats(void); #endif /*STATISTICS*/ diff --git a/src/modules/kex/doc/kex_admin.xml b/src/modules/kex/doc/kex_admin.xml index 11de6837631..9ceb2cc6082 100644 --- a/src/modules/kex/doc/kex_admin.xml +++ b/src/modules/kex/doc/kex_admin.xml @@ -435,84 +435,88 @@ resetdebug();
- MI Commands -
+ RPC Commands +
- <function moreinfo="none">arg</function> + <function moreinfo="none">core.arg</function> Print command line arguments. - Name: arg + Name: core.arg Parameters: none. - MI FIFO Command Format: + RPC Command Format: - - :arg:_reply_fifo_file_ - _empty_line_ + +... +&kamcmd; core.arg +...
-
+
- <function moreinfo="none">kill</function> + <function moreinfo="none">core.kill</function> Kill the application. - Name: kill + Name: core.kill Parameters: none. - MI FIFO Command Format: + RPC Command Format: - - :kill:_reply_fifo_file_ - _empty_line_ + +... +&kamcmd; core.kill +...
-
+
- <function moreinfo="none">pwd</function> + <function moreinfo="none">core.pwd</function> Print working directory. - Name: pwd + Name: core.pwd Parameters: none. - MI FIFO Command Format: + RPC Command Format: - - :pwd:_reply_fifo_file_ - _empty_line_ + +... +&kamcmd; core.pwd +...
-
+
- <function moreinfo="none">uptime</function> + <function moreinfo="none">core.uptime</function> Print uptime. - Name: uptime + Name: core.uptime Parameters: none. - MI FIFO Command Format: + RPC Command Format: - - :uptime:_reply_fifo_file_ - _empty_line_ + +... +&kamcmd; core.uptime +...
-
+
<function moreinfo="none">version</function> @@ -520,37 +524,39 @@ resetdebug(); Print version information. - Name: version + Name: core.version Parameters: none. - MI FIFO Command Format: + RPC Command Format: - - :version:_reply_fifo_file_ - _empty_line_ + +... +&kamcmd; core.version +...
-
+
- <function moreinfo="none">which</function> + <function moreinfo="none">system.listMethods</function> - Print list of available MI commands. + Print list of available RPC commands. Name: which Parameters: none. - MI FIFO Command Format: + RPC Command Format: - - :which:_reply_fifo_file_ - _empty_line_ + +... +&kamcmd; system.listMethods +...
-
+
<function moreinfo="none">get_statistics</function> @@ -558,7 +564,7 @@ resetdebug(); Print the list of available internal statistics. - Name: get_statistics + Name: stats.get_statistics Parameters: statsid - which statistics to be printed. If set to 'all' then all statistics are printed; if @@ -566,36 +572,36 @@ resetdebug(); if set to 'statsname' then the statistics identified by the name is printed. - MI FIFO Command Format: + RPC Command Format: - - :get_statistics:_reply_fifo_file_ - _statsid_ - _empty_line_ + +... +&kamcmd; stats.get_statistics +...
-
+
- <function moreinfo="none">reset_statistics</function> + <function moreinfo="none">stats.reset_statistics</function> Reset internal statistics. - Name: reset_statistics + Name: statsreset_statistics Parameters: statsid - which statistics to be reset, give as name. - MI FIFO Command Format: + RPC Command Format: - - :reset_statistics:_reply_fifo_file_ - _statsid_ - _empty_line_ + +... +&kamcmd; reset_statistics _statsid_ +...
-
+
<function moreinfo="none">clear_statistics</function> @@ -603,24 +609,20 @@ resetdebug(); Return statistics and reset their value in one command. - Name: get_statistics + Name: stats.get_statistics Parameters: statsid - same as for get_statistics. - MI FIFO Command Format: + RPC Command Format: - - :clear_statistics:_reply_fifo_file_ - _statsid_ - _empty_line_ + +... +&kamcmd; clear_statistics _statsid_ +...
-
- -
- RPC Commands
<function moreinfo="none">pkg.stats</function> @@ -778,7 +780,7 @@ Module: kex { // this is the pkg zone of the module // function_name(line_where_pkg_malloc_was_called): size_alloc'ed_by_pkg_malloc - init_mi_uptime(74): 56 + init_rpc_uptime(74): 56 Total: 56 } { diff --git a/src/modules/kex/kex_mod.c b/src/modules/kex/kex_mod.c index 02841379a64..9af58c6cfb5 100644 --- a/src/modules/kex/kex_mod.c +++ b/src/modules/kex/kex_mod.c @@ -37,7 +37,6 @@ #include "flags.h" #include "km_core.h" -#include "mi_core.h" #include "core_stats.h" #include "pkg_stats.h" #include "mod_stats.h" @@ -136,13 +135,9 @@ static int mod_init(void) { if(sruid_init(&_kex_sruid, '-', NULL, 0)<0) return -1; - if(init_mi_core()<0) - return -1; #ifdef STATISTICS if(register_core_stats()<0) return -1; - if(register_mi_stats()<0) - return -1; #endif register_pkg_proc_stats(); pkg_proc_stats_init_rpc(); diff --git a/src/modules/kex/mi_core.c b/src/modules/kex/mi_core.c deleted file mode 100644 index 602e9f2c874..00000000000 --- a/src/modules/kex/mi_core.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Copyright (C) 2006 Voice Sistem SRL - * - * This file is part of Kamailio, a free SIP server. - * - * Kamailio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Kamailio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - - -/*! - * \file - * \brief MI :: Core - * \ingroup mi - */ - - - -#include <time.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <sys/types.h> -#include <signal.h> - -#include "../../core/dprint.h" -#include "../../core/globals.h" -#include "../../core/ut.h" -#include "../../core/pt.h" -#include "../../core/mem/mem.h" -#include "../../lib/kmi/mi.h" -#include "../../core/ver.h" -#include "../../core/cfg/cfg.h" -#include "../../core/cfg/cfg_ctx.h" - -#ifdef VERSION_NODATE -#define BUILD_STR __FILE__ " compiled with " COMPILER "\n" -#else -#ifdef VERSION_DATE -#define BUILD_STR __FILE__ " compiled on " VERSION_DATE " with " COMPILER "\n" -#else -#define BUILD_STR __FILE__ " compiled on "__TIME__ " " __DATE__ " with " COMPILER "\n" -#endif -#endif -#define BUILD_STR_LEN (sizeof(BUILD_STR)-1) - -#ifndef SVNREVISION -#define SVNREVISION "unknown" -#endif - -static time_t kmi_up_since = 0; -static str kmi_up_since_ctime = {0, 0}; -static cfg_ctx_t *_kex_cfg_ctx = NULL; - -static int init_mi_uptime(void) -{ - char *p; - - if (kmi_up_since_ctime.s!=0) - return 0; - time(&kmi_up_since); - p = ctime(&kmi_up_since); - kmi_up_since_ctime.len = strlen(p)-1; - kmi_up_since_ctime.s = (char*)pkg_malloc(kmi_up_since_ctime.len); - if (kmi_up_since_ctime.s==0) { - LM_ERR("no more pkg mem\n"); - return -1; - } - memcpy(kmi_up_since_ctime.s, p, kmi_up_since_ctime.len); - return 0; -} - - -static struct mi_root *mi_uptime(struct mi_root *cmd, void *param) -{ - struct mi_root *rpl_tree; - struct mi_node *rpl; - struct mi_node *node; - time_t now; - char *p; - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - time(&now); - p = ctime(&now); - node = add_mi_node_child( rpl, MI_DUP_VALUE, MI_SSTR("Now"), - p, strlen(p)-1); - if (node==0) - goto error; - - node = add_mi_node_child( rpl, 0, MI_SSTR("Up since"), - kmi_up_since_ctime.s, kmi_up_since_ctime.len); - if (node==0) - goto error; - - node = addf_mi_node_child( rpl, 0, MI_SSTR("Up time"), - "%lu [sec]", (unsigned long)difftime(now, kmi_up_since) ); - if (node==0) - goto error; - - return rpl_tree; -error: - LM_ERR("failed to add node\n"); - free_mi_tree(rpl_tree); - return 0; -} - -static struct mi_root *mi_version(struct mi_root *cmd, void *param) -{ - struct mi_root *rpl_tree; - struct mi_node *rpl; - struct mi_node *node; - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - node = add_mi_node_child( rpl, 0, MI_SSTR("Server"), SERVER_HDR+8, - SERVER_HDR_LEN-8); - if (node==0) - goto error; - - node = add_mi_node_child( rpl, 0, MI_SSTR("Build"), BUILD_STR, - BUILD_STR_LEN); - if (node==0) - goto error; - - node = add_mi_node_child( rpl, 0, MI_SSTR("Flags"), (char*)ver_flags, - strlen(ver_flags)); - if (node==0) - goto error; - - node = add_mi_node_child( rpl, 0, MI_SSTR("GIT"), (char*)repo_hash, - strlen(repo_hash)); - if (node==0) - goto error; - - return rpl_tree; -error: - LM_ERR("failed to add node\n"); - free_mi_tree(rpl_tree); - return 0; - -} - - - -static struct mi_root *mi_pwd(struct mi_root *cmd, void *param) -{ - static int max_len = 0; - static char *cwd_buf = 0; - struct mi_root *rpl_tree; - struct mi_node *rpl; - struct mi_node *node; - - if (cwd_buf==NULL) { - max_len = pathmax(); - cwd_buf = pkg_malloc(max_len); - if (cwd_buf==NULL) { - LM_ERR("no more pkg mem\n"); - return 0; - } - } - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - if (getcwd(cwd_buf, max_len)==0) { - LM_ERR("getcwd failed = %s\n",strerror(errno)); - goto error; - } - - node = add_mi_node_child( rpl, 0, MI_SSTR("WD"), cwd_buf,strlen(cwd_buf)); - if (node==0) { - LM_ERR("failed to add node\n"); - goto error; - } - - return rpl_tree; -error: - free_mi_tree(rpl_tree); - return 0; -} - - - -static struct mi_root *mi_arg(struct mi_root *cmd, void *param) -{ - struct mi_root *rpl_tree; - struct mi_node *rpl; - struct mi_node *node; - int n; - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - for ( n=0; n<my_argc ; n++ ) { - node = add_mi_node_child(rpl, 0, 0, 0, my_argv[n], strlen(my_argv[n])); - if (node==0) { - LM_ERR("failed to add node\n"); - free_mi_tree(rpl_tree); - return 0; - } - } - - return rpl_tree; -} - - - -static struct mi_root *mi_which(struct mi_root *cmd, void *param) -{ - struct mi_root *rpl_tree; - struct mi_cmd *cmds; - struct mi_node *rpl; - struct mi_node *node; - int size; - int i; - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - get_mi_cmds( &cmds, &size); - for ( i=0 ; i<size ; i++ ) { - node = add_mi_node_child( rpl, 0, 0, 0, cmds[i].name.s, - cmds[i].name.len); - if (node==0) { - LM_ERR("failed to add node\n"); - free_mi_tree(rpl_tree); - return 0; - } - } - - return rpl_tree; -} - - -static struct mi_root *mi_ps(struct mi_root *cmd, void *param) -{ - struct mi_root *rpl_tree; - struct mi_node *rpl; - struct mi_node *node; - struct mi_attr *attr; - char *p; - int len; - int i; - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - for ( i=0 ; i<get_proc_no() ; i++ ) { - node = add_mi_node_child(rpl, 0, MI_SSTR("Process"), 0, 0 ); - if (node==0) - goto error; - - p = int2str((unsigned long)i, &len); - attr = add_mi_attr( node, MI_DUP_VALUE, MI_SSTR("ID"), p, len); - if (attr==0) - goto error; - - p = int2str((unsigned long)pt[i].pid, &len); - attr = add_mi_attr( node, MI_DUP_VALUE, MI_SSTR("PID"), p, len); - if (attr==0) - goto error; - - attr = add_mi_attr( node, 0, MI_SSTR("Type"), - pt[i].desc, strlen(pt[i].desc)); - if (attr==0) - goto error; - } - - return rpl_tree; -error: - LM_ERR("failed to add node\n"); - free_mi_tree(rpl_tree); - return 0; -} - - -static struct mi_root *mi_kill(struct mi_root *cmd, void *param) -{ - kill(0, SIGTERM); - - return 0; -} - - -static struct mi_root *mi_debug(struct mi_root *cmd, void *param) -{ - struct mi_root *rpl_tree; - struct mi_node *node; - char *p; - int len; - int new_debug = 0; - str group_name = {"core", 4}; - str var_name = {"debug", 5}; - void *vval = 0; - int set = 0; - unsigned int val_type; - - node = cmd->node.kids; - if (node!=NULL) { - if (str2sint( &node->value, &new_debug) < 0) - return init_mi_tree( 400, MI_SSTR(MI_BAD_PARM)); - set = 1; - } else { - if(cfg_get_by_name(_kex_cfg_ctx, &group_name, NULL /* group id */, &var_name, &vval, - &val_type)!=0) - return init_mi_tree( 500, MI_SSTR(MI_INTERNAL_ERR)); - new_debug = (int)(long)vval; - } - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - - p = sint2str((long)new_debug, &len); - node = add_mi_node_child( &rpl_tree->node, MI_DUP_VALUE, - MI_SSTR("DEBUG"),p, len); - if (node==0) { - free_mi_tree(rpl_tree); - return 0; - } - - if(set==1) { - cfg_set_now(_kex_cfg_ctx, &group_name, NULL /* group id */, &var_name, - (void *)(long)new_debug, CFG_VAR_INT); - } - - return rpl_tree; -} - - -static mi_export_t mi_core_cmds[] = { - { "uptime", mi_uptime, MI_NO_INPUT_FLAG, 0, init_mi_uptime }, - { "version", mi_version, MI_NO_INPUT_FLAG, 0, 0 }, - { "pwd", mi_pwd, MI_NO_INPUT_FLAG, 0, 0 }, - { "arg", mi_arg, MI_NO_INPUT_FLAG, 0, 0 }, - { "which", mi_which, MI_NO_INPUT_FLAG, 0, 0 }, - { "kill", mi_kill, MI_NO_INPUT_FLAG, 0, 0 }, - { "ps", mi_ps, MI_NO_INPUT_FLAG, 0, 0 }, - { "debug", mi_debug, 0, 0, 0 }, - { 0, 0, 0, 0, 0} -}; - - - -int init_mi_core(void) -{ - if (cfg_register_ctx(&_kex_cfg_ctx, NULL)) { - LM_ERR("failed to register cfg context\n"); - return -1; - } - - if (register_mi_mod( "core", mi_core_cmds)<0) { - LM_ERR("unable to register core MI cmds\n"); - return -1; - } - - if(init_mi_uptime()<0) { - return -1; - } - - return 0; -} diff --git a/src/modules/kex/mi_core.h b/src/modules/kex/mi_core.h deleted file mode 100644 index bc6c2f49195..00000000000 --- a/src/modules/kex/mi_core.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2006 Voice Sistem SRL - * - * This file is part of Kamailio, a free SIP server. - * - * Kamailio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Kamailio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/*! - * \file - * \brief MI :: Core - * \ingroup mi - */ - - - -#ifndef _MI_MI_CORE_H_ -#define _MI_MI_CORE_H_ - -int init_mi_core(void); - -#endif