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_airpcap_interface_list()".
|
||||
*/
|
||||
gchar *
|
||||
static gchar *
|
||||
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);
|
||||
|
@ -1125,19 +1125,20 @@ free_airpcap_interface_list(GList *if_list)
|
|||
* Will return null if no device is found.
|
||||
*/
|
||||
GList*
|
||||
get_airpcap_interface_list(int *err, char *err_str)
|
||||
get_airpcap_interface_list(int *err, char **err_str)
|
||||
{
|
||||
GList *il = NULL;
|
||||
airpcap_if_info_t *if_info;
|
||||
int i, n_adapts;
|
||||
AirpcapDeviceDescription *devsList, *adListEntry;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
if (err)
|
||||
*err = NO_AIRPCAP_INTERFACES_FOUND;
|
||||
|
||||
if(!AirpcapLoaded || !g_PAirpcapGetDeviceList(&devsList, err_str))
|
||||
if(!AirpcapLoaded || !g_PAirpcapGetDeviceList(&devsList, errbuf))
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -1156,6 +1157,9 @@ get_airpcap_interface_list(int *err, char *err_str)
|
|||
{
|
||||
/* No interfaces, return il= NULL */
|
||||
g_PAirpcapFreeDeviceList(devsList);
|
||||
*err = NO_AIRPCAP_INTERFACES_FOUND;
|
||||
if (err_str != NULL)
|
||||
*err_str = NULL;
|
||||
return il;
|
||||
}
|
||||
|
||||
|
@ -1173,6 +1177,7 @@ get_airpcap_interface_list(int *err, char *err_str)
|
|||
|
||||
g_PAirpcapFreeDeviceList(devsList);
|
||||
|
||||
*err = 0;
|
||||
return il;
|
||||
}
|
||||
|
||||
|
|
|
@ -304,13 +304,6 @@ airpcap_if_info_t* airpcap_driver_fake_if_info_new();
|
|||
*/
|
||||
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.
|
||||
* Will return null if no device is found.
|
||||
|
|
|
@ -30,9 +30,16 @@
|
|||
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);
|
||||
#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
|
||||
|
||||
/*
|
||||
* 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 /* __PCAP_UTIL_INT_H__ */
|
||||
|
|
|
@ -74,7 +74,7 @@ search_for_if_cb(gpointer data, gpointer user_data);
|
|||
#endif
|
||||
|
||||
GList *
|
||||
get_interface_list(int *err, char *err_str)
|
||||
get_interface_list(int *err, char **err_str)
|
||||
{
|
||||
#ifdef HAVE_PCAP_FINDALLDEVS
|
||||
return get_interface_list_findalldevs(err, err_str);
|
||||
|
@ -90,11 +90,15 @@ get_interface_list(int *err, char *err_str)
|
|||
int len, lastlen;
|
||||
char *buf;
|
||||
if_info_t *if_info;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
if (sock < 0) {
|
||||
*err = CANT_GET_INTERFACE_LIST;
|
||||
g_snprintf(err_str, PCAP_ERRBUF_SIZE, "Error opening socket: %s",
|
||||
if (err_str != NULL) {
|
||||
*err_str = g_strdup_printf(
|
||||
"Can't get list of interfaces: error opening socket: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -111,15 +115,19 @@ get_interface_list(int *err, char *err_str)
|
|||
memset (buf, 0, len);
|
||||
if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
|
||||
if (errno != EINVAL || lastlen != 0) {
|
||||
g_snprintf(err_str, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFCONF ioctl error getting list of interfaces: %s",
|
||||
if (err_str != NULL) {
|
||||
*err_str = g_strdup_printf(
|
||||
"Can't get list of interfaces: SIOCGIFCONF ioctl error: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
if ((unsigned) ifc.ifc_len < sizeof(struct ifreq)) {
|
||||
g_snprintf(err_str, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFCONF ioctl gave too small return buffer");
|
||||
if (err_str != NULL) {
|
||||
*err_str = g_strdup(
|
||||
"Can't get list of interfaces: SIOCGIFCONF ioctl gave too small return buffer");
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
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 (errno == ENXIO)
|
||||
goto next;
|
||||
g_snprintf(err_str, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFFLAGS error getting flags for interface %s: %s",
|
||||
if (err_str != NULL) {
|
||||
*err_str = g_strdup_printf(
|
||||
"Can't get list of interfaces: SIOCGIFFLAGS error getting flags for interface %s: %s",
|
||||
ifr->ifr_name, strerror(errno));
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -184,7 +194,7 @@ get_interface_list(int *err, char *err_str)
|
|||
* supplied is too large, rather than just truncating it.
|
||||
*/
|
||||
pch = pcap_open_live(ifr->ifr_name, MIN_PACKET_SIZE, 0, 0,
|
||||
err_str);
|
||||
errbuf);
|
||||
if (pch == NULL)
|
||||
goto next;
|
||||
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
|
||||
* 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) {
|
||||
/*
|
||||
* It worked; we can use the "any" device.
|
||||
|
@ -250,6 +260,8 @@ get_interface_list(int *err, char *err_str)
|
|||
* No interfaces found.
|
||||
*/
|
||||
*err = NO_INTERFACES_FOUND;
|
||||
if (err_str != NULL)
|
||||
*err_str = NULL;
|
||||
}
|
||||
return il;
|
||||
|
||||
|
|
|
@ -249,14 +249,17 @@ if_info_ip(if_info_t *if_info, pcap_if_t *d)
|
|||
}
|
||||
|
||||
GList *
|
||||
get_interface_list_findalldevs(int *err, char *err_str)
|
||||
get_interface_list_findalldevs(int *err, char **err_str)
|
||||
{
|
||||
GList *il = NULL;
|
||||
pcap_if_t *alldevs, *dev;
|
||||
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;
|
||||
if (err_str != NULL)
|
||||
*err_str = cant_get_if_list_error_message(errbuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -265,6 +268,8 @@ get_interface_list_findalldevs(int *err, char *err_str)
|
|||
* No interfaces found.
|
||||
*/
|
||||
*err = NO_INTERFACES_FOUND;
|
||||
if (err_str != NULL)
|
||||
*err_str = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -349,26 +354,31 @@ create_data_link_info(int dlt)
|
|||
}
|
||||
|
||||
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;
|
||||
pcap_t *pch;
|
||||
int deflt;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
#ifdef HAVE_PCAP_SET_DATALINK
|
||||
int *linktypes;
|
||||
int i, nlt;
|
||||
#endif
|
||||
data_link_info_t *data_link_info;
|
||||
|
||||
pch = pcap_open_live(devname, MIN_PACKET_SIZE, 0, 0, err_buf);
|
||||
if (pch == NULL)
|
||||
pch = pcap_open_live(devname, MIN_PACKET_SIZE, 0, 0, errbuf);
|
||||
if (pch == NULL) {
|
||||
if (err_str != NULL)
|
||||
*err_str = g_strdup(errbuf);
|
||||
return NULL;
|
||||
err_buf[0] = '\0'; /* an empty list doesn't mean an error */
|
||||
}
|
||||
deflt = get_pcap_linktype(pch, devname);
|
||||
#ifdef HAVE_PCAP_LIST_DATALINKS
|
||||
nlt = pcap_list_datalinks(pch, &linktypes);
|
||||
if (nlt == 0 || linktypes == NULL) {
|
||||
pcap_close(pch);
|
||||
if (err_str != NULL)
|
||||
*err_str = NULL; /* an empty list doesn't mean an error */
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < nlt; i++) {
|
||||
|
|
|
@ -35,10 +35,6 @@ extern "C" {
|
|||
|
||||
#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
|
||||
* 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 */
|
||||
|
||||
/* 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
|
||||
* a list of these structures.
|
||||
|
@ -74,7 +67,7 @@ typedef struct {
|
|||
} ip_addr;
|
||||
} 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()". */
|
||||
#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);
|
||||
|
||||
/*
|
||||
* 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
|
||||
* a list of these structures.
|
||||
|
@ -98,7 +85,7 @@ typedef struct {
|
|||
char *description; /* descriptive name from wiretap e.g. "Ethernet", NULL if unknown */
|
||||
} 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);
|
||||
|
||||
/* 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()".
|
||||
*/
|
||||
GList *
|
||||
get_interface_list(int *err, char *err_str)
|
||||
get_interface_list(int *err, char **err_str)
|
||||
{
|
||||
GList *il = NULL;
|
||||
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_desc[MAX_WIN_IF_NAME_LEN + 1];
|
||||
int i, j;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
#ifdef HAVE_PCAP_FINDALLDEVS
|
||||
if (p_pcap_findalldevs != NULL)
|
||||
|
@ -522,7 +523,7 @@ get_interface_list(int *err, char *err_str)
|
|||
* description of the Nth adapter.
|
||||
*/
|
||||
|
||||
names = (wchar_t *)pcap_lookupdev(err_str);
|
||||
names = (wchar_t *)pcap_lookupdev(errbuf);
|
||||
i = 0;
|
||||
|
||||
if (names) {
|
||||
|
@ -609,6 +610,8 @@ get_interface_list(int *err, char *err_str)
|
|||
* No interfaces found.
|
||||
*/
|
||||
*err = NO_INTERFACES_FOUND;
|
||||
if (err_str != NULL)
|
||||
*err_str = NULL;
|
||||
}
|
||||
|
||||
return il;
|
||||
|
|
|
@ -238,8 +238,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg)
|
|||
GList *if_list;
|
||||
if_info_t *if_info;
|
||||
int err;
|
||||
gchar err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
gchar *cant_get_if_list_errstr;
|
||||
gchar *err_str;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -262,18 +261,16 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg)
|
|||
return 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if_list = get_interface_list(&err, err_str);
|
||||
if_list = get_interface_list(&err, &err_str);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
cant_get_if_list_errstr =
|
||||
cant_get_if_list_error_message(err_str);
|
||||
cmdarg_err("%s", cant_get_if_list_errstr);
|
||||
g_free(cant_get_if_list_errstr);
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
break;
|
||||
|
||||
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 (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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
gchar err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
gchar *err_str;
|
||||
GList *lt_list, *lt_entry;
|
||||
data_link_info_t *data_link_info;
|
||||
|
||||
/* 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 (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)."
|
||||
"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);
|
||||
g_free(err_str);
|
||||
} else
|
||||
cmdarg_err("The capture device \"%s\" has no data link types.", capture_opts->iface);
|
||||
return 2;
|
||||
|
@ -434,8 +432,7 @@ int capture_opts_list_interfaces()
|
|||
GList *if_entry;
|
||||
if_info_t *if_info;
|
||||
int err;
|
||||
gchar err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
gchar *cant_get_if_list_errstr;
|
||||
gchar *err_str;
|
||||
int i;
|
||||
#if 0
|
||||
GSList *ip_addr;
|
||||
|
@ -444,13 +441,12 @@ int capture_opts_list_interfaces()
|
|||
#endif
|
||||
|
||||
|
||||
if_list = get_interface_list(&err, err_str);
|
||||
if_list = get_interface_list(&err, &err_str);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
||||
cmdarg_err("%s", cant_get_if_list_errstr);
|
||||
g_free(cant_get_if_list_errstr);
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
|
@ -520,8 +516,7 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
|
|||
GList *if_list;
|
||||
if_info_t *if_info;
|
||||
int err;
|
||||
gchar err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
gchar *cant_get_if_list_errstr;
|
||||
gchar *err_str;
|
||||
|
||||
|
||||
/* 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);
|
||||
} else {
|
||||
/* 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) {
|
||||
switch (err) {
|
||||
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
||||
cmdarg_err("%s", cant_get_if_list_errstr);
|
||||
g_free(cant_get_if_list_errstr);
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
|
|
|
@ -109,7 +109,6 @@ get_interface_descriptive_name(const char *if_name)
|
|||
GList *if_entry;
|
||||
if_info_t *if_info;
|
||||
int err;
|
||||
char err_buf[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
|
||||
/* Do we have a user-supplied description? */
|
||||
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
|
||||
one from the OS or libpcap? */
|
||||
descr = NULL;
|
||||
if_list = get_interface_list(&err, err_buf);
|
||||
if_list = get_interface_list(&err, NULL);
|
||||
if (if_list != NULL) {
|
||||
if_entry = if_list;
|
||||
do {
|
||||
|
|
|
@ -178,7 +178,6 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
|
|||
if_info_t *if_info;
|
||||
GList *lt_list;
|
||||
int err;
|
||||
char err_buf[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
GtkWidget *lt_menu, *lt_menu_item;
|
||||
GList *lt_entry;
|
||||
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.
|
||||
*/
|
||||
if_list = get_interface_list(&err, err_buf);
|
||||
if_list = get_interface_list(&err, NULL);
|
||||
if (if_list != NULL) {
|
||||
/*
|
||||
* We have the list - check it.
|
||||
|
@ -250,7 +249,7 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
|
|||
* It's in the list.
|
||||
* 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 */
|
||||
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;
|
||||
int row;
|
||||
int err;
|
||||
char err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
gchar *cant_get_if_list_errstr;
|
||||
gchar *err_str;
|
||||
#ifdef _WIN32
|
||||
GtkAdjustment *buffer_size_adj;
|
||||
GtkWidget *buffer_size_lb, *buffer_size_sb;
|
||||
|
@ -623,16 +621,15 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
}
|
||||
#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) {
|
||||
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
|
||||
cant_get_if_list_errstr);
|
||||
g_free(cant_get_if_list_errstr);
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||
g_free(err_str);
|
||||
}
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
/* update airpcap interface list */
|
||||
|
||||
/* load the airpcap interfaces */
|
||||
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
|
||||
|
||||
|
@ -640,10 +637,8 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
update_decryption_mode_list(decryption_cm);
|
||||
|
||||
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",
|
||||
cant_get_if_list_errstr);
|
||||
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) */
|
||||
|
|
|
@ -189,7 +189,7 @@ capture_details_cb(GtkWidget *details_bt _U_, gpointer if_data)
|
|||
static void
|
||||
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
|
||||
|
@ -412,8 +412,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
#endif
|
||||
GtkTooltips *tooltips;
|
||||
int err;
|
||||
char err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
gchar *cant_get_if_list_errstr;
|
||||
gchar *err_str;
|
||||
GtkRequisition requisition;
|
||||
int row, height;
|
||||
if_dlg_data_t *if_dlg_data;
|
||||
|
@ -444,41 +443,33 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
#endif
|
||||
|
||||
/* 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) {
|
||||
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
|
||||
cant_get_if_list_errstr);
|
||||
g_free(cant_get_if_list_errstr);
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||
g_free(err_str);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
/* LOAD AIRPCAP INTERFACES */
|
||||
/* load the airpcap interfaces */
|
||||
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
|
||||
if(airpcap_if_list == NULL) airpcap_if_active = airpcap_if_selected = NULL;
|
||||
if (airpcap_if_list == NULL)
|
||||
airpcap_if_active = airpcap_if_selected = NULL;
|
||||
|
||||
decryption_cm = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
||||
update_decryption_mode_list(decryption_cm);
|
||||
|
||||
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",
|
||||
cant_get_if_list_errstr);
|
||||
g_free(cant_get_if_list_errstr);
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||
g_free(err_str);
|
||||
}
|
||||
|
||||
/* If no airpcap interface is present, gray everything */
|
||||
if(airpcap_if_active == NULL)
|
||||
{
|
||||
if(airpcap_if_list == NULL)
|
||||
{
|
||||
if (airpcap_if_active == NULL) {
|
||||
if (airpcap_if_list == NULL) {
|
||||
/*No airpcap device found */
|
||||
airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* 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);
|
||||
|
|
|
@ -84,7 +84,6 @@ capture_prefs_show(void)
|
|||
GtkWidget *ifopts_lb, *ifopts_bt;
|
||||
GList *if_list, *combo_list;
|
||||
int err;
|
||||
char err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
int row = 0;
|
||||
GtkTooltips *tooltips = gtk_tooltips_new();
|
||||
|
||||
|
@ -109,7 +108,7 @@ capture_prefs_show(void)
|
|||
/*
|
||||
* 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);
|
||||
free_interface_list(if_list);
|
||||
if (combo_list != NULL) {
|
||||
|
@ -692,19 +691,15 @@ ifopts_if_clist_add(void)
|
|||
{
|
||||
GList *if_list;
|
||||
int err;
|
||||
char err_str[CAPTURE_PCAP_ERRBUF_SIZE];
|
||||
gchar *cant_get_if_list_errstr;
|
||||
gchar *err_str;
|
||||
if_info_t *if_info;
|
||||
guint i;
|
||||
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) {
|
||||
cant_get_if_list_errstr =
|
||||
cant_get_if_list_error_message(err_str);
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
|
||||
cant_get_if_list_errstr);
|
||||
g_free(cant_get_if_list_errstr);
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||
g_free(err_str);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2167,9 +2167,8 @@ main(int argc, char *argv[])
|
|||
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
|
||||
|
||||
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", cant_get_if_list_errstr);
|
||||
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) */
|
||||
airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
|
||||
|
|
Loading…
Reference in New Issue