summaryrefslogtreecommitdiff
path: root/src/mrl_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mrl_main.cpp')
-rw-r--r--src/mrl_main.cpp128
1 files changed, 65 insertions, 63 deletions
diff --git a/src/mrl_main.cpp b/src/mrl_main.cpp
index 6440270..ebad461 100644
--- a/src/mrl_main.cpp
+++ b/src/mrl_main.cpp
@@ -66,7 +66,7 @@ void test_Maat_set_nominee_line()
void mrl_cfg_init(const char *profile)
{
- int temp_port = 0;
+ unsigned int temp_port = 0;
/********** load log info **********/
MESA_load_profile_int_def(profile, "LOG_INFO", "log_level", &(mrl_instance.mrl_cfg.mrl_log_level),RLOG_LV_DEBUG);
MESA_load_profile_string_def(profile, "LOG_INFO", "log_path", mrl_instance.mrl_cfg.mrl_log_path, MRL_MAX_PATH, "./log/mrl.log");
@@ -82,21 +82,25 @@ void mrl_cfg_init(const char *profile)
/********** load detect info **********/
- MESA_load_profile_string_def(profile, "DETECT_INFO", "dest_ip", mrl_instance.mrl_cfg.dest_ip, MRL_STR_IP_LEN, "0.0.0.0");
- MESA_load_profile_int_def(profile, "DETECT_INFO", "dest_port",&(temp_port),8888);
+ MESA_load_profile_string_def(profile, "DETECT_INFO", "inside_detect_ip", mrl_instance.mrl_cfg.inside_detect_ip, MRL_STR_IP_LEN, "0.0.0.0");
+ MESA_load_profile_string_def(profile, "DETECT_INFO", "outside_detect_ip", mrl_instance.mrl_cfg.outside_detect_ip, MRL_STR_IP_LEN, "0.0.0.0");
+
+ MESA_load_profile_uint_def(profile, "DETECT_INFO", "detect_port",&(temp_port),8888);
assert(temp_port > 0 && temp_port <= 65535);
- mrl_instance.mrl_cfg.dest_port = temp_port;
- MESA_load_profile_int_def(profile, "DETECT_INFO", "local_port",&(temp_port),8888);
+ mrl_instance.mrl_cfg.detect_port = temp_port;
+
+ MESA_load_profile_uint_def(profile, "DETECT_INFO", "local_port",&(temp_port),8888);
assert(temp_port > 0 && temp_port <= 65535);
mrl_instance.mrl_cfg.local_port = temp_port;
MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_cfg_init","load detect info is:"
- "[dest_ip:%s,dest_port:%hu,local_port:%hu]",
- mrl_instance.mrl_cfg.dest_ip,mrl_instance.mrl_cfg.dest_port, mrl_instance.mrl_cfg.local_port);
+ "[inside_detect_ip:%s,outside_detect_ip:%s,detect_port:%hu,local_port:%hu]",
+ mrl_instance.mrl_cfg.inside_detect_ip, mrl_instance.mrl_cfg.outside_detect_ip,
+ mrl_instance.mrl_cfg.detect_port,mrl_instance.mrl_cfg.local_port);
/********** load sock info **********/
MESA_load_profile_string_def(profile, "SOCK_INFO", "mgw_ip", mrl_instance.mrl_cfg.mgw_ip, MRL_STR_IP_LEN, "0.0.0.0");
- MESA_load_profile_int_def(profile, "SOCK_INFO", "mgw_port",&(temp_port),8888);
+ MESA_load_profile_uint_def(profile, "SOCK_INFO", "mgw_port",&(temp_port),8888);
assert(temp_port > 0 && temp_port <= 65535);
mrl_instance.mrl_cfg.mgw_port = temp_port;
@@ -110,7 +114,7 @@ void mrl_cfg_init(const char *profile)
assert(0);
}
inet_ntop(AF_INET,(void *)&temp_mrl_ip, mrl_instance.mrl_cfg.mrl_ip,MRL_STR_IP_LEN);
- MESA_load_profile_int_def(profile, "SOCK_INFO", "mrl_port",&(temp_port),8888);
+ MESA_load_profile_uint_def(profile, "SOCK_INFO", "mrl_port",&(temp_port),8888);
assert(temp_port > 0 && temp_port <= 65535);
mrl_instance.mrl_cfg.mrl_port = temp_port;
@@ -126,13 +130,13 @@ void mrl_cfg_init(const char *profile)
MESA_load_profile_string_def(profile, "MAAT_INFO", "Maat_stat_path", mrl_instance.mrl_cfg.Maat_stat_path,MRL_MAX_PATH, "./log/Maat_stat.log");
MESA_load_profile_string_def(profile, "MAAT_INFO", "static_redis_ip", mrl_instance.mrl_cfg.static_redis_ip, MRL_STR_IP_LEN, "127.0.0.1");
- MESA_load_profile_int_def(profile, "MAAT_INFO", "static_redis_port", &(temp_port), 6379);
+ MESA_load_profile_uint_def(profile, "MAAT_INFO", "static_redis_port", &(temp_port), 6379);
assert(temp_port > 0 && temp_port <= 65535);
mrl_instance.mrl_cfg.static_redis_port = temp_port;
MESA_load_profile_int_def(profile, "MAAT_INFO", "static_redis_index", &(mrl_instance.mrl_cfg.static_redis_index), 1);
MESA_load_profile_string_def(profile, "MAAT_INFO", "dynamic_redis_ip", mrl_instance.mrl_cfg.dynamic_redis_ip, MRL_STR_IP_LEN, "127.0.0.1");
- MESA_load_profile_int_def(profile, "MAAT_INFO", "dynamic_redis_port", &(temp_port), 6379);
+ MESA_load_profile_uint_def(profile, "MAAT_INFO", "dynamic_redis_port", &(temp_port), 6379);
assert(temp_port > 0 && temp_port <= 65535);
mrl_instance.mrl_cfg.dynamic_redis_port = temp_port;
MESA_load_profile_int_def(profile, "MAAT_INFO", "dynamic_redis_index", &(mrl_instance.mrl_cfg.dynamic_redis_index), 1);
@@ -155,11 +159,12 @@ void mrl_cfg_init(const char *profile)
"[ht_slot_size:%d,ht_max_element_num:%d,ht_mutex_num:%d]",
mrl_instance.mrl_cfg.ht_slot_size,mrl_instance.mrl_cfg.ht_max_element_num, mrl_instance.mrl_cfg.ht_mutex_num);
- /********** load candidate info **********/
- MESA_load_profile_string_def(profile, "CANDIDATE_INFO", "ip_location", mrl_instance.mrl_cfg.ip_location, MRL_LOCATION_LEN, "China");
-
- MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_cfg_init","load candidate info is:"
- "[ip_location:%s]",mrl_instance.mrl_cfg.ip_location);
+ /********** load ip location info **********/
+ MESA_load_profile_uint_def(profile, "IP_LOCATION_INFO", "ip_location_enable", &(mrl_instance.mrl_cfg.ip_location_enable), 0);
+ MESA_load_profile_uint_def(profile, "IP_LOCATION_INFO", "ip_location_level", &(mrl_instance.mrl_cfg.ip_location_level),0);
+ MESA_load_profile_string_def(profile, "IP_LOCATION_INFO", "ip_location_name", mrl_instance.mrl_cfg.ip_location_name, MRL_LOCATION_NAME_LEN, "China");
+ MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_cfg_init","load ip location info is:"
+ "[ip_location_enable::%u,ip_location_level:%u,ip_location_name:%s]",mrl_instance.mrl_cfg.ip_location_enable,mrl_instance.mrl_cfg.ip_location_level,mrl_instance.mrl_cfg.ip_location_name);
/********** load link identity info **********/
MESA_load_profile_string_def(profile, "LINK_INFO", "link_identity_path", mrl_instance.mrl_cfg.link_identity_path, MRL_MAX_PATH, "./conf/link_dentity.json");
@@ -338,62 +343,59 @@ extern "C" char mrl_udp_entry(struct streaminfo *a_udp, void **pme, int thread_
dport = ntohs(a_udp->addr.tuple4_v4->dest);
MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_udp_entry","cur udp pkt streaminfo:[sip:%s,sport:%hu,dip:%s,dport:%hu]",
sip,sport,dip,dport);
- }
- switch(a_udp->pktstate){
- case OP_STATE_PENDING:
- if(mrl_identify_detect_pkt(a_udp,(const char*)raw_packet,&tuple))
+ if(mrl_identify_detect_pkt(a_udp,(const char*)raw_packet,&tuple))
+ {
+ global_stat.recv_detect_pkts ++;
+ ret =APP_STATE_GIVEME|APP_STATE_DROPPKT;
+ }
+ else
+ {
+ switch(a_udp->pktstate)
{
- global_stat.recv_detect_pkts ++;
- ret =APP_STATE_DROPME|APP_STATE_DROPPKT;
- }
- else
- {
- if(mrl_dnat_pkt_identify(a_udp,&tuple))
- {
- global_stat.recv_ir_udp_pkts ++;
- send_len=mrl_send_to_mgw(raw_packet, thread_seq);
- MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_udp_entry","send %d Bytes pkt[sip:%s,sport:%hu,dip:%s,dport:%hu]to mgw.",
- send_len,tuple.sip,tuple.sport,tuple.dip,tuple.dport);
- ret = APP_STATE_GIVEME|APP_STATE_DROPPKT;
- }
- else
- {
- if(mrl_snat_pkt_identify(a_udp,&tuple))
+ case OP_STATE_PENDING:
+ if(mrl_dnat_pkt_identify(a_udp,&tuple))
{
- global_stat.recv_ir_udp_pkts ++;
+ global_stat.recv_ir_udp_pkts ++;
send_len=mrl_send_to_mgw(raw_packet, thread_seq);
+ MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_udp_entry","send %d Bytes pkt[sip:%s,sport:%hu,dip:%s,dport:%hu]to mgw.",
+ send_len,tuple.sip,tuple.sport,tuple.dip,tuple.dport);
ret = APP_STATE_GIVEME|APP_STATE_DROPPKT;
}
else
{
- ret =APP_STATE_DROPME|APP_STATE_FAWPKT;
- }
- }
- }
- break;
- case OP_STATE_DATA:
- global_stat.recv_ir_udp_pkts ++;
- send_len=mrl_send_to_mgw(raw_packet, thread_seq);
- MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_udp_entry","send %d Bytes pkt[sip:%s,sport:%hu,dip:%s,dport:%hu]to mgw.",
+ if(mrl_snat_pkt_identify(a_udp,&tuple))
+ {
+ global_stat.recv_ir_udp_pkts ++;
+ send_len=mrl_send_to_mgw(raw_packet, thread_seq);
+ ret = APP_STATE_GIVEME|APP_STATE_DROPPKT;
+ }
+ else
+ {
+ ret =APP_STATE_DROPME|APP_STATE_FAWPKT;
+ }
+ }
+ break;
+ case OP_STATE_DATA:
+ global_stat.recv_ir_udp_pkts ++;
+ send_len=mrl_send_to_mgw(raw_packet, thread_seq);
+ MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_udp_entry","send %d Bytes pkt[sip:%s,sport:%hu,dip:%s,dport:%hu]to mgw.",
send_len,tuple.sip,tuple.sport,tuple.dip,tuple.dport);
- ret = APP_STATE_GIVEME|APP_STATE_DROPPKT;
- break;
-
- case OP_STATE_CLOSE:
- if(raw_packet != NULL)
- {
- global_stat.recv_ir_udp_pkts ++;
- send_len=mrl_send_to_mgw(raw_packet, thread_seq);
- MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_udp_entry","send %d Bytes pkt[sip:%s,sport:%hu,dip:%s,dport:%hu]to mgw.",
+ ret = APP_STATE_GIVEME|APP_STATE_DROPPKT;
+ break;
+ case OP_STATE_CLOSE:
+ global_stat.recv_ir_udp_pkts ++;
+ send_len=mrl_send_to_mgw(raw_packet, thread_seq);
+ MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_udp_entry","send %d Bytes pkt[sip:%s,sport:%hu,dip:%s,dport:%hu]to mgw.",
send_len,tuple.sip,tuple.sport,tuple.dip,tuple.dport);
- }
- ret = APP_STATE_DROPME|APP_STATE_DROPPKT;
- break;
-
- default:
- ret = APP_STATE_DROPME | APP_STATE_FAWPKT;
- break;
- }
+ ret = APP_STATE_DROPME|APP_STATE_DROPPKT;
+ break;
+ default:
+ ret = APP_STATE_DROPME | APP_STATE_FAWPKT;
+ break;
+ }
+
+ }
+ }
return ret;
}