mirror of
https://github.com/digarok/gsplus.git
synced 2024-11-30 16:50:45 +00:00
rawnet - close pcap if not an ethernet device.
This commit is contained in:
parent
c4796f77ec
commit
5884e751bc
@ -228,6 +228,8 @@ static int rawnet_pcap_open_adapter(const char *interface_name)
|
|||||||
/* Check the link layer. We support only Ethernet for simplicity. */
|
/* Check the link layer. We support only Ethernet for simplicity. */
|
||||||
if (pcap_datalink(rawnet_pcap_fp) != DLT_EN10MB) {
|
if (pcap_datalink(rawnet_pcap_fp) != DLT_EN10MB) {
|
||||||
log_message(rawnet_arch_log, "ERROR: TFE works only on Ethernet networks.");
|
log_message(rawnet_arch_log, "ERROR: TFE works only on Ethernet networks.");
|
||||||
|
pcap_close(rawnet_pcap_fp);
|
||||||
|
rawnet_pcap_fp = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include "rawnetsupp.h"
|
#include "rawnetsupp.h"
|
||||||
|
|
||||||
typedef pcap_t *(*pcap_open_live_t)(const char *, int, int, int, char *);
|
typedef pcap_t *(*pcap_open_live_t)(const char *, int, int, int, char *);
|
||||||
|
typedef void *(*pcap_close_t)(pcap_if_t *);
|
||||||
typedef int (*pcap_dispatch_t)(pcap_t *, int, pcap_handler, u_char *);
|
typedef int (*pcap_dispatch_t)(pcap_t *, int, pcap_handler, u_char *);
|
||||||
typedef int (*pcap_setnonblock_t)(pcap_t *, int, char *);
|
typedef int (*pcap_setnonblock_t)(pcap_t *, int, char *);
|
||||||
typedef int (*pcap_datalink_t)(pcap_t *);
|
typedef int (*pcap_datalink_t)(pcap_t *);
|
||||||
@ -61,6 +62,7 @@ typedef char *(*pcap_lookupdev_t)(char *);
|
|||||||
#define RAWNET_DEBUG_WARN 1 /* this should not be deactivated */
|
#define RAWNET_DEBUG_WARN 1 /* this should not be deactivated */
|
||||||
|
|
||||||
static pcap_open_live_t p_pcap_open_live;
|
static pcap_open_live_t p_pcap_open_live;
|
||||||
|
static pcap_close_t p_pcap_close;
|
||||||
static pcap_dispatch_t p_pcap_dispatch;
|
static pcap_dispatch_t p_pcap_dispatch;
|
||||||
static pcap_setnonblock_t p_pcap_setnonblock;
|
static pcap_setnonblock_t p_pcap_setnonblock;
|
||||||
static pcap_findalldevs_t p_pcap_findalldevs;
|
static pcap_findalldevs_t p_pcap_findalldevs;
|
||||||
@ -117,6 +119,7 @@ static void EthernetPcapFreeLibrary(void)
|
|||||||
pcap_library = NULL;
|
pcap_library = NULL;
|
||||||
|
|
||||||
p_pcap_open_live = NULL;
|
p_pcap_open_live = NULL;
|
||||||
|
p_pcap_close = NULL;
|
||||||
p_pcap_dispatch = NULL;
|
p_pcap_dispatch = NULL;
|
||||||
p_pcap_setnonblock = NULL;
|
p_pcap_setnonblock = NULL;
|
||||||
p_pcap_findalldevs = NULL;
|
p_pcap_findalldevs = NULL;
|
||||||
@ -161,6 +164,7 @@ static BOOL EthernetPcapLoadLibrary(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GET_PROC_ADDRESS_AND_TEST(pcap_open_live);
|
GET_PROC_ADDRESS_AND_TEST(pcap_open_live);
|
||||||
|
GET_PROC_ADDRESS_AND_TEST(pcap_close);
|
||||||
GET_PROC_ADDRESS_AND_TEST(pcap_dispatch);
|
GET_PROC_ADDRESS_AND_TEST(pcap_dispatch);
|
||||||
GET_PROC_ADDRESS_AND_TEST(pcap_setnonblock);
|
GET_PROC_ADDRESS_AND_TEST(pcap_setnonblock);
|
||||||
GET_PROC_ADDRESS_AND_TEST(pcap_findalldevs);
|
GET_PROC_ADDRESS_AND_TEST(pcap_findalldevs);
|
||||||
@ -288,6 +292,8 @@ static BOOL EthernetPcapOpenAdapter(const char *interface_name)
|
|||||||
if ((*p_pcap_datalink)(EthernetPcapFP) != DLT_EN10MB) {
|
if ((*p_pcap_datalink)(EthernetPcapFP) != DLT_EN10MB) {
|
||||||
log_message(rawnet_arch_log, "ERROR: Ethernet works only on Ethernet networks.");
|
log_message(rawnet_arch_log, "ERROR: Ethernet works only on Ethernet networks.");
|
||||||
rawnet_enumadapter_close();
|
rawnet_enumadapter_close();
|
||||||
|
*(p_pcap_close(EthernetPcapFP));
|
||||||
|
EthernetPcapFP = NULL;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user