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
This commit is contained in:
parent
ac5dba4586
commit
1655ca17d0
|
@ -29,9 +29,9 @@
|
|||
#ifdef HAVE_PCAP_REMOTE
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
#include <pcap.h>
|
||||
#endif
|
||||
#endif /* HAVE_PCAP_REMOTE */
|
||||
|
||||
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);
|
||||
|
@ -39,10 +39,9 @@ extern void if_info_add_address(if_info_t *if_info, struct sockaddr *addr);
|
|||
#ifdef HAVE_PCAP_REMOTE
|
||||
extern GList *get_interface_list_findalldevs_ex(const char *source,
|
||||
struct pcap_rmtauth *auth, int *err, char **err_str);
|
||||
#else
|
||||
#endif /* HAVE_PCAP_REMOTE */
|
||||
extern GList *get_interface_list_findalldevs(int *err, char **err_str);
|
||||
#endif
|
||||
#endif
|
||||
#endif /* HAVE_PCAP_FINDALLDEVS */
|
||||
|
||||
/*
|
||||
* Get an error message string for a CANT_GET_INTERFACE_LIST error from
|
||||
|
|
|
@ -82,10 +82,7 @@ get_remote_interface_list(const char *hostname, const char *port,
|
|||
struct pcap_rmtauth auth;
|
||||
char source[PCAP_BUF_SIZE];
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
auth.type = auth_type;
|
||||
auth.username = username;
|
||||
auth.password = passwd;
|
||||
GList *result;
|
||||
|
||||
if (pcap_createsrcstr(source, PCAP_SRC_IFREMOTE, hostname, port,
|
||||
NULL, errbuf) == -1) {
|
||||
|
@ -94,7 +91,16 @@ get_remote_interface_list(const char *hostname, const char *port,
|
|||
*err_str = cant_get_if_list_error_message(errbuf);
|
||||
return NULL;
|
||||
}
|
||||
return get_interface_list_findalldevs_ex(source, &auth, err, err_str);
|
||||
|
||||
auth.type = auth_type;
|
||||
auth.username = g_strdup(username);
|
||||
auth.password = g_strdup(passwd);
|
||||
|
||||
result = get_interface_list_findalldevs_ex(source, &auth, err, err_str);
|
||||
g_free(auth.username);
|
||||
g_free(auth.password);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -102,21 +108,7 @@ GList *
|
|||
get_interface_list(int *err, char **err_str)
|
||||
{
|
||||
#ifdef HAVE_PCAP_FINDALLDEVS
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
char source[PCAP_BUF_SIZE];
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
if (pcap_createsrcstr(source, PCAP_SRC_IFLOCAL,
|
||||
NULL, NULL, NULL, errbuf) == -1) {
|
||||
*err = CANT_GET_INTERFACE_LIST;
|
||||
if (err_str != NULL)
|
||||
*err_str = cant_get_if_list_error_message(errbuf);
|
||||
return NULL;
|
||||
}
|
||||
return get_interface_list_findalldevs_ex(source, NULL, err, err_str);
|
||||
#else
|
||||
return get_interface_list_findalldevs(err, err_str);
|
||||
#endif
|
||||
#else
|
||||
GList *il = NULL;
|
||||
gint nonloopback_pos = 0;
|
||||
|
|
|
@ -254,21 +254,49 @@ GList *
|
|||
get_interface_list_findalldevs_ex(const char *source,
|
||||
struct pcap_rmtauth *auth,
|
||||
int *err, char **err_str)
|
||||
#else
|
||||
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) {
|
||||
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)
|
||||
{
|
||||
GList *il = NULL;
|
||||
pcap_if_t *alldevs, *dev;
|
||||
if_info_t *if_info;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
if (pcap_findalldevs(&alldevs, errbuf) == -1) {
|
||||
*err = CANT_GET_INTERFACE_LIST;
|
||||
if (err_str != NULL)
|
||||
*err_str = cant_get_if_list_error_message(errbuf);
|
||||
|
|
|
@ -612,29 +612,14 @@ get_remote_interface_list(const char *hostname, const char *port,
|
|||
GList *
|
||||
get_interface_list(int *err, char **err_str)
|
||||
{
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
char source[PCAP_BUF_SIZE];
|
||||
#else
|
||||
GList *il = NULL;
|
||||
wchar_t *names;
|
||||
char *win95names;
|
||||
char ascii_name[MAX_WIN_IF_NAME_LEN + 1];
|
||||
char ascii_desc[MAX_WIN_IF_NAME_LEN + 1];
|
||||
int i, j;
|
||||
#endif
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
if (p_pcap_createsrcstr(source, PCAP_SRC_IFLOCAL, NULL, NULL,
|
||||
NULL, errbuf) == -1) {
|
||||
*err = CANT_GET_INTERFACE_LIST;
|
||||
if (err_str != NULL)
|
||||
*err_str = cant_get_if_list_error_message(errbuf);
|
||||
return NULL;
|
||||
}
|
||||
return get_interface_list_findalldevs_ex(source, NULL, err, err_str);
|
||||
#else
|
||||
|
||||
#ifdef HAVE_PCAP_FINDALLDEVS
|
||||
if (p_pcap_findalldevs != NULL)
|
||||
return get_interface_list_findalldevs(err, err_str);
|
||||
|
@ -775,7 +760,6 @@ get_interface_list(int *err, char **err_str)
|
|||
}
|
||||
|
||||
return il;
|
||||
#endif /* HAVE_PCAP_REMOTE */
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -288,7 +288,19 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
|
|||
/*
|
||||
* Try to get the list of known interfaces.
|
||||
*/
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
if (global_capture_opts.src_type == CAPTURE_IFREMOTE)
|
||||
if_list = get_remote_interface_list(global_capture_opts.remote_host,
|
||||
global_capture_opts.remote_port,
|
||||
global_capture_opts.auth_type,
|
||||
global_capture_opts.auth_username,
|
||||
global_capture_opts.auth_password,
|
||||
&err, NULL);
|
||||
else
|
||||
if_list = capture_interface_list(&err, NULL);
|
||||
#else
|
||||
if_list = capture_interface_list(&err, NULL);
|
||||
#endif
|
||||
if (if_list != NULL) {
|
||||
/*
|
||||
* We have the list - check it.
|
||||
|
@ -671,7 +683,7 @@ update_interface_list()
|
|||
global_capture_opts.auth_password,
|
||||
&err, &err_str);
|
||||
else
|
||||
if_list = get_interface_list(&err, &err_str);
|
||||
if_list = capture_interface_list(&err, &err_str);
|
||||
|
||||
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||
|
@ -1005,7 +1017,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
global_capture_opts.auth_password,
|
||||
&err, &err_str);
|
||||
else
|
||||
if_list = get_interface_list(&err, &err_str);
|
||||
if_list = capture_interface_list(&err, &err_str);
|
||||
#else
|
||||
if_list = capture_interface_list(&err, &err_str);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue