diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2008-11-03 20:04:01 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2008-11-03 20:04:01 +0000 |
commit | 1655ca17d054004bddc0a411ce64d49551eddb6d (patch) | |
tree | ac45abc2cf294565955ca34d2af1eda9d05fbebc /capture-pcap-util.c | |
parent | ac5dba4586827e722a1579fcc6d3c398bd4ffd77 (diff) |
Do not use functions for remote capture on local interfaces.
This makes it possible to compile with remote capture features on unix.
svn path=/trunk/; revision=26681
Diffstat (limited to 'capture-pcap-util.c')
-rw-r--r-- | capture-pcap-util.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/capture-pcap-util.c b/capture-pcap-util.c index 54c572609a..aeb1153ab4 100644 --- a/capture-pcap-util.c +++ b/capture-pcap-util.c @@ -254,21 +254,49 @@ GList * get_interface_list_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, int *err, char **err_str) -#else +{ + GList *il = NULL; + pcap_if_t *alldevs, *dev; + if_info_t *if_info; + char errbuf[PCAP_ERRBUF_SIZE]; + + if (pcap_findalldevs_ex((char *)source, auth, &alldevs, errbuf) == -1) { + *err = CANT_GET_INTERFACE_LIST; + if (err_str != NULL) + *err_str = cant_get_if_list_error_message(errbuf); + return NULL; + } + + if (alldevs == NULL) { + /* + * No interfaces found. + */ + *err = NO_INTERFACES_FOUND; + if (err_str != NULL) + *err_str = NULL; + return NULL; + } + + for (dev = alldevs; dev != NULL; dev = dev->next) { + if_info = if_info_new(dev->name, dev->description); + il = g_list_append(il, if_info); + if_info_ip(if_info, dev); + } + pcap_freealldevs(alldevs); + + return il; +} +#endif + GList * get_interface_list_findalldevs(int *err, char **err_str) -#endif { GList *il = NULL; pcap_if_t *alldevs, *dev; if_info_t *if_info; char errbuf[PCAP_ERRBUF_SIZE]; -#ifdef HAVE_PCAP_REMOTE - if (pcap_findalldevs_ex((char *)source, auth, &alldevs, errbuf) == -1) { -#else if (pcap_findalldevs(&alldevs, errbuf) == -1) { -#endif *err = CANT_GET_INTERFACE_LIST; if (err_str != NULL) *err_str = cant_get_if_list_error_message(errbuf); |