reduce diff with non-mp version

This commit is contained in:
wangyu- 2018-08-28 16:42:16 -05:00
parent a130936947
commit 5f29a46aae
3 changed files with 62 additions and 13 deletions

@ -16,6 +16,7 @@ extern int disable_anti_replay;
#include "network.h"
#include "misc.h"
//const int disable_conv_clear=0;//a udp connection in the multiplexer is called conversation in this program,conv for short.
struct anti_replay_t //its for anti replay attack,similar to openvpn/ipsec 's anti replay window
@ -30,6 +31,9 @@ struct anti_replay_t //its for anti replay attack,similar to openvpn/ipsec 's a
int is_vaild(u64_t seq);
};//anti_replay;
void server_clear_function(u64_t u64);
#include <type_traits>
struct conv_manager_t // manage the udp connections
{

@ -40,6 +40,10 @@ const u32_t receive_window_lower_bound=40960;
const u32_t receive_window_random_range=512;
const unsigned char wscale=0x05;
char g_packet_buf[buf_len]; //looks dirty but works well
int g_packet_buf_len=-1;
int g_packet_buf_cnt=0;
#ifndef NO_LIBNET
libnet_t *libnet_handle;
libnet_ptag_t g_ptag=0;
@ -66,9 +70,6 @@ ev_loop* g_default_loop;
pthread_t pcap_recv_thread;
char g_packet_buf[buf_len]; //dirty code, fix it later
int g_packet_buf_len=-1;
int g_packet_buf_cnt=0;

@ -19,14 +19,17 @@ extern int disable_bpf_filter;
//extern int lower_level;
//extern int lower_level_manual;
extern char if_name[100];
extern unsigned char dest_hw_addr[];
extern char dev[100];
extern unsigned char dest_hw_addr[];
extern int random_drop;
extern int ifindex;
extern char g_packet_buf[buf_len];
extern int g_packet_buf_len;
extern int g_packet_buf_cnt;
extern queue_t my_queue;
extern ev_async async_watcher;
@ -35,10 +38,6 @@ extern ev_loop* g_default_loop;
extern pthread_mutex_t queue_mutex;
extern int pcap_cnt;
extern char g_packet_buf[buf_len];
extern int g_packet_buf_len;
extern int g_packet_buf_cnt;
extern int pcap_link_header_len;
extern int send_with_pcap;
@ -162,6 +161,36 @@ struct my_tcphdr
};
struct my_ip6hdr
{
# ifdef UDP2RAW_LITTLE_ENDIAN
uint8_t traffic_class_high:4;
uint8_t version:4;
uint8_t flow_label_high:4;
uint8_t traffic_class_low:4;
#else
uint8_t version:4;
uint8_t traffic_class_high:4;
uint8_t traffic_class_low:4;
uint8_t flow_label_high:4;
#endif
u_int16_t flow_label_low;
u_int16_t payload_len;
uint8_t next_header;
uint8_t hop_limit;
struct in6_addr src;
struct in6_addr dst;
};
struct my_icmphdr
{
uint8_t type;
uint8_t code;
uint16_t check_sum;
uint16_t id;
uint16_t seq;
};
struct pseudo_header {
u_int32_t source_address;
@ -171,14 +200,25 @@ struct pseudo_header {
u_int16_t tcp_length;
};
struct pseudo_header6 {
struct in6_addr src;
struct in6_addr dst;
u_int32_t tcp_length;
u_int16_t placeholder1;
u_int8_t placeholder2;
u_int8_t next_header;
};
struct packet_info_t //todo change this to union
{
uint8_t protocol;
//ip_part:
u32_t src_ip;
uint16_t src_port;
//u32_t src_ip;
//u32_t dst_ip;
u32_t src_ip;
u32_t dst_ip;
uint16_t src_port;
uint16_t dst_port;
//tcp_part:
@ -209,6 +249,9 @@ struct raw_info_t
//int last_send_len;
//int last_recv_len;
bool peek=0;
//bool csum=1;
u32_t reserved_send_seq;
//uint32_t first_seq,first_ack_seq;
int rst_received=0;
@ -224,6 +267,7 @@ void init_filter(int port);
void remove_filter();
//int init_ifindex(const char * if_name,int fd,int &index);
int init_ifindex(const char * if_name,int &index);
int find_lower_level_info(u32_t ip,u32_t &dest_ip,string &if_name,string &hw);
@ -236,7 +280,7 @@ int client_bind_to_a_new_port(int & bind_fd,u32_t local_ip_uint32);//find a free
int send_raw_ip(raw_info_t &raw_info,const char * payload,int payloadlen);
int peek_raw(packet_info_t &peek_info);
int peek_raw(raw_info_t &peek_info);
int recv_raw_ip(raw_info_t &raw_info,char * &payload,int &payloadlen);