Loading Makefile +1 −1 Changes for Makefile: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ FLAGS2 = endif # this works on llvm or real gcc CC = gcc CC = clang DEFINES = CFLAGS = -g -ggdb $(FLAGS2) $(INCLUDES) $(DEFINES) -Wall -O3 Loading src/rawsock-pcap.c +8 −91 Changes for src/rawsock-pcap.c: 8 added lines, 91 removed lines. Original line number Diff line number Diff line Loading @@ -168,74 +168,10 @@ static const char *null_PCAP_LIB_VERSION(void) return "stub/0.0"; } #ifdef WIN32 static void *null_PCAP_GET_AIRPCAP_HANDLE(void *p) { UNUSEDPARM(p); return NULL; } #endif #ifdef WIN32 static unsigned null_AIRPCAP_SET_DEVICE_CHANNEL(void *p, unsigned channel) { UNUSEDPARM(p);UNUSEDPARM(channel); return 0; /*0=failure, 1=success*/ } #endif static unsigned null_CAN_TRANSMIT(const char *devicename) { #if WIN32 struct DeviceCapabilities { unsigned AdapterId; /* An Id that identifies the adapter model.*/ char AdapterModelName; /* String containing a printable adapter model.*/ unsigned AdapterBus; /* The type of bus the adapter is plugged to. */ unsigned CanTransmit; /* TRUE if the adapter is able to perform frame injection.*/ unsigned CanSetTransmitPower; /* TRUE if the adapter's transmit power is can be specified by the user application.*/ unsigned ExternalAntennaPlug; /* TRUE if the adapter supports plugging one or more external antennas.*/ unsigned SupportedMedia; unsigned SupportedBands; } caps; void * (*myopen)(const char *devicename, char *errbuf); void (*myclose)(void *h); unsigned (*mycapabilities)(void *h, struct DeviceCapabilities *caps); unsigned result = 0; void *hAirpcap; hAirpcap = LoadLibraryA("airpcap.dll"); if (hAirpcap == NULL) return 0; myopen = (void * (*)(const char *, char*))GetProcAddress(hAirpcap, "AirpcapOpen"); myclose = (void (*)(void*))GetProcAddress(hAirpcap, "AirpcapClose"); mycapabilities = (unsigned (*)(void*, struct DeviceCapabilities *))GetProcAddress(hAirpcap, "AirpcapGetDeviceCapabilities"); if (myopen && mycapabilities && myclose ) { void *h = myopen(devicename, NULL); if (h) { if (mycapabilities(h, &caps)) { result = caps.CanTransmit; } myclose(h); } } FreeLibrary(hAirpcap); return result; #elif defined(__linux__) return 1; #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) return 1; #else #error unknown os #endif } struct PcapFunctions PCAP = { 0,0,0,0,0, null_PCAP_CLOSE, Loading Loading @@ -345,40 +281,36 @@ int pcap_init(void) #ifdef WIN32 void * hPacket; void * hLibpcap; void * hAirpcap; pl->is_available = 0; pl->is_printing_debug = 1; /* Look for the Packet.dll */ hPacket = LoadLibraryA("NPcap\\Packet.dll"); if (hPacket == NULL) hPacket = LoadLibraryA("Packet.dll"); if (hPacket == NULL) { if (pl->is_printing_debug) switch (GetLastError()) { case ERROR_MOD_NOT_FOUND: fprintf(stderr, "%s: not found\n", "Packet.dll"); return; return -1; default: fprintf(stderr, "%s: couldn't load %d\n", "Packet.dll", (int)GetLastError()); return; return -1; } } /* Look for the Packet.dll */ /* Look for the winpcap.dll */ hLibpcap = LoadLibraryA("Npcap\\wpcap.dll"); if (hLibpcap == NULL) hLibpcap = LoadLibraryA("wpcap.dll"); if (hLibpcap == NULL) { if (pl->is_printing_debug) fprintf(stderr, "%s: couldn't load %d\n", "wpcap.dll", (int)GetLastError()); return; return -1; } /* Look for the Packet.dll */ hAirpcap = LoadLibraryA("airpcap.dll"); if (hLibpcap == NULL) { if (pl->is_printing_debug) fprintf(stderr, "%s: couldn't load %d\n", "airpcap.dll", (int)GetLastError()); return; } #define DOLINK(PCAP_DATALINK, datalink) \ pl->datalink = (PCAP_DATALINK)GetProcAddress(hLibpcap, "pcap_"#datalink); \ Loading Loading @@ -430,20 +362,6 @@ pl->func_err=0, pl->datalink = null_##PCAP_DATALINK; #endif #endif #ifdef WIN32 DOLINK(PCAP_GET_AIRPCAP_HANDLE, get_airpcap_handle); if (pl->func_err) { pl->func_err = 0; } if (hAirpcap) { pl->airpcap_set_device_channel = (AIRPCAP_SET_DEVICE_CHANNEL)GetProcAddress(hAirpcap, "AirpcapSetDeviceChannel"); if (pl->airpcap_set_device_channel == NULL) pl->airpcap_set_device_channel = null_AIRPCAP_SET_DEVICE_CHANNEL; } #endif DOLINK(PCAP_CLOSE , close); DOLINK(PCAP_DATALINK , datalink); DOLINK(PCAP_DISPATCH , dispatch); Loading Loading @@ -472,7 +390,6 @@ pl->func_err=0, pl->datalink = null_##PCAP_DATALINK; DOLINK(PCAP_SENDQUEUE_QUEUE , sendqueue_queue); pl->can_transmit = null_CAN_TRANSMIT; if (!pl->func_err) pl->is_available = 1; Loading src/rawsock-pcap.h −8 Changes for src/rawsock-pcap.h: 0 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -74,9 +74,6 @@ typedef int (*PCAP_MAJOR_VERSION)(void *p); typedef int (*PCAP_MINOR_VERSION)(void *p); typedef void * (*PCAP_OPEN_LIVE)(const char *devicename, unsigned snap_length, unsigned is_promiscuous, unsigned read_timeout, char *errbuf); typedef void (*PCAP_FREEALLDEVS)(pcap_if_t *alldevs); typedef void * (*PCAP_GET_AIRPCAP_HANDLE)(void *p); typedef unsigned (*AIRPCAP_SET_DEVICE_CHANNEL)(void *p, unsigned channel); typedef unsigned (*CAN_TRANSMIT)(const char *devicename); typedef pcap_t * (*PCAP_OPEN_OFFLINE)(const char *fname, char *errbuf); typedef int (*PCAP_SENDPACKET)(pcap_t *p, const unsigned char *buf, int size); typedef const unsigned char *(*PCAP_NEXT)(pcap_t *p, struct pcap_pkthdr *h); Loading Loading @@ -121,12 +118,7 @@ struct PcapFunctions { PCAP_MAJOR_VERSION major_version; PCAP_MINOR_VERSION minor_version; PCAP_OPEN_LIVE open_live; PCAP_GET_AIRPCAP_HANDLE get_airpcap_handle; AIRPCAP_SET_DEVICE_CHANNEL airpcap_set_device_channel; //AIRPCAP_SET_FCS_PRESENCE airpcap_set_fcs_presence; //BOOL AirpcapSetFcsPresence(PAirpcapHandle AdapterHandle, BOOL IsFcsPresent); CAN_TRANSMIT can_transmit; PCAP_OPEN_OFFLINE open_offline; PCAP_SENDPACKET sendpacket; Loading src/rawsock.c +8 Changes for src/rawsock.c: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -485,6 +485,14 @@ rawsock_ignore_transmits(struct Adapter *adapter, const unsigned char *adapter_m return; } if (adapter->pcap) { int err; err = PCAP.setdirection(adapter->pcap, PCAP_D_IN); if (err) { PCAP.perror(adapter->pcap, "pcap_setdirection(IN)"); } } #if !defined(WIN32) /* PORTABILITY: this is what we do on all systems except windows, because Loading Loading
Makefile +1 −1 Changes for Makefile: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ FLAGS2 = endif # this works on llvm or real gcc CC = gcc CC = clang DEFINES = CFLAGS = -g -ggdb $(FLAGS2) $(INCLUDES) $(DEFINES) -Wall -O3 Loading
src/rawsock-pcap.c +8 −91 Changes for src/rawsock-pcap.c: 8 added lines, 91 removed lines. Original line number Diff line number Diff line Loading @@ -168,74 +168,10 @@ static const char *null_PCAP_LIB_VERSION(void) return "stub/0.0"; } #ifdef WIN32 static void *null_PCAP_GET_AIRPCAP_HANDLE(void *p) { UNUSEDPARM(p); return NULL; } #endif #ifdef WIN32 static unsigned null_AIRPCAP_SET_DEVICE_CHANNEL(void *p, unsigned channel) { UNUSEDPARM(p);UNUSEDPARM(channel); return 0; /*0=failure, 1=success*/ } #endif static unsigned null_CAN_TRANSMIT(const char *devicename) { #if WIN32 struct DeviceCapabilities { unsigned AdapterId; /* An Id that identifies the adapter model.*/ char AdapterModelName; /* String containing a printable adapter model.*/ unsigned AdapterBus; /* The type of bus the adapter is plugged to. */ unsigned CanTransmit; /* TRUE if the adapter is able to perform frame injection.*/ unsigned CanSetTransmitPower; /* TRUE if the adapter's transmit power is can be specified by the user application.*/ unsigned ExternalAntennaPlug; /* TRUE if the adapter supports plugging one or more external antennas.*/ unsigned SupportedMedia; unsigned SupportedBands; } caps; void * (*myopen)(const char *devicename, char *errbuf); void (*myclose)(void *h); unsigned (*mycapabilities)(void *h, struct DeviceCapabilities *caps); unsigned result = 0; void *hAirpcap; hAirpcap = LoadLibraryA("airpcap.dll"); if (hAirpcap == NULL) return 0; myopen = (void * (*)(const char *, char*))GetProcAddress(hAirpcap, "AirpcapOpen"); myclose = (void (*)(void*))GetProcAddress(hAirpcap, "AirpcapClose"); mycapabilities = (unsigned (*)(void*, struct DeviceCapabilities *))GetProcAddress(hAirpcap, "AirpcapGetDeviceCapabilities"); if (myopen && mycapabilities && myclose ) { void *h = myopen(devicename, NULL); if (h) { if (mycapabilities(h, &caps)) { result = caps.CanTransmit; } myclose(h); } } FreeLibrary(hAirpcap); return result; #elif defined(__linux__) return 1; #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) return 1; #else #error unknown os #endif } struct PcapFunctions PCAP = { 0,0,0,0,0, null_PCAP_CLOSE, Loading Loading @@ -345,40 +281,36 @@ int pcap_init(void) #ifdef WIN32 void * hPacket; void * hLibpcap; void * hAirpcap; pl->is_available = 0; pl->is_printing_debug = 1; /* Look for the Packet.dll */ hPacket = LoadLibraryA("NPcap\\Packet.dll"); if (hPacket == NULL) hPacket = LoadLibraryA("Packet.dll"); if (hPacket == NULL) { if (pl->is_printing_debug) switch (GetLastError()) { case ERROR_MOD_NOT_FOUND: fprintf(stderr, "%s: not found\n", "Packet.dll"); return; return -1; default: fprintf(stderr, "%s: couldn't load %d\n", "Packet.dll", (int)GetLastError()); return; return -1; } } /* Look for the Packet.dll */ /* Look for the winpcap.dll */ hLibpcap = LoadLibraryA("Npcap\\wpcap.dll"); if (hLibpcap == NULL) hLibpcap = LoadLibraryA("wpcap.dll"); if (hLibpcap == NULL) { if (pl->is_printing_debug) fprintf(stderr, "%s: couldn't load %d\n", "wpcap.dll", (int)GetLastError()); return; return -1; } /* Look for the Packet.dll */ hAirpcap = LoadLibraryA("airpcap.dll"); if (hLibpcap == NULL) { if (pl->is_printing_debug) fprintf(stderr, "%s: couldn't load %d\n", "airpcap.dll", (int)GetLastError()); return; } #define DOLINK(PCAP_DATALINK, datalink) \ pl->datalink = (PCAP_DATALINK)GetProcAddress(hLibpcap, "pcap_"#datalink); \ Loading Loading @@ -430,20 +362,6 @@ pl->func_err=0, pl->datalink = null_##PCAP_DATALINK; #endif #endif #ifdef WIN32 DOLINK(PCAP_GET_AIRPCAP_HANDLE, get_airpcap_handle); if (pl->func_err) { pl->func_err = 0; } if (hAirpcap) { pl->airpcap_set_device_channel = (AIRPCAP_SET_DEVICE_CHANNEL)GetProcAddress(hAirpcap, "AirpcapSetDeviceChannel"); if (pl->airpcap_set_device_channel == NULL) pl->airpcap_set_device_channel = null_AIRPCAP_SET_DEVICE_CHANNEL; } #endif DOLINK(PCAP_CLOSE , close); DOLINK(PCAP_DATALINK , datalink); DOLINK(PCAP_DISPATCH , dispatch); Loading Loading @@ -472,7 +390,6 @@ pl->func_err=0, pl->datalink = null_##PCAP_DATALINK; DOLINK(PCAP_SENDQUEUE_QUEUE , sendqueue_queue); pl->can_transmit = null_CAN_TRANSMIT; if (!pl->func_err) pl->is_available = 1; Loading
src/rawsock-pcap.h −8 Changes for src/rawsock-pcap.h: 0 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -74,9 +74,6 @@ typedef int (*PCAP_MAJOR_VERSION)(void *p); typedef int (*PCAP_MINOR_VERSION)(void *p); typedef void * (*PCAP_OPEN_LIVE)(const char *devicename, unsigned snap_length, unsigned is_promiscuous, unsigned read_timeout, char *errbuf); typedef void (*PCAP_FREEALLDEVS)(pcap_if_t *alldevs); typedef void * (*PCAP_GET_AIRPCAP_HANDLE)(void *p); typedef unsigned (*AIRPCAP_SET_DEVICE_CHANNEL)(void *p, unsigned channel); typedef unsigned (*CAN_TRANSMIT)(const char *devicename); typedef pcap_t * (*PCAP_OPEN_OFFLINE)(const char *fname, char *errbuf); typedef int (*PCAP_SENDPACKET)(pcap_t *p, const unsigned char *buf, int size); typedef const unsigned char *(*PCAP_NEXT)(pcap_t *p, struct pcap_pkthdr *h); Loading Loading @@ -121,12 +118,7 @@ struct PcapFunctions { PCAP_MAJOR_VERSION major_version; PCAP_MINOR_VERSION minor_version; PCAP_OPEN_LIVE open_live; PCAP_GET_AIRPCAP_HANDLE get_airpcap_handle; AIRPCAP_SET_DEVICE_CHANNEL airpcap_set_device_channel; //AIRPCAP_SET_FCS_PRESENCE airpcap_set_fcs_presence; //BOOL AirpcapSetFcsPresence(PAirpcapHandle AdapterHandle, BOOL IsFcsPresent); CAN_TRANSMIT can_transmit; PCAP_OPEN_OFFLINE open_offline; PCAP_SENDPACKET sendpacket; Loading
src/rawsock.c +8 Changes for src/rawsock.c: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -485,6 +485,14 @@ rawsock_ignore_transmits(struct Adapter *adapter, const unsigned char *adapter_m return; } if (adapter->pcap) { int err; err = PCAP.setdirection(adapter->pcap, PCAP_D_IN); if (err) { PCAP.perror(adapter->pcap, "pcap_setdirection(IN)"); } } #if !defined(WIN32) /* PORTABILITY: this is what we do on all systems except windows, because Loading