Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

pdt.c File Reference

#include <stdio.h>
#include <unistd.h>
#include <stdlib.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 "../../rpc.h"
#include "../../action.h"
#include "domains.h"
#include "pdtree.h"

Go to the source code of this file.

Defines

#define NR_KEYS   2

Functions

int w_prefix2domain (struct sip_msg *msg, char *str1, char *str2)
int w_prefix2domain_1 (struct sip_msg *msg, char *mode, char *str2)
int mod_init (void)
void mod_destroy (void)
int child_init (int r)
int prefix2domain (struct sip_msg *, int mode)
int update_new_uri (struct sip_msg *msg, int plen, str *d, int mode)
int pdt_load_db ()
int pdt_sync_cache ()
void pdt_clean_cache (unsigned int ticks, void *param)
void pdt_db_close (void)
int pdt_db_init (void)
void rpc_add (rpc_t *rpc, void *c)
void rpc_delete (rpc_t *rpc, void *c)
void rpc_list (rpc_t *rpc, void *c)
 Fifo command example:.

Variables

int hs_two_pow = 2
pdt_hash_t_dhash = NULL
 structure containing prefix-domain pairs
pdt_tree_t_ptree = NULL
time_t last_sync
db_ctx_tctx = NULL
 database connection
db_cmd_tdb_load = NULL
db_cmd_tdb_insert = NULL
db_cmd_tdb_delete = NULL
db_cmd_tdb_del_domain = NULL
char * db_url = DEFAULT_DB_URL
 parameters
char * db_table = "pdt"
char * prefix_column = "prefix"
char * domain_column = "domain"
str prefix = STR_STATIC_INIT("")
 pstn prefix
int sync_time = 600
int clean_time = 900
rpc_export_t pdt_rpc []
cmd_export_t cmds []
param_export_t params []
module_exports exports
const char * rpc_add_doc [2]
const char * rpc_delete_doc [2]
const char * rpc_list_doc [2]


Define Documentation

#define NR_KEYS   2
 

Definition at line 65 of file pdt.c.


Function Documentation

int child_init int  r  )  [static]
 

Definition at line 273 of file pdt.c.

References _dhash, _ptree, DBG, _pdt_hash::diff_lock, L_ERR, LOG, pdt_db_init(), pdt_free_tree(), PROC_INIT, PROC_MAIN, sync_time, and _pdt_hash::workers.

void mod_destroy void   )  [static]
 

Definition at line 310 of file pdt.c.

References _dhash, _ptree, DBG, pdt_db_close(), pdt_free_hash(), and pdt_free_tree().

int mod_init void   )  [static]
 

Definition at line 206 of file pdt.c.

References _dhash, _ptree, clean_time, DBG, hs_two_pow, L_ERR, last_sync, _str::len, LOG, MAX_HSIZE_TWO_POW, pdt_clean_cache(), pdt_db_close(), pdt_db_init(), pdt_free_hash(), pdt_free_tree(), pdt_init_hash(), pdt_init_tree(), pdt_load_db(), pdt_print_hash(), pdt_print_tree(), prefix, register_timer(), and _str::s.

void pdt_clean_cache unsigned int  ticks,
void param
 

Definition at line 562 of file pdt.c.

References _dhash, _pd_op::cell, _pd_op::count, DBG, _pdt_hash::diff, _pdt_hash::diff_lock, free_cell(), _pd_op::id, L_ERR, LOG, _pd_op::n, _pd_op::op, _pd_op::p, pd_op_t, and _pdt_hash::workers.

Referenced by mod_init().

void pdt_db_close void   )  [static]
 

Definition at line 141 of file pdt.c.

References ctx, db_cmd_free(), db_ctx_free(), db_del_domain, db_delete, db_disconnect(), db_insert, and db_load.

Referenced by mod_destroy(), mod_init(), and pdt_db_init().

int pdt_db_init void   )  [static]
 

Definition at line 163 of file pdt.c.

References ctx, db_add_db(), db_cmd(), db_connect(), db_ctx(), DB_DEL, db_del_domain, db_delete, db_fld_t, DB_GET, db_insert, db_load, DB_PUT, DB_STR, db_table, db_url, ERR, and pdt_db_close().

Referenced by child_init(), and mod_init().

int pdt_load_db  ) 
 

Definition at line 454 of file pdt.c.

References _dhash, _ptree, db_exec(), db_first(), db_load, db_next(), DB_NULL, db_rec_t, db_res_free(), db_res_t, ERR, db_fld::flags, db_rec::fld, INFO, db_fld_val::lstr, pdt_add_to_hash(), pdt_add_to_tree(), pdt_check_pd(), STR_FMT, and db_fld::v.

Referenced by mod_init().

int pdt_sync_cache  ) 
 

Definition at line 502 of file pdt.c.

References _dhash, _ptree, _pd_op::cell, _pd_op::count, DBG, _pdt_hash::diff, _pdt_hash::diff_lock, _pd::domain, _pd_op::id, _pdt_tree::idsync, L_ERR, LOG, _pdt_hash::max_id, _pd_op::n, _pd_op::op, pd_op_t, PDT_ADD, pdt_add_to_tree(), PDT_DELETE, pdt_remove_from_tree(), and _pd::prefix.

Referenced by prefix2domain().

int prefix2domain struct sip_msg ,
int  mode
[static]
 

Definition at line 337 of file pdt.c.

References _ptree, DBG, L_ERR, L_INFO, last_sync, _str::len, LOG, parse_sip_msg_uri(), sip_msg::parsed_uri, sip_msg::parsed_uri_ok, pdt_get_domain(), pdt_sync_cache(), prefix, _str::s, str, sync_time, update_new_uri(), and sip_uri::user.

Referenced by w_prefix2domain(), and w_prefix2domain_1().

void rpc_add rpc_t rpc,
void c
[static]
 

Definition at line 609 of file pdt.c.

References _dhash, db_delete, db_exec(), db_insert, DBG, _pdt_hash::diff, _pdt_hash::diff_lock, rpc::fault, free_cell(), free_pd_op(), _pd_op::id, L_ERR, _str::len, LOG, db_fld_val::lstr, _pdt_hash::max_id, _pd_op::n, new_cell(), new_pd_op(), _pd_op::op, _pd_op::p, pd_op_t, pd_t, PDT_ADD, pdt_add_to_hash(), pdt_check_pd(), rpc_t, _str::s, rpc::scan, str, STR_FMT, db_fld::v, and db_cmd::vals.

void rpc_delete rpc_t rpc,
void c
[static]
 

Definition at line 719 of file pdt.c.

References _dhash, db_del_domain, db_exec(), DBG, _pd::dhash, _pdt_hash::dhash, _pdt_hash::diff, _pdt_hash::diff_lock, _pd::domain, _pd_entry::e, rpc::fault, get_hash_entry, _pdt_hash::hash_size, _pd_op::id, L_ERR, L_INFO, _str::len, _pd_entry::lock, LOG, db_fld_val::lstr, db_cmd::match, _pdt_hash::max_id, _pd_op::n, _pd::n, new_pd_op(), _pd_op::op, _pd_op::p, _pd::p, pd_op_t, pd_t, pdt_compute_hash(), PDT_DELETE, rpc_t, _str::s, rpc::scan, str, and db_fld::v.

void rpc_list rpc_t rpc,
void c
[static]
 

Fifo command example:.

--- :pdt_list:[response_file]
prefix
domain

--

  • '.' (dot) means NULL value for [prefix] and [domain]
  • if both [prefix] and [domain] are NULL, all prefix-domain pairs are listed
  • the comparison operation is 'START WITH' -- if domain is 'a' then all domains starting with 'a' are listed

Definition at line 835 of file pdt.c.

References _dhash, rpc::add, _pdt_hash::dhash, _pdt_hash::diff_lock, _pd::domain, _pd_entry::e, rpc::fault, _pdt_hash::hash_size, L_ERR, _str::len, _pd_entry::lock, LOG, _pd::n, pd_t, pkg_free, pkg_malloc, _pd::prefix, rpc_t, _str::s, rpc::scan, and str.

int update_new_uri struct sip_msg msg,
int  plen,
str d,
int  mode
 

Definition at line 407 of file pdt.c.

References DBG, do_action(), init_run_actions_ctx, L_ERR, _str::len, LOG, prefix, _str::s, and str.

Referenced by prefix2domain().

int w_prefix2domain struct sip_msg msg,
char *  str1,
char *  str2
[static]
 

Definition at line 322 of file pdt.c.

References prefix2domain().

int w_prefix2domain_1 struct sip_msg msg,
char *  mode,
char *  str2
[static]
 

Definition at line 327 of file pdt.c.

References prefix2domain().


Variable Documentation

pdt_hash_t* _dhash = NULL
 

structure containing prefix-domain pairs

Definition at line 70 of file pdt.c.

Referenced by child_init(), mod_destroy(), mod_init(), pdt_clean_cache(), pdt_load_db(), pdt_sync_cache(), rpc_add(), rpc_delete(), and rpc_list().

pdt_tree_t* _ptree = NULL
 

Definition at line 71 of file pdt.c.

Referenced by child_init(), mod_destroy(), mod_init(), pdt_load_db(), pdt_sync_cache(), and prefix2domain().

int clean_time = 900
 

Definition at line 92 of file pdt.c.

Referenced by mod_init().

cmd_export_t cmds[] [static]
 

Initial value:

{
        {"prefix2domain", w_prefix2domain,   0, 0, REQUEST_ROUTE|FAILURE_ROUTE},
        {"prefix2domain", w_prefix2domain_1, 1, 0, REQUEST_ROUTE|FAILURE_ROUTE},
        {0, 0, 0, 0, 0}
}

Definition at line 109 of file pdt.c.

db_ctx_t* ctx = NULL [static]
 

database connection

Definition at line 76 of file pdt.c.

db_cmd_t* db_del_domain = NULL [static]
 

Definition at line 80 of file pdt.c.

Referenced by pdt_db_close(), pdt_db_init(), and rpc_delete().

db_cmd_t* db_delete = NULL [static]
 

Definition at line 79 of file pdt.c.

Referenced by pdt_db_close(), pdt_db_init(), and rpc_add().

db_cmd_t* db_insert = NULL [static]
 

Definition at line 78 of file pdt.c.

Referenced by pdt_db_close(), pdt_db_init(), and rpc_add().

db_cmd_t* db_load = NULL [static]
 

Definition at line 77 of file pdt.c.

Referenced by pdt_db_close(), pdt_db_init(), and pdt_load_db().

char* db_table = "pdt"
 

Definition at line 85 of file pdt.c.

char* db_url = DEFAULT_DB_URL [static]
 

parameters

Definition at line 84 of file pdt.c.

char* domain_column = "domain"
 

Definition at line 87 of file pdt.c.

struct module_exports exports
 

Initial value:

 {
        "pdt",
        cmds,
        pdt_rpc,         
        params,

        mod_init,               
        0,                              
        mod_destroy,    
        0,                              
        child_init              
}

Definition at line 127 of file pdt.c.

int hs_two_pow = 2
 

Definition at line 67 of file pdt.c.

Referenced by mod_init(), and pdt_init_hash().

time_t last_sync
 

Definition at line 73 of file pdt.c.

Referenced by mod_init(), and prefix2domain().

param_export_t params[] [static]
 

Initial value:

{
        {"db_url",        PARAM_STRING, &db_url},
        {"db_table",      PARAM_STRING, &db_table},
        {"prefix_column", PARAM_STRING, &prefix_column},
        {"domain_column", PARAM_STRING, &domain_column},
        {"prefix",        PARAM_STR,    &prefix},
        {"hsize_2pow",    PARAM_INT,    &hs_two_pow},
        {"sync_time",     PARAM_INT,    &sync_time},
        {"clean_time",    PARAM_INT,    &clean_time},
        {0, 0, 0}
}

Definition at line 115 of file pdt.c.

rpc_export_t pdt_rpc [static]
 

Initial value:

 {
        {"pdt.add",    rpc_add,    rpc_add_doc,    0},
        {"pdt.delete", rpc_delete, rpc_delete_doc, 0},
        {"pdt.list",   rpc_list,   rpc_list_doc,   RET_ARRAY},
        {0, 0, 0, 0}
}

Definition at line 914 of file pdt.c.

str prefix = STR_STATIC_INIT("")
 

pstn prefix

Definition at line 90 of file pdt.c.

Referenced by add_route(), attr_hdr_body2attrs(), build_rr(), dump(), ip_set_add_ip_s(), load_gws(), mod_init(), pr_db_load(), prefix2domain(), print_formatting(), print_value(), reload_gws(), rpc_ip_tree_print(), tree_item_add(), and update_new_uri().

char* prefix_column = "prefix"
 

Definition at line 86 of file pdt.c.

const char* rpc_add_doc[2] [static]
 

Initial value:

 {
        "Add new prefix/domain translation rule.",
        0
}

Definition at line 604 of file pdt.c.

const char* rpc_delete_doc[2] [static]
 

Initial value:

 {
        "Delete prefix/domain translation rule.",
        0
}

Definition at line 714 of file pdt.c.

const char* rpc_list_doc[2] [static]
 

Initial value:

 {
        "List existin prefix/domain translation rules",
        0
}

Definition at line 815 of file pdt.c.

int sync_time = 600
 

Definition at line 91 of file pdt.c.

Referenced by child_init(), and prefix2domain().


Generated on Thu Sep 9 04:16:17 2010 for SIPExpressRouter by  doxygen 1.3.9.1