Browse Source

port fd64 to udp2raw

wangyu- 8 years ago
parent
commit
6515d428e9
3 changed files with 34 additions and 2 deletions
  1. 15 1
      common.cpp
  2. 18 0
      common.h
  3. 1 1
      makefile

+ 15 - 1
common.cpp

@@ -593,7 +593,21 @@ int create_fifo(char * file)
 	return fifo_fd;
 }
 
-
+void ip_port_t::from_u64(u64_t u64)
+{
+	ip=get_u64_h(u64);
+	port=get_u64_l(u64);
+}
+u64_t ip_port_t::to_u64()
+{
+	return pack_u64(ip,port);
+}
+char * ip_port_t::to_s()
+{
+	static char res[40];
+	sprintf(res,"%s:%d",my_ntoa(ip),port);
+	return res;
+}
 
 
 

+ 18 - 0
common.h

@@ -70,6 +70,24 @@ typedef u64_t padding_t;
 
 typedef u64_t anti_replay_seq_t;
 
+
+struct ip_port_t
+{
+	u32_t ip;
+	int port;
+	void from_u64(u64_t u64);
+	u64_t to_u64();
+	char * to_s();
+};
+
+struct fd_info_t
+{
+	ip_port_t ip_port;
+};
+
+
+typedef u64_t fd64_t;
+
 const int max_data_len=1600;
 const int buf_len=max_data_len+400;
 

+ 1 - 1
makefile

@@ -8,7 +8,7 @@ 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
 
-COMMON=main.cpp lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp  connection.cpp misc.cpp -lpthread
+COMMON=main.cpp lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp  connection.cpp misc.cpp fd_manager.cpp -lpthread
 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)