Loading src/rawsock-pcap.c +41 −4 Changes for src/rawsock-pcap.c: 41 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ #ifndef UNUSEDPARM #ifdef __GNUC__ #define UNUSEDPARM(x) x=(x) #else #define UNUSEDPARM(x) x=(x) #endif #endif Loading Loading @@ -234,6 +236,7 @@ struct PcapFunctions PCAP = { static void *my_null(int x, ...) { UNUSEDPARM(x); return 0; } static pcap_t *null_PCAP_OPEN_OFFLINE(const char *fname, char *errbuf) Loading @@ -242,23 +245,29 @@ static pcap_t *null_PCAP_OPEN_OFFLINE(const char *fname, char *errbuf) } static int null_PCAP_SENDPACKET(pcap_t *p, const unsigned char *buf, int size) { return (int)my_null(p, buf, size); my_null(3, p, buf, size); return 0; } static const unsigned char *null_PCAP_NEXT(pcap_t *p, struct pcap_pkthdr *h) { my_null(3, p, h); return 0; } static int null_PCAP_SETDIRECTION(pcap_t *p, pcap_direction_t d) { my_null(2, p, d); return 0; } static const char *null_PCAP_DATALINK_VAL_TO_NAME(int dlt) { my_null(1, dlt); return 0; } static void null_PCAP_PERROR(pcap_t *p, char *prefix) { UNUSEDPARM(p); fprintf(stderr, "%s\n", prefix); perror("pcap"); } static const char *null_PCAP_DEV_NAME(const pcap_if_t *dev) Loading @@ -274,6 +283,29 @@ static const pcap_if_t *null_PCAP_DEV_NEXT(const pcap_if_t *dev) return dev->next; } static pcap_send_queue *null_PCAP_SENDQUEUE_ALLOC(size_t size) { UNUSEDPARM(size); return 0; } static unsigned null_PCAP_SENDQUEUE_TRANSMIT(pcap_t *p, pcap_send_queue *queue, int sync) { my_null(3, p, queue, sync); return 0; } static void null_PCAP_SENDQUEUE_DESTROY(pcap_send_queue *queue) { my_null(1, queue); UNUSEDPARM(queue); } static int null_PCAP_SENDQUEUE_QUEUE(pcap_send_queue *queue, const struct pcap_pkthdr *pkt_header, const unsigned char *pkt_data) { my_null(4, queue, pkt_header, pkt_data); return 0; } /** * Runtime-load the libpcap shared-object or the winpcap DLL. We * load at runtime rather than loadtime to allow this program to Loading @@ -284,9 +316,9 @@ void pcap_init(void) { struct PcapFunctions *pl = &PCAP; #ifdef WIN32 HMODULE hPacket; HMODULE hLibpcap; HMODULE hAirpcap; void * hPacket; void * hLibpcap; void * hAirpcap; pl->is_available = 0; pl->is_printing_debug = 1; Loading Loading @@ -405,6 +437,11 @@ pl->func_err=0, pl->datalink = null_##PCAP_DATALINK; DOLINK(PCAP_DEV_DESCRIPTION , dev_description); DOLINK(PCAP_DEV_NEXT , dev_next); DOLINK(PCAP_SENDQUEUE_ALLOC , sendqueue_alloc); DOLINK(PCAP_SENDQUEUE_TRANSMIT , sendqueue_transmit); DOLINK(PCAP_SENDQUEUE_DESTROY , sendqueue_destroy); DOLINK(PCAP_SENDQUEUE_QUEUE , sendqueue_queue); pl->can_transmit = null_CAN_TRANSMIT; Loading src/rawsock-pcap.h +27 −2 Changes for src/rawsock-pcap.h: 27 added lines, 2 removed lines. Original line number Diff line number Diff line #ifndef RAWSOCK_PCAP_H #define RAWSOCK_PCAP_H #include <sys/time.h> #include <stdio.h> struct pcap_timeval { long tv_sec; /* seconds */ long tv_usec; /* and microseconds */ }; struct pcap; typedef struct pcap pcap_t; Loading @@ -17,7 +22,7 @@ typedef enum { } pcap_direction_t; struct pcap_pkthdr { struct timeval ts; struct pcap_timeval ts; unsigned caplen; unsigned len; #ifdef __APPLE__ Loading Loading @@ -51,6 +56,21 @@ typedef const char *(*PCAP_DEV_NAME)(const pcap_if_t *dev); typedef const char *(*PCAP_DEV_DESCRIPTION)(const pcap_if_t *dev); typedef const pcap_if_t *(*PCAP_DEV_NEXT)(const pcap_if_t *dev); /* * PORTABILITY: Windows supports the "sendq" feature, and is really slow * without this feature. It's not needed on Linux, so we just create * equivelent functions that do nothing */ struct pcap_send_queue; typedef struct pcap_send_queue pcap_send_queue; typedef pcap_send_queue *(*PCAP_SENDQUEUE_ALLOC)(size_t size); typedef unsigned (*PCAP_SENDQUEUE_TRANSMIT)(pcap_t *p, pcap_send_queue *queue, int sync); typedef void (*PCAP_SENDQUEUE_DESTROY)(pcap_send_queue *queue); typedef int (*PCAP_SENDQUEUE_QUEUE)(pcap_send_queue *queue, const struct pcap_pkthdr *pkt_header, const unsigned char *pkt_data); struct PcapFunctions { Loading Loading @@ -88,6 +108,11 @@ struct PcapFunctions { PCAP_DEV_DESCRIPTION dev_description; PCAP_DEV_NEXT dev_next; PCAP_SENDQUEUE_ALLOC sendqueue_alloc; PCAP_SENDQUEUE_TRANSMIT sendqueue_transmit; PCAP_SENDQUEUE_DESTROY sendqueue_destroy; PCAP_SENDQUEUE_QUEUE sendqueue_queue; }; extern struct PcapFunctions PCAP; Loading src/rawsock.c +11 −29 Changes for src/rawsock.c: 11 added lines, 29 removed lines. Original line number Diff line number Diff line Loading @@ -12,8 +12,8 @@ #include "rawsock-pfring.h" #include "pixie-timer.h" #include "main-globals.h" #include "rawsock-pcap.h" //#include <pcap.h> #include <assert.h> #include <ctype.h> Loading @@ -21,12 +21,10 @@ static int is_pcap_file = 0; #ifdef WIN32 #include <Win32-Extensions.h> #include <winsock.h> #include <iphlpapi.h> #if defined(_MSC_VER) #pragma comment(lib, "packet.lib") #pragma comment(lib, "wpcap.lib") #pragma comment(lib, "IPHLPAPI.lib") #endif Loading @@ -39,20 +37,6 @@ static int is_pcap_file = 0; #include <net/if.h> #include <arpa/inet.h> /* * PORTABILITY: Windows supports the "sendq" feature, and is really slow * without this feature. It's not needed on Linux, so we just create * equivelent functions that do nothing */ struct pcap_send_queue; typedef struct pcap_send_queue pcap_send_queue; static pcap_send_queue *pcap_sendqueue_alloc(size_t size) {return 0;} static unsigned pcap_sendqueue_transmit( pcap_t *p, pcap_send_queue *queue, int sync) {return 0;} static void pcap_sendqueue_destroy(pcap_send_queue *queue) {;} static int pcap_sendqueue_queue(pcap_send_queue *queue, const struct pcap_pkthdr *pkt_header, const unsigned char *pkt_data) {return 0;} #else #endif Loading @@ -78,7 +62,7 @@ int pcap_setdirection(pcap_t *pcap, pcap_direction_t direction) static int (*real_setdirection)(pcap_t *, pcap_direction_t) = 0; if (real_setdirection == 0) { HMODULE h = LoadLibraryA("wpcap.dll"); void* h = LoadLibraryA("wpcap.dll"); if (h == NULL) { fprintf(stderr, "couldn't load wpcap.dll: %u\n", (unsigned)GetLastError()); Loading Loading @@ -274,12 +258,12 @@ void rawsock_flush(struct Adapter *adapter) { if (adapter->sendq) { pcap_sendqueue_transmit(adapter->pcap, adapter->sendq, 0); PCAP.sendqueue_transmit(adapter->pcap, adapter->sendq, 0); /* Dude, I totally forget why this step is necessary. I vaguely * remember there's a good reason for it though */ pcap_sendqueue_destroy(adapter->sendq); adapter->sendq = pcap_sendqueue_alloc(SENDQ_SIZE); PCAP.sendqueue_destroy(adapter->sendq); adapter->sendq = PCAP.sendqueue_alloc(SENDQ_SIZE); } } Loading Loading @@ -326,10 +310,10 @@ rawsock_send_packet( hdr.len = length; hdr.caplen = length; err = pcap_sendqueue_queue(adapter->sendq, &hdr, packet); err = PCAP.sendqueue_queue(adapter->sendq, &hdr, packet); if (err) { rawsock_flush(adapter); pcap_sendqueue_queue(adapter->sendq, &hdr, packet); PCAP.sendqueue_queue(adapter->sendq, &hdr, packet); } if (flush) { Loading Loading @@ -513,7 +497,7 @@ rawsock_ignore_transmits(struct Adapter *adapter, const unsigned char *adapter_m PCAP.perror(adapter->pcap, "pcap_setdirection(IN)"); } } #else #elif defined(WIN32xxx) if (adapter->pcap) { int err; char filter[256]; Loading Loading @@ -543,8 +527,6 @@ rawsock_ignore_transmits(struct Adapter *adapter, const unsigned char *adapter_m } } #endif } /*************************************************************************** Loading @@ -559,7 +541,7 @@ rawsock_close_adapter(struct Adapter *adapter) PCAP.close(adapter->pcap); } if (adapter->sendq) { pcap_sendqueue_destroy(adapter->sendq); PCAP.sendqueue_destroy(adapter->sendq); } free(adapter); Loading Loading @@ -835,7 +817,7 @@ rawsock_init_adapter(const char *adapter_name, adapter->sendq = 0; #if defined(WIN32) if (is_sendq) adapter->sendq = pcap_sendqueue_alloc(SENDQ_SIZE); adapter->sendq = PCAP.sendqueue_alloc(SENDQ_SIZE); #endif Loading vs10/include/Packet32.h −359 File deleted. Show changes vs10/include/Win32-Extensions.h −113 File deleted.Preview size limit exceeded, changes collapsed. Show changes Loading
src/rawsock-pcap.c +41 −4 Changes for src/rawsock-pcap.c: 41 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ #ifndef UNUSEDPARM #ifdef __GNUC__ #define UNUSEDPARM(x) x=(x) #else #define UNUSEDPARM(x) x=(x) #endif #endif Loading Loading @@ -234,6 +236,7 @@ struct PcapFunctions PCAP = { static void *my_null(int x, ...) { UNUSEDPARM(x); return 0; } static pcap_t *null_PCAP_OPEN_OFFLINE(const char *fname, char *errbuf) Loading @@ -242,23 +245,29 @@ static pcap_t *null_PCAP_OPEN_OFFLINE(const char *fname, char *errbuf) } static int null_PCAP_SENDPACKET(pcap_t *p, const unsigned char *buf, int size) { return (int)my_null(p, buf, size); my_null(3, p, buf, size); return 0; } static const unsigned char *null_PCAP_NEXT(pcap_t *p, struct pcap_pkthdr *h) { my_null(3, p, h); return 0; } static int null_PCAP_SETDIRECTION(pcap_t *p, pcap_direction_t d) { my_null(2, p, d); return 0; } static const char *null_PCAP_DATALINK_VAL_TO_NAME(int dlt) { my_null(1, dlt); return 0; } static void null_PCAP_PERROR(pcap_t *p, char *prefix) { UNUSEDPARM(p); fprintf(stderr, "%s\n", prefix); perror("pcap"); } static const char *null_PCAP_DEV_NAME(const pcap_if_t *dev) Loading @@ -274,6 +283,29 @@ static const pcap_if_t *null_PCAP_DEV_NEXT(const pcap_if_t *dev) return dev->next; } static pcap_send_queue *null_PCAP_SENDQUEUE_ALLOC(size_t size) { UNUSEDPARM(size); return 0; } static unsigned null_PCAP_SENDQUEUE_TRANSMIT(pcap_t *p, pcap_send_queue *queue, int sync) { my_null(3, p, queue, sync); return 0; } static void null_PCAP_SENDQUEUE_DESTROY(pcap_send_queue *queue) { my_null(1, queue); UNUSEDPARM(queue); } static int null_PCAP_SENDQUEUE_QUEUE(pcap_send_queue *queue, const struct pcap_pkthdr *pkt_header, const unsigned char *pkt_data) { my_null(4, queue, pkt_header, pkt_data); return 0; } /** * Runtime-load the libpcap shared-object or the winpcap DLL. We * load at runtime rather than loadtime to allow this program to Loading @@ -284,9 +316,9 @@ void pcap_init(void) { struct PcapFunctions *pl = &PCAP; #ifdef WIN32 HMODULE hPacket; HMODULE hLibpcap; HMODULE hAirpcap; void * hPacket; void * hLibpcap; void * hAirpcap; pl->is_available = 0; pl->is_printing_debug = 1; Loading Loading @@ -405,6 +437,11 @@ pl->func_err=0, pl->datalink = null_##PCAP_DATALINK; DOLINK(PCAP_DEV_DESCRIPTION , dev_description); DOLINK(PCAP_DEV_NEXT , dev_next); DOLINK(PCAP_SENDQUEUE_ALLOC , sendqueue_alloc); DOLINK(PCAP_SENDQUEUE_TRANSMIT , sendqueue_transmit); DOLINK(PCAP_SENDQUEUE_DESTROY , sendqueue_destroy); DOLINK(PCAP_SENDQUEUE_QUEUE , sendqueue_queue); pl->can_transmit = null_CAN_TRANSMIT; Loading
src/rawsock-pcap.h +27 −2 Changes for src/rawsock-pcap.h: 27 added lines, 2 removed lines. Original line number Diff line number Diff line #ifndef RAWSOCK_PCAP_H #define RAWSOCK_PCAP_H #include <sys/time.h> #include <stdio.h> struct pcap_timeval { long tv_sec; /* seconds */ long tv_usec; /* and microseconds */ }; struct pcap; typedef struct pcap pcap_t; Loading @@ -17,7 +22,7 @@ typedef enum { } pcap_direction_t; struct pcap_pkthdr { struct timeval ts; struct pcap_timeval ts; unsigned caplen; unsigned len; #ifdef __APPLE__ Loading Loading @@ -51,6 +56,21 @@ typedef const char *(*PCAP_DEV_NAME)(const pcap_if_t *dev); typedef const char *(*PCAP_DEV_DESCRIPTION)(const pcap_if_t *dev); typedef const pcap_if_t *(*PCAP_DEV_NEXT)(const pcap_if_t *dev); /* * PORTABILITY: Windows supports the "sendq" feature, and is really slow * without this feature. It's not needed on Linux, so we just create * equivelent functions that do nothing */ struct pcap_send_queue; typedef struct pcap_send_queue pcap_send_queue; typedef pcap_send_queue *(*PCAP_SENDQUEUE_ALLOC)(size_t size); typedef unsigned (*PCAP_SENDQUEUE_TRANSMIT)(pcap_t *p, pcap_send_queue *queue, int sync); typedef void (*PCAP_SENDQUEUE_DESTROY)(pcap_send_queue *queue); typedef int (*PCAP_SENDQUEUE_QUEUE)(pcap_send_queue *queue, const struct pcap_pkthdr *pkt_header, const unsigned char *pkt_data); struct PcapFunctions { Loading Loading @@ -88,6 +108,11 @@ struct PcapFunctions { PCAP_DEV_DESCRIPTION dev_description; PCAP_DEV_NEXT dev_next; PCAP_SENDQUEUE_ALLOC sendqueue_alloc; PCAP_SENDQUEUE_TRANSMIT sendqueue_transmit; PCAP_SENDQUEUE_DESTROY sendqueue_destroy; PCAP_SENDQUEUE_QUEUE sendqueue_queue; }; extern struct PcapFunctions PCAP; Loading
src/rawsock.c +11 −29 Changes for src/rawsock.c: 11 added lines, 29 removed lines. Original line number Diff line number Diff line Loading @@ -12,8 +12,8 @@ #include "rawsock-pfring.h" #include "pixie-timer.h" #include "main-globals.h" #include "rawsock-pcap.h" //#include <pcap.h> #include <assert.h> #include <ctype.h> Loading @@ -21,12 +21,10 @@ static int is_pcap_file = 0; #ifdef WIN32 #include <Win32-Extensions.h> #include <winsock.h> #include <iphlpapi.h> #if defined(_MSC_VER) #pragma comment(lib, "packet.lib") #pragma comment(lib, "wpcap.lib") #pragma comment(lib, "IPHLPAPI.lib") #endif Loading @@ -39,20 +37,6 @@ static int is_pcap_file = 0; #include <net/if.h> #include <arpa/inet.h> /* * PORTABILITY: Windows supports the "sendq" feature, and is really slow * without this feature. It's not needed on Linux, so we just create * equivelent functions that do nothing */ struct pcap_send_queue; typedef struct pcap_send_queue pcap_send_queue; static pcap_send_queue *pcap_sendqueue_alloc(size_t size) {return 0;} static unsigned pcap_sendqueue_transmit( pcap_t *p, pcap_send_queue *queue, int sync) {return 0;} static void pcap_sendqueue_destroy(pcap_send_queue *queue) {;} static int pcap_sendqueue_queue(pcap_send_queue *queue, const struct pcap_pkthdr *pkt_header, const unsigned char *pkt_data) {return 0;} #else #endif Loading @@ -78,7 +62,7 @@ int pcap_setdirection(pcap_t *pcap, pcap_direction_t direction) static int (*real_setdirection)(pcap_t *, pcap_direction_t) = 0; if (real_setdirection == 0) { HMODULE h = LoadLibraryA("wpcap.dll"); void* h = LoadLibraryA("wpcap.dll"); if (h == NULL) { fprintf(stderr, "couldn't load wpcap.dll: %u\n", (unsigned)GetLastError()); Loading Loading @@ -274,12 +258,12 @@ void rawsock_flush(struct Adapter *adapter) { if (adapter->sendq) { pcap_sendqueue_transmit(adapter->pcap, adapter->sendq, 0); PCAP.sendqueue_transmit(adapter->pcap, adapter->sendq, 0); /* Dude, I totally forget why this step is necessary. I vaguely * remember there's a good reason for it though */ pcap_sendqueue_destroy(adapter->sendq); adapter->sendq = pcap_sendqueue_alloc(SENDQ_SIZE); PCAP.sendqueue_destroy(adapter->sendq); adapter->sendq = PCAP.sendqueue_alloc(SENDQ_SIZE); } } Loading Loading @@ -326,10 +310,10 @@ rawsock_send_packet( hdr.len = length; hdr.caplen = length; err = pcap_sendqueue_queue(adapter->sendq, &hdr, packet); err = PCAP.sendqueue_queue(adapter->sendq, &hdr, packet); if (err) { rawsock_flush(adapter); pcap_sendqueue_queue(adapter->sendq, &hdr, packet); PCAP.sendqueue_queue(adapter->sendq, &hdr, packet); } if (flush) { Loading Loading @@ -513,7 +497,7 @@ rawsock_ignore_transmits(struct Adapter *adapter, const unsigned char *adapter_m PCAP.perror(adapter->pcap, "pcap_setdirection(IN)"); } } #else #elif defined(WIN32xxx) if (adapter->pcap) { int err; char filter[256]; Loading Loading @@ -543,8 +527,6 @@ rawsock_ignore_transmits(struct Adapter *adapter, const unsigned char *adapter_m } } #endif } /*************************************************************************** Loading @@ -559,7 +541,7 @@ rawsock_close_adapter(struct Adapter *adapter) PCAP.close(adapter->pcap); } if (adapter->sendq) { pcap_sendqueue_destroy(adapter->sendq); PCAP.sendqueue_destroy(adapter->sendq); } free(adapter); Loading Loading @@ -835,7 +817,7 @@ rawsock_init_adapter(const char *adapter_name, adapter->sendq = 0; #if defined(WIN32) if (is_sendq) adapter->sendq = pcap_sendqueue_alloc(SENDQ_SIZE); adapter->sendq = PCAP.sendqueue_alloc(SENDQ_SIZE); #endif Loading
vs10/include/Win32-Extensions.h −113 File deleted.Preview size limit exceeded, changes collapsed. Show changes