diff options
Diffstat (limited to 'caputils')
-rw-r--r-- | caputils/capture-pcap-util-int.h | 5 | ||||
-rw-r--r-- | caputils/capture-pcap-util-unix.c | 24 | ||||
-rw-r--r-- | caputils/capture-pcap-util.c | 28 | ||||
-rw-r--r-- | caputils/capture-wpcap.c | 24 |
4 files changed, 31 insertions, 50 deletions
diff --git a/caputils/capture-pcap-util-int.h b/caputils/capture-pcap-util-int.h index 789f96dfdf..efeb467409 100644 --- a/caputils/capture-pcap-util-int.h +++ b/caputils/capture-pcap-util-int.h @@ -15,8 +15,9 @@ extern if_info_t *if_info_new(const char *name, const char *description, gboolean loopback); 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); +extern GList *get_interface_list_findalldevs_ex(const char *hostname, + const char *port, int auth_type, const char *username, const char *passwd, + int *err, char **err_str); #endif /* HAVE_PCAP_REMOTE */ extern GList *get_interface_list_findalldevs(int *err, char **err_str); diff --git a/caputils/capture-pcap-util-unix.c b/caputils/capture-pcap-util-unix.c index 9ad2296fbc..e963f3de60 100644 --- a/caputils/capture-pcap-util-unix.c +++ b/caputils/capture-pcap-util-unix.c @@ -36,28 +36,8 @@ get_remote_interface_list(const char *hostname, const char *port, int auth_type, const char *username, const char *passwd, int *err, char **err_str) { - struct pcap_rmtauth auth; - char source[PCAP_BUF_SIZE]; - char errbuf[PCAP_ERRBUF_SIZE]; - GList *result; - - if (pcap_createsrcstr(source, PCAP_SRC_IFREMOTE, hostname, port, - NULL, errbuf) == -1) { - *err = CANT_GET_INTERFACE_LIST; - if (err_str != NULL) - *err_str = cant_get_if_list_error_message(errbuf); - return NULL; - } - - 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; + return get_interface_list_findalldevs_ex(hostname, port, auth_type, + username, passwd, err, err_str); } #endif diff --git a/caputils/capture-pcap-util.c b/caputils/capture-pcap-util.c index 6fb1eb4dd5..6b16ddceca 100644 --- a/caputils/capture-pcap-util.c +++ b/caputils/capture-pcap-util.c @@ -591,10 +591,12 @@ if_info_ip(if_info_t *if_info, pcap_if_t *d) #ifdef HAVE_PCAP_REMOTE GList * -get_interface_list_findalldevs_ex(const char *source, - struct pcap_rmtauth *auth, - int *err, char **err_str) +get_interface_list_findalldevs_ex(const char *hostname, const char *port, + int auth_type, const char *username, + const char *passwd, int *err, char **err_str) { + char source[PCAP_BUF_SIZE]; + struct pcap_rmtauth auth; GList *il = NULL; pcap_if_t *alldevs, *dev; if_info_t *if_info; @@ -604,10 +606,24 @@ get_interface_list_findalldevs_ex(const char *source, */ char errbuf[PCAP_ERRBUF_SIZE*4]; - if (pcap_findalldevs_ex((char *)source, auth, &alldevs, errbuf) == -1) { + if (pcap_createsrcstr(source, PCAP_SRC_IFREMOTE, hostname, port, + NULL, errbuf) == -1) { + *err = CANT_GET_INTERFACE_LIST; + if (err_str != NULL) + *err_str = cant_get_if_list_error_message(errbuf); + return NULL; + } + + auth.type = auth_type; + auth.username = g_strdup(username); + auth.password = g_strdup(passwd); + + if (pcap_findalldevs_ex(source, &auth, &alldevs, errbuf) == -1) { *err = CANT_GET_INTERFACE_LIST; if (err_str != NULL) *err_str = cant_get_if_list_error_message(errbuf); + g_free(auth.username); + g_free(auth.password); return NULL; } @@ -618,6 +634,8 @@ get_interface_list_findalldevs_ex(const char *source, *err = 0; if (err_str != NULL) *err_str = NULL; + g_free(auth.username); + g_free(auth.password); return NULL; } @@ -628,6 +646,8 @@ get_interface_list_findalldevs_ex(const char *source, if_info_ip(if_info, dev); } pcap_freealldevs(alldevs); + g_free(auth.username); + g_free(auth.password); return il; } diff --git a/caputils/capture-wpcap.c b/caputils/capture-wpcap.c index 0835b707c4..0d856fe8a5 100644 --- a/caputils/capture-wpcap.c +++ b/caputils/capture-wpcap.c @@ -633,11 +633,6 @@ get_remote_interface_list(const char *hostname, const char *port, int auth_type, const char *username, const char *passwd, int *err, char **err_str) { - struct pcap_rmtauth auth; - char source[PCAP_BUF_SIZE]; - char errbuf[PCAP_ERRBUF_SIZE]; - GList *result; - if (!has_wpcap) { /* * We don't have Npcap or WinPcap, so we can't get a list of @@ -649,23 +644,8 @@ get_remote_interface_list(const char *hostname, const char *port, return NULL; } - if (pcap_createsrcstr(source, PCAP_SRC_IFREMOTE, hostname, port, - NULL, errbuf) == -1) { - *err = CANT_GET_INTERFACE_LIST; - if (err_str != NULL) - *err_str = cant_get_if_list_error_message(errbuf); - return NULL; - } - - 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; + return get_interface_list_findalldevs_ex(hostname, port, auth_type, + username, passwd, err, err_str); } #endif |