From Clemens Auer:
[obnox/wireshark/wip.git] / capture-pcap-util-unix.c
index d707cc695ac3eff0a5cd541361a4b44f14a2ca89..3ffda24fac59d7047e9ba47d38a7cf1ef1b534dd 100644 (file)
@@ -47,8 +47,6 @@
 #include <sys/ioctl.h>
 #endif
 
-#include <pcap.h>
-
 /*
  * Keep Digital UNIX happy when including <net/if.h>.
  */
@@ -60,6 +58,7 @@ struct rtentry;
 # include <sys/sockio.h>
 #endif
 
+#include "capture_ifinfo.h"
 #include "capture-pcap-util.h"
 #include "capture-pcap-util-int.h"
 
@@ -82,10 +81,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 +90,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 +107,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;
@@ -207,7 +198,7 @@ get_interface_list(int *err, char **err_str)
                 * 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)
@@ -345,7 +336,7 @@ get_compiled_pcap_version(GString *str)
 #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
@@ -357,9 +348,9 @@ get_compiled_pcap_version(GString *str)
 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