forked from osmocom/wireshark
Have the routines to get interface lists take a pointer to a "gchar *"
as an argument, and, on an error, if they have an error message, have them set that "gchar *" to point to a g_malloc()ed string containing the error message, rather than taking a pointer to a buffer for that message as an argument. That's more like what's done in Wiretap, and doesn't impose an upper limit on the lengths of those error messages. If that pointer is null, don't allocate the message string and return it. Have that error message already have the "cant_get" processing applied to it, so nobody other than those routines need to call the "cant_get" routines to process the error messages. Have get_airpcap_interface_list() explicitly set "*err" to the appropriate error code. Clean up indentation. svn path=/trunk/; revision=20521
This commit is contained in:
parent
62c148c1d5
commit
cc22748169
|
@ -649,7 +649,7 @@ save_wlan_wireshark_wep_keys(GList* key_ls)
|
||||||
* Get an error message string for a CANT_GET_INTERFACE_LIST error from
|
* Get an error message string for a CANT_GET_INTERFACE_LIST error from
|
||||||
* "get_airpcap_interface_list()".
|
* "get_airpcap_interface_list()".
|
||||||
*/
|
*/
|
||||||
gchar *
|
static gchar *
|
||||||
cant_get_airpcap_if_list_error_message(const char *err_str)
|
cant_get_airpcap_if_list_error_message(const char *err_str)
|
||||||
{
|
{
|
||||||
return g_strdup_printf("Can't get list of Wireless interfaces: %s", err_str);
|
return g_strdup_printf("Can't get list of Wireless interfaces: %s", err_str);
|
||||||
|
@ -1125,19 +1125,20 @@ free_airpcap_interface_list(GList *if_list)
|
||||||
* Will return null if no device is found.
|
* Will return null if no device is found.
|
||||||
*/
|
*/
|
||||||
GList*
|
GList*
|
||||||
get_airpcap_interface_list(int *err, char *err_str)
|
get_airpcap_interface_list(int *err, char **err_str)
|
||||||
{
|
{
|
||||||
GList *il = NULL;
|
GList *il = NULL;
|
||||||
airpcap_if_info_t *if_info;
|
airpcap_if_info_t *if_info;
|
||||||
int i, n_adapts;
|
int i, n_adapts;
|
||||||
AirpcapDeviceDescription *devsList, *adListEntry;
|
AirpcapDeviceDescription *devsList, *adListEntry;
|
||||||
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
|
|
||||||
if (err)
|
if(!AirpcapLoaded || !g_PAirpcapGetDeviceList(&devsList, errbuf))
|
||||||
*err = NO_AIRPCAP_INTERFACES_FOUND;
|
|
||||||
|
|
||||||
if(!AirpcapLoaded || !g_PAirpcapGetDeviceList(&devsList, err_str))
|
|
||||||
{
|
{
|
||||||
/* No interfaces, return il = NULL; */
|
/* No interfaces, return il = NULL; */
|
||||||
|
*err = CANT_GET_AIRPCAP_INTERFACE_LIST;
|
||||||
|
if (err_str != NULL)
|
||||||
|
*err_str = cant_get_airpcap_if_list_error_message(errbuf);
|
||||||
return il;
|
return il;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,6 +1157,9 @@ get_airpcap_interface_list(int *err, char *err_str)
|
||||||
{
|
{
|
||||||
/* No interfaces, return il= NULL */
|
/* No interfaces, return il= NULL */
|
||||||
g_PAirpcapFreeDeviceList(devsList);
|
g_PAirpcapFreeDeviceList(devsList);
|
||||||
|
*err = NO_AIRPCAP_INTERFACES_FOUND;
|
||||||
|
if (err_str != NULL)
|
||||||
|
*err_str = NULL;
|
||||||
return il;
|
return il;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,14 +1169,15 @@ get_airpcap_interface_list(int *err, char *err_str)
|
||||||
adListEntry = devsList;
|
adListEntry = devsList;
|
||||||
for(i = 0; i < n_adapts; i++)
|
for(i = 0; i < n_adapts; i++)
|
||||||
{
|
{
|
||||||
if_info = airpcap_if_info_new(adListEntry->Name, adListEntry->Description);
|
if_info = airpcap_if_info_new(adListEntry->Name, adListEntry->Description);
|
||||||
il = g_list_append(il, if_info);
|
il = g_list_append(il, if_info);
|
||||||
|
|
||||||
adListEntry = adListEntry->next;
|
adListEntry = adListEntry->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_PAirpcapFreeDeviceList(devsList);
|
g_PAirpcapFreeDeviceList(devsList);
|
||||||
|
|
||||||
|
*err = 0;
|
||||||
return il;
|
return il;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -304,13 +304,6 @@ airpcap_if_info_t* airpcap_driver_fake_if_info_new();
|
||||||
*/
|
*/
|
||||||
int load_airpcap(void);
|
int load_airpcap(void);
|
||||||
|
|
||||||
/*
|
|
||||||
* Get an error message string for a CANT_GET_INTERFACE_LIST error from
|
|
||||||
* "get_airpcap_interface_list()".
|
|
||||||
*/
|
|
||||||
gchar*
|
|
||||||
cant_get_airpcap_if_list_error_message(const char *err_str);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function will use the airpcap.dll to find all the airpcap devices.
|
* This function will use the airpcap.dll to find all the airpcap devices.
|
||||||
* Will return null if no device is found.
|
* Will return null if no device is found.
|
||||||
|
|
|
@ -30,9 +30,16 @@
|
||||||
extern if_info_t *if_info_new(char *name, char *description);
|
extern if_info_t *if_info_new(char *name, char *description);
|
||||||
extern void if_info_add_address(if_info_t *if_info, struct sockaddr *addr);
|
extern void if_info_add_address(if_info_t *if_info, struct sockaddr *addr);
|
||||||
#ifdef HAVE_PCAP_FINDALLDEVS
|
#ifdef HAVE_PCAP_FINDALLDEVS
|
||||||
extern GList *get_interface_list_findalldevs(int *err, char *err_str);
|
extern GList *get_interface_list_findalldevs(int *err, char **err_str);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get an error message string for a CANT_GET_INTERFACE_LIST error from
|
||||||
|
* "get_interface_list()". This is used to let the error message string
|
||||||
|
* be platform-dependent.
|
||||||
|
*/
|
||||||
|
extern gchar *cant_get_if_list_error_message(const char *err_str);
|
||||||
|
|
||||||
#endif /* HAVE_LIBPCAP */
|
#endif /* HAVE_LIBPCAP */
|
||||||
|
|
||||||
#endif /* __PCAP_UTIL_INT_H__ */
|
#endif /* __PCAP_UTIL_INT_H__ */
|
||||||
|
|
|
@ -74,7 +74,7 @@ search_for_if_cb(gpointer data, gpointer user_data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GList *
|
GList *
|
||||||
get_interface_list(int *err, char *err_str)
|
get_interface_list(int *err, char **err_str)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PCAP_FINDALLDEVS
|
#ifdef HAVE_PCAP_FINDALLDEVS
|
||||||
return get_interface_list_findalldevs(err, err_str);
|
return get_interface_list_findalldevs(err, err_str);
|
||||||
|
@ -90,11 +90,15 @@ get_interface_list(int *err, char *err_str)
|
||||||
int len, lastlen;
|
int len, lastlen;
|
||||||
char *buf;
|
char *buf;
|
||||||
if_info_t *if_info;
|
if_info_t *if_info;
|
||||||
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
|
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
*err = CANT_GET_INTERFACE_LIST;
|
*err = CANT_GET_INTERFACE_LIST;
|
||||||
g_snprintf(err_str, PCAP_ERRBUF_SIZE, "Error opening socket: %s",
|
if (err_str != NULL) {
|
||||||
strerror(errno));
|
*err_str = g_strdup_printf(
|
||||||
|
"Can't get list of interfaces: error opening socket: %s",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,15 +115,19 @@ get_interface_list(int *err, char *err_str)
|
||||||
memset (buf, 0, len);
|
memset (buf, 0, len);
|
||||||
if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
|
if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
|
||||||
if (errno != EINVAL || lastlen != 0) {
|
if (errno != EINVAL || lastlen != 0) {
|
||||||
g_snprintf(err_str, PCAP_ERRBUF_SIZE,
|
if (err_str != NULL) {
|
||||||
"SIOCGIFCONF ioctl error getting list of interfaces: %s",
|
*err_str = g_strdup_printf(
|
||||||
strerror(errno));
|
"Can't get list of interfaces: SIOCGIFCONF ioctl error: %s",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((unsigned) ifc.ifc_len < sizeof(struct ifreq)) {
|
if ((unsigned) ifc.ifc_len < sizeof(struct ifreq)) {
|
||||||
g_snprintf(err_str, PCAP_ERRBUF_SIZE,
|
if (err_str != NULL) {
|
||||||
"SIOCGIFCONF ioctl gave too small return buffer");
|
*err_str = g_strdup(
|
||||||
|
"Can't get list of interfaces: SIOCGIFCONF ioctl gave too small return buffer");
|
||||||
|
}
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (ifc.ifc_len == lastlen)
|
if (ifc.ifc_len == lastlen)
|
||||||
|
@ -165,9 +173,11 @@ get_interface_list(int *err, char *err_str)
|
||||||
if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
|
if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
|
||||||
if (errno == ENXIO)
|
if (errno == ENXIO)
|
||||||
goto next;
|
goto next;
|
||||||
g_snprintf(err_str, PCAP_ERRBUF_SIZE,
|
if (err_str != NULL) {
|
||||||
"SIOCGIFFLAGS error getting flags for interface %s: %s",
|
*err_str = g_strdup_printf(
|
||||||
ifr->ifr_name, strerror(errno));
|
"Can't get list of interfaces: SIOCGIFFLAGS error getting flags for interface %s: %s",
|
||||||
|
ifr->ifr_name, strerror(errno));
|
||||||
|
}
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +194,7 @@ get_interface_list(int *err, char *err_str)
|
||||||
* supplied is too large, rather than just truncating it.
|
* supplied is too large, rather than just truncating it.
|
||||||
*/
|
*/
|
||||||
pch = pcap_open_live(ifr->ifr_name, MIN_PACKET_SIZE, 0, 0,
|
pch = pcap_open_live(ifr->ifr_name, MIN_PACKET_SIZE, 0, 0,
|
||||||
err_str);
|
errbuf);
|
||||||
if (pch == NULL)
|
if (pch == NULL)
|
||||||
goto next;
|
goto next;
|
||||||
pcap_close(pch);
|
pcap_close(pch);
|
||||||
|
@ -230,7 +240,7 @@ get_interface_list(int *err, char *err_str)
|
||||||
* Try opening it and, if that succeeds, add it to the end of
|
* Try opening it and, if that succeeds, add it to the end of
|
||||||
* the list of interfaces.
|
* the list of interfaces.
|
||||||
*/
|
*/
|
||||||
pch = pcap_open_live("any", MIN_PACKET_SIZE, 0, 0, err_str);
|
pch = pcap_open_live("any", MIN_PACKET_SIZE, 0, 0, errbuf);
|
||||||
if (pch != NULL) {
|
if (pch != NULL) {
|
||||||
/*
|
/*
|
||||||
* It worked; we can use the "any" device.
|
* It worked; we can use the "any" device.
|
||||||
|
@ -250,6 +260,8 @@ get_interface_list(int *err, char *err_str)
|
||||||
* No interfaces found.
|
* No interfaces found.
|
||||||
*/
|
*/
|
||||||
*err = NO_INTERFACES_FOUND;
|
*err = NO_INTERFACES_FOUND;
|
||||||
|
if (err_str != NULL)
|
||||||
|
*err_str = NULL;
|
||||||
}
|
}
|
||||||
return il;
|
return il;
|
||||||
|
|
||||||
|
|
|
@ -249,14 +249,17 @@ if_info_ip(if_info_t *if_info, pcap_if_t *d)
|
||||||
}
|
}
|
||||||
|
|
||||||
GList *
|
GList *
|
||||||
get_interface_list_findalldevs(int *err, char *err_str)
|
get_interface_list_findalldevs(int *err, char **err_str)
|
||||||
{
|
{
|
||||||
GList *il = NULL;
|
GList *il = NULL;
|
||||||
pcap_if_t *alldevs, *dev;
|
pcap_if_t *alldevs, *dev;
|
||||||
if_info_t *if_info;
|
if_info_t *if_info;
|
||||||
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
|
|
||||||
if (pcap_findalldevs(&alldevs, err_str) == -1) {
|
if (pcap_findalldevs(&alldevs, errbuf) == -1) {
|
||||||
*err = CANT_GET_INTERFACE_LIST;
|
*err = CANT_GET_INTERFACE_LIST;
|
||||||
|
if (err_str != NULL)
|
||||||
|
*err_str = cant_get_if_list_error_message(errbuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,6 +268,8 @@ get_interface_list_findalldevs(int *err, char *err_str)
|
||||||
* No interfaces found.
|
* No interfaces found.
|
||||||
*/
|
*/
|
||||||
*err = NO_INTERFACES_FOUND;
|
*err = NO_INTERFACES_FOUND;
|
||||||
|
if (err_str != NULL)
|
||||||
|
*err_str = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,28 +354,33 @@ create_data_link_info(int dlt)
|
||||||
}
|
}
|
||||||
|
|
||||||
GList *
|
GList *
|
||||||
get_pcap_linktype_list(const char *devname, char *err_buf)
|
get_pcap_linktype_list(const char *devname, char **err_str)
|
||||||
{
|
{
|
||||||
GList *linktype_list = NULL;
|
GList *linktype_list = NULL;
|
||||||
pcap_t *pch;
|
pcap_t *pch;
|
||||||
int deflt;
|
int deflt;
|
||||||
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
#ifdef HAVE_PCAP_SET_DATALINK
|
#ifdef HAVE_PCAP_SET_DATALINK
|
||||||
int *linktypes;
|
int *linktypes;
|
||||||
int i, nlt;
|
int i, nlt;
|
||||||
#endif
|
#endif
|
||||||
data_link_info_t *data_link_info;
|
data_link_info_t *data_link_info;
|
||||||
|
|
||||||
pch = pcap_open_live(devname, MIN_PACKET_SIZE, 0, 0, err_buf);
|
pch = pcap_open_live(devname, MIN_PACKET_SIZE, 0, 0, errbuf);
|
||||||
if (pch == NULL)
|
if (pch == NULL) {
|
||||||
|
if (err_str != NULL)
|
||||||
|
*err_str = g_strdup(errbuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
err_buf[0] = '\0'; /* an empty list doesn't mean an error */
|
}
|
||||||
deflt = get_pcap_linktype(pch, devname);
|
deflt = get_pcap_linktype(pch, devname);
|
||||||
#ifdef HAVE_PCAP_LIST_DATALINKS
|
#ifdef HAVE_PCAP_LIST_DATALINKS
|
||||||
nlt = pcap_list_datalinks(pch, &linktypes);
|
nlt = pcap_list_datalinks(pch, &linktypes);
|
||||||
if (nlt == 0 || linktypes == NULL) {
|
if (nlt == 0 || linktypes == NULL) {
|
||||||
pcap_close(pch);
|
pcap_close(pch);
|
||||||
|
if (err_str != NULL)
|
||||||
|
*err_str = NULL; /* an empty list doesn't mean an error */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i = 0; i < nlt; i++) {
|
for (i = 0; i < nlt; i++) {
|
||||||
data_link_info = create_data_link_info(linktypes[i]);
|
data_link_info = create_data_link_info(linktypes[i]);
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,6 @@ extern "C" {
|
||||||
|
|
||||||
#include <pcap.h>
|
#include <pcap.h>
|
||||||
|
|
||||||
/* declaration of pcap_t here, to reduce pcap dependencies */
|
|
||||||
/*typedef struct pcap pcap_t;*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX - this is also the traditional default snapshot size in
|
* XXX - this is also the traditional default snapshot size in
|
||||||
* tcpdump - but, if IPv6 is enabled, it defaults to 96, to get an
|
* tcpdump - but, if IPv6 is enabled, it defaults to 96, to get an
|
||||||
|
@ -49,9 +45,6 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define MIN_PACKET_SIZE 68 /* minimum amount of packet data we can read */
|
#define MIN_PACKET_SIZE 68 /* minimum amount of packet data we can read */
|
||||||
|
|
||||||
/* XXX - this must be optimized, removing the dependency!!! */
|
|
||||||
#define CAPTURE_PCAP_ERRBUF_SIZE PCAP_ERRBUF_SIZE
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The list of interfaces returned by "get_interface_list()" is
|
* The list of interfaces returned by "get_interface_list()" is
|
||||||
* a list of these structures.
|
* a list of these structures.
|
||||||
|
@ -74,7 +67,7 @@ typedef struct {
|
||||||
} ip_addr;
|
} ip_addr;
|
||||||
} if_addr_t;
|
} if_addr_t;
|
||||||
|
|
||||||
GList *get_interface_list(int *err, char *err_str);
|
GList *get_interface_list(int *err, char **err_str);
|
||||||
|
|
||||||
/* Error values from "get_interface_list()". */
|
/* Error values from "get_interface_list()". */
|
||||||
#define CANT_GET_INTERFACE_LIST 0 /* error getting list */
|
#define CANT_GET_INTERFACE_LIST 0 /* error getting list */
|
||||||
|
@ -82,12 +75,6 @@ GList *get_interface_list(int *err, char *err_str);
|
||||||
|
|
||||||
void free_interface_list(GList *if_list);
|
void free_interface_list(GList *if_list);
|
||||||
|
|
||||||
/*
|
|
||||||
* Get an error message string for a CANT_GET_INTERFACE_LIST error from
|
|
||||||
* "get_interface_list()".
|
|
||||||
*/
|
|
||||||
gchar *cant_get_if_list_error_message(const char *err_str);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The list of data link types returned by "get_pcap_linktype_list()" is
|
* The list of data link types returned by "get_pcap_linktype_list()" is
|
||||||
* a list of these structures.
|
* a list of these structures.
|
||||||
|
@ -98,7 +85,7 @@ typedef struct {
|
||||||
char *description; /* descriptive name from wiretap e.g. "Ethernet", NULL if unknown */
|
char *description; /* descriptive name from wiretap e.g. "Ethernet", NULL if unknown */
|
||||||
} data_link_info_t;
|
} data_link_info_t;
|
||||||
|
|
||||||
GList *get_pcap_linktype_list(const char *devname, char *err_buf);
|
GList *get_pcap_linktype_list(const char *devname, char **err_str);
|
||||||
void free_pcap_linktype_list(GList *linktype_list);
|
void free_pcap_linktype_list(GList *linktype_list);
|
||||||
|
|
||||||
/* get/set the link type of an interface */
|
/* get/set the link type of an interface */
|
||||||
|
|
|
@ -465,7 +465,7 @@ int pcap_next_ex (pcap_t *a, struct pcap_pkthdr **b, const u_char **c)
|
||||||
* fall back on "pcap_lookupdev()".
|
* fall back on "pcap_lookupdev()".
|
||||||
*/
|
*/
|
||||||
GList *
|
GList *
|
||||||
get_interface_list(int *err, char *err_str)
|
get_interface_list(int *err, char **err_str)
|
||||||
{
|
{
|
||||||
GList *il = NULL;
|
GList *il = NULL;
|
||||||
wchar_t *names;
|
wchar_t *names;
|
||||||
|
@ -473,6 +473,7 @@ get_interface_list(int *err, char *err_str)
|
||||||
char ascii_name[MAX_WIN_IF_NAME_LEN + 1];
|
char ascii_name[MAX_WIN_IF_NAME_LEN + 1];
|
||||||
char ascii_desc[MAX_WIN_IF_NAME_LEN + 1];
|
char ascii_desc[MAX_WIN_IF_NAME_LEN + 1];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
|
|
||||||
#ifdef HAVE_PCAP_FINDALLDEVS
|
#ifdef HAVE_PCAP_FINDALLDEVS
|
||||||
if (p_pcap_findalldevs != NULL)
|
if (p_pcap_findalldevs != NULL)
|
||||||
|
@ -522,7 +523,7 @@ get_interface_list(int *err, char *err_str)
|
||||||
* description of the Nth adapter.
|
* description of the Nth adapter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
names = (wchar_t *)pcap_lookupdev(err_str);
|
names = (wchar_t *)pcap_lookupdev(errbuf);
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if (names) {
|
if (names) {
|
||||||
|
@ -609,6 +610,8 @@ get_interface_list(int *err, char *err_str)
|
||||||
* No interfaces found.
|
* No interfaces found.
|
||||||
*/
|
*/
|
||||||
*err = NO_INTERFACES_FOUND;
|
*err = NO_INTERFACES_FOUND;
|
||||||
|
if (err_str != NULL)
|
||||||
|
*err_str = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return il;
|
return il;
|
||||||
|
|
|
@ -238,8 +238,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg)
|
||||||
GList *if_list;
|
GList *if_list;
|
||||||
if_info_t *if_info;
|
if_info_t *if_info;
|
||||||
int err;
|
int err;
|
||||||
gchar err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
gchar *err_str;
|
||||||
gchar *cant_get_if_list_errstr;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -262,18 +261,16 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (adapter_index == 0) {
|
if (adapter_index == 0) {
|
||||||
cmdarg_err("there is no interface with that adapter index");
|
cmdarg_err("There is no interface with that adapter index");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if_list = get_interface_list(&err, err_str);
|
if_list = get_interface_list(&err, &err_str);
|
||||||
if (if_list == NULL) {
|
if (if_list == NULL) {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case CANT_GET_INTERFACE_LIST:
|
case CANT_GET_INTERFACE_LIST:
|
||||||
cant_get_if_list_errstr =
|
cmdarg_err("%s", err_str);
|
||||||
cant_get_if_list_error_message(err_str);
|
g_free(err_str);
|
||||||
cmdarg_err("%s", cant_get_if_list_errstr);
|
|
||||||
g_free(cant_get_if_list_errstr);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_INTERFACES_FOUND:
|
case NO_INTERFACES_FOUND:
|
||||||
|
@ -284,7 +281,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg)
|
||||||
}
|
}
|
||||||
if_info = g_list_nth_data(if_list, adapter_index - 1);
|
if_info = g_list_nth_data(if_list, adapter_index - 1);
|
||||||
if (if_info == NULL) {
|
if (if_info == NULL) {
|
||||||
cmdarg_err("there is no interface with that adapter index");
|
cmdarg_err("There is no interface with that adapter index");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
capture_opts->iface = g_strdup(if_info->name);
|
capture_opts->iface = g_strdup(if_info->name);
|
||||||
|
@ -396,17 +393,18 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg,
|
||||||
|
|
||||||
int capture_opts_list_link_layer_types(capture_options *capture_opts)
|
int capture_opts_list_link_layer_types(capture_options *capture_opts)
|
||||||
{
|
{
|
||||||
gchar err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
gchar *err_str;
|
||||||
GList *lt_list, *lt_entry;
|
GList *lt_list, *lt_entry;
|
||||||
data_link_info_t *data_link_info;
|
data_link_info_t *data_link_info;
|
||||||
|
|
||||||
/* Get the list of link-layer types for the capture device. */
|
/* Get the list of link-layer types for the capture device. */
|
||||||
lt_list = get_pcap_linktype_list(capture_opts->iface, err_str);
|
lt_list = get_pcap_linktype_list(capture_opts->iface, &err_str);
|
||||||
if (lt_list == NULL) {
|
if (lt_list == NULL) {
|
||||||
if (err_str[0] != '\0') {
|
if (err_str != NULL) {
|
||||||
cmdarg_err("The list of data link types for the capture device \"%s\" could not be obtained (%s)."
|
cmdarg_err("The list of data link types for the capture device \"%s\" could not be obtained (%s)."
|
||||||
"Please check to make sure you have sufficient permissions, and that\n"
|
"Please check to make sure you have sufficient permissions, and that\n"
|
||||||
"you have the proper interface or pipe specified.\n", capture_opts->iface, err_str);
|
"you have the proper interface or pipe specified.\n", capture_opts->iface, err_str);
|
||||||
|
g_free(err_str);
|
||||||
} else
|
} else
|
||||||
cmdarg_err("The capture device \"%s\" has no data link types.", capture_opts->iface);
|
cmdarg_err("The capture device \"%s\" has no data link types.", capture_opts->iface);
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -434,8 +432,7 @@ int capture_opts_list_interfaces()
|
||||||
GList *if_entry;
|
GList *if_entry;
|
||||||
if_info_t *if_info;
|
if_info_t *if_info;
|
||||||
int err;
|
int err;
|
||||||
gchar err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
gchar *err_str;
|
||||||
gchar *cant_get_if_list_errstr;
|
|
||||||
int i;
|
int i;
|
||||||
#if 0
|
#if 0
|
||||||
GSList *ip_addr;
|
GSList *ip_addr;
|
||||||
|
@ -444,13 +441,12 @@ int capture_opts_list_interfaces()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if_list = get_interface_list(&err, err_str);
|
if_list = get_interface_list(&err, &err_str);
|
||||||
if (if_list == NULL) {
|
if (if_list == NULL) {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case CANT_GET_INTERFACE_LIST:
|
case CANT_GET_INTERFACE_LIST:
|
||||||
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
cmdarg_err("%s", err_str);
|
||||||
cmdarg_err("%s", cant_get_if_list_errstr);
|
g_free(err_str);
|
||||||
g_free(cant_get_if_list_errstr);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_INTERFACES_FOUND:
|
case NO_INTERFACES_FOUND:
|
||||||
|
@ -520,8 +516,7 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
|
||||||
GList *if_list;
|
GList *if_list;
|
||||||
if_info_t *if_info;
|
if_info_t *if_info;
|
||||||
int err;
|
int err;
|
||||||
gchar err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
gchar *err_str;
|
||||||
gchar *cant_get_if_list_errstr;
|
|
||||||
|
|
||||||
|
|
||||||
/* Did the user specify an interface to use? */
|
/* Did the user specify an interface to use? */
|
||||||
|
@ -532,14 +527,13 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
|
||||||
capture_opts->iface = g_strdup(capture_device);
|
capture_opts->iface = g_strdup(capture_device);
|
||||||
} else {
|
} else {
|
||||||
/* No - pick the first one from the list of interfaces. */
|
/* No - pick the first one from the list of interfaces. */
|
||||||
if_list = get_interface_list(&err, err_str);
|
if_list = get_interface_list(&err, &err_str);
|
||||||
if (if_list == NULL) {
|
if (if_list == NULL) {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case CANT_GET_INTERFACE_LIST:
|
case CANT_GET_INTERFACE_LIST:
|
||||||
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
cmdarg_err("%s", err_str);
|
||||||
cmdarg_err("%s", cant_get_if_list_errstr);
|
g_free(err_str);
|
||||||
g_free(cant_get_if_list_errstr);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_INTERFACES_FOUND:
|
case NO_INTERFACES_FOUND:
|
||||||
|
|
|
@ -109,7 +109,6 @@ get_interface_descriptive_name(const char *if_name)
|
||||||
GList *if_entry;
|
GList *if_entry;
|
||||||
if_info_t *if_info;
|
if_info_t *if_info;
|
||||||
int err;
|
int err;
|
||||||
char err_buf[CAPTURE_PCAP_ERRBUF_SIZE];
|
|
||||||
|
|
||||||
/* Do we have a user-supplied description? */
|
/* Do we have a user-supplied description? */
|
||||||
descr = capture_dev_user_descr_find(if_name);
|
descr = capture_dev_user_descr_find(if_name);
|
||||||
|
@ -120,7 +119,7 @@ get_interface_descriptive_name(const char *if_name)
|
||||||
/* No, we don't have a user-supplied description; did we get
|
/* No, we don't have a user-supplied description; did we get
|
||||||
one from the OS or libpcap? */
|
one from the OS or libpcap? */
|
||||||
descr = NULL;
|
descr = NULL;
|
||||||
if_list = get_interface_list(&err, err_buf);
|
if_list = get_interface_list(&err, NULL);
|
||||||
if (if_list != NULL) {
|
if (if_list != NULL) {
|
||||||
if_entry = if_list;
|
if_entry = if_list;
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -178,7 +178,6 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
|
||||||
if_info_t *if_info;
|
if_info_t *if_info;
|
||||||
GList *lt_list;
|
GList *lt_list;
|
||||||
int err;
|
int err;
|
||||||
char err_buf[CAPTURE_PCAP_ERRBUF_SIZE];
|
|
||||||
GtkWidget *lt_menu, *lt_menu_item;
|
GtkWidget *lt_menu, *lt_menu_item;
|
||||||
GList *lt_entry;
|
GList *lt_entry;
|
||||||
data_link_info_t *data_link_info;
|
data_link_info_t *data_link_info;
|
||||||
|
@ -237,7 +236,7 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
|
||||||
/*
|
/*
|
||||||
* Try to get the list of known interfaces.
|
* Try to get the list of known interfaces.
|
||||||
*/
|
*/
|
||||||
if_list = get_interface_list(&err, err_buf);
|
if_list = get_interface_list(&err, NULL);
|
||||||
if (if_list != NULL) {
|
if (if_list != NULL) {
|
||||||
/*
|
/*
|
||||||
* We have the list - check it.
|
* We have the list - check it.
|
||||||
|
@ -250,7 +249,7 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
|
||||||
* It's in the list.
|
* It's in the list.
|
||||||
* Get the list of link-layer types for it.
|
* Get the list of link-layer types for it.
|
||||||
*/
|
*/
|
||||||
lt_list = get_pcap_linktype_list(if_name, err_buf);
|
lt_list = get_pcap_linktype_list(if_name, NULL);
|
||||||
|
|
||||||
/* create string of list of IP addresses of this interface */
|
/* create string of list of IP addresses of this interface */
|
||||||
for (; (curr_ip = g_slist_nth(if_info->ip_addr, ips)) != NULL; ips++) {
|
for (; (curr_ip = g_slist_nth(if_info->ip_addr, ips)) != NULL; ips++) {
|
||||||
|
@ -591,8 +590,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
GList *if_list, *combo_list, *cfilter_list;
|
GList *if_list, *combo_list, *cfilter_list;
|
||||||
int row;
|
int row;
|
||||||
int err;
|
int err;
|
||||||
char err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
gchar *err_str;
|
||||||
gchar *cant_get_if_list_errstr;
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
GtkAdjustment *buffer_size_adj;
|
GtkAdjustment *buffer_size_adj;
|
||||||
GtkWidget *buffer_size_lb, *buffer_size_sb;
|
GtkWidget *buffer_size_lb, *buffer_size_sb;
|
||||||
|
@ -623,28 +621,25 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if_list = get_interface_list(&err, err_str);
|
if_list = get_interface_list(&err, &err_str);
|
||||||
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
|
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
|
||||||
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
|
g_free(err_str);
|
||||||
cant_get_if_list_errstr);
|
|
||||||
g_free(cant_get_if_list_errstr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_AIRPCAP
|
#ifdef HAVE_AIRPCAP
|
||||||
/* update airpcap interface list */
|
/* update airpcap interface list */
|
||||||
/* load the airpcap interfaces */
|
|
||||||
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
|
|
||||||
|
|
||||||
decryption_cm = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
/* load the airpcap interfaces */
|
||||||
update_decryption_mode_list(decryption_cm);
|
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
|
||||||
|
|
||||||
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
|
decryption_cm = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
||||||
cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
|
update_decryption_mode_list(decryption_cm);
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
|
|
||||||
cant_get_if_list_errstr);
|
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
|
||||||
g_free(cant_get_if_list_errstr);
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||||
}
|
g_free(err_str);
|
||||||
|
}
|
||||||
|
|
||||||
/* select the first ad default (THIS SHOULD BE CHANGED) */
|
/* select the first ad default (THIS SHOULD BE CHANGED) */
|
||||||
airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
|
airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
|
||||||
|
|
|
@ -189,7 +189,7 @@ capture_details_cb(GtkWidget *details_bt _U_, gpointer if_data)
|
||||||
static void
|
static void
|
||||||
open_if(gchar *name, if_dlg_data_t *if_dlg_data)
|
open_if(gchar *name, if_dlg_data_t *if_dlg_data)
|
||||||
{
|
{
|
||||||
gchar open_err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
gchar open_err_str[PCAP_ERRBUF_SIZE];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX - on systems with BPF, the number of BPF devices limits the
|
* XXX - on systems with BPF, the number of BPF devices limits the
|
||||||
|
@ -412,8 +412,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
#endif
|
#endif
|
||||||
GtkTooltips *tooltips;
|
GtkTooltips *tooltips;
|
||||||
int err;
|
int err;
|
||||||
char err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
gchar *err_str;
|
||||||
gchar *cant_get_if_list_errstr;
|
|
||||||
GtkRequisition requisition;
|
GtkRequisition requisition;
|
||||||
int row, height;
|
int row, height;
|
||||||
if_dlg_data_t *if_dlg_data;
|
if_dlg_data_t *if_dlg_data;
|
||||||
|
@ -444,46 +443,38 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* LOAD THE INTERFACES */
|
/* LOAD THE INTERFACES */
|
||||||
if_list = get_interface_list(&err, err_str);
|
if_list = get_interface_list(&err, &err_str);
|
||||||
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
|
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
|
||||||
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
|
g_free(err_str);
|
||||||
cant_get_if_list_errstr);
|
|
||||||
g_free(cant_get_if_list_errstr);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_AIRPCAP
|
#ifdef HAVE_AIRPCAP
|
||||||
/* LOAD AIRPCAP INTERFACES */
|
/* LOAD AIRPCAP INTERFACES */
|
||||||
/* load the airpcap interfaces */
|
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
|
||||||
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
|
if (airpcap_if_list == NULL)
|
||||||
if(airpcap_if_list == NULL) airpcap_if_active = airpcap_if_selected = NULL;
|
airpcap_if_active = airpcap_if_selected = NULL;
|
||||||
|
|
||||||
decryption_cm = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
decryption_cm = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
||||||
update_decryption_mode_list(decryption_cm);
|
update_decryption_mode_list(decryption_cm);
|
||||||
|
|
||||||
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
|
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
|
||||||
cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
|
g_free(err_str);
|
||||||
cant_get_if_list_errstr);
|
}
|
||||||
g_free(cant_get_if_list_errstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If no airpcap interface is present, gray everything */
|
/* If no airpcap interface is present, gray everything */
|
||||||
if(airpcap_if_active == NULL)
|
if (airpcap_if_active == NULL) {
|
||||||
{
|
if (airpcap_if_list == NULL) {
|
||||||
if(airpcap_if_list == NULL)
|
/*No airpcap device found */
|
||||||
{
|
airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
|
||||||
/*No airpcap device found */
|
} else {
|
||||||
airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
|
/* default adapter is not airpcap... or is airpcap but is not found*/
|
||||||
}
|
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
||||||
else
|
airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
|
||||||
{
|
}
|
||||||
/* default adapter is not airpcap... or is airpcap but is not found*/
|
}
|
||||||
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
|
||||||
airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -84,9 +84,8 @@ capture_prefs_show(void)
|
||||||
GtkWidget *ifopts_lb, *ifopts_bt;
|
GtkWidget *ifopts_lb, *ifopts_bt;
|
||||||
GList *if_list, *combo_list;
|
GList *if_list, *combo_list;
|
||||||
int err;
|
int err;
|
||||||
char err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
int row = 0;
|
||||||
int row = 0;
|
GtkTooltips *tooltips = gtk_tooltips_new();
|
||||||
GtkTooltips *tooltips = gtk_tooltips_new();
|
|
||||||
|
|
||||||
/* Main vertical box */
|
/* Main vertical box */
|
||||||
main_vb = gtk_vbox_new(FALSE, 7);
|
main_vb = gtk_vbox_new(FALSE, 7);
|
||||||
|
@ -109,7 +108,7 @@ capture_prefs_show(void)
|
||||||
/*
|
/*
|
||||||
* XXX - what if we can't get the list?
|
* XXX - what if we can't get the list?
|
||||||
*/
|
*/
|
||||||
if_list = get_interface_list(&err, err_str);
|
if_list = get_interface_list(&err, NULL);
|
||||||
combo_list = build_capture_combo_list(if_list, FALSE);
|
combo_list = build_capture_combo_list(if_list, FALSE);
|
||||||
free_interface_list(if_list);
|
free_interface_list(if_list);
|
||||||
if (combo_list != NULL) {
|
if (combo_list != NULL) {
|
||||||
|
@ -120,11 +119,11 @@ capture_prefs_show(void)
|
||||||
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
|
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
|
||||||
prefs.capture_device);
|
prefs.capture_device);
|
||||||
gtk_table_attach_defaults(GTK_TABLE(main_tb), if_cb, 1, 2, row, row+1);
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), if_cb, 1, 2, row, row+1);
|
||||||
gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry,
|
gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry,
|
||||||
"The default interface to be captured from.", NULL);
|
"The default interface to be captured from.", NULL);
|
||||||
gtk_widget_show(if_cb);
|
gtk_widget_show(if_cb);
|
||||||
OBJECT_SET_DATA(main_vb, DEVICE_KEY, if_cb);
|
OBJECT_SET_DATA(main_vb, DEVICE_KEY, if_cb);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
/* Interface properties */
|
/* Interface properties */
|
||||||
ifopts_lb = gtk_label_new("Interfaces:");
|
ifopts_lb = gtk_label_new("Interfaces:");
|
||||||
|
@ -133,27 +132,27 @@ capture_prefs_show(void)
|
||||||
gtk_widget_show(ifopts_lb);
|
gtk_widget_show(ifopts_lb);
|
||||||
|
|
||||||
ifopts_bt = BUTTON_NEW_FROM_STOCK(WIRESHARK_STOCK_EDIT);
|
ifopts_bt = BUTTON_NEW_FROM_STOCK(WIRESHARK_STOCK_EDIT);
|
||||||
gtk_tooltips_set_tip(tooltips, ifopts_bt,
|
gtk_tooltips_set_tip(tooltips, ifopts_bt,
|
||||||
"Open a dialog box to set various interface options.", NULL);
|
"Open a dialog box to set various interface options.", NULL);
|
||||||
SIGNAL_CONNECT(ifopts_bt, "clicked", ifopts_edit_cb, NULL);
|
SIGNAL_CONNECT(ifopts_bt, "clicked", ifopts_edit_cb, NULL);
|
||||||
gtk_table_attach_defaults(GTK_TABLE(main_tb), ifopts_bt, 1, 2, row, row+1);
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), ifopts_bt, 1, 2, row, row+1);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
/* Promiscuous mode */
|
/* Promiscuous mode */
|
||||||
promisc_cb = create_preference_check_button(main_tb, row++,
|
promisc_cb = create_preference_check_button(main_tb, row++,
|
||||||
"Capture packets in promiscuous mode:", NULL,
|
"Capture packets in promiscuous mode:", NULL,
|
||||||
prefs.capture_prom_mode);
|
prefs.capture_prom_mode);
|
||||||
gtk_tooltips_set_tip(tooltips, promisc_cb,
|
gtk_tooltips_set_tip(tooltips, promisc_cb,
|
||||||
"Usually a network card will only capture the traffic sent to its own network address. "
|
"Usually a network card will only capture the traffic sent to its own network address. "
|
||||||
"If you want to capture all traffic that the network card can \"see\", mark this option. "
|
"If you want to capture all traffic that the network card can \"see\", mark this option. "
|
||||||
"See the FAQ for some more details of capturing packets from a switched network.", NULL);
|
"See the FAQ for some more details of capturing packets from a switched network.", NULL);
|
||||||
OBJECT_SET_DATA(main_vb, PROM_MODE_KEY, promisc_cb);
|
OBJECT_SET_DATA(main_vb, PROM_MODE_KEY, promisc_cb);
|
||||||
|
|
||||||
/* Real-time capture */
|
/* Real-time capture */
|
||||||
sync_cb = create_preference_check_button(main_tb, row++,
|
sync_cb = create_preference_check_button(main_tb, row++,
|
||||||
"Update list of packets in real time:", NULL,
|
"Update list of packets in real time:", NULL,
|
||||||
prefs.capture_real_time);
|
prefs.capture_real_time);
|
||||||
gtk_tooltips_set_tip(tooltips, sync_cb,
|
gtk_tooltips_set_tip(tooltips, sync_cb,
|
||||||
"Update the list of packets while capture is in progress. "
|
"Update the list of packets while capture is in progress. "
|
||||||
"Don't use this option if you notice packet drops.", NULL);
|
"Don't use this option if you notice packet drops.", NULL);
|
||||||
OBJECT_SET_DATA(main_vb, CAPTURE_REAL_TIME_KEY, sync_cb);
|
OBJECT_SET_DATA(main_vb, CAPTURE_REAL_TIME_KEY, sync_cb);
|
||||||
|
@ -162,7 +161,7 @@ capture_prefs_show(void)
|
||||||
auto_scroll_cb = create_preference_check_button(main_tb, row++,
|
auto_scroll_cb = create_preference_check_button(main_tb, row++,
|
||||||
"Automatic scrolling in live capture:", NULL,
|
"Automatic scrolling in live capture:", NULL,
|
||||||
prefs.capture_auto_scroll);
|
prefs.capture_auto_scroll);
|
||||||
gtk_tooltips_set_tip(tooltips, auto_scroll_cb,
|
gtk_tooltips_set_tip(tooltips, auto_scroll_cb,
|
||||||
"Automatic scrolling of the packet list while live capture is in progress. ", NULL);
|
"Automatic scrolling of the packet list while live capture is in progress. ", NULL);
|
||||||
OBJECT_SET_DATA(main_vb, AUTO_SCROLL_KEY, auto_scroll_cb);
|
OBJECT_SET_DATA(main_vb, AUTO_SCROLL_KEY, auto_scroll_cb);
|
||||||
|
|
||||||
|
@ -170,8 +169,8 @@ capture_prefs_show(void)
|
||||||
show_info_cb = create_preference_check_button(main_tb, row++,
|
show_info_cb = create_preference_check_button(main_tb, row++,
|
||||||
"Hide capture info dialog:", NULL,
|
"Hide capture info dialog:", NULL,
|
||||||
!prefs.capture_show_info);
|
!prefs.capture_show_info);
|
||||||
gtk_tooltips_set_tip(tooltips, show_info_cb,
|
gtk_tooltips_set_tip(tooltips, show_info_cb,
|
||||||
"Hide the capture info dialog while capturing. ", NULL);
|
"Hide the capture info dialog while capturing. ", NULL);
|
||||||
OBJECT_SET_DATA(main_vb, SHOW_INFO_KEY, show_info_cb);
|
OBJECT_SET_DATA(main_vb, SHOW_INFO_KEY, show_info_cb);
|
||||||
|
|
||||||
/* Show 'em what we got */
|
/* Show 'em what we got */
|
||||||
|
@ -692,19 +691,15 @@ ifopts_if_clist_add(void)
|
||||||
{
|
{
|
||||||
GList *if_list;
|
GList *if_list;
|
||||||
int err;
|
int err;
|
||||||
char err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
gchar *err_str;
|
||||||
gchar *cant_get_if_list_errstr;
|
|
||||||
if_info_t *if_info;
|
if_info_t *if_info;
|
||||||
guint i;
|
guint i;
|
||||||
guint nitems;
|
guint nitems;
|
||||||
|
|
||||||
if_list = get_interface_list(&err, err_str);
|
if_list = get_interface_list(&err, &err_str);
|
||||||
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
|
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
|
||||||
cant_get_if_list_errstr =
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||||
cant_get_if_list_error_message(err_str);
|
g_free(err_str);
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
|
|
||||||
cant_get_if_list_errstr);
|
|
||||||
g_free(cant_get_if_list_errstr);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -719,7 +714,7 @@ ifopts_if_clist_add(void)
|
||||||
if (if_info == NULL)
|
if (if_info == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* fill current options CList with current preference values */
|
/* fill current options CList with current preference values */
|
||||||
ifopts_options_add(GTK_CLIST(cur_clist), if_info);
|
ifopts_options_add(GTK_CLIST(cur_clist), if_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2157,8 +2157,8 @@ main(int argc, char *argv[])
|
||||||
wpcap_packet_load();
|
wpcap_packet_load();
|
||||||
|
|
||||||
#ifdef HAVE_AIRPCAP
|
#ifdef HAVE_AIRPCAP
|
||||||
/* Load the airpcap.dll. This must also be done before collecting
|
/* Load the airpcap.dll. This must also be done before collecting
|
||||||
* run-time version information. */
|
* run-time version information. */
|
||||||
airpcap_dll_ret_val = load_airpcap();
|
airpcap_dll_ret_val = load_airpcap();
|
||||||
|
|
||||||
switch (airpcap_dll_ret_val) {
|
switch (airpcap_dll_ret_val) {
|
||||||
|
@ -2167,9 +2167,8 @@ main(int argc, char *argv[])
|
||||||
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
|
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
|
||||||
|
|
||||||
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
|
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
|
||||||
cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", cant_get_if_list_errstr);
|
g_free(err_str);
|
||||||
g_free(cant_get_if_list_errstr);
|
|
||||||
}
|
}
|
||||||
/* select the first ad default (THIS SHOULD BE CHANGED) */
|
/* select the first ad default (THIS SHOULD BE CHANGED) */
|
||||||
airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
|
airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
|
||||||
|
|
Loading…
Reference in New Issue