modules/lcr/mi.c

Go to the documentation of this file.
00001 /*
00002  * $Id: mi.c 5084 2008-10-16 16:58:34Z juhe $
00003  *
00004  * lcr MI functions
00005  *
00006  * Copyright (C) 2006 Voice Sistem SRL
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  * History:
00025  * --------
00026  *  2006-10-05  created (bogdan)
00027  */
00028 
00029 
00030 #include "lcr_mod.h"
00031 #include "../../dprint.h"
00032 #include "../../db/db.h"
00033 #include "mi.h"
00034 
00035 
00036 /*
00037  * MI function to reload lcr table(s)
00038  */
00039 struct mi_root*  mi_lcr_reload(struct mi_root* cmd_tree, void* param)
00040 {
00041     lock_get(reload_lock);
00042     if (reload_gws_and_lcrs() == 1) {
00043    lock_release(reload_lock);
00044    return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
00045     } else {
00046    lock_release(reload_lock);
00047    return init_mi_tree( 400, "Reload of gateways failed", 25);
00048     }
00049 }
00050 
00051 
00052 /*
00053  * MI function to print gws from current gw table
00054  */
00055 struct mi_root* mi_lcr_gw_dump(struct mi_root* cmd_tree, void* param)
00056 {
00057     struct mi_root* rpl_tree = NULL;
00058 
00059     rpl_tree = init_mi_tree(200, MI_OK_S, MI_OK_LEN);
00060     if (rpl_tree == 0)
00061    return 0;
00062 
00063     if (mi_print_gws(&rpl_tree->node ) < 0) {
00064    LM_ERR("failed to add node\n");
00065    free_mi_tree(rpl_tree);
00066    return 0;
00067     }
00068 
00069     return rpl_tree;
00070 }
00071 
00072 /*
00073  * MI function to print lcrs from current lcr table
00074  */
00075 struct mi_root* mi_lcr_lcr_dump(struct mi_root* cmd_tree, void* param)
00076 {
00077     struct mi_root* rpl_tree = NULL;
00078     
00079     rpl_tree = init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
00080     if (rpl_tree == 0)
00081    return 0;
00082 
00083     if (mi_print_lcrs(&rpl_tree->node) < 0) {
00084    LM_ERR("failed to add node\n");
00085    free_mi_tree(rpl_tree);
00086    return 0;
00087     }
00088 
00089     return rpl_tree;
00090 }

Generated on Wed May 23 20:00:27 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6