Exemplo n.º 1
0
/*
 * MI function to print subnets from current subnet table
 */
struct mi_root* mi_subnet_dump(struct mi_root *cmd_tree, void *param)
{
	struct mi_root* rpl_tree;
	struct mi_node *node = NULL;
	struct pm_part_struct *it, *ps;

	if (cmd_tree)
		node = cmd_tree->node.kids;

	rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK));
	if (node == NULL) {
		/* dump all subnets */
		for (it=get_part_structs(); it; it = it->next) {
			if (it->subnet_table == NULL)
				continue;

			if (subnet_table_mi_print(*it->subnet_table, &rpl_tree->node, it) <  0) {
				LM_ERR("failed to add a node\n");
				 free_mi_tree(rpl_tree);
				return 0;
			}
		}
	} else {
		ps = get_part_struct(&node->value);
		if (ps == NULL)
			return init_mi_tree(404, MI_SSTR("No such partition"));
		if (ps->subnet_table == NULL)
			return init_mi_tree( 200, MI_SSTR(MI_OK));

		/* dump requested subnet*/
		if (subnet_table_mi_print(*ps->subnet_table, &rpl_tree->node, ps) <  0) {
			LM_ERR("failed to add a node\n");
			 free_mi_tree(rpl_tree);
			return 0;
		}
	}

	return rpl_tree;
}
Exemplo n.º 2
0
Arquivo: mi.c Projeto: gbour/kamailio
/*
 * MI function to print subnets from current subnet table
 */
struct mi_root* mi_subnet_dump(struct mi_root *cmd_tree, void *param)
{
    struct mi_root* rpl_tree;
    
    rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK));
    if (rpl_tree==NULL) return 0;
    
    if(subnet_table && subnet_table_mi_print(*subnet_table, &rpl_tree->node) <  0) {
	LM_ERR("failed to add a node\n");
	free_mi_tree(rpl_tree);
	return 0;
    }

    return rpl_tree;
}