summaryrefslogtreecommitdiff
path: root/access/src/ip_mgr.cpp
diff options
context:
space:
mode:
author崔一鸣 <[email protected]>2018-12-18 18:03:01 +0800
committer崔一鸣 <[email protected]>2018-12-18 18:13:38 +0800
commit5679a4d71da19564c42ea7f8edf5c274dd6cb86f (patch)
tree841ff50608861106c0bb2cff444af70870d4bf0b /access/src/ip_mgr.cpp
parentabaa4322165f523736f9d847d1cffdf438d64968 (diff)
修改dnat代码,方便测试1.1.1
Diffstat (limited to 'access/src/ip_mgr.cpp')
-rw-r--r--access/src/ip_mgr.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/access/src/ip_mgr.cpp b/access/src/ip_mgr.cpp
index ccad08c..28ef5ec 100644
--- a/access/src/ip_mgr.cpp
+++ b/access/src/ip_mgr.cpp
@@ -17,6 +17,7 @@ struct ip_mgr_handle
MESA_htable_handle dnat_policy_htable; //expire_time: 0
MESA_htable_handle snat_cand_ip_htable; //expire_time: 0
MESA_htable_handle mrl_ip_htable; //expire_time: 0
+ uint32_t default_mrl_ip;
};
struct snat_policy_htable_value
@@ -182,7 +183,9 @@ int ip_mgr_mrl_ip_query(struct ip_mgr_handle *handle, uint32_t back_ip, uint32_t
{
FS_operate(g_fs_handle->handle, g_fs_handle->line_mrl_ip, g_fs_handle->cloumn_cache_miss, FS_OP_ADD, 1);
MGW_LOG_ERROR(logger, "MESA_htable: key not existed, table is %s, back ip is %s", "mrl_ip_htable", back_ip_str);
- return -1;
+ //for test
+ *mrl_ip = handle->default_mrl_ip;
+ return 0;
}
mgw_utils_inet_ntoa(dup_value.mrl_ip, mrl_ip_str);
*mrl_ip = dup_value.mrl_ip;
@@ -300,7 +303,7 @@ static void mrl_ip_htable_data_free_cb(void *data)
static void Maat_snat_policy_start_cb(int update_type, void* args)
{
- printf("call Maat_snat_policy_start_cb, update_type is %d\n", update_type);
+ //printf("call Maat_snat_policy_start_cb, update_type is %d\n", update_type);
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: start callback, table is IP_SNAT_POLICY, update_type is %d\n", update_type);
@@ -309,7 +312,7 @@ static void Maat_snat_policy_start_cb(int update_type, void* args)
static void Maat_snat_policy_update_cb(int table_id, const char* table_line, void* args)
{
- printf("call Maat_snat_policy_update_cb, table_line is %s\n", table_line);
+ //printf("call Maat_snat_policy_update_cb, table_line is %s\n", table_line);
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: update callback, table is IP_SNAT_POLICY, table line is %s", table_line);
@@ -360,7 +363,7 @@ static void Maat_snat_policy_update_cb(int table_id, const char* table_line, voi
static void Maat_snat_policy_finish_cb(void* args)
{
- printf("call Maat_snat_policy_finish_cb\n");
+ //printf("call Maat_snat_policy_finish_cb\n");
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: finish callback, table is SNAT_POLICY");
@@ -380,7 +383,7 @@ static void Maat_snat_policy_finish_cb(void* args)
static void Maat_snat_cand_ip_start_cb(int update_type,void* args)
{
- printf("call Maat_snat_cand_ip_start_cb, update_type is %d\n", update_type);
+ //printf("call Maat_snat_cand_ip_start_cb, update_type is %d\n", update_type);
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: start callback, table is IR_CANDIDATE_IP, updata_type is %d\n", update_type);
@@ -503,7 +506,7 @@ static long snat_cand_ip_query_cb_del(void *data, const uchar *key, uint size, v
static void Maat_snat_cand_ip_update_cb(int table_id, const char* table_line, void* args)
{
- printf("call Maat_snat_cand_ip_update_cb, table line is %s\n", table_line);
+ //printf("call Maat_snat_cand_ip_update_cb, table line is %s\n", table_line);
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: update callback, table is IR_CANDIDATE_IP, table line is %s", table_line);
@@ -543,7 +546,7 @@ static void Maat_snat_cand_ip_update_cb(int table_id, const char* table_line, vo
static void Maat_snat_cand_ip_finish_cb(void* args)
{
- printf("call Maat_snat_cand_ip_finish_cb\n");
+ //printf("call Maat_snat_cand_ip_finish_cb\n");
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: finish callback, table is CAND_IP_TABLE");
@@ -553,7 +556,7 @@ static void Maat_snat_cand_ip_finish_cb(void* args)
static void Maat_dnat_policy_start_cb(int update_type, void* args)
{
- printf("call Maat_dnat_policy_start_cb, update_type is %d\n", update_type);
+ //printf("call Maat_dnat_policy_start_cb, update_type is %d\n", update_type);
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: start callback, update_type is %d, table is IP_DNAT_POLICY", update_type);
@@ -562,7 +565,7 @@ static void Maat_dnat_policy_start_cb(int update_type, void* args)
static void Maat_dnat_policy_update_cb(int table_id, const char* table_line, void* args)
{
- printf("call Maat_dnat_policy_update_cb, table line is %s\n", table_line);
+ //printf("call Maat_dnat_policy_update_cb, table line is %s\n", table_line);
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: update callback, table is IP_DNAT_POLICY, table line is %s", table_line);
@@ -628,7 +631,7 @@ static void Maat_dnat_policy_update_cb(int table_id, const char* table_line, voi
static void Maat_dnat_policy_finish_cb(void* args)
{
- printf("call Maat_dnat_policy_finish_cb\n");
+ //printf("call Maat_dnat_policy_finish_cb\n");
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: finish callback, table is IP_DNAT_POLICY");
@@ -637,7 +640,7 @@ static void Maat_dnat_policy_finish_cb(void* args)
static void Maat_mrl_ip_start_cb(int update_type, void* args)
{
- printf("call Maat_mrl_ip_start_cb, update_type is %d\n", update_type);
+ //printf("call Maat_mrl_ip_start_cb, update_type is %d\n", update_type);
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: start callback, table is IP_MRL_IP_INFO, update_type is %d", update_type);
@@ -646,7 +649,7 @@ static void Maat_mrl_ip_start_cb(int update_type, void* args)
static void Maat_mrl_ip_update_cb(int table_id, const char* table_line, void* args)
{
- printf("call Maat_mrl_ip_update_cb, table_line is %s\n", table_line);
+ //printf("call Maat_mrl_ip_update_cb, table_line is %s\n", table_line);
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: update callback, table is IP_MRL_IP_INFO, table line is %s", table_line);
@@ -699,7 +702,7 @@ static void Maat_mrl_ip_update_cb(int table_id, const char* table_line, void* ar
static void Maat_mrl_ip_finish_cb(void* args)
{
- printf("call Maat_mrl_ip_finish_cb\n");
+ //printf("call Maat_mrl_ip_finish_cb\n");
struct ip_mgr_handle *handle = (struct ip_mgr_handle *)args;
void *logger = handle->logger;
MGW_LOG_INFO(logger, "Maat_redis: finish callback, table is IP_MRL_IP_INFO");
@@ -787,6 +790,11 @@ static Maat_feather_t Maat_init(const char *profile, const char *section, void
struct ip_mgr_handle *ip_mgr_init(const char *profile, struct field_stat_handle *fs_handle, void *logger)
{
struct ip_mgr_handle *handle = ALLOC(struct ip_mgr_handle, 1);
+ char _default_mrl_ip[MGW_SYMBOL_MAX];
+ char *section = (char *)"mrl";
+ MESA_load_profile_string_def(profile, section, "default_ip", _default_mrl_ip, sizeof(_default_mrl_ip), "192.168.11.242");
+ MGW_LOG_INFO(logger, "MESA_prof_load, [%s]:\n default_ip: %s\n", section, _default_mrl_ip);
+ handle->default_mrl_ip = inet_addr(_default_mrl_ip);
handle->Maat_feather_snat_policy = Maat_init(profile, "Maat_snat_policy", logger);
handle->Maat_feather_dnat_policy = Maat_init(profile, "Maat_dnat_policy", logger);
handle->Maat_feather_snat_cand_ip = Maat_init(profile, "Maat_snat_cand_ip", logger);