Scope:
Definition in file mod.c.
#include "mod.h"
#include "../../sr_module.h"
#include "../../timer.h"
#include "../../locking.h"
#include "../tm/tm_load.h"
#include "../cdp/cdp_load.h"
#include "db.h"
#include "nds.h"
#include "scscf_list.h"
#include "registration.h"
#include "location.h"
#include "cx.h"
#include "sip.h"
#include "thig_ims_enc.h"
#include "thig.h"
#include "ims_pm_icscf.h"
Go to the source code of this file.
Functions | |
| static MODULE_VERSION int | icscf_mod_init (void) |
| static int | icscf_mod_child_init (int rank) |
| static void | icscf_mod_destroy (void) |
| static int | fix_parameters () |
| int | I_add_p_charging_vector (struct sip_msg *msg, char *str1, char *str2) |
| Inserts the P-Charging-Vector header P-Charging-Vector:. | |
Variables | |
| char * | icscf_name = "icscf.open-ims.test" |
| parameters storage name of the I-CSCF | |
| char * | icscf_thig_name = "thig@icscf.open-ims.test" |
| name of the I-CSCF for THIG | |
| char * | icscf_thig_host = "127.0.0.1" |
| host for THIG | |
| int | icscf_thig_port = 5060 |
| port for THIG | |
| char * | icscf_thig_param = "thigenc" |
| THIG parameter name. | |
| char * | icscf_db_url = "mysql://icscf:heslo@localhost/hssdata" |
| DB URL. | |
| char * | icscf_db_nds_table = "nds_trusted_domains" |
| NDS table in DB. | |
| char * | icscf_db_scscf_table = "s_cscf" |
| S-CSCF table in db. | |
| char * | icscf_db_capabilities_table = "s_cscf_capabilities" |
| S-CSCF capabilities table in db. | |
| char * | icscf_forced_hss_peer = "" |
| Forced Diameter Peer FQDN (HSS). | |
| int | icscf_hash_size = 128 |
| size of the hash for storing S-CSCF lists | |
| char * | icscf_default_realm = "open-ims.test" |
| default realm for LIR if none available | |
| static char * | icscf_route_on_term_user_unknown = 0 |
| script route to run for Initial request after HSS replies with User Unknown to the LIR for terminating user (default none) | |
| int | route_on_term_user_unknown_n = -1 |
| script route number for Initial request processing after HSS says User Unknown | |
| char * | cscf_icid_value_prefix |
| hexadecimal prefix for the icid-value - must be unique on each node | |
| unsigned int * | cscf_icid_value_count |
| to keep the number of generated icid-values | |
| gen_lock_t * | cscf_icid_value_count_lock |
| to lock acces on the above counter | |
| char * | cscf_icid_gen_addr |
| address of the generator of the icid-value | |
| char * | cscf_orig_ioi |
| name of the Originating network | |
| char * | cscf_term_ioi |
| name of the Terminating network | |
| str | icscf_name_str |
| fixed name of the I-CSCF | |
| str | icscf_thig_name_str |
| fixed name of the I-CSCF for THIG | |
| str | icscf_thig_host_str |
| fixed host for THIG | |
| str | icscf_thig_port_str |
| fixed port for THIG | |
| str | icscf_thig_param_str |
| fixed THIG parameter name | |
| str | icscf_thig_path_str |
| fixed Path header | |
| str | icscf_thig_rr_str |
| fixed Record-route header | |
| str | icscf_default_realm_str |
| fixed default realm | |
| str | icscf_forced_hss_peer_str |
| FQDN of the Diameter peer to send requests to. | |
| str | cscf_icid_value_prefix_str |
| fixed hexadecimal prefix for the icid-value - must be unique on each node | |
| str | cscf_icid_gen_addr_str |
| fixed address of the generator of the icid-value | |
| str | cscf_orig_ioi_str |
| fixed name of the Originating network | |
| str | cscf_term_ioi_str |
| fixed name of the Terminating network | |
| keyInstance | ki |
| key information, including tables | |
| cipherInstance | ci |
| keeps mode (ECB, CBC) and IV | |
| static cmd_export_t | icscf_cmds [] |
| Exported functions. | |
| static param_export_t | icscf_params [] |
| Exported parameters. | |
| module_exports | exports |
| module exports | |
| int(*) | sl_reply (struct sip_msg *_msg, char *_str1, char *_str2) |
| link to the stateless reply function in sl module | |
| tm_binds | tmb |
| Structure with pointers to tm funcs. | |
| cdp_binds | cdpb |
| Structure with pointers to cdp funcs. | |
| static str | s_path_s = {"Path: <sip:",11} |
| static str | s_path_e = {";lr>\r\n",6} |
| static str | s_rr_s = {"Record-Route: <sip:",19} |
| static str | s_rr_e = {";lr>\r\n",6} |
| static int icscf_mod_init | ( | void | ) | [static] |
initialize twofish variables and tables (THIG)
Definition at line 332 of file mod.c.
References cdpb, ci, cscf_icid_value_count, cscf_icid_value_count_lock, fix_parameters(), I_get_capabilities(), i_hash_table_init(), I_NDS_get_trusted_domains(), icscf_db_bind(), icscf_db_url, icscf_hash_size, icscf_name_str, icscf_route_on_term_user_unknown, ki, load_cdp(), M_NAME, NO_SCRIPT, NULL, route_on_term_user_unknown_n, sl_reply, thig_key_and_cipher_init(), and tmb.
00333 { 00334 load_tm_f load_tm; 00335 load_cdp_f load_cdp; 00336 LOG(L_INFO,"INFO:"M_NAME":mod_init: Initialization of module\n"); 00337 /* fix the parameters */ 00338 if (!fix_parameters()) goto error; 00339 00340 #ifdef WITH_IMS_PM 00341 ims_pm_init(icscf_name_str,ims_pm_node_type, ims_pm_logfile); 00342 ims_pm_init_icscf(); 00343 #endif /* WITH_IMS_PM */ 00344 00345 cscf_icid_value_count = shm_malloc(sizeof(unsigned int)); 00346 *cscf_icid_value_count = 0; 00347 cscf_icid_value_count_lock = lock_alloc(); 00348 cscf_icid_value_count_lock = lock_init(cscf_icid_value_count_lock); 00349 00350 /* load the send_reply function from sl module */ 00351 sl_reply = find_export("sl_send_reply", 2, 0); 00352 if (!sl_reply) { 00353 LOG(L_ERR, "ERR"M_NAME":mod_init: This module requires sl module\n"); 00354 goto error; 00355 } 00356 00357 /* bind to the db module */ 00358 if ( icscf_db_bind( icscf_db_url ) < 0 ) goto error; 00359 00360 /* bind to the tm module */ 00361 if (!(load_tm = (load_tm_f)find_export("load_tm",NO_SCRIPT,0))) { 00362 LOG(L_ERR, "ERR"M_NAME":mod_init: Can not import load_tm. This module requires tm module\n"); 00363 goto error; 00364 } 00365 if (load_tm(&tmb) == -1) 00366 goto error; 00367 00368 /* bind to the cdp module */ 00369 if (!(load_cdp = (load_cdp_f)find_export("load_cdp",NO_SCRIPT,0))) { 00370 LOG(L_ERR, "ERR"M_NAME":mod_init: Can not import load_cdp. This module requires cdp module\n"); 00371 goto error; 00372 } 00373 if (load_cdp(&cdpb) == -1) 00374 goto error; 00375 00376 /* cache the trusted domain names and capabilities */ 00377 I_NDS_get_trusted_domains(); 00378 I_get_capabilities(); 00379 00380 if (!i_hash_table_init(icscf_hash_size)){ 00381 LOG(L_ERR, "ERR"M_NAME":mod_init: Error initializing the Hash Table for stored S-CSCF lists\n"); 00382 goto error; 00383 } 00384 // //TODO - only for S-CSCF - I-CSCF does not respond to request 00386 // /* don't register response callback as we always set callback per transactions 00387 // * and we're not interested in other responses */ 00388 // /*AAAAddResponseHandler(&CxAnswerHandler,0);*/ 00389 // 00391 srand((unsigned) time(NULL)); 00392 thig_key_and_cipher_init(&ki,&ci); 00393 LOG(L_INFO,"Twofish encryption ready\n"); 00394 00395 int route_no; 00396 /* try to fix the icscf_route_on_term_user_unknown route */ 00397 if (icscf_route_on_term_user_unknown){ 00398 route_no=route_get(&main_rt, icscf_route_on_term_user_unknown); 00399 if (route_no==-1){ 00400 LOG(L_ERR, "ERR"M_NAME":mod_init: failed to fix route \"%s\": route_get() failed\n", 00401 icscf_route_on_term_user_unknown); 00402 return -1; 00403 } 00404 if (main_rt.rlist[route_no]==0){ 00405 LOG(L_ERR, "ERR"M_NAME":mod_init: icscf_route_on_term_user_unknown \"%s\" is empty / doesn't exist\n", 00406 icscf_route_on_term_user_unknown); 00407 } 00408 route_on_term_user_unknown_n=route_no; 00409 } 00410 00411 return 0; 00412 error: 00413 return -1; 00414 }
| static int icscf_mod_child_init | ( | int | rank | ) | [static] |
Definition at line 416 of file mod.c.
References icscf_db_capabilities_table, icscf_db_init(), icscf_db_nds_table, icscf_db_scscf_table, icscf_db_url, M_NAME, and process_no.
00417 { 00418 LOG(L_INFO,"INFO:"M_NAME":mod_init: Initialization of module in child [%d] %s \n", 00419 rank,pt[process_no].desc); 00420 /* don't do anything for main process and TCP manager process */ 00421 if ( rank == PROC_MAIN || rank == PROC_TCP_MAIN ) 00422 return 0; 00423 00424 /* db child init */ 00425 icscf_db_init( icscf_db_url, 00426 icscf_db_nds_table, 00427 icscf_db_scscf_table, 00428 icscf_db_capabilities_table); 00429 00430 return 0; 00431 }
| static void icscf_mod_destroy | ( | void | ) | [static] |
Definition at line 433 of file mod.c.
References i_hash_table_destroy(), and M_NAME.
00434 { 00435 LOG(L_INFO,"INFO:"M_NAME":mod_destroy: child exit\n"); 00436 i_hash_table_destroy(); 00437 #ifdef WITH_IMS_PM 00438 ims_pm_destroy(); 00439 #endif /* WITH_IMS_PM */ 00440 }
| static int fix_parameters | ( | ) | [static] |
Definition at line 266 of file mod.c.
References cscf_icid_gen_addr, cscf_icid_gen_addr_str, cscf_icid_value_prefix, cscf_icid_value_prefix_str, cscf_orig_ioi, cscf_orig_ioi_str, cscf_term_ioi, cscf_term_ioi_str, icscf_default_realm, icscf_default_realm_str, icscf_forced_hss_peer, icscf_forced_hss_peer_str, icscf_name, icscf_name_str, icscf_thig_host, icscf_thig_host_str, icscf_thig_name, icscf_thig_name_str, icscf_thig_param, icscf_thig_param_str, icscf_thig_path_str, icscf_thig_port, icscf_thig_port_str, icscf_thig_rr_str, M_NAME, s_path_e, s_path_s, s_rr_e, s_rr_s, and STR_APPEND.
Referenced by icscf_mod_init(), and mod_init().
00267 { 00268 icscf_name_str.s = icscf_name; 00269 icscf_name_str.len = strlen(icscf_name); 00270 00271 icscf_thig_name_str.s = icscf_thig_name; 00272 icscf_thig_name_str.len = strlen(icscf_thig_name); 00273 00274 icscf_thig_host_str.s = icscf_thig_host; 00275 icscf_thig_host_str.len = strlen(icscf_thig_host); 00276 00277 icscf_thig_port_str.s = pkg_malloc(12); 00278 if (!icscf_thig_port_str.s){ 00279 LOG(L_ERR,"ERR:"M_NAME":fix_parameters: error allocating %d bytes\n",12); 00280 return 0; 00281 } 00282 sprintf(icscf_thig_port_str.s,"%d",icscf_thig_port); 00283 icscf_thig_port_str.len = strlen(icscf_thig_port_str.s); 00284 00285 00286 icscf_thig_param_str.s = icscf_thig_param; 00287 icscf_thig_param_str.len = strlen(icscf_thig_param); 00288 00289 icscf_thig_path_str.len = s_path_s.len+icscf_thig_name_str.len+s_path_e.len; 00290 icscf_thig_path_str.s = pkg_malloc(icscf_thig_path_str.len); 00291 if (!icscf_thig_path_str.s){ 00292 LOG(L_ERR,"ERR:"M_NAME":fix_parameters: error allocating %d bytes\n",icscf_thig_path_str.len); 00293 return 0; 00294 } 00295 icscf_thig_path_str.len = 0; 00296 STR_APPEND(icscf_thig_path_str,s_path_s); 00297 STR_APPEND(icscf_thig_path_str,icscf_thig_name_str); 00298 STR_APPEND(icscf_thig_path_str,s_path_e); 00299 00300 icscf_thig_rr_str.len = s_rr_s.len+icscf_thig_name_str.len+s_rr_e.len; 00301 icscf_thig_rr_str.s = pkg_malloc(icscf_thig_rr_str.len); 00302 if (!icscf_thig_rr_str.s){ 00303 LOG(L_ERR,"ERR:"M_NAME":fix_parameters: error allocating %d bytes\n",icscf_thig_rr_str.len); 00304 return 0; 00305 } 00306 icscf_thig_rr_str.len = 0; 00307 STR_APPEND(icscf_thig_rr_str,s_rr_s); 00308 STR_APPEND(icscf_thig_rr_str,icscf_thig_name_str); 00309 STR_APPEND(icscf_thig_rr_str,s_rr_e); 00310 00311 icscf_forced_hss_peer_str.s = icscf_forced_hss_peer; 00312 icscf_forced_hss_peer_str.len = strlen(icscf_forced_hss_peer); 00313 00314 icscf_default_realm_str.s = icscf_default_realm; 00315 icscf_default_realm_str.len = strlen(icscf_default_realm); 00316 00317 cscf_icid_value_prefix_str.s = cscf_icid_value_prefix; 00318 cscf_icid_value_prefix_str.len = strlen(cscf_icid_value_prefix); 00319 00320 cscf_icid_gen_addr_str.s = cscf_icid_gen_addr; 00321 cscf_icid_gen_addr_str.len = strlen(cscf_icid_gen_addr); 00322 00323 cscf_orig_ioi_str.s = cscf_orig_ioi; 00324 cscf_orig_ioi_str.len = strlen(cscf_orig_ioi); 00325 00326 cscf_term_ioi_str.s = cscf_term_ioi; 00327 cscf_term_ioi_str.len = strlen(cscf_term_ioi); 00328 00329 return 1; 00330 }
| int I_add_p_charging_vector | ( | struct sip_msg * | msg, | |
| char * | str1, | |||
| char * | str2 | |||
| ) |
Inserts the P-Charging-Vector header P-Charging-Vector:.
| msg | - the SIP message to add to | |
| str1 | - not used | |
| str2 | - not used |
Definition at line 454 of file mod.c.
References cscf_add_p_charging_vector().
00455 { 00456 return cscf_add_p_charging_vector(msg); 00457 }
| char* icscf_name = "icscf.open-ims.test" |
parameters storage name of the I-CSCF
Definition at line 89 of file mod.c.
Referenced by fix_parameters().
| char* icscf_thig_name = "thig@icscf.open-ims.test" |
| char* icscf_thig_host = "127.0.0.1" |
| int icscf_thig_port = 5060 |
port for THIG
Definition at line 92 of file mod.c.
Referenced by fix_parameters(), and I_THIG_decrypt_header().
| char* icscf_thig_param = "thigenc" |
| char* icscf_db_url = "mysql://icscf:heslo@localhost/hssdata" |
DB URL.
Definition at line 95 of file mod.c.
Referenced by icscf_db_bind(), icscf_db_check_init(), icscf_mod_child_init(), and icscf_mod_init().
| char* icscf_db_nds_table = "nds_trusted_domains" |
NDS table in DB.
Definition at line 96 of file mod.c.
Referenced by icscf_db_check_init(), and icscf_mod_child_init().
| char* icscf_db_scscf_table = "s_cscf" |
S-CSCF table in db.
Definition at line 97 of file mod.c.
Referenced by icscf_db_check_init(), and icscf_mod_child_init().
| char* icscf_db_capabilities_table = "s_cscf_capabilities" |
S-CSCF capabilities table in db.
Definition at line 98 of file mod.c.
Referenced by icscf_db_check_init(), and icscf_mod_child_init().
| char* icscf_forced_hss_peer = "" |
Forced Diameter Peer FQDN (HSS).
Definition at line 100 of file mod.c.
Referenced by fix_parameters().
| int icscf_hash_size = 128 |
size of the hash for storing S-CSCF lists
Definition at line 102 of file mod.c.
Referenced by icscf_mod_init().
| char* icscf_default_realm = "open-ims.test" |
default realm for LIR if none available
Definition at line 104 of file mod.c.
Referenced by fix_parameters().
char* icscf_route_on_term_user_unknown = 0 [static] |
script route to run for Initial request after HSS replies with User Unknown to the LIR for terminating user (default none)
Definition at line 106 of file mod.c.
Referenced by icscf_mod_init().
| int route_on_term_user_unknown_n = -1 |
script route number for Initial request processing after HSS says User Unknown
Definition at line 107 of file mod.c.
Referenced by I_LIA(), and icscf_mod_init().
| char* cscf_icid_value_prefix |
hexadecimal prefix for the icid-value - must be unique on each node
Definition at line 2715 of file sip.c.
Referenced by fix_parameters().
| unsigned int* cscf_icid_value_count |
to keep the number of generated icid-values
Definition at line 2716 of file sip.c.
Referenced by icscf_mod_init(), and mod_init().
| gen_lock_t* cscf_icid_value_count_lock |
to lock acces on the above counter
Definition at line 2717 of file sip.c.
Referenced by icscf_mod_init(), and mod_init().
| char* cscf_icid_gen_addr |
address of the generator of the icid-value
Definition at line 2718 of file sip.c.
Referenced by fix_parameters().
| char* cscf_orig_ioi |
name of the Originating network
Definition at line 2719 of file sip.c.
Referenced by fix_parameters().
| char* cscf_term_ioi |
name of the Terminating network
Definition at line 2720 of file sip.c.
Referenced by fix_parameters().
| str icscf_name_str |
fixed name of the I-CSCF
Definition at line 119 of file mod.c.
Referenced by fix_parameters(), and icscf_mod_init().
fixed name of the I-CSCF for THIG
Definition at line 120 of file mod.c.
Referenced by fix_parameters().
fixed host for THIG
Definition at line 121 of file mod.c.
Referenced by fix_parameters(), I_THIG_decrypt_header(), and I_THIG_encrypt_header().
fixed port for THIG
Definition at line 122 of file mod.c.
Referenced by fix_parameters(), and I_THIG_encrypt_header().
fixed THIG parameter name
Definition at line 123 of file mod.c.
Referenced by fix_parameters(), I_THIG_decrypt_header(), and I_THIG_encrypt_header().
fixed Path header
Definition at line 124 of file mod.c.
Referenced by fix_parameters(), and I_THIG_add_Path().
fixed Record-route header
Definition at line 125 of file mod.c.
Referenced by fix_parameters(), and I_THIG_add_RR().
fixed default realm
Definition at line 126 of file mod.c.
Referenced by fix_parameters(), and I_LIR().
FQDN of the Diameter peer to send requests to.
Definition at line 127 of file mod.c.
Referenced by Cx_LIR(), Cx_UAR(), and fix_parameters().
fixed hexadecimal prefix for the icid-value - must be unique on each node
Definition at line 2722 of file sip.c.
Referenced by fix_parameters().
fixed address of the generator of the icid-value
Definition at line 2723 of file sip.c.
Referenced by fix_parameters().
fixed name of the Originating network
Definition at line 2724 of file sip.c.
Referenced by fix_parameters().
fixed name of the Terminating network
Definition at line 2725 of file sip.c.
Referenced by fix_parameters().
key information, including tables
Definition at line 135 of file mod.c.
Referenced by icscf_mod_init(), thig_decrypt(), thig_encrypt(), and thig_key_and_cipher_init().
keeps mode (ECB, CBC) and IV
Definition at line 136 of file mod.c.
Referenced by icscf_mod_init(), S_assign_server(), save_location(), thig_decrypt(), thig_encrypt(), thig_key_and_cipher_init(), and update_contacts().
cmd_export_t icscf_cmds[] [static] |
Initial value:
{
{"I_NDS_check_trusted", I_NDS_check_trusted, 0, 0, REQUEST_ROUTE},
{"I_NDS_is_trusted", I_NDS_is_trusted, 0, 0, REQUEST_ROUTE},
{"I_NDS_strip_headers", I_NDS_strip_headers, 0, 0, REQUEST_ROUTE},
{"I_trans_in_processing", I_trans_in_processing, 0, 0, REQUEST_ROUTE},
{"I_UAR", I_UAR, 1, 0, REQUEST_ROUTE},
{"I_LIR", I_LIR, 0, 0, REQUEST_ROUTE},
{"I_scscf_select", I_scscf_select, 1, 0, REQUEST_ROUTE|FAILURE_ROUTE},
{"I_scscf_drop", I_scscf_drop, 0, 0, REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE},
{"I_THIG_add_Path", I_THIG_add_Path, 0, 0, REQUEST_ROUTE},
{"I_THIG_add_RR", I_THIG_add_RR, 0, 0, REQUEST_ROUTE},
{"I_THIG_encrypt_header", I_THIG_encrypt_header, 1, 0, REQUEST_ROUTE|ONREPLY_ROUTE},
{"I_THIG_encrypt_all_headers", I_THIG_encrypt_all_headers, 0, 0, REQUEST_ROUTE|ONREPLY_ROUTE},
{"I_THIG_decrypt_header", I_THIG_decrypt_header, 1, 0, REQUEST_ROUTE|ONREPLY_ROUTE},
{"I_THIG_decrypt_all_headers", I_THIG_decrypt_all_headers, 0, 0, REQUEST_ROUTE|ONREPLY_ROUTE},
{"I_add_p_charging_vector", I_add_p_charging_vector, 0, 0, REQUEST_ROUTE},
{"I_originating", I_originating, 0, 0, REQUEST_ROUTE},
{0, 0, 0, 0, 0}
}
param_export_t icscf_params[] [static] |
Initial value:
{
{"name", STR_PARAM, &icscf_name},
{"db_url", STR_PARAM, &icscf_db_url},
{"db_nds_table", STR_PARAM, &icscf_db_nds_table},
{"db_scscf_table", STR_PARAM, &icscf_db_scscf_table},
{"db_capabilities_table", STR_PARAM, &icscf_db_capabilities_table},
{"forced_hss_peer", STR_PARAM, &icscf_forced_hss_peer},
{"hash_size", INT_PARAM, &icscf_hash_size},
{"default_realm", STR_PARAM, &icscf_default_realm},
{"thig_name", STR_PARAM, &icscf_thig_name},
{"thig_host", STR_PARAM, &icscf_thig_host},
{"thig_port", INT_PARAM, &icscf_thig_port},
{"thig_param", STR_PARAM, &icscf_thig_param},
{"icid_value_prefix", STR_PARAM, &cscf_icid_value_prefix},
{"icid_gen_addr", STR_PARAM, &cscf_icid_gen_addr},
{"orig_ioi", STR_PARAM, &cscf_orig_ioi},
{"term_ioi", STR_PARAM, &cscf_term_ioi},
{"route_on_term_user_unknown", STR_PARAM, &icscf_route_on_term_user_unknown},
{0,0,0}
}
| struct module_exports exports |
Initial value:
{
"icscf",
icscf_cmds,
0,
icscf_params,
icscf_mod_init,
0,
icscf_mod_destroy,
0,
icscf_mod_child_init
}
| int(*) sl_reply(struct sip_msg *_msg, char *_str1, char *_str2) |
link to the stateless reply function in sl module
Definition at line 254 of file mod.c.
Referenced by I_NDS_check_trusted(), icscf_mod_init(), mod_init(), P_422_session_expires(), and S_422_session_expires().
str s_path_s = {"Path: <sip:",11} [static] |
str s_path_e = {";lr>\r\n",6} [static] |
str s_rr_s = {"Record-Route: <sip:",19} [static] |
str s_rr_e = {";lr>\r\n",6} [static] |
1.5.2