#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include "../../db/db_op.h"#include "../../sr_module.h"#include "../../db/db.h"#include "../../mem/shm_mem.h"#include "../../mem/mem.h"#include "../../dprint.h"#include "../../parser/parse_uri.h"#include "../../timer.h"#include "../../ut.h"#include "../../locking.h"#include "../../action.h"#include "../../mod_fix.h"#include "../../parser/parse_from.h"#include "pdtree.h"

Go to the source code of this file.
Defines | |
| #define | NR_KEYS 3 |
Functions | |
| static int | child_init (void) |
| static int | mod_child_init (int r) |
| static void | mod_destroy (void) |
| static int | mod_init (void) |
| static int | pdt_load_db () |
| static struct mi_root * | pdt_mi_add (struct mi_root *, void *param) |
| static struct mi_root * | pdt_mi_delete (struct mi_root *, void *param) |
| static struct mi_root * | pdt_mi_list (struct mi_root *, void *param) |
| static struct mi_root * | pdt_mi_reload (struct mi_root *, void *param) |
| int | pdt_print_mi_node (pdt_node_t *pt, struct mi_node *rpl, char *code, int len, str *sdomain, str *sd, str *sp) |
| static int | prefix2domain (struct sip_msg *, int mode, int sd_en) |
| static int | update_new_uri (struct sip_msg *msg, int plen, str *d, int mode) |
| static int | w_prefix2domain (struct sip_msg *msg, char *str1, char *str2) |
| static int | w_prefix2domain_1 (struct sip_msg *msg, char *mode, char *str2) |
| static int | w_prefix2domain_2 (struct sip_msg *msg, char *mode, char *sd_en) |
Variables | |
| pdt_tree_t ** | _ptree = NULL |
| static cmd_export_t | cmds [] |
| static db_con_t * | db_con = NULL |
| static str | db_table = str_init("pdt") |
| static str | db_url = str_init(DEFAULT_DB_URL) |
| static str | domain_column = str_init("domain") |
| struct module_exports | exports |
| static mi_export_t | mi_cmds [] |
| static param_export_t | params [] |
| str | pdt_char_list = {"0123456789", 10} |
| static int | pdt_check_domain = 1 |
| static db_func_t | pdt_dbf |
| int | pdt_fetch_rows = 1000 |
| static gen_lock_t * | pdt_lock = 0 |
| static volatile int | pdt_reload_flag = 0 |
| static volatile int | pdt_tree_refcnt = 0 |
| str | prefix = {"", 0} |
| static str | prefix_column = str_init("prefix") |
| static str | sdomain_column = str_init("sdomain") |
| #define NR_KEYS 3 |
Copyright (C) 2001-2003 FhG Fokus
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
History: ------- 2003-04-07: a structure for both hashes introduced (ramona) 2003-04-06: db connection closed in mod_init (janakj) 2004-06-07: updated to the new DB api (andrei) 2005-01-26: removed terminating code (ramona) prefix hash replaced with tree (ramona) FIFO commands to add/list/delete prefix domains (ramona) pdt cache per process for fast translation (ramona) 2006-01-30: multi domain support added
| static int child_init | ( | void | ) | [static] |
Definition at line 263 of file pdt.c.
References db_func::init, LM_ERR, NULL, and db_func::use_table.
| static int mod_child_init | ( | int | r | ) | [static] |
| static void mod_destroy | ( | void | ) | [static] |
Definition at line 293 of file pdt.c.
References db_func::close, LM_DBG, NULL, pdt_free_tree(), pdt_lock, and shm_free.
| static int mod_init | ( | void | ) | [static] |
init module function
Definition at line 161 of file pdt.c.
References db_func::close, db_bind_mod(), DB_CAP_ALL, DB_CAPABILITY, db_func::init, _str::len, LM_CRIT, LM_DBG, LM_ERR, LM_INFO, NULL, pdt_fetch_rows, pdt_load_db(), pdt_lock, pdt_print_tree(), _str::s, shm_free, shm_malloc(), and db_func::use_table.
| static int pdt_load_db | ( | void | ) | [static] |
Definition at line 548 of file pdt.c.
References DB_CAP_FETCH, DB_CAPABILITY, db_func::fetch_result, db_func::free_result, _str::len, LM_ERR, NULL, pdt_add_to_tree(), pdt_check_domain, pdt_check_pd(), pdt_fetch_rows, pdt_free_tree(), pdt_lock, pdt_reload_flag, pdt_tree_refcnt, db_func::query, RES_ROW_N, RES_ROWS, _str::s, sleep_us(), and db_func::use_table.
Referenced by mod_init(), pdt_mi_add(), pdt_mi_delete(), and pdt_mi_reload().
"pdt_add" syntax : sdomain prefix domain
Definition at line 707 of file pdt.c.
References DB_STR, db_func::delete, init_mi_tree(), db_func::insert, mi_node::kids, _str::len, LM_DBG, LM_ERR, MI_INTERNAL_ERR_LEN, MI_INTERNAL_ERR_S, MI_MISSING_PARM_LEN, MI_MISSING_PARM_S, MI_OK_LEN, MI_OK_S, mi_node::next, mi_root::node, NR_KEYS, db_val_t::nul, NULL, OP_EQ, pdt_check_domain, pdt_check_pd(), pdt_load_db(), _str::s, db_val_t::str_val, strpos, db_val_t::type, db_val_t::val, and mi_node::value.
"pdt_delete" syntax: sdomain domain
Definition at line 828 of file pdt.c.
References DB_STR, db_func::delete, init_mi_tree(), mi_node::kids, _str::len, LM_DBG, LM_ERR, MI_MISSING_PARM_LEN, MI_MISSING_PARM_S, MI_OK_LEN, MI_OK_S, mi_node::next, mi_root::node, db_val_t::nul, NULL, OP_EQ, pdt_load_db(), _str::s, db_val_t::str_val, db_val_t::type, db_val_t::val, and mi_node::value.
"pdt_list" syntax : sdomain prefix domain
Examples pdt_list o 2 . - lists the entries where sdomain is starting with 'o', prefix is starting with '2' and domain is anything
pdt_list . 2 open - lists the entries where sdomain is anything, prefix starts with '2' and domain starts with 'open'
Definition at line 964 of file pdt.c.
References free_mi_tree(), _pdt_tree::head, init_mi_tree(), mi_node::kids, _str::len, len, LM_ERR, MI_INTERNAL_ERR_LEN, MI_INTERNAL_ERR_S, MI_OK_LEN, MI_OK_S, _pdt_tree::next, mi_node::next, mi_root::node, NULL, PDT_MAX_DEPTH, pdt_print_mi_node(), pt, _str::s, _pdt_tree::sdomain, strpos, and mi_node::value.
"pdt_reload" syntax :
Definition at line 684 of file pdt.c.
References init_mi_tree(), LM_ERR, MI_OK_LEN, MI_OK_S, and pdt_load_db().
| int pdt_print_mi_node | ( | pdt_node_t * | pt, | |
| struct mi_node * | rpl, | |||
| char * | code, | |||
| int | len, | |||
| str * | sdomain, | |||
| str * | sd, | |||
| str * | sp | |||
| ) |
Definition at line 894 of file pdt.c.
References add_mi_attr(), add_mi_node_child(), _pdt_node::domain, domain, _str::len, MI_DUP_VALUE, NULL, PDT_MAX_DEPTH, PDT_NODE_SIZE, and _str::s.
Referenced by pdt_mi_list().
| static int prefix2domain | ( | struct sip_msg * | msg, | |
| int | mode, | |||
| int | sd_en | |||
| ) | [static] |
Definition at line 362 of file pdt.c.
References sip_msg::from, get_from, sip_uri::host, _str::len, LM_DBG, LM_ERR, LM_INFO, NULL, parse_from_header(), parse_sip_msg_uri(), parse_uri(), sip_msg::parsed_uri, sip_msg::parsed_uri_ok, pdt_get_domain(), pdt_lock, pdt_reload_flag, pdt_tree_refcnt, _str::s, sleep_us(), update_new_uri(), and sip_uri::user.
Referenced by w_prefix2domain(), w_prefix2domain_1(), and w_prefix2domain_2().
Definition at line 505 of file pdt.c.
References do_action(), action::elem, _str::len, LM_DBG, LM_ERR, sip_msg::new_uri, action::next, NULL, action_elem_::number, NUMBER_ST, _str::s, SET_HOSTPORT_T, action_elem_::string, STRING_ST, STRIP_T, action_elem_::type, action::type, and action_elem_::u.
Referenced by prefix2domain().
| static int w_prefix2domain | ( | struct sip_msg * | msg, | |
| char * | str1, | |||
| char * | str2 | |||
| ) | [static] |
| static int w_prefix2domain_1 | ( | struct sip_msg * | msg, | |
| char * | mode, | |||
| char * | str2 | |||
| ) | [static] |
| static int w_prefix2domain_2 | ( | struct sip_msg * | msg, | |
| char * | mode, | |||
| char * | sd_en | |||
| ) | [static] |
Definition at line 336 of file pdt.c.
References fixup_get_ivalue(), LM_ERR, prefix2domain(), and s.
| pdt_tree_t** _ptree = NULL |
cmd_export_t cmds[] [static] |
str domain_column = str_init("domain") [static] |
| struct module_exports exports |
mi_export_t mi_cmds[] [static] |
param_export_t params[] [static] |
| str pdt_char_list = {"0123456789", 10} |
Copyright (C) 2005 Voice Sistem SRL (Voice-System.RO)
This file is part of Kamailio, a free SIP server.
This file 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
This file 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
History: ------- 2005-01-25 first tree version (ramona) 2006-01-30 multi domain support added (ramona)
int pdt_check_domain = 1 [static] |
| int pdt_fetch_rows = 1000 |
gen_lock_t* pdt_lock = 0 [static] |
Definition at line 88 of file pdt.c.
Referenced by mod_destroy(), mod_init(), pdt_load_db(), and prefix2domain().
volatile int pdt_reload_flag = 0 [static] |
volatile int pdt_tree_refcnt = 0 [static] |
pstn prefix
Definition at line 83 of file pdt.c.
Referenced by build_rr(), generate_ETag(), load_config(), prepend_path(), preprocess_request(), print_msg_info(), and reload_gws_and_lcrs().
str prefix_column = str_init("prefix") [static] |
str sdomain_column = str_init("sdomain") [static] |
1.5.6