#include <sys/ioctl.h>
#endif
-#include <pcap.h>
-
/*
* Keep Digital UNIX happy when including <net/if.h>.
*/
# include <sys/sockio.h>
#endif
+#include "capture_ifinfo.h"
#include "capture-pcap-util.h"
#include "capture-pcap-util-int.h"
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) {
*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
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;
* Get the interface flags.
*/
memset(&ifrflags, 0, sizeof ifrflags);
- strncpy(ifrflags.ifr_name, ifr->ifr_name,
+ g_strlcpy(ifrflags.ifr_name, ifr->ifr_name,
sizeof ifrflags.ifr_name);
if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
if (errno == ENXIO)
#ifdef HAVE_PCAP_VERSION
extern char pcap_version[];
- g_string_sprintfa(str, "with libpcap %s", pcap_version);
+ g_string_append_printf(str, "with libpcap %s", pcap_version);
#else
g_string_append(str, "with libpcap (version unknown)");
#endif
void
get_runtime_pcap_version(GString *str)
{
- g_string_sprintfa(str, "with ");
+ g_string_append_printf(str, "with ");
#ifdef HAVE_PCAP_LIB_VERSION
- g_string_sprintfa(str, pcap_lib_version());
+ g_string_append(str, pcap_lib_version());
#else
g_string_append(str, "libpcap (version unknown)");
#endif