mingw works

This commit is contained in:
U-DESKTOP-T772REH\wangyu 2018-06-19 00:36:53 +08:00
parent dfcc799876
commit a1dae3b22e
3 changed files with 12 additions and 15 deletions

View File

@ -22,7 +22,7 @@ int use_tcp_for_detection=1;
extern pcap_t *pcap_handle;
int cap_len;
extern int pcap_captured_full_len;
int client_on_timer(conn_info_t &conn_info) //for client. called when a timer is ready in epoll
{
@ -671,7 +671,7 @@ void async_cb(struct ev_loop *loop, struct ev_async *watcher, int revents)
log_bare(log_info,"link level header captured:\n");
unsigned char *tmp=(unsigned char*)pcap_header_buf;
cap_len=len;
pcap_captured_full_len=len;
for(int i=0;i<pcap_link_header_len;i++)
log_bare(log_info,"<%x>",(u32_t)tmp[i]);
@ -1038,13 +1038,9 @@ void sigint_cb(struct ev_loop *l, ev_signal *w, int revents)
int main(int argc, char *argv[])
{
int xxxx; int aaaa;
#define xxxx xxxx + 1;
#define aaaa bbbb
#define bbbb aaaa
xxxx ; aaaa ;
assert(sizeof(unsigned short)==2);
assert(sizeof(unsigned int)==4);
assert(sizeof(unsigned long long)==8);
init_ws();

View File

@ -50,6 +50,7 @@ int send_with_pcap=1;
int pcap_header_captured=0;
int pcap_header_buf[buf_len];
int pcap_captured_full_len=-1;
pcap_t *pcap_handle;
int pcap_link_header_len=-1;
@ -221,14 +222,14 @@ void my_packet_handler(
printf("<%x>",int( p[i] ));
}
printf("\n");*/
mylog(log_debug,"received a packet!\n");
//mylog(log_debug,"received a packet!\n");
assert(packet_header->caplen <= packet_header->len);
assert(packet_header->caplen <= max_data_len);
//if(packet_header->caplen > max_data_len) return ;
if(packet_header->caplen<packet_header->len) return;
if((int)packet_header->caplen<pcap_link_header_len) return;
mylog(log_debug,"and its vaild!\n");
//mylog(log_debug,"and its vaild!\n");
pthread_mutex_lock(&queue_mutex);
if(!my_queue.full())
@ -813,7 +814,6 @@ int find_lower_level_info(u32_t ip,u32_t &dest_ip,string &if_name,string &hw)
return 0;
}*/
extern int cap_len;
int send_raw_ip(raw_info_t &raw_info,const char * payload,int payloadlen)
{
const packet_info_t &send_info=raw_info.send_info;
@ -900,6 +900,7 @@ int send_raw_ip(raw_info_t &raw_info,const char * payload,int payloadlen)
assert(pcap_link_header_len!=-1);
memcpy(send_raw_ip_buf0,pcap_header_buf,pcap_link_header_len);
assert(pcap_sendpacket(pcap_handle,(const unsigned char *)send_raw_ip_buf0,ip_tot_len+pcap_link_header_len)==0);
/*
unsigned char *p=(unsigned char *)send_raw_ip_buf0;
for(int i=0;i<ip_tot_len+pcap_link_header_len;i++)
printf("<%02x>",int(p[i]));
@ -910,7 +911,7 @@ int send_raw_ip(raw_info_t &raw_info,const char * payload,int payloadlen)
printf("<%02x>",int(p[i]));
printf("\n");
printf("pcap send!\n");
printf("pcap send!\n");*/
}

View File

@ -58,11 +58,11 @@ struct icmphdr
struct my_iphdr
{
#ifdef UDP2RAW_LITTLE_ENDIAN
unsigned int ihl:4;
unsigned int version:4;
unsigned char ihl:4;
unsigned char version:4;
#else
unsigned int version:4;
unsigned int ihl:4;
unsigned char version:4;
unsigned char ihl:4;
#endif
u_int8_t tos;
u_int16_t tot_len;