diff options
-rw-r--r-- | pcap-win32.c | 25 | ||||
-rw-r--r-- | portability.h | 2 |
2 files changed, 12 insertions, 15 deletions
diff --git a/pcap-win32.c b/pcap-win32.c index e554ae01..984774cf 100644 --- a/pcap-win32.c +++ b/pcap-win32.c @@ -464,6 +464,11 @@ pcap_live_dump_win32(pcap_t *p, char *filename, int maxsize, int maxpacks) /* Set the limits of the dump file */ res = PacketSetDumpLimits(p->adapter, maxsize, maxpacks); + if(res == FALSE) { + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Error setting dump limit"); + return (-1); + } return (0); } @@ -821,26 +826,16 @@ pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user) /* Send a packet to the network */ static int -pcap_inject_win32(pcap_t *p, const void *buf, size_t size){ - LPPACKET PacketToSend; - - PacketToSend=PacketAllocatePacket(); - - if (PacketToSend == NULL) - { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send error: PacketAllocatePacket failed"); - return (-1); - } +pcap_inject_win32(pcap_t *p, const void *buf, size_t size) +{ + PACKET pkt; - PacketInitPacket(PacketToSend, (PVOID)buf, (UINT)size); - if(PacketSendPacket(p->adapter,PacketToSend,TRUE) == FALSE){ + PacketInitPacket(&pkt, (PVOID)buf, size); + if(PacketSendPacket(p->adapter,&pkt,TRUE) == FALSE) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send error: PacketSendPacket failed"); - PacketFreePacket(PacketToSend); return (-1); } - PacketFreePacket(PacketToSend); - /* * We assume it all got sent if "PacketSendPacket()" succeeded. * "pcap_inject()" is expected to return the number of bytes diff --git a/portability.h b/portability.h index d4343e62..179ecd92 100644 --- a/portability.h +++ b/portability.h @@ -88,7 +88,9 @@ extern "C" { #endif #ifdef _MSC_VER + #ifndef _DEBUG #define strdup _strdup + #endif #define sscanf sscanf_s #define setbuf(x, y) \ setvbuf((x), (y), _IONBF, 0) |