diff --git a/common.h b/common.h index 89d5f46..0436cf9 100644 --- a/common.h +++ b/common.h @@ -59,7 +59,7 @@ typedef int i32_t; const int max_data_len=1600; -const int buf_len=max_data_len+200; +const int buf_len=max_data_len+400; const u32_t max_handshake_conn_num=10000; const u32_t max_ready_conn_num=1000; const u32_t anti_replay_window_size=1000; diff --git a/encrypt.h b/encrypt.h index 8495ca8..b1b4e63 100755 --- a/encrypt.h +++ b/encrypt.h @@ -29,10 +29,6 @@ enum cipher_mode_t {cipher_none=0,cipher_aes128cbc,cipher_xor,cipher_end}; extern auth_mode_t auth_mode; extern cipher_mode_t cipher_mode; -struct a -{ - char * buf[buf_len]; -}; extern unordered_map auth_mode_tostring; extern unordered_map cipher_mode_tostring; diff --git a/main.cpp b/main.cpp index a44d5be..b2d21d7 100755 --- a/main.cpp +++ b/main.cpp @@ -2034,7 +2034,7 @@ int client_event_loop() int recv_len; struct sockaddr_in udp_new_addr_in; - if ((recv_len = recvfrom(udp_fd, buf, buf_len, 0, + if ((recv_len = recvfrom(udp_fd, buf, max_data_len, 0, (struct sockaddr *) &udp_new_addr_in, &slen)) == -1) { mylog(log_error,"recv_from error,this shouldnt happen at client\n"); myexit(1); @@ -2307,7 +2307,7 @@ int server_event_loop() u32_t conv_id=conn_info.blob->conv_manager.find_conv_by_u64(fd); - int recv_len=recv(fd,buf,buf_len,0); + int recv_len=recv(fd,buf,max_data_len,0); mylog(log_trace,"received a packet from udp_fd,len:%d\n",recv_len); diff --git a/makefile b/makefile index 670669a..1b868ef 100755 --- a/makefile +++ b/makefile @@ -4,7 +4,7 @@ FLAGS2= -O3 all: sudo killall udp2raw||true sleep 0.2 - gcc main.cpp -o udp2raw -static -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} ${FLAGS2} + g++ main.cpp -o udp2raw -static -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} ${FLAGS2} # ${ccmips} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} ${FLAGS2} fast: sudo killall udp2raw||true diff --git a/network.cpp b/network.cpp index 3e7c48b..be84833 100644 --- a/network.cpp +++ b/network.cpp @@ -391,7 +391,7 @@ int peek_raw(packet_info_t &peek_info) char *ip_begin=peek_raw_buf+link_level_header_len; struct sockaddr saddr; socklen_t saddr_size; - int recv_len = recvfrom(raw_recv_fd, peek_raw_buf,buf_len, MSG_PEEK ,&saddr , &saddr_size);//change buf_len to something smaller,we only need header here + int recv_len = recvfrom(raw_recv_fd, peek_raw_buf,max_data_len, MSG_PEEK ,&saddr , &saddr_size);//change max_data_len to something smaller,we only need header here iphdr * iph = (struct iphdr *) (ip_begin); //mylog(log_info,"recv_len %d\n",recv_len); if(recv_len