diff --git a/common.cpp b/common.cpp index 160e5e7..aafff5b 100644 --- a/common.cpp +++ b/common.cpp @@ -20,9 +20,9 @@ int delay_capacity=0; char iptables_rule[200]=""; //int is_client = 0, is_server = 0; -program_mode_t program_mode=unset_mode;//0 unset; 1client 2server - +program_mode_t client_or_server=unset_mode;//0 unset; 1client 2server +working_mode_t working_mode=unset_mode; struct random_fd_t { diff --git a/common.h b/common.h index 8eb69af..7d143c8 100644 --- a/common.h +++ b/common.h @@ -115,9 +115,12 @@ extern int about_to_exit; enum raw_mode_t{mode_faketcp=0,mode_udp,mode_icmp,mode_end}; extern raw_mode_t raw_mode; enum program_mode_t {unset_mode=0,client_mode,server_mode}; -extern program_mode_t program_mode; +extern program_mode_t client_or_server; extern unordered_map raw_mode_tostring ; +enum working_mode_t {unset_mode=0,tunnel_mode,tun_dev_mode}; +extern working_mode_t working_mode; + extern int delay_capacity; diff --git a/connection.cpp b/connection.cpp index d5d6a3b..a1c8416 100644 --- a/connection.cpp +++ b/connection.cpp @@ -47,7 +47,7 @@ void conv_manager_t::clear() { //if(disable_conv_clear) return ;//////what was the purpose of this code? - if(program_mode==server_mode) + if(client_or_server==server_mode) { for(auto it=conv_to_u64.begin();it!=conv_to_u64.end();it++) { @@ -111,7 +111,7 @@ int conv_manager_t::erase_conv(u32_t conv) //if(disable_conv_clear) return 0; assert(conv_last_active_time.find(conv)!=conv_last_active_time.end()); u64_t u64=conv_to_u64[conv]; - if(program_mode==server_mode) + if(client_or_server==server_mode) { server_clear_function(u64); } diff --git a/main.cpp b/main.cpp index 8b0c31e..c39353c 100644 --- a/main.cpp +++ b/main.cpp @@ -14,20 +14,9 @@ using namespace std; int main(int argc, char *argv[]) { + working_mode=tun_dev_mode; + - /* - if(argc==1||argc==0) - { - printf("this_program classic\n"); - printf("this_program fec\n"); - return 0; - }*/ - /* - if(argc>=2&&strcmp(argv[1],"fec")!=0) - { - printf("running into classic mode!\n"); - return classic::main(argc,argv); - }*/ assert(sizeof(u64_t)==8); assert(sizeof(i64_t)==8); @@ -43,13 +32,25 @@ int main(int argc, char *argv[]) local_ip_uint32=inet_addr(local_ip); remote_ip_uint32=inet_addr(remote_ip); - if(program_mode==client_mode) + if(working_mode==tunnel_mode) { - client_event_loop(); + if(client_or_server==client_mode) + { + tunnel_client_event_loop(); + } + else + { + tunnel_server_event_loop(); + } } else { - server_event_loop(); + if(client_or_server==client_mode) + { + } + else + { + } } return 0; diff --git a/misc.cpp b/misc.cpp index aee9a87..70ce0c5 100644 --- a/misc.cpp +++ b/misc.cpp @@ -41,7 +41,6 @@ int time_mono_test=0; int socket_buf_size=1024*1024; - int from_normal_to_fec(conn_info_t & conn_info,char *data,int len,int & out_n,char **&out_arr,int *&out_len,my_time_t *&out_delay) { @@ -899,11 +898,11 @@ void process_arg(int argc, char *argv[]) } if(is_client==1) { - program_mode=client_mode; + client_or_server=client_mode; } else { - program_mode=server_mode; + client_or_server=server_mode; } print_parameter(); diff --git a/tunnel.cpp b/tunnel.cpp index 62d2585..b8469c8 100644 --- a/tunnel.cpp +++ b/tunnel.cpp @@ -65,7 +65,7 @@ int new_connected_socket(int &fd,u32_t ip,int port) return 0; } -int client_event_loop() +int tunnel_client_event_loop() { //char buf[buf_len]; int i, j, k;int ret; @@ -392,7 +392,7 @@ int client_event_loop() return 0; } -int server_event_loop() +int tunnel_server_event_loop() { //char buf[buf_len]; int i, j, k;int ret; diff --git a/tunnel.h b/tunnel.h index 288b3b2..a074154 100644 --- a/tunnel.h +++ b/tunnel.h @@ -11,7 +11,7 @@ #include "misc.h" -int client_event_loop(); -int server_event_loop(); +int tunnel_client_event_loop(); +int tunnel_server_event_loop(); #endif /* TUNNEL_H_ */