2
0
Эх сурвалжийг харах

usrloc: use ul prefix for global param variables

Daniel-Constantin Mierla 5 жил өмнө
parent
commit
ae2f1fdc40

+ 36 - 36
src/modules/usrloc/dlist.c

@@ -75,10 +75,10 @@ static inline int find_dlist(str* _n, dlist_t** _d)
 			*_d = ptr;
 			return 0;
 		}
-		
+
 		ptr = ptr->next;
 	}
-	
+
 	return 1;
 }
 
@@ -106,22 +106,22 @@ int ul_ka_db_records(int partidx)
 	int i = 0;
 
 	/* select fields */
-	keys2[0] = &received_col;
-	keys2[1] = &contact_col;
-	keys2[2] = &sock_col;
-	keys2[3] = &cflags_col;
-	keys2[4] = &path_col;
-	keys2[5] = &ruid_col;
-	keys2[6] = &user_col;
-	keys2[7] = &domain_col;
+	keys2[0] = &ul_received_col;
+	keys2[1] = &ul_contact_col;
+	keys2[2] = &ul_sock_col;
+	keys2[3] = &ul_cflags_col;
+	keys2[4] = &ul_path_col;
+	keys2[5] = &ul_ruid_col;
+	keys2[6] = &ul_user_col;
+	keys2[7] = &ul_domain_col;
 
 	/* where fields */
-	keys1[0] = &expires_col;
+	keys1[0] = &ul_expires_col;
 	ops1[0] = OP_GT;
 	vals1[0].nul = 0;
 	UL_DB_EXPIRES_SET(&vals1[0], time(0));
 
-	keys1[1] = &partition_col;
+	keys1[1] = &ul_partition_col;
 	ops1[1] = OP_EQ;
 	vals1[1].type = DB1_INT;
 	vals1[1].nul = 0;
@@ -131,7 +131,7 @@ int ul_ka_db_records(int partidx)
 		vals1[1].val.int_val = 0;
 
 	if (ul_ka_mode & ULKA_NAT) {
-		keys1[n[0]] = &keepalive_col;
+		keys1[n[0]] = &ul_keepalive_col;
 		ops1[n[0]] = OP_EQ;
 		vals1[n[0]].type = DB1_INT;
 		vals1[n[0]].nul = 0;
@@ -139,7 +139,7 @@ int ul_ka_db_records(int partidx)
 		n[0]++;
 	}
 	if(ul_ka_filter&GAU_OPT_SERVER_ID) {
-		keys1[n[0]] = &srv_id_col;
+		keys1[n[0]] = &ul_srv_id_col;
 		ops1[n[0]] = OP_EQ;
 		vals1[n[0]].type = DB1_INT;
 		vals1[n[0]].nul = 0;
@@ -310,20 +310,20 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
 	aorhash = 0;
 
 	/* select fields */
-	keys2[0] = &received_col;
-	keys2[1] = &contact_col;
-	keys2[2] = &sock_col;
-	keys2[3] = &cflags_col;
-	keys2[4] = &path_col;
-	keys2[5] = &ruid_col;
+	keys2[0] = &ul_received_col;
+	keys2[1] = &ul_contact_col;
+	keys2[2] = &ul_sock_col;
+	keys2[3] = &ul_cflags_col;
+	keys2[4] = &ul_path_col;
+	keys2[5] = &ul_ruid_col;
 
 	/* where fields */
-	keys1[0] = &expires_col;
+	keys1[0] = &ul_expires_col;
 	ops1[0] = OP_GT;
 	vals1[0].nul = 0;
 	UL_DB_EXPIRES_SET(&vals1[0], time(0));
 
-	keys1[1] = &partition_col;
+	keys1[1] = &ul_partition_col;
 	ops1[1] = OP_EQ;
 	vals1[1].type = DB1_INT;
 	vals1[1].nul = 0;
@@ -332,8 +332,8 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
 	else
 		vals1[1].val.int_val = 0;
 
-	if (flags & nat_bflag) {
-		keys1[n[0]] = &keepalive_col;
+	if (flags & ul_nat_bflag) {
+		keys1[n[0]] = &ul_keepalive_col;
 		ops1[n[0]] = OP_EQ;
 		vals1[n[0]].type = DB1_INT;
 		vals1[n[0]].nul = 0;
@@ -341,7 +341,7 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
 		n[0]++;
 	}
 	if(options&GAU_OPT_SERVER_ID) {
-		keys1[n[0]] = &srv_id_col;
+		keys1[n[0]] = &ul_srv_id_col;
 		ops1[n[0]] = OP_EQ;
 		vals1[n[0]].type = DB1_INT;
 		vals1[n[0]].nul = 0;
@@ -668,7 +668,7 @@ int get_all_ucontacts(void *buf, int len, unsigned int flags,
 								unsigned int part_idx, unsigned int part_max,
 								int options)
 {
-	if (db_mode==DB_ONLY)
+	if (ul_db_mode==DB_ONLY)
 		return get_all_db_ucontacts( buf, len, flags, part_idx, part_max, options);
 	else
 		return get_all_mem_ucontacts( buf, len, flags, part_idx, part_max, options);
@@ -826,7 +826,7 @@ int register_udomain(const char* _n, udomain_t** _d)
 		*_d = d->d;
 		return 0;
 	}
-	
+
 	if (new_dlist(&s, &d) < 0) {
 		LM_ERR("failed to create new domain\n");
 		return -1;
@@ -835,8 +835,8 @@ int register_udomain(const char* _n, udomain_t** _d)
 	/* Test tables from database if we are gonna
 	 * to use database
 	 */
-	if (db_mode != NO_DB) {
-		con = ul_dbf.init(&db_url);
+	if (ul_db_mode != NO_DB) {
+		con = ul_dbf.init(&ul_db_url);
 		if (!con) {
 			LM_ERR("failed to open database connection\n");
 			goto dberror;
@@ -859,7 +859,7 @@ int register_udomain(const char* _n, udomain_t** _d)
 
 	d->next = _ksr_ul_root;
 	_ksr_ul_root = d;
-	
+
 	*_d = d->d;
 	return 0;
 
@@ -898,7 +898,7 @@ void free_all_udomains(void)
 void print_all_udomains(FILE* _f)
 {
 	dlist_t* ptr;
-	
+
 	ptr = _ksr_ul_root;
 
 	fprintf(_f, "===Domain list===\n");
@@ -919,12 +919,12 @@ unsigned long get_number_of_users(void)
 	long numberOfUsers = 0;
 
 	dlist_t* current_dlist;
-	
+
 	current_dlist = _ksr_ul_root;
 
 	while (current_dlist)
 	{
-		numberOfUsers += get_stat_val(current_dlist->d->users); 
+		numberOfUsers += get_stat_val(current_dlist->d->users);
 		current_dlist  = current_dlist->next;
 	}
 
@@ -941,9 +941,9 @@ int synchronize_all_udomains(int istart, int istep)
 	int res = 0;
 	dlist_t* ptr;
 
-	get_act_time(); /* Get and save actual time */
+	ul_get_act_time(); /* Get and save actual time */
 
-	if (db_mode==DB_ONLY) {
+	if (ul_db_mode==DB_ONLY) {
 		if(istart == 0) {
 			for( ptr=_ksr_ul_root ; ptr ; ptr=ptr->next) {
 				res |= db_timer_udomain(ptr->d);
@@ -968,7 +968,7 @@ int ul_db_clean_udomains(void)
 	int res = 0;
 	dlist_t* ptr;
 
-	get_act_time(); /* Get and save actual time */
+	ul_get_act_time(); /* Get and save actual time */
 
 	for( ptr=_ksr_ul_root ; ptr ; ptr=ptr->next)
 		res |= db_timer_udomain(ptr->d);

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 172 - 172
src/modules/usrloc/ucontact.c


+ 131 - 129
src/modules/usrloc/udomain.c

@@ -318,7 +318,7 @@ static inline ucontact_info_t* dbrow2info(db_val_t *vals, str *contact, int rcon
 		ci.sock = grep_sock_info( &host, (unsigned short)port, proto);
 		if (ci.sock==0) {
 			LM_DBG("non-local socket <%s>...ignoring\n", p);
-			if (skip_remote_socket) {
+			if (ul_skip_remote_socket) {
 				return 0;
 			}
 		}
@@ -400,27 +400,27 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
 	urecord_t* r;
 	ucontact_t* c;
 
-	columns[0] = &user_col;
-	columns[1] = &contact_col;
-	columns[2] = &expires_col;
-	columns[3] = &q_col;
-	columns[4] = &callid_col;
-	columns[5] = &cseq_col;
-	columns[6] = &flags_col;
-	columns[7] = &cflags_col;
-	columns[8] = &user_agent_col;
-	columns[9] = &received_col;
-	columns[10] = &path_col;
-	columns[11] = &sock_col;
-	columns[12] = &methods_col;
-	columns[13] = &last_mod_col;
-	columns[14] = &ruid_col;
-	columns[15] = &instance_col;
-	columns[16] = &reg_id_col;
-	columns[17] = &srv_id_col;
-	columns[18] = &con_id_col;
-	columns[19] = &keepalive_col;
-	columns[20] = &domain_col;
+	columns[0] = &ul_user_col;
+	columns[1] = &ul_contact_col;
+	columns[2] = &ul_expires_col;
+	columns[3] = &ul_q_col;
+	columns[4] = &ul_callid_col;
+	columns[5] = &ul_cseq_col;
+	columns[6] = &ul_flags_col;
+	columns[7] = &ul_cflags_col;
+	columns[8] = &ul_user_agent_col;
+	columns[9] = &ul_received_col;
+	columns[10] = &ul_path_col;
+	columns[11] = &ul_sock_col;
+	columns[12] = &ul_methods_col;
+	columns[13] = &ul_last_mod_col;
+	columns[14] = &ul_ruid_col;
+	columns[15] = &ul_instance_col;
+	columns[16] = &ul_reg_id_col;
+	columns[17] = &ul_srv_id_col;
+	columns[18] = &ul_con_id_col;
+	columns[19] = &ul_keepalive_col;
+	columns[20] = &ul_domain_col;
 
 	if (ul_dbf.use_table(_c, _d->name) < 0) {
 		LM_ERR("sql use_table failed\n");
@@ -433,7 +433,7 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
 
 	if (ul_db_srvid) {
 		LM_NOTICE("filtered by server_id[%d]\n", server_id);
-		keys[0] = &srv_id_col;
+		keys[0] = &ul_srv_id_col;
 		ops[0] = OP_EQ;
 		vals[0].type = DB1_INT;
 		vals[0].nul = 0;
@@ -444,7 +444,7 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
 		if (ul_dbf.query(_c, (ul_db_srvid)?(keys):(0),
 							(ul_db_srvid)?(ops):(0), (ul_db_srvid)?(vals):(0),
 							columns, (ul_db_srvid)?(1):(0),
-							(use_domain)?(21):(20), 0, 0) < 0)
+							(ul_use_domain)?(21):(20), 0, 0) < 0)
 		{
 			LM_ERR("db_query (1) failed\n");
 			return -1;
@@ -457,7 +457,7 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
 		if (ul_dbf.query(_c, (ul_db_srvid)?(keys):(0),
 							(ul_db_srvid)?(ops):(0), (ul_db_srvid)?(vals):(0),
 							columns, (ul_db_srvid)?(1):(0),
-							(use_domain)?(21):(20), 0, &res) < 0)
+							(ul_use_domain)?(21):(20), 0, &res) < 0)
 		{
 			LM_ERR("db_query failed\n");
 			return -1;
@@ -492,7 +492,7 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
 				continue;
 			}
 
-			if (use_domain) {
+			if (ul_use_domain) {
 				domain = (char*)VAL_STRING(ROW_VALUES(row) + 20);
 				if (VAL_NULL(ROW_VALUES(row)+17) || domain==0 || domain[0]==0){
 					LM_CRIT("empty domain record for user %.*s...skipping\n",
@@ -585,11 +585,11 @@ urecord_t* db_load_urecord(db1_con_t* _c, udomain_t* _d, str *_aor)
 	urecord_t* r;
 	ucontact_t* c;
 
-	keys[0] = &user_col;
+	keys[0] = &ul_user_col;
 	vals[0].type = DB1_STR;
 	vals[0].nul = 0;
-	if (use_domain) {
-		keys[1] = &domain_col;
+	if (ul_use_domain) {
+		keys[1] = &ul_domain_col;
 		vals[1].type = DB1_STR;
 		vals[1].nul = 0;
 		domain = memchr(_aor->s, '@', _aor->len);
@@ -606,37 +606,37 @@ urecord_t* db_load_urecord(db1_con_t* _c, udomain_t* _d, str *_aor)
 		vals[0].val.str_val = *_aor;
 	}
 
-	columns[0] = &contact_col;
-	columns[1] = &expires_col;
-	columns[2] = &q_col;
-	columns[3] = &callid_col;
-	columns[4] = &cseq_col;
-	columns[5] = &flags_col;
-	columns[6] = &cflags_col;
-	columns[7] = &user_agent_col;
-	columns[8] = &received_col;
-	columns[9] = &path_col;
-	columns[10] = &sock_col;
-	columns[11] = &methods_col;
-	columns[12] = &last_mod_col;
-	columns[13] = &ruid_col;
-	columns[14] = &instance_col;
-	columns[15] = &reg_id_col;
-	columns[16] = &srv_id_col;
-	columns[17] = &con_id_col;
-	columns[18] = &keepalive_col;
-
-	if (desc_time_order)
-		order = &last_mod_col;
+	columns[0] = &ul_contact_col;
+	columns[1] = &ul_expires_col;
+	columns[2] = &ul_q_col;
+	columns[3] = &ul_callid_col;
+	columns[4] = &ul_cseq_col;
+	columns[5] = &ul_flags_col;
+	columns[6] = &ul_cflags_col;
+	columns[7] = &ul_user_agent_col;
+	columns[8] = &ul_received_col;
+	columns[9] = &ul_path_col;
+	columns[10] = &ul_sock_col;
+	columns[11] = &ul_methods_col;
+	columns[12] = &ul_last_mod_col;
+	columns[13] = &ul_ruid_col;
+	columns[14] = &ul_instance_col;
+	columns[15] = &ul_reg_id_col;
+	columns[16] = &ul_srv_id_col;
+	columns[17] = &ul_con_id_col;
+	columns[18] = &ul_keepalive_col;
+
+	if (ul_desc_time_order)
+		order = &ul_last_mod_col;
 	else
-		order = &q_col;
+		order = &ul_q_col;
 
 	if (ul_dbf.use_table(_c, _d->name) < 0) {
 		LM_ERR("failed to use table %.*s\n", _d->name->len, _d->name->s);
 		return 0;
 	}
 
-	if (ul_dbf.query(_c, keys, 0, vals, columns, (use_domain)?2:1, 19, order,
+	if (ul_dbf.query(_c, keys, 0, vals, columns, (ul_use_domain)?2:1, 19, order,
 				&res) < 0) {
 		LM_ERR("db_query failed\n");
 		return 0;
@@ -785,37 +785,37 @@ urecord_t* db_load_urecord_by_ruid(db1_con_t* _c, udomain_t* _d, str *_ruid)
 	urecord_t* r;
 	ucontact_t* c;
 
-	keys[0] = &ruid_col;
+	keys[0] = &ul_ruid_col;
 	vals[0].type = DB1_STR;
 	vals[0].nul = 0;
 	vals[0].val.str_val = *_ruid;
 
-	columns[0] = &contact_col;
-	columns[1] = &expires_col;
-	columns[2] = &q_col;
-	columns[3] = &callid_col;
-	columns[4] = &cseq_col;
-	columns[5] = &flags_col;
-	columns[6] = &cflags_col;
-	columns[7] = &user_agent_col;
-	columns[8] = &received_col;
-	columns[9] = &path_col;
-	columns[10] = &sock_col;
-	columns[11] = &methods_col;
-	columns[12] = &last_mod_col;
-	columns[13] = &ruid_col;
-	columns[14] = &instance_col;
-	columns[15] = &reg_id_col;
-	columns[16] = &srv_id_col;
-	columns[17] = &con_id_col;
-	columns[18] = &keepalive_col;
-	columns[19] = &user_col;
-	columns[20] = &domain_col;
-
-	if (desc_time_order)
-		order = &last_mod_col;
+	columns[0] = &ul_contact_col;
+	columns[1] = &ul_expires_col;
+	columns[2] = &ul_q_col;
+	columns[3] = &ul_callid_col;
+	columns[4] = &ul_cseq_col;
+	columns[5] = &ul_flags_col;
+	columns[6] = &ul_cflags_col;
+	columns[7] = &ul_user_agent_col;
+	columns[8] = &ul_received_col;
+	columns[9] = &ul_path_col;
+	columns[10] = &ul_sock_col;
+	columns[11] = &ul_methods_col;
+	columns[12] = &ul_last_mod_col;
+	columns[13] = &ul_ruid_col;
+	columns[14] = &ul_instance_col;
+	columns[15] = &ul_reg_id_col;
+	columns[16] = &ul_srv_id_col;
+	columns[17] = &ul_con_id_col;
+	columns[18] = &ul_keepalive_col;
+	columns[19] = &ul_user_col;
+	columns[20] = &ul_domain_col;
+
+	if (ul_desc_time_order)
+		order = &ul_last_mod_col;
 	else
-		order = &q_col;
+		order = &ul_q_col;
 
 	if (ul_dbf.use_table(_c, _d->name) < 0) {
 		LM_ERR("failed to use table %.*s\n", _d->name->len, _d->name->s);
@@ -850,7 +850,7 @@ urecord_t* db_load_urecord_by_ruid(db1_con_t* _c, udomain_t* _d, str *_ruid)
 	aor.s = (char*)VAL_STRING(ROW_VALUES(row) + 19);
 	aor.len = strlen(aor.s);
 
-	if (use_domain) {
+	if (ul_use_domain) {
 		domain.s = (char*)VAL_STRING(ROW_VALUES(row) + 20);
 		if (VAL_NULL(ROW_VALUES(row)+20) || domain.s==0 || domain.s[0]==0){
 			LM_CRIT("empty domain record for user %.*s...skipping\n",
@@ -914,44 +914,44 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d)
 	char ruidbuf[RUIDBUF_SIZE];
 	str ruid;
 
-	if (db_mode!=DB_ONLY) {
+	if (ul_db_mode!=DB_ONLY) {
 		return 0;
 	}
 
-	columns[0] = &user_col;
-	columns[1] = &contact_col;
-	columns[2] = &expires_col;
-	columns[3] = &q_col;
-	columns[4] = &callid_col;
-	columns[5] = &cseq_col;
-	columns[6] = &flags_col;
-	columns[7] = &cflags_col;
-	columns[8] = &user_agent_col;
-	columns[9] = &received_col;
-	columns[10] = &path_col;
-	columns[11] = &sock_col;
-	columns[12] = &methods_col;
-	columns[13] = &last_mod_col;
-	columns[14] = &ruid_col;
-	columns[15] = &instance_col;
-	columns[16] = &reg_id_col;
-	columns[17] = &srv_id_col;
-	columns[18] = &con_id_col;
-	columns[19] = &keepalive_col;
-	columns[20] = &domain_col;
-
-	query_cols[0] = &expires_col;
+	columns[0] = &ul_user_col;
+	columns[1] = &ul_contact_col;
+	columns[2] = &ul_expires_col;
+	columns[3] = &ul_q_col;
+	columns[4] = &ul_callid_col;
+	columns[5] = &ul_cseq_col;
+	columns[6] = &ul_flags_col;
+	columns[7] = &ul_cflags_col;
+	columns[8] = &ul_user_agent_col;
+	columns[9] = &ul_received_col;
+	columns[10] = &ul_path_col;
+	columns[11] = &ul_sock_col;
+	columns[12] = &ul_methods_col;
+	columns[13] = &ul_last_mod_col;
+	columns[14] = &ul_ruid_col;
+	columns[15] = &ul_instance_col;
+	columns[16] = &ul_reg_id_col;
+	columns[17] = &ul_srv_id_col;
+	columns[18] = &ul_con_id_col;
+	columns[19] = &ul_keepalive_col;
+	columns[20] = &ul_domain_col;
+
+	query_cols[0] = &ul_expires_col;
 	query_ops[0] = "<";
 	query_vals[0].nul = 0;
-	UL_DB_EXPIRES_SET(&query_vals[0], act_time + 1 - ul_rm_expired_delay);
+	UL_DB_EXPIRES_SET(&query_vals[0], ul_act_time + 1 - ul_rm_expired_delay);
 
-	query_cols[1] = &expires_col;
+	query_cols[1] = &ul_expires_col;
 	query_ops[1] = OP_NEQ;
 	query_vals[1].nul = 0;
 	UL_DB_EXPIRES_SET(&query_vals[1], 0);
 
 	if (ul_db_srvid != 0) {
-		query_cols[2] = &srv_id_col;
+		query_cols[2] = &ul_srv_id_col;
 		query_ops[2] = OP_EQ;
 		query_vals[2].type = DB1_INT;
 		query_vals[2].nul = 0;
@@ -969,7 +969,8 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d)
 #endif
 
 	if (DB_CAPABILITY(ul_dbf, DB_CAP_FETCH)) {
-		if (ul_dbf.query(_c, query_cols, query_ops, query_vals, columns, key_num, (use_domain)?(21):(20), 0,
+		if (ul_dbf.query(_c, query_cols, query_ops, query_vals, columns, key_num,
+					(ul_use_domain)?(21):(20), 0,
 		0) < 0) {
 			LM_ERR("db_query (1) failed\n");
 			return -1;
@@ -979,7 +980,8 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d)
 			return -1;
 		}
 	} else {
-		if (ul_dbf.query(_c, query_cols, query_ops, query_vals, columns, key_num, (use_domain)?(21):(20), 0,
+		if (ul_dbf.query(_c, query_cols, query_ops, query_vals, columns, key_num,
+					(ul_use_domain)?(21):(20), 0,
 		&res) < 0) {
 			LM_ERR("db_query failed\n");
 			return -1;
@@ -1095,18 +1097,18 @@ int db_timer_udomain(udomain_t* _d)
 	/* call contact expired call back for a domain before deleting database rows */
 	udomain_contact_expired_cb(ul_dbh, _d);
 
-	keys[0] = &expires_col;
+	keys[0] = &ul_expires_col;
 	ops[0] = "<";
 	vals[0].nul = 0;
-	UL_DB_EXPIRES_SET(&vals[0], act_time + 1 - ul_rm_expired_delay);
+	UL_DB_EXPIRES_SET(&vals[0], ul_act_time + 1 - ul_rm_expired_delay);
 
-	keys[1] = &expires_col;
+	keys[1] = &ul_expires_col;
 	ops[1] = OP_NEQ;
 	vals[1].nul = 0;
 	UL_DB_EXPIRES_SET(&vals[1], 0);
 
 	if (ul_db_srvid != 0) {
-		keys[2] = &srv_id_col;
+		keys[2] = &ul_srv_id_col;
 		ops[2] = OP_EQ;
 		vals[2].type = DB1_INT;
 		vals[2].nul = 0;
@@ -1144,10 +1146,10 @@ int testdb_udomain(db1_con_t* con, udomain_t* d)
 		return -1;
 	}
 
-	key[0] = &user_col;
-	key[1] = &domain_col;
+	key[0] = &ul_user_col;
+	key[1] = &ul_domain_col;
 
-	col[0] = &user_col;
+	col[0] = &ul_user_col;
 
 	VAL_TYPE(val) = DB1_STRING;
 	VAL_NULL(val) = 0;
@@ -1157,7 +1159,7 @@ int testdb_udomain(db1_con_t* con, udomain_t* d)
 	VAL_NULL(val+1) = 0;
 	VAL_STRING(val+1) = "dummy_domain";
 
-	if(ul_dbf.query(con, key, 0, val, col, (use_domain)?2:1, 1, 0, &res)<0) {
+	if(ul_dbf.query(con, key, 0, val, col, (ul_use_domain)?2:1, 1, 0, &res)<0) {
 		if(res) ul_dbf.free_result( con, res);
 		LM_ERR("failure in db_query\n");
 		return -1;
@@ -1246,7 +1248,7 @@ void mem_timer_udomain(udomain_t* _d, int istart, int istep)
 void lock_udomain(udomain_t* _d, str* _aor)
 {
 	unsigned int sl;
-	if (db_mode!=DB_ONLY)
+	if (ul_db_mode!=DB_ONLY)
 	{
 		sl = ul_get_aorhash(_aor) & (_d->size - 1);
 
@@ -1263,7 +1265,7 @@ void lock_udomain(udomain_t* _d, str* _aor)
 void unlock_udomain(udomain_t* _d, str* _aor)
 {
 	unsigned int sl;
-	if (db_mode!=DB_ONLY)
+	if (ul_db_mode!=DB_ONLY)
 	{
 		sl = ul_get_aorhash(_aor) & (_d->size - 1);
 		rec_lock_release(&_d->table[sl].rlock);
@@ -1277,7 +1279,7 @@ void unlock_udomain(udomain_t* _d, str* _aor)
  */
 void lock_ulslot(udomain_t* _d, int i)
 {
-	if (db_mode!=DB_ONLY)
+	if (ul_db_mode!=DB_ONLY)
 		rec_lock_get(&_d->table[i].rlock);
 }
 
@@ -1289,7 +1291,7 @@ void lock_ulslot(udomain_t* _d, int i)
  */
 void unlock_ulslot(udomain_t* _d, int i)
 {
-	if (db_mode!=DB_ONLY)
+	if (ul_db_mode!=DB_ONLY)
 		rec_lock_release(&_d->table[i].rlock);
 }
 
@@ -1304,7 +1306,7 @@ void unlock_ulslot(udomain_t* _d, int i)
  */
 int insert_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
 {
-	if (db_mode!=DB_ONLY) {
+	if (ul_db_mode!=DB_ONLY) {
 		if (mem_insert_urecord(_d, _aor, _r) < 0) {
 			LM_ERR("inserting record failed\n");
 			return -1;
@@ -1329,7 +1331,7 @@ int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
 	urecord_t* r;
 	ucontact_t* ptr = NULL;
 
-	if (db_mode!=DB_ONLY) {
+	if (ul_db_mode!=DB_ONLY) {
 		/* search in cache */
 		aorhash = ul_get_aorhash(_aor);
 		sl = aorhash&(_d->size-1);
@@ -1339,7 +1341,7 @@ int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
 			if((r->aorhash==aorhash) && (r->aor.len==_aor->len)
 						&& !memcmp(r->aor.s,_aor->s,_aor->len))
 			{
-				if (handle_lost_tcp)
+				if (ul_handle_lost_tcp)
 				{
 					for (ptr = r->contacts;ptr;ptr = ptr->next)
 					{
@@ -1386,7 +1388,7 @@ int get_urecord_by_ruid(udomain_t* _d, unsigned int _aorhash,
 	sl = _aorhash&(_d->size-1);
 	lock_ulslot(_d, sl);
 
-	if (db_mode!=DB_ONLY) {
+	if (ul_db_mode!=DB_ONLY) {
 		/* search in cache */
 		r = _d->table[sl].first;
 
@@ -1439,7 +1441,7 @@ int delete_urecord(udomain_t* _d, str* _aor, struct urecord* _r)
 {
 	struct ucontact* c, *t;
 
-	if (db_mode==DB_ONLY) {
+	if (ul_db_mode==DB_ONLY) {
 		if (_r==0)
 			get_static_urecord( _d, _aor, &_r);
 		if (db_delete_urecord(_r)<0) {
@@ -1531,7 +1533,7 @@ int uldb_preload_attrs(udomain_t *_d)
 #endif
 
 	if (DB_CAPABILITY(ul_dbf, DB_CAP_FETCH)) {
-		if (ul_dbf.query(ul_dbh, 0, 0, 0, columns, 0, (use_domain)?(6):(5), 0,
+		if (ul_dbf.query(ul_dbh, 0, 0, 0, columns, 0, (ul_use_domain)?(6):(5), 0,
 					0) < 0) {
 			LM_ERR("db_query (1) failed\n");
 			return -1;
@@ -1541,7 +1543,7 @@ int uldb_preload_attrs(udomain_t *_d)
 			return -1;
 		}
 	} else {
-		if (ul_dbf.query(ul_dbh, 0, 0, 0, columns, 0, (use_domain)?(6):(5), 0,
+		if (ul_dbf.query(ul_dbh, 0, 0, 0, columns, 0, (ul_use_domain)?(6):(5), 0,
 		&res) < 0) {
 			LM_ERR("db_query failed\n");
 			return -1;
@@ -1589,7 +1591,7 @@ int uldb_preload_attrs(udomain_t *_d)
 				continue;
 			}
 
-			if (use_domain) {
+			if (ul_use_domain) {
 				domain.s = (char*)VAL_STRING(ROW_VALUES(row) + 5);
 				if (VAL_NULL(ROW_VALUES(row)+5) || domain.s==0 || domain.s[0]==0){
 					LM_CRIT("empty domain record for user %.*s...skipping\n",

+ 4 - 4
src/modules/usrloc/ul_keepalive.c

@@ -75,7 +75,7 @@ extern int ul_ka_filter;
 extern int ul_ka_loglevel;
 extern pv_elem_t *ul_ka_logfmt;
 
-extern unsigned int nat_bflag;
+extern unsigned int ul_nat_bflag;
 
 static unsigned int _ul_ka_counter = 0;
 
@@ -124,10 +124,10 @@ int ul_ka_urecord(urecord_t *ur)
 		}
 		if(ul_ka_mode & ULKA_NAT) {
 			/* keepalive for natted contacts only */
-			if (nat_bflag == 0) {
+			if (ul_nat_bflag == 0) {
 				continue;
 			}
-			if ((uc->cflags & nat_bflag) != nat_bflag) {
+			if ((uc->cflags & ul_nat_bflag) != ul_nat_bflag) {
 				continue;
 			}
 		}
@@ -228,7 +228,7 @@ int ul_ka_urecord(urecord_t *ur)
  *
  */
 static int ul_ka_send(str *kamsg, dest_info_t *kadst)
-{ 
+{
 	if (kadst->proto == PROTO_UDP) {
 		return udp_send(kadst, kamsg->s, kamsg->len);
 	}

+ 11 - 11
src/modules/usrloc/ul_rpc.c

@@ -359,7 +359,7 @@ static inline int rpc_fix_aor(str *aor)
 	char *p;
 
 	p = memchr( aor->s, '@', aor->len);
-	if (use_domain) {
+	if (ul_use_domain) {
 		if (p==NULL)
 			return -1;
 	} else {
@@ -421,7 +421,7 @@ static void ul_rpc_lookup(rpc_t* rpc, void* ctx)
 		return;
 	}
 
-	get_act_time();
+	ul_get_act_time();
 	rpl_tree = 0;
 
 	if (rpc->add(ctx, "{", &th) < 0)
@@ -443,7 +443,7 @@ static void ul_rpc_lookup(rpc_t* rpc, void* ctx)
 
 	/* We have contacts, list them */
 	for( con=rec->contacts ; con ; con=con->next) {
-		if (VALID_CONTACT( con, act_time)) {
+		if (VALID_CONTACT(con, ul_act_time)) {
 			rpl_tree++;
 			if (rpc_dump_contact(rpc, ctx, ih, con) == -1) {
 				release_urecord(rec);
@@ -700,14 +700,14 @@ static void ul_rpc_add(rpc_t* rpc, void* ctx)
 		}
 	}
 
-	get_act_time();
+	ul_get_act_time();
 
 	ci.callid = &rpc_ul_cid;
 	ci.user_agent = &rpc_ul_ua;
 	ci.cseq = RPC_UL_CSEQ;
 	/* 0 expires means permanent contact */
 	if (ci.expires!=0)
-		ci.expires += act_time;
+		ci.expires += ul_act_time;
 
 	if (c) {
 		if (update_ucontact( r, c, &ci) < 0)
@@ -747,7 +747,7 @@ static void ul_rpc_db_users(rpc_t* rpc, void* ctx)
 	db1_res_t* res = NULL;
 	int count = 0;
 
-	if (db_mode == NO_DB) {
+	if (ul_db_mode == NO_DB) {
 		rpc->fault(ctx, 500, "Command is not supported in db_mode=0");
 		return;
 	}
@@ -757,7 +757,7 @@ static void ul_rpc_db_users(rpc_t* rpc, void* ctx)
 		return;
 	}
 
-	if (user_col.len + domain_col.len + table.len + 32 > QUERY_LEN) {
+	if (ul_user_col.len + ul_domain_col.len + table.len + 32 > QUERY_LEN) {
 		rpc->fault(ctx, 500, "Too long database query");
 		return;
 	}
@@ -774,8 +774,8 @@ static void ul_rpc_db_users(rpc_t* rpc, void* ctx)
 	memset(query, 0, QUERY_LEN);
 	query_str.len = snprintf(query, QUERY_LEN,
 			"SELECT COUNT(DISTINCT %.*s, %.*s) FROM %.*s WHERE (UNIX_TIMESTAMP(expires) = 0) OR (expires > NOW())",
-			user_col.len, user_col.s,
-			domain_col.len, domain_col.s,
+			ul_user_col.len, ul_user_col.s,
+			ul_domain_col.len, ul_domain_col.s,
 			table.len, table.s);
 	query_str.s = query;
 	if (ul_dbf.raw_query(ul_dbh, &query_str, &res) < 0 || res==NULL) {
@@ -803,7 +803,7 @@ static void ul_rpc_db_contacts(rpc_t* rpc, void* ctx)
 	db1_res_t* res = NULL;
 	int count = 0;
 
-	if (db_mode == NO_DB) {
+	if (ul_db_mode == NO_DB) {
 		rpc->fault(ctx, 500, "Command is not supported in db_mode=0");
 		return;
 	}
@@ -857,7 +857,7 @@ static void ul_rpc_db_expired_contacts(rpc_t* rpc, void* ctx)
 	db1_res_t* res = NULL;
 	int count = 0;
 
-	if (db_mode == NO_DB) {
+	if (ul_db_mode == NO_DB) {
 		rpc->fault(ctx, 500, "Command is not supported in db_mode=0");
 		return;
 	}

+ 37 - 34
src/modules/usrloc/urecord.c

@@ -96,7 +96,7 @@ void free_urecord(urecord_t* _r)
 	}
 
 	/* if mem cache is not used, the urecord struct is static*/
-	if (db_mode!=DB_ONLY) {
+	if (ul_db_mode!=DB_ONLY) {
 		if (_r->aor.s) shm_free(_r->aor.s);
 		shm_free(_r);
 	}
@@ -153,7 +153,7 @@ ucontact_t* mem_insert_ucontact(urecord_t* _r, str* _c, ucontact_info_t* _ci)
 
 	ptr = _r->contacts;
 
-	if (!desc_time_order) {
+	if (!ul_desc_time_order) {
 		while(ptr) {
 			if (ptr->q < c->q) break;
 			prev = ptr;
@@ -279,12 +279,12 @@ static inline void nodb_timer(urecord_t* _r)
 	ptr = _r->contacts;
 
 	while(ptr) {
-		if (handle_lost_tcp && is_valid_tcpconn(ptr) && !is_tcp_alive(ptr)) {
+		if (ul_handle_lost_tcp && is_valid_tcpconn(ptr) && !is_tcp_alive(ptr)) {
 			LM_DBG("tcp connection has been lost, expiring contact %.*s\n", ptr->c.len, ptr->c.s);
 			ptr->expires = UL_EXPIRED_TIME;
 		}
 
-		if (!VALID_CONTACT(ptr, act_time)) {
+		if (!VALID_CONTACT(ptr, ul_act_time)) {
 			/* run callbacks for EXPIRE event */
 			if (!(ptr->flags&FL_EXPCLB) && exists_ulcb_type(UL_CONTACT_EXPIRE)) {
 				run_ul_callbacks( UL_CONTACT_EXPIRE, ptr);
@@ -295,7 +295,7 @@ static inline void nodb_timer(urecord_t* _r)
 				ptr->aor->len, ZSW(ptr->aor->s),
 				ptr->c.len, ZSW(ptr->c.s));
 
-			if (close_expired_tcp && is_valid_tcpconn(ptr)) {
+			if (ul_close_expired_tcp && is_valid_tcpconn(ptr)) {
 				close_connection(ptr->tcpconn_id);
 			}
 
@@ -326,7 +326,7 @@ static inline void wt_timer(urecord_t* _r)
 	ptr = _r->contacts;
 
 	while(ptr) {
-		if (!VALID_CONTACT(ptr, act_time)) {
+		if (!VALID_CONTACT(ptr, ul_act_time)) {
 			/* run callbacks for EXPIRE event */
 			if (exists_ulcb_type(UL_CONTACT_EXPIRE)) {
 				run_ul_callbacks( UL_CONTACT_EXPIRE, ptr);
@@ -336,7 +336,7 @@ static inline void wt_timer(urecord_t* _r)
 				ptr->aor->len, ZSW(ptr->aor->s),
 				ptr->c.len, ZSW(ptr->c.s));
 
-			if (close_expired_tcp && is_valid_tcpconn(ptr)) {
+			if (ul_close_expired_tcp && is_valid_tcpconn(ptr)) {
 				close_connection(ptr->tcpconn_id);
 			}
 
@@ -373,12 +373,12 @@ static inline void wb_timer(urecord_t* _r)
 	ptr = _r->contacts;
 
 	while(ptr) {
-		if (handle_lost_tcp && is_valid_tcpconn(ptr) && !is_tcp_alive(ptr)) {
+		if (ul_handle_lost_tcp && is_valid_tcpconn(ptr) && !is_tcp_alive(ptr)) {
 			LM_DBG("tcp connection has been lost, expiring contact %.*s\n", ptr->c.len, ptr->c.s);
 			ptr->expires = UL_EXPIRED_TIME;
 		}
 
-		if (!VALID_CONTACT(ptr, act_time)) {
+		if (!VALID_CONTACT(ptr, ul_act_time)) {
 			/* run callbacks for EXPIRE event */
 			if (exists_ulcb_type(UL_CONTACT_EXPIRE)) {
 				run_ul_callbacks( UL_CONTACT_EXPIRE, ptr);
@@ -389,7 +389,7 @@ static inline void wb_timer(urecord_t* _r)
 				ptr->c.len, ZSW(ptr->c.s));
 			update_stat( _r->slot->d->expires, 1);
 
-			if (close_expired_tcp && is_valid_tcpconn(ptr)) {
+			if (ul_close_expired_tcp && is_valid_tcpconn(ptr)) {
 				close_connection(ptr->tcpconn_id);
 			}
 
@@ -452,16 +452,19 @@ static inline void wb_timer(urecord_t* _r)
  */
 void timer_urecord(urecord_t* _r)
 {
-	switch(db_mode) {
-	case DB_READONLY:
-	case NO_DB:         nodb_timer(_r);
-						break;
-	/* use also the write_back timer routine to handle the failed
-	 * realtime inserts/updates */
-	case WRITE_THROUGH: wb_timer(_r); /*wt_timer(_r);*/
-						break;
-	case WRITE_BACK:    wb_timer(_r);
-						break;
+	switch(ul_db_mode) {
+		case DB_READONLY:
+		case NO_DB:
+			nodb_timer(_r);
+			break;
+		/* use also the write_back timer routine to handle the failed
+		* realtime inserts/updates */
+		case WRITE_THROUGH:
+			wb_timer(_r); /*wt_timer(_r);*/
+			break;
+		case WRITE_BACK:
+			wb_timer(_r);
+			break;
 	}
 }
 
@@ -477,14 +480,14 @@ int db_delete_urecord(urecord_t* _r)
 	db_val_t vals[2];
 	char* dom;
 
-	keys[0] = &user_col;
-	keys[1] = &domain_col;
+	keys[0] = &ul_user_col;
+	keys[1] = &ul_domain_col;
 	vals[0].type = DB1_STR;
 	vals[0].nul = 0;
 	vals[0].val.str_val.s = _r->aor.s;
 	vals[0].val.str_val.len = _r->aor.len;
 
-	if (use_domain) {
+	if (ul_use_domain) {
 		dom = memchr(_r->aor.s, '@', _r->aor.len);
 		vals[0].val.str_val.len = dom - _r->aor.s;
 
@@ -499,7 +502,7 @@ int db_delete_urecord(urecord_t* _r)
 		return -1;
 	}
 
-	if (ul_dbf.delete(ul_dbh, keys, 0, vals, (use_domain) ? (2) : (1)) < 0) {
+	if (ul_dbf.delete(ul_dbh, keys, 0, vals, (ul_use_domain) ? (2) : (1)) < 0) {
 		LM_ERR("failed to delete from database\n");
 		return -1;
 	}
@@ -517,7 +520,7 @@ int db_delete_urecord_by_ruid(str *_table, str *_ruid)
 	db_key_t keys[1];
 	db_val_t vals[1];
 
-	keys[0] = &ruid_col;
+	keys[0] = &ul_ruid_col;
 	vals[0].type = DB1_STR;
 	vals[0].nul = 0;
 	vals[0].val.str_val.s = _ruid->s;
@@ -551,7 +554,7 @@ int db_delete_urecord_by_ruid(str *_table, str *_ruid)
  */
 void release_urecord(urecord_t* _r)
 {
-	if (db_mode==DB_ONLY) {
+	if (ul_db_mode==DB_ONLY) {
 		free_urecord(_r);
 	} else if (_r->contacts == 0) {
 		mem_delete_urecord(_r->slot->d, _r);
@@ -576,7 +579,7 @@ int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci,
 		return -1;
 	}
 
-	if (db_mode==DB_ONLY) {
+	if (ul_db_mode==DB_ONLY) {
 		/* urecord is static generate a copy for later */
 		memcpy(&_ur, _r, sizeof(struct urecord));
 
@@ -592,7 +595,7 @@ int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci,
 		run_ul_callbacks( UL_CONTACT_INSERT, *_c);
 	}
 
-	switch (db_mode) {
+	switch (ul_db_mode) {
 		case WRITE_THROUGH:
 			if (db_insert_ucontact(*_c) < 0) {
 				LM_ERR("failed to insert in database\n");
@@ -622,7 +625,7 @@ int delete_ucontact(urecord_t* _r, struct ucontact* _c)
 	int ret = 0;
 	struct urecord _ur;
 
-	if (db_mode==DB_ONLY) {
+	if (ul_db_mode==DB_ONLY) {
 		/* urecord is static generate a copy for later */
 		memcpy(&_ur, _r, sizeof(struct urecord));
 	}
@@ -631,13 +634,13 @@ int delete_ucontact(urecord_t* _r, struct ucontact* _c)
 		run_ul_callbacks( UL_CONTACT_DELETE, _c);
 	}
 
-	if (db_mode==DB_ONLY) {
+	if (ul_db_mode==DB_ONLY) {
 		/* urecord was static restore copy */
 		memcpy(_r, &_ur, sizeof(struct urecord));
 	}
 
 	if (st_delete_ucontact(_c) > 0) {
-		if (db_mode == WRITE_THROUGH || db_mode==DB_ONLY) {
+		if (ul_db_mode == WRITE_THROUGH || ul_db_mode==DB_ONLY) {
 			if (db_delete_ucontact(_c) < 0) {
 				LM_ERR("failed to remove contact from database\n");
 				ret = -1;
@@ -653,7 +656,7 @@ int delete_ucontact(urecord_t* _r, struct ucontact* _c)
 
 int delete_urecord_by_ruid(udomain_t* _d, str *_ruid)
 {
-	if (db_mode != DB_ONLY) {
+	if (ul_db_mode != DB_ONLY) {
 		LM_ERR("delete_urecord_by_ruid currently available only in db_mode=3\n");
 		return -1;
 	}
@@ -797,8 +800,8 @@ int get_ucontact(urecord_t* _r, str* _c, str* _callid, str* _path, int _cseq,
 			if (_cseq<ptr->cseq)
 				return -1;
 			if (_cseq==ptr->cseq) {
-				get_act_time();
-				return (ptr->last_modified+cseq_delay>act_time)?-2:-1;
+				ul_get_act_time();
+				return (ptr->last_modified+cseq_delay>ul_act_time)?-2:-1;
 			}
 		}
 		*_co = ptr;

+ 4 - 4
src/modules/usrloc/usrloc.c

@@ -46,7 +46,7 @@ int bind_usrloc(usrloc_api_t* api)
 		LM_ERR("invalid parameter value\n");
 		return -1;
 	}
-	if (init_flag==0) {
+	if (ul_init_flag==0) {
 		LM_ERR("configuration error - trying to bind to usrloc module"
 				" before being initialized\n");
 		return -1;
@@ -76,9 +76,9 @@ int bind_usrloc(usrloc_api_t* api)
 	api->refresh_keepalive        = ul_refresh_keepalive;
 	api->set_max_partition        = ul_set_max_partition;
 
-	api->use_domain = use_domain;
-	api->db_mode    = db_mode;
-	api->nat_flag   = nat_bflag;
+	api->use_domain = ul_use_domain;
+	api->db_mode    = ul_db_mode;
+	api->nat_flag   = ul_nat_bflag;
 
 	return 0;
 }

+ 89 - 89
src/modules/usrloc/usrloc_mod.c

@@ -134,28 +134,28 @@ sruid_t _ul_sruid;
  * Module parameters and their default values
  */
 
-str ruid_col        = str_init(RUID_COL); 		/*!< Name of column containing record unique id */
-str user_col        = str_init(USER_COL); 		/*!< Name of column containing usernames */
-str domain_col      = str_init(DOMAIN_COL); 	/*!< Name of column containing domains */
-str contact_col     = str_init(CONTACT_COL);	/*!< Name of column containing contact addresses */
-str expires_col     = str_init(EXPIRES_COL);	/*!< Name of column containing expires values */
-str q_col           = str_init(Q_COL);			/*!< Name of column containing q values */
-str callid_col      = str_init(CALLID_COL);		/*!< Name of column containing callid string */
-str cseq_col        = str_init(CSEQ_COL);		/*!< Name of column containing cseq values */
-str flags_col       = str_init(FLAGS_COL);		/*!< Name of column containing internal flags */
-str cflags_col      = str_init(CFLAGS_COL);		/*!< Name of column containing contact flags */
-str user_agent_col  = str_init(USER_AGENT_COL);	/*!< Name of column containing user agent string */
-str received_col    = str_init(RECEIVED_COL);	/*!< Name of column containing transport info of REGISTER */
-str path_col        = str_init(PATH_COL);		/*!< Name of column containing the Path header */
-str sock_col        = str_init(SOCK_COL);		/*!< Name of column containing the received socket */
-str methods_col     = str_init(METHODS_COL);	/*!< Name of column containing the supported methods */
-str instance_col    = str_init(INSTANCE_COL);	/*!< Name of column containing the SIP instance value */
-str reg_id_col      = str_init(REG_ID_COL);		/*!< Name of column containing the reg-id value */
-str last_mod_col    = str_init(LAST_MOD_COL);	/*!< Name of column containing the last modified date */
-str srv_id_col      = str_init(SRV_ID_COL);		/*!< Name of column containing the server id value */
-str con_id_col      = str_init(CON_ID_COL);		/*!< Name of column containing the connection id value */
-str keepalive_col   = str_init(KEEPALIVE_COL);	/*!< Name of column containing the keepalive value */
-str partition_col   = str_init(PARTITION_COL);	/*!< Name of column containing the partition value */
+str ul_ruid_col        = str_init(RUID_COL); 		/*!< Name of column containing record unique id */
+str ul_user_col        = str_init(USER_COL); 		/*!< Name of column containing usernames */
+str ul_domain_col      = str_init(DOMAIN_COL); 	/*!< Name of column containing domains */
+str ul_contact_col     = str_init(CONTACT_COL);	/*!< Name of column containing contact addresses */
+str ul_expires_col     = str_init(EXPIRES_COL);	/*!< Name of column containing expires values */
+str ul_q_col           = str_init(Q_COL);			/*!< Name of column containing q values */
+str ul_callid_col      = str_init(CALLID_COL);		/*!< Name of column containing callid string */
+str ul_cseq_col        = str_init(CSEQ_COL);		/*!< Name of column containing cseq values */
+str ul_flags_col       = str_init(FLAGS_COL);		/*!< Name of column containing internal flags */
+str ul_cflags_col      = str_init(CFLAGS_COL);		/*!< Name of column containing contact flags */
+str ul_user_agent_col  = str_init(USER_AGENT_COL);	/*!< Name of column containing user agent string */
+str ul_received_col    = str_init(RECEIVED_COL);	/*!< Name of column containing transport info of REGISTER */
+str ul_path_col        = str_init(PATH_COL);		/*!< Name of column containing the Path header */
+str ul_sock_col        = str_init(SOCK_COL);		/*!< Name of column containing the received socket */
+str ul_methods_col     = str_init(METHODS_COL);	/*!< Name of column containing the supported methods */
+str ul_instance_col    = str_init(INSTANCE_COL);	/*!< Name of column containing the SIP instance value */
+str ul_reg_id_col      = str_init(REG_ID_COL);		/*!< Name of column containing the reg-id value */
+str ul_last_mod_col    = str_init(LAST_MOD_COL);	/*!< Name of column containing the last modified date */
+str ul_srv_id_col      = str_init(SRV_ID_COL);		/*!< Name of column containing the server id value */
+str ul_con_id_col      = str_init(CON_ID_COL);		/*!< Name of column containing the connection id value */
+str ul_keepalive_col   = str_init(KEEPALIVE_COL);	/*!< Name of column containing the keepalive value */
+str ul_partition_col   = str_init(PARTITION_COL);	/*!< Name of column containing the partition value */
 
 str ulattrs_user_col   = str_init(ULATTRS_USER_COL);   /*!< Name of column containing username */
 str ulattrs_domain_col = str_init(ULATTRS_DOMAIN_COL); /*!< Name of column containing domain */
@@ -165,16 +165,16 @@ str ulattrs_atype_col  = str_init(ULATTRS_ATYPE_COL);  /*!< Name of column conta
 str ulattrs_avalue_col = str_init(ULATTRS_AVALUE_COL); /*!< Name of column containing attribute value */
 str ulattrs_last_mod_col = str_init(ULATTRS_LAST_MOD_COL);	/*!< Name of column containing the last modified date */
 
-str db_url          = str_init(DEFAULT_DB_URL);	/*!< Database URL */
-int timer_interval  = 60;				/*!< Timer interval in seconds */
-int db_mode         = 0;				/*!< Database sync scheme: 0-no db, 1-write through, 2-write back, 3-only db */
-int db_load         = 1;				/*!< Database load after restart: 1- true, 0- false (only the db_mode allows it) */
-int db_insert_update = 0;				/*!< Database : update on duplicate key instead of error */
-int use_domain      = 0;				/*!< Whether usrloc should use domain part of aor */
-int desc_time_order = 0;				/*!< By default do not enable timestamp ordering */
-int handle_lost_tcp = 0;				/*!< By default do not remove contacts before expiration time */
-int close_expired_tcp = 0;				/*!< By default do not close TCP connections for expired contacts */
-int skip_remote_socket = 0;				/*!< By default do not skip remote socket */
+str ul_db_url          = str_init(DEFAULT_DB_URL);	/*!< Database URL */
+int ul_timer_interval  = 60;				/*!< Timer interval in seconds */
+int ul_db_mode         = 0;				/*!< Database sync scheme: 0-no db, 1-write through, 2-write back, 3-only db */
+int ul_db_load         = 1;				/*!< Database load after restart: 1- true, 0- false (only the db_mode allows it) */
+int ul_db_insert_update = 0;				/*!< Database : update on duplicate key instead of error */
+int ul_use_domain      = 0;				/*!< Whether usrloc should use domain part of aor */
+int ul_desc_time_order = 0;				/*!< By default do not enable timestamp ordering */
+int ul_handle_lost_tcp = 0;				/*!< By default do not remove contacts before expiration time */
+int ul_close_expired_tcp = 0;				/*!< By default do not close TCP connections for expired contacts */
+int ul_skip_remote_socket = 0;				/*!< By default do not skip remote socket */
 
 int ul_fetch_rows = 2000;				/*!< number of rows to fetch from result */
 int ul_hash_size = 10;
@@ -182,8 +182,8 @@ int ul_db_insert_null = 0;
 int ul_db_timer_clean = 0;
 
 /* flags */
-unsigned int nat_bflag = (unsigned int)-1;
-unsigned int init_flag = 0;
+unsigned int ul_nat_bflag = (unsigned int)-1;
+unsigned int ul_init_flag = 0;
 
 db1_con_t* ul_dbh = 0; /* Database connection handle */
 db_func_t ul_dbf;
@@ -204,42 +204,42 @@ static cmd_export_t cmds[] = {
  * Exported parameters
  */
 static param_export_t params[] = {
-	{"ruid_column",         PARAM_STR, &ruid_col      },
-	{"user_column",         PARAM_STR, &user_col      },
-	{"domain_column",       PARAM_STR, &domain_col    },
-	{"contact_column",      PARAM_STR, &contact_col   },
-	{"expires_column",      PARAM_STR, &expires_col   },
-	{"q_column",            PARAM_STR, &q_col         },
-	{"callid_column",       PARAM_STR, &callid_col    },
-	{"cseq_column",         PARAM_STR, &cseq_col      },
-	{"flags_column",        PARAM_STR, &flags_col     },
-	{"cflags_column",       PARAM_STR, &cflags_col    },
-	{"db_url",              PARAM_STR, &db_url        },
-	{"timer_interval",      INT_PARAM, &timer_interval  },
-	{"db_mode",             INT_PARAM, &db_mode         },
-	{"db_load",             INT_PARAM, &db_load         },
-	{"db_insert_update",    INT_PARAM, &db_insert_update },
-	{"use_domain",          INT_PARAM, &use_domain      },
-	{"desc_time_order",     INT_PARAM, &desc_time_order },
-	{"user_agent_column",   PARAM_STR, &user_agent_col},
-	{"received_column",     PARAM_STR, &received_col  },
-	{"path_column",         PARAM_STR, &path_col      },
-	{"socket_column",       PARAM_STR, &sock_col      },
-	{"methods_column",      PARAM_STR, &methods_col   },
-	{"instance_column",     PARAM_STR, &instance_col  },
-	{"reg_id_column",       PARAM_STR, &reg_id_col    },
-	{"server_id_column",    PARAM_STR, &srv_id_col    },
-	{"connection_id_column",PARAM_STR, &con_id_col    },
-	{"keepalive_column",    PARAM_STR, &keepalive_col },
-	{"partition_column",    PARAM_STR, &partition_col },
+	{"ruid_column",         PARAM_STR, &ul_ruid_col      },
+	{"user_column",         PARAM_STR, &ul_user_col      },
+	{"domain_column",       PARAM_STR, &ul_domain_col    },
+	{"contact_column",      PARAM_STR, &ul_contact_col   },
+	{"expires_column",      PARAM_STR, &ul_expires_col   },
+	{"q_column",            PARAM_STR, &ul_q_col         },
+	{"callid_column",       PARAM_STR, &ul_callid_col    },
+	{"cseq_column",         PARAM_STR, &ul_cseq_col      },
+	{"flags_column",        PARAM_STR, &ul_flags_col     },
+	{"cflags_column",       PARAM_STR, &ul_cflags_col    },
+	{"db_url",              PARAM_STR, &ul_db_url        },
+	{"timer_interval",      INT_PARAM, &ul_timer_interval  },
+	{"db_mode",             INT_PARAM, &ul_db_mode         },
+	{"db_load",             INT_PARAM, &ul_db_load         },
+	{"db_insert_update",    INT_PARAM, &ul_db_insert_update },
+	{"use_domain",          INT_PARAM, &ul_use_domain      },
+	{"desc_time_order",     INT_PARAM, &ul_desc_time_order },
+	{"user_agent_column",   PARAM_STR, &ul_user_agent_col},
+	{"received_column",     PARAM_STR, &ul_received_col  },
+	{"path_column",         PARAM_STR, &ul_path_col      },
+	{"socket_column",       PARAM_STR, &ul_sock_col      },
+	{"methods_column",      PARAM_STR, &ul_methods_col   },
+	{"instance_column",     PARAM_STR, &ul_instance_col  },
+	{"reg_id_column",       PARAM_STR, &ul_reg_id_col    },
+	{"server_id_column",    PARAM_STR, &ul_srv_id_col    },
+	{"connection_id_column",PARAM_STR, &ul_con_id_col    },
+	{"keepalive_column",    PARAM_STR, &ul_keepalive_col },
+	{"partition_column",    PARAM_STR, &ul_partition_col },
 	{"matching_mode",       INT_PARAM, &ul_matching_mode },
-	{"cseq_delay",          INT_PARAM, &cseq_delay      },
+	{"cseq_delay",          INT_PARAM, &ul_cseq_delay      },
 	{"fetch_rows",          INT_PARAM, &ul_fetch_rows   },
 	{"hash_size",           INT_PARAM, &ul_hash_size    },
-	{"nat_bflag",           INT_PARAM, &nat_bflag       },
-	{"handle_lost_tcp",     INT_PARAM, &handle_lost_tcp },
-	{"close_expired_tcp",   INT_PARAM, &close_expired_tcp },
-	{"skip_remote_socket",  INT_PARAM, &skip_remote_socket },
+	{"nat_bflag",           INT_PARAM, &ul_nat_bflag       },
+	{"handle_lost_tcp",     INT_PARAM, &ul_handle_lost_tcp },
+	{"close_expired_tcp",   INT_PARAM, &ul_close_expired_tcp },
+	{"skip_remote_socket",  INT_PARAM, &ul_skip_remote_socket },
 	{"preload",             PARAM_STRING|USE_FUNC_PARAM, (void*)ul_preload_param},
 	{"db_update_as_insert", INT_PARAM, &ul_db_update_as_insert},
 	{"timer_procs",         INT_PARAM, &ul_timer_procs},
@@ -292,7 +292,7 @@ static int mod_init(void)
 	udomain_t* d;
 
 	if(ul_rm_expired_delay!=0) {
-		if(db_mode != DB_ONLY) {
+		if(ul_db_mode != DB_ONLY) {
 			LM_ERR("rm expired delay feature is available for db only mode\n");
 			return -1;
 		}
@@ -308,7 +308,7 @@ static int mod_init(void)
 
 #ifdef STATISTICS
 	/* register statistics */
-	if (register_module_stats( exports.name, mod_stats)!=0 ) {
+	if (register_module_stats(exports.name, mod_stats)!=0 ) {
 		LM_ERR("failed to register core statistics\n");
 		return -1;
 	}
@@ -338,22 +338,22 @@ static int mod_init(void)
 
 	/* Register cache timer */
 	if(ul_timer_procs<=0) {
-		if (timer_interval > 0) {
-			register_timer(ul_core_timer, 0, timer_interval);
+		if (ul_timer_interval > 0) {
+			register_timer(ul_core_timer, 0, ul_timer_interval);
 		}
 	} else {
 		register_sync_timers(ul_timer_procs);
 	}
 
 	/* init the callbacks list */
-	if ( init_ulcb_list() < 0) {
+	if (init_ulcb_list() < 0) {
 		LM_ERR("usrloc/callbacks initialization failed\n");
 		return -1;
 	}
 
 	/* Shall we use database ? */
-	if (db_mode != NO_DB) { /* Yes */
-		if (db_bind_mod(&db_url, &ul_dbf) < 0) { /* Find database module */
+	if (ul_db_mode != NO_DB) { /* Yes */
+		if (db_bind_mod(&ul_db_url, &ul_dbf) < 0) { /* Find database module */
 			LM_ERR("failed to bind database module\n");
 			return -1;
 		}
@@ -367,22 +367,22 @@ static int mod_init(void)
 			return -1;
 		}
 	}
-	if(db_mode==WRITE_THROUGH || db_mode==WRITE_BACK) {
+	if(ul_db_mode==WRITE_THROUGH || ul_db_mode==WRITE_BACK) {
 		if(ul_db_timer_clean!=0) {
-			if(sr_wtimer_add(ul_db_clean_timer, 0, timer_interval)<0) {
+			if(sr_wtimer_add(ul_db_clean_timer, 0, ul_timer_interval)<0) {
 				LM_ERR("failed to add db clean timer routine\n");
 				return -1;
 			}
 		}
 	}
 
-	if (nat_bflag==(unsigned int)-1) {
-		nat_bflag = 0;
-	} else if ( nat_bflag>=8*sizeof(nat_bflag) ) {
-		LM_ERR("bflag index (%d) too big!\n", nat_bflag);
+	if (ul_nat_bflag==(unsigned int)-1) {
+		ul_nat_bflag = 0;
+	} else if (ul_nat_bflag>=8*sizeof(ul_nat_bflag) ) {
+		LM_ERR("bflag index (%d) too big!\n", ul_nat_bflag);
 		return -1;
 	} else {
-		nat_bflag = 1<<nat_bflag;
+		ul_nat_bflag = 1<<ul_nat_bflag;
 	}
 
 	for(i=0; i<ul_preload_index; i++) {
@@ -392,11 +392,11 @@ static int mod_init(void)
 		}
 	}
 
-	if (handle_lost_tcp && db_mode == DB_ONLY) {
+	if (ul_handle_lost_tcp && ul_db_mode == DB_ONLY) {
 		LM_WARN("handle_lost_tcp option makes nothing in DB_ONLY mode\n");
 	}
 
-	if(db_mode != DB_ONLY) {
+	if(ul_db_mode != DB_ONLY) {
 		ul_set_xavp_contact_clone(1);
 	}
 
@@ -413,7 +413,7 @@ static int mod_init(void)
 		}
 	}
 
-	init_flag = 1;
+	ul_init_flag = 1;
 	return 0;
 }
 
@@ -431,7 +431,7 @@ static int child_init(int _rank)
 		for(i=0; i<ul_timer_procs; i++)
 		{
 			if(fork_sync_timer(PROC_TIMER, "USRLOC Timer", 1 /*socks flag*/,
-					ul_local_timer, (void*)(long)i, timer_interval /*sec*/)<0) {
+					ul_local_timer, (void*)(long)i, ul_timer_interval /*sec*/)<0) {
 				LM_ERR("failed to start timer routine as process\n");
 				return -1; /* error */
 			}
@@ -439,7 +439,7 @@ static int child_init(int _rank)
 	}
 
 	/* connecting to DB ? */
-	switch (db_mode) {
+	switch (ul_db_mode) {
 		case NO_DB:
 			return 0;
 		case DB_ONLY:
@@ -458,19 +458,19 @@ static int child_init(int _rank)
 			break;
 		case DB_READONLY:
 			/* connect to db only from child 1 for preload */
-			db_load=1; /* we always load from the db in this mode */
+			ul_db_load=1; /* we always load from the db in this mode */
 			if(_rank!=PROC_SIPINIT)
 				return 0;
 			break;
 	}
 
-	ul_dbh = ul_dbf.init(&db_url); /* Get a database connection per child */
+	ul_dbh = ul_dbf.init(&ul_db_url); /* Get a database connection per child */
 	if (!ul_dbh) {
 		LM_ERR("child(%d): failed to connect to database\n", _rank);
 		return -1;
 	}
 	/* _rank==PROC_SIPINIT is used even when fork is disabled */
-	if (_rank==PROC_SIPINIT && db_mode!=DB_ONLY && db_load) {
+	if (_rank==PROC_SIPINIT && ul_db_mode!=DB_ONLY && ul_db_load) {
 		/* if cache is used, populate domains from DB */
 		for(ptr=_ksr_ul_root ; ptr ; ptr=ptr->next) {
 			if (preload_udomain(ul_dbh, ptr->d) < 0) {

+ 34 - 34
src/modules/usrloc/usrloc_mod.h

@@ -41,28 +41,28 @@
 
 #define UL_TABLE_VERSION 9
 
-extern str ruid_col;
-extern str user_col;
-extern str domain_col;
-extern str contact_col;
-extern str expires_col;
-extern str q_col;
-extern str callid_col;
-extern str cseq_col;
-extern str flags_col;
-extern str cflags_col;
-extern str user_agent_col;
-extern str received_col;
-extern str path_col;
-extern str sock_col;
-extern str methods_col;
-extern str instance_col;
-extern str reg_id_col;
-extern str srv_id_col;
-extern str con_id_col;
-extern str keepalive_col;
-extern str partition_col;
-extern str last_mod_col;
+extern str ul_ruid_col;
+extern str ul_user_col;
+extern str ul_domain_col;
+extern str ul_contact_col;
+extern str ul_expires_col;
+extern str ul_q_col;
+extern str ul_callid_col;
+extern str ul_cseq_col;
+extern str ul_flags_col;
+extern str ul_cflags_col;
+extern str ul_user_agent_col;
+extern str ul_received_col;
+extern str ul_path_col;
+extern str ul_sock_col;
+extern str ul_methods_col;
+extern str ul_instance_col;
+extern str ul_reg_id_col;
+extern str ul_srv_id_col;
+extern str ul_con_id_col;
+extern str ul_keepalive_col;
+extern str ul_partition_col;
+extern str ul_last_mod_col;
 
 extern str ulattrs_user_col;
 extern str ulattrs_domain_col;
@@ -73,27 +73,27 @@ extern str ulattrs_avalue_col;
 extern str ulattrs_last_mod_col;
 
 
-extern str db_url;
-extern int timer_interval;
-extern int db_mode;
-extern int db_insert_update;
-extern int use_domain;
-extern int desc_time_order;
-extern int cseq_delay;
+extern str ul_db_url;
+extern int ul_timer_interval;
+extern int ul_db_mode;
+extern int ul_db_insert_update;
+extern int ul_use_domain;
+extern int ul_desc_time_order;
+extern int ul_cseq_delay;
 extern int ul_fetch_rows;
 extern int ul_hash_size;
 extern int ul_db_update_as_insert;
 extern int ul_db_check_update;
 extern int ul_keepalive_timeout;
-extern int handle_lost_tcp;
-extern int close_expired_tcp;
-extern int skip_remote_socket;
+extern int ul_handle_lost_tcp;
+extern int ul_close_expired_tcp;
+extern int ul_skip_remote_socket;
 
 
 /*! nat branch flag */
-extern unsigned int nat_bflag;
+extern unsigned int ul_nat_bflag;
 /*! flag to protect against wrong initialization */
-extern unsigned int init_flag;
+extern unsigned int ul_init_flag;
 
 extern str ul_xavp_contact_name;
 

+ 3 - 5
src/modules/usrloc/utime.c

@@ -30,11 +30,9 @@
 #include "utime.h"
 
 
-time_t act_time;
+time_t ul_act_time = 0;
 
-
-void get_act_time(void)
+void ul_get_act_time(void)
 {
-
-	act_time = time(0);
+	ul_act_time = time(0);
 }

+ 2 - 2
src/modules/usrloc/utime.h

@@ -31,13 +31,13 @@
 #include <time.h>
 
 
-extern time_t act_time;
+extern time_t ul_act_time;
 
 
 /*! \brief
  * Get actual time
  */
-void get_act_time(void);
+void ul_get_act_time(void);
 
 
 #endif /* UTIME_H */

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно