diff --git a/airpcap_loader.c b/airpcap_loader.c index 52614f7ca6..1c63b20d1b 100644 --- a/airpcap_loader.c +++ b/airpcap_loader.c @@ -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; } @@ -1165,14 +1169,15 @@ get_airpcap_interface_list(int *err, char *err_str) adListEntry = devsList; for(i = 0; i < n_adapts; i++) { - if_info = airpcap_if_info_new(adListEntry->Name, adListEntry->Description); - il = g_list_append(il, if_info); + if_info = airpcap_if_info_new(adListEntry->Name, adListEntry->Description); + il = g_list_append(il, if_info); - adListEntry = adListEntry->next; + adListEntry = adListEntry->next; } g_PAirpcapFreeDeviceList(devsList); + *err = 0; return il; } diff --git a/airpcap_loader.h b/airpcap_loader.h index 0ca213e86b..e0302d5cc2 100644 --- a/airpcap_loader.h +++ b/airpcap_loader.h @@ -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. diff --git a/capture-pcap-util-int.h b/capture-pcap-util-int.h index 5eb98d9690..3ab330aedd 100644 --- a/capture-pcap-util-int.h +++ b/capture-pcap-util-int.h @@ -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__ */ diff --git a/capture-pcap-util-unix.c b/capture-pcap-util-unix.c index bfb124c538..ea8968b7d0 100644 --- a/capture-pcap-util-unix.c +++ b/capture-pcap-util-unix.c @@ -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", - strerror(errno)); + 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", - strerror(errno)); + 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", - ifr->ifr_name, strerror(errno)); + 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; diff --git a/capture-pcap-util.c b/capture-pcap-util.c index 1342267a91..2a5ae50bcf 100644 --- a/capture-pcap-util.c +++ b/capture-pcap-util.c @@ -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,28 +354,33 @@ 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) { + 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++) { data_link_info = create_data_link_info(linktypes[i]); diff --git a/capture-pcap-util.h b/capture-pcap-util.h index 96873ed1d8..5f824135d7 100644 --- a/capture-pcap-util.h +++ b/capture-pcap-util.h @@ -35,10 +35,6 @@ extern "C" { #include -/* 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 */ diff --git a/capture-wpcap.c b/capture-wpcap.c index dcbb1adef6..7b1ecb3429 100644 --- a/capture-wpcap.c +++ b/capture-wpcap.c @@ -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; diff --git a/capture_opts.c b/capture_opts.c index 37db6321df..804b15deb5 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -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: diff --git a/capture_ui_utils.c b/capture_ui_utils.c index a684e16805..67e659219a 100644 --- a/capture_ui_utils.c +++ b/capture_ui_utils.c @@ -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 { diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c index 831381d3f6..8676b57a12 100644 --- a/gtk/capture_dlg.c +++ b/gtk/capture_dlg.c @@ -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,28 +621,25 @@ 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); - decryption_cm = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY); - update_decryption_mode_list(decryption_cm); + /* load the airpcap interfaces */ + 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); - } + 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) { + 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); diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c index b12e301271..fdcd0c6068 100644 --- a/gtk/capture_if_dlg.c +++ b/gtk/capture_if_dlg.c @@ -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,46 +443,38 @@ 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; + airpcap_if_list = get_airpcap_interface_list(&err, err_str); + 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); + 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); - } + if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) { + 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) - { - /*No airpcap device found */ - airpcap_enable_toolbar_widgets(airpcap_tb,FALSE); - } - 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); - } - } + /* If no airpcap interface is present, gray everything */ + if (airpcap_if_active == NULL) { + if (airpcap_if_list == NULL) { + /*No airpcap device found */ + airpcap_enable_toolbar_widgets(airpcap_tb,FALSE); + } 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); + } + } airpcap_set_toolbar_start_capture(airpcap_if_active); #endif diff --git a/gtk/capture_prefs.c b/gtk/capture_prefs.c index 6ca7322f37..f761b0174c 100644 --- a/gtk/capture_prefs.c +++ b/gtk/capture_prefs.c @@ -84,9 +84,8 @@ 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(); + int row = 0; + GtkTooltips *tooltips = gtk_tooltips_new(); /* Main vertical box */ main_vb = gtk_vbox_new(FALSE, 7); @@ -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) { @@ -120,11 +119,11 @@ capture_prefs_show(void) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), prefs.capture_device); 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, - "The default interface to be captured from.", NULL); + gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry, + "The default interface to be captured from.", NULL); gtk_widget_show(if_cb); OBJECT_SET_DATA(main_vb, DEVICE_KEY, if_cb); - row++; + row++; /* Interface properties */ ifopts_lb = gtk_label_new("Interfaces:"); @@ -133,27 +132,27 @@ capture_prefs_show(void) gtk_widget_show(ifopts_lb); ifopts_bt = BUTTON_NEW_FROM_STOCK(WIRESHARK_STOCK_EDIT); - gtk_tooltips_set_tip(tooltips, ifopts_bt, - "Open a dialog box to set various interface options.", NULL); + gtk_tooltips_set_tip(tooltips, ifopts_bt, + "Open a dialog box to set various interface options.", 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); - row++; + row++; /* Promiscuous mode */ promisc_cb = create_preference_check_button(main_tb, row++, "Capture packets in promiscuous mode:", NULL, prefs.capture_prom_mode); - gtk_tooltips_set_tip(tooltips, promisc_cb, - "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. " - "See the FAQ for some more details of capturing packets from a switched network.", NULL); + gtk_tooltips_set_tip(tooltips, promisc_cb, + "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. " + "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); /* Real-time capture */ sync_cb = create_preference_check_button(main_tb, row++, "Update list of packets in real time:", NULL, 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. " "Don't use this option if you notice packet drops.", NULL); 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++, "Automatic scrolling in live capture:", NULL, 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); 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++, "Hide capture info dialog:", NULL, !prefs.capture_show_info); - gtk_tooltips_set_tip(tooltips, show_info_cb, - "Hide the capture info dialog while capturing. ", NULL); + gtk_tooltips_set_tip(tooltips, show_info_cb, + "Hide the capture info dialog while capturing. ", NULL); OBJECT_SET_DATA(main_vb, SHOW_INFO_KEY, show_info_cb); /* Show 'em what we got */ @@ -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; } @@ -719,7 +714,7 @@ ifopts_if_clist_add(void) if (if_info == NULL) 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); } diff --git a/gtk/main.c b/gtk/main.c index 71933666b7..bfb442408f 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2157,8 +2157,8 @@ main(int argc, char *argv[]) wpcap_packet_load(); #ifdef HAVE_AIRPCAP - /* Load the airpcap.dll. This must also be done before collecting - * run-time version information. */ + /* Load the airpcap.dll. This must also be done before collecting + * run-time version information. */ airpcap_dll_ret_val = load_airpcap(); switch (airpcap_dll_ret_val) { @@ -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);