Пример #1
0
void Library::LookupWithRule(const string &str, TSearchResultList& res_list)
{
	std::vector<gchar *> match_res((MAX_MATCH_ITEM_PER_LIB) * ndicts());

	gint nfound=Libs::LookupWithRule(str.c_str(), &match_res[0]);
	if (!nfound)
		return;

	for (gint i=0; i<nfound; ++i) {
		SimpleLookup(match_res[i], res_list);
		g_free(match_res[i]);
	}
}
Пример #2
0
/*
 * Checks based on given source IP address and protocol, and From URI
 * of request if request can be trusted without authentication.
 */
int allow_trusted(struct sip_msg* msg, char *src_ip, int proto) 
{
	int result;
	db1_res_t* res = NULL;
	
	db_key_t keys[1];
	db_val_t vals[1];
	db_key_t cols[4];

	if (db_mode == DISABLE_CACHE) {
		db_key_t order = &priority_col;
	
	        if (db_handle == 0) {
		    LM_ERR("no connection to database\n");
		    return -1;
	        }

		keys[0] = &source_col;
		cols[0] = &proto_col;
		cols[1] = &from_col;
		cols[2] = &ruri_col;
		cols[3] = &tag_col;

		if (perm_dbf.use_table(db_handle, &trusted_table) < 0) {
			LM_ERR("failed to use trusted table\n");
			return -1;
		}
		
		VAL_TYPE(vals) = DB1_STRING;
		VAL_NULL(vals) = 0;
		VAL_STRING(vals) = src_ip;

		if (perm_dbf.query(db_handle, keys, 0, vals, cols, 1, 4, order,
				   &res) < 0){
			LM_ERR("failed to query database\n");
			return -1;
		}

		if (RES_ROW_N(res) == 0) {
			perm_dbf.free_result(db_handle, res);
			return -1;
		}
		
		result = match_res(msg, proto, res);
		perm_dbf.free_result(db_handle, res);
		return result;
	} else {
		return match_hash_table(*hash_table, msg, src_ip, proto);
	}
}