]> The Tcpdump Group git mirrors - libpcap/commitdiff
When fetching interfaces over TLS, put rpcaps:// into the interface names.
authorGuy Harris <[email protected]>
Wed, 6 Feb 2019 21:00:46 +0000 (13:00 -0800)
committerGuy Harris <[email protected]>
Wed, 6 Feb 2019 21:00:46 +0000 (13:00 -0800)
If we're fetching interfaces with pcap_findalldevs_ex() with an
rpcaps:// URL, put rpcaps:// rather than rpcap:// into the URLs that we
return.

pcap-int.h
pcap-rpcap.c
pcap.c

index d18dd1928ec533cfbe982b60c2908824c7a2ee4b..c46c5a519d9b05032c7aea1ae5e53bda31f33383 100644 (file)
@@ -526,11 +526,14 @@ int       install_bpf_program(pcap_t *, struct bpf_program *);
 int    pcap_strcasecmp(const char *, const char *);
 
 /*
- * Internal interface for pcap_parsesrcstr with the additional bit of
- * information regarding SSL support (rpcap:// vs rpcaps://)
+ * Internal interfaces for pcap_createsrcstr and pcap_parsesrcstr with
+ * the additional bit of information regarding SSL support (rpcap:// vs.
+ * rpcaps://).
  */
-int pcap_parsesrcstr_ex(const char *source, int *type, char *host, char *port,
-                        char *name, unsigned char *uses_ssl, char *errbuf);
+int    pcap_createsrcstr_ex(char *, int, const char *, const char *,
+    const char *, unsigned char, char *);
+int    pcap_parsesrcstr_ex(const char *, int *, char *, char *,
+    char *, unsigned char *, char *);
 
 #ifdef YYDEBUG
 extern int pcap_debug;
index 64b66c99ea48491dbd4b5565a0b88dfa83b149f6..5b2850047bb6ad29395f0f34807b06e45acb1ae1 100644 (file)
@@ -2566,8 +2566,8 @@ pcap_findalldevs_ex_remote(const char *source, struct pcap_rmtauth *auth, pcap_i
                        tmpstring[findalldevs_if.namelen] = 0;
 
                        /* Create the new device identifier */
-                       if (pcap_createsrcstr(tmpstring2, PCAP_SRC_IFREMOTE,
-                           host, port, tmpstring, errbuf) == -1)
+                       if (pcap_createsrcstr_ex(tmpstring2, PCAP_SRC_IFREMOTE,
+                           host, port, tmpstring, uses_ssl, errbuf) == -1)
                                goto error;
 
                        stringlen = strlen(tmpstring2);
diff --git a/pcap.c b/pcap.c
index c410ca5a5a946e6651e0196280ca1d9b8367bb2e..541b7bfbaa7b30441724bf57f8d3e4c1f75afdf0 100644 (file)
--- a/pcap.c
+++ b/pcap.c
@@ -1806,8 +1806,8 @@ pcap_parse_source(const char *source, char **schemep, char **userinfop,
 }
 
 int
-pcap_createsrcstr(char *source, int type, const char *host, const char *port,
-    const char *name, char *errbuf)
+pcap_createsrcstr_ex(char *source, int type, const char *host, const char *port,
+    const char *name, unsigned char uses_ssl, char *errbuf)
 {
        switch (type) {
 
@@ -1823,7 +1823,9 @@ pcap_createsrcstr(char *source, int type, const char *host, const char *port,
                }
 
        case PCAP_SRC_IFREMOTE:
-               pcap_strlcpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE);
+               pcap_strlcpy(source,
+                   (uses_ssl ? "rpcaps://" : PCAP_SRC_IF_STRING),
+                   PCAP_BUF_SIZE);
                if (host != NULL && *host != '\0') {
                        if (strchr(host, ':') != NULL) {
                                /*
@@ -1869,6 +1871,14 @@ pcap_createsrcstr(char *source, int type, const char *host, const char *port,
        }
 }
 
+
+int
+pcap_createsrcstr(char *source, int type, const char *host, const char *port,
+    const char *name, char *errbuf)
+{
+       return (pcap_createsrcstr_ex(source, type, host, port, name, 0, errbuf));
+}
+
 int
 pcap_parsesrcstr_ex(const char *source, int *type, char *host, char *port,
     char *name, unsigned char *uses_ssl, char *errbuf)