aboutsummaryrefslogtreecommitdiffstats
path: root/airpcap_loader.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2007-01-21 23:45:36 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2007-01-21 23:45:36 +0000
commita77c32bbd28a4bf9ff3e49c7766d1327b86d41db (patch)
tree5512510787af52895ceb934713d75bf182fa3033 /airpcap_loader.c
parentc02e067a72dd0f37f65a7da9fc8a632e8ed71bfa (diff)
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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@20521 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'airpcap_loader.c')
-rw-r--r--airpcap_loader.c23
1 files changed, 14 insertions, 9 deletions
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;
}