packet header print fix

This commit is contained in:
U-DESKTOP-T772REH\wangyu 2018-06-17 17:52:33 +08:00
parent e630f81c6e
commit c03e60be51
2 changed files with 16 additions and 4 deletions

@ -668,8 +668,10 @@ void async_cb(struct ev_loop *loop, struct ev_async *watcher, int revents)
memcpy(pcap_header_buf,p,pcap_link_header_len);
log_bare(log_info,"link level header captured:\n");
unsigned char *tmp=(unsigned char*)pcap_header_buf;
for(int i=0;i<pcap_link_header_len;i++)
log_bare(log_info,"<%x>",(u32_t)(unsigned char)pcap_header_buf[i]);
log_bare(log_info,"<%x>",(u32_t)tmp[i]);
log_bare(log_info,"\n");
return ;
}
@ -787,7 +789,7 @@ int client_event_loop()
{
mylog(log_info,"--dev have not been set, trying to detect automatically, avaliable deives:\n");
mylog(log_info,"avaliable deives(and ip address):\n");
mylog(log_info,"avaliable deives(device name: ip address ; description):\n");
char errbuf[PCAP_ERRBUF_SIZE];
@ -816,7 +818,12 @@ int client_event_loop()
}
}
}
if(cnt==0) log_bare(log_info," (no ip found)");
if(cnt==0) log_bare(log_info," [no ip found]");
if(d->description==0)
{
log_bare(log_info,"; (null)");
}
log_bare(log_info,"; %s", d->description);
log_bare(log_info,"\n");
}

@ -1,7 +1,7 @@
#include <windows.h>
#include <pcap_wrapper.h>
#include <assert.h>
#include <stdio.h>
int (*pcap_loop )(pcap_t *, int, pcap_handler, u_char *);
pcap_t* (*pcap_create)(const char *, char *);
@ -43,6 +43,11 @@ struct init_pcap_t
int init_pcap()
{
HMODULE wpcap=LoadLibrary("wpcap.dll");
if(wpcap==0)
{
printf("cant not open wpcap.dll, make sure winpcap/npcap is installed\n");
exit(-1);
}
assert(wpcap!=0);
pcap_loop = (__typeof__(pcap_loop))GetProcAddress(wpcap, "pcap_loop");