diff --git a/common.h b/common.h index cbe78a5..839b622 100644 --- a/common.h +++ b/common.h @@ -48,6 +48,8 @@ #include #include +#include + #include #include #include diff --git a/main.cpp b/main.cpp index 16cfebe..87eed2b 100755 --- a/main.cpp +++ b/main.cpp @@ -474,81 +474,6 @@ int client_event_loop() conn_info.prepare(); packet_info_t &send_info=conn_info.raw_info.send_info; packet_info_t &recv_info=conn_info.raw_info.recv_info; - - if(lower_level) - { - if(lower_level_manual) - { - int index; - init_ifindex(if_name,index); - //init_ifindex(if_name); - memset(&send_info.addr_ll, 0, sizeof(send_info.addr_ll)); - send_info.addr_ll.sll_family = AF_PACKET; - send_info.addr_ll.sll_ifindex =index; - send_info.addr_ll.sll_halen = ETHER_ADDR_LEN; - send_info.addr_ll.sll_protocol = htons(ETH_P_IP); - memcpy(&send_info.addr_ll.sll_addr, dest_hw_addr, ETHER_ADDR_LEN); - mylog(log_info,"we are running at lower-level (manual) mode\n"); - } - else - { - u32_t dest_ip; - string if_name_string; - string hw_string; - - if(retry_on_error==0) - { - if(find_lower_level_info(remote_ip_uint32,dest_ip,if_name_string,hw_string)!=0) - { - mylog(log_fatal,"auto detect lower-level info failed for %s,specific it manually\n",remote_ip); - myexit(-1); - } - } - else - { - int ok=0; - while(!ok) - { - if(find_lower_level_info(remote_ip_uint32,dest_ip,if_name_string,hw_string)!=0) - { - mylog(log_warn,"auto detect lower-level info failed for %s,retry in %d seconds\n",remote_ip,retry_on_error_interval); - sleep(retry_on_error_interval); - } - else - { - ok=1; - } - - } - } - mylog(log_info,"we are running at lower-level (auto) mode,%s %s %s\n",my_ntoa(dest_ip),if_name_string.c_str(),hw_string.c_str()); - - u32_t hw[6]; - memset(hw, 0, sizeof(hw)); - sscanf(hw_string.c_str(), "%x:%x:%x:%x:%x:%x",&hw[0], &hw[1], &hw[2], - &hw[3], &hw[4], &hw[5]); - - mylog(log_warn, - "make sure this is correct: if_name=<%s> dest_mac_adress=<%02x:%02x:%02x:%02x:%02x:%02x> \n", - if_name_string.c_str(), hw[0], hw[1], hw[2], hw[3], hw[4], hw[5]); - for (int i = 0; i < 6; i++) { - dest_hw_addr[i] = uint8_t(hw[i]); - } - - //mylog(log_fatal,"--lower-level auto for client hasnt been implemented\n"); - int index; - init_ifindex(if_name_string.c_str(),index); - - memset(&send_info.addr_ll, 0, sizeof(send_info.addr_ll)); - send_info.addr_ll.sll_family = AF_PACKET; - send_info.addr_ll.sll_ifindex = index; - send_info.addr_ll.sll_halen = ETHER_ADDR_LEN; - send_info.addr_ll.sll_protocol = htons(ETH_P_IP); - memcpy(&send_info.addr_ll.sll_addr, dest_hw_addr, ETHER_ADDR_LEN); - //mylog(log_info,"we are running at lower-level (manual) mode\n"); - } - - } if(source_ip_uint32==0) { diff --git a/makefile b/makefile index 54e2ac2..cc3074e 100755 --- a/makefile +++ b/makefile @@ -10,7 +10,8 @@ cc_arm= /toolchains/arm-2014.05/bin/arm-none-linux-gnueabi-g++ #cc_bcm2708=/home/wangyu/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ FLAGS= -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers ${OPT} -COMMON=main.cpp lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp connection.cpp misc.cpp fd_manager.cpp -lpthread +COMMON=main.cpp lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp connection.cpp misc.cpp fd_manager.cpp -lpthread my_ev.cpp -isystem libev + SOURCES= $(COMMON) lib/aes_faster_c/aes.c lib/aes_faster_c/wrapper.c SOURCES_TINY_AES= $(COMMON) lib/aes.c SOURCES_AES_ACC=$(COMMON) $(wildcard lib/aes_acc/aes*.c) diff --git a/misc.cpp b/misc.cpp index 1b583a5..e721882 100644 --- a/misc.cpp +++ b/misc.cpp @@ -435,6 +435,7 @@ void process_arg(int argc, char *argv[]) //process all options case 'h': break; case 'a': + assert(0==1); auto_add_iptables_rule=1; break; case 'g': @@ -522,6 +523,7 @@ void process_arg(int argc, char *argv[]) //process all options } else if(strcmp(long_options[option_index].name,"lower-level")==0) { + assert(0==1); process_lower_level_arg(); //lower_level=1; //strcpy(lower_level_arg,optarg); diff --git a/my_ev.cpp b/my_ev.cpp new file mode 100644 index 0000000..5880a4c --- /dev/null +++ b/my_ev.cpp @@ -0,0 +1,16 @@ +#pragma GCC diagnostic push + +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wcomment" +#pragma GCC diagnostic ignored "-Wparentheses" +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#pragma GCC diagnostic ignored "-Wunused-value" + +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-W" + +#include "my_ev_common.h" +#include "ev.c" + +#pragma GCC diagnostic pop diff --git a/my_ev.h b/my_ev.h new file mode 100644 index 0000000..c0c0e24 --- /dev/null +++ b/my_ev.h @@ -0,0 +1,5 @@ +#pragma once + +#include "my_ev_common.h" +#include "ev.h" + diff --git a/my_ev_common.h b/my_ev_common.h new file mode 100644 index 0000000..0755f45 --- /dev/null +++ b/my_ev_common.h @@ -0,0 +1,5 @@ + +#define EV_STANDALONE 1 +#define EV_COMMON void *data; unsigned long long u64; +#define EV_COMPAT3 0 +//#define EV_VERIFY 2