]> The Tcpdump Group git mirrors - libpcap/commitdiff
From Yoann Vandoorselaere <[email protected]>: make the "device"
authorguy <guy>
Sun, 22 Dec 2002 02:36:48 +0000 (02:36 +0000)
committerguy <guy>
Sun, 22 Dec 2002 02:36:48 +0000 (02:36 +0000)
argument to "pcap_open_live()" a "const" pointer.

Constify some additional device name arguments, and update the man page
to reflect some arguments that were already consts.

13 files changed:
CREDITS
inet.c
pcap-bpf.c
pcap-int.h
pcap-linux.c
pcap-nit.c
pcap-null.c
pcap-pf.c
pcap-snit.c
pcap-snoop.c
pcap-win32.c
pcap.3
pcap.h

diff --git a/CREDITS b/CREDITS
index 46fb8550fbc14ac8a34ccd871984ba3d9e9b5913..16c829721d2d19caf51848b08db2fb030cb1674c 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -64,6 +64,7 @@ Additional people who have contributed patches:
        Uwe Girlich                     <[email protected]>
        Xianjie Zhang                   <[email protected]>
        Yen Yen Lim
+       Yoann Vandoorselaere            <[email protected]>
 
 The original LBL crew:
        Steve McCanne
diff --git a/inet.c b/inet.c
index 03cf3cc7cdbaf696150d406bc8f63eeaf45c2344..f62065cd636c9907e68150b600f2dbd10d1d6043 100644 (file)
--- a/inet.c
+++ b/inet.c
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.53 2002-11-13 06:46:16 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.54 2002-12-22 02:36:48 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -103,9 +103,9 @@ dup_sockaddr(struct sockaddr *sa, size_t sa_length)
 }
 
 static int
-get_instance(char *name)
+get_instance(const char *name)
 {
-       char *cp, *endcp;
+       const char *cp, *endcp;
        int n;
 
        if (strcmp(name, "any") == 0) {
@@ -129,7 +129,7 @@ get_instance(char *name)
 }
 
 int
-add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, char *name,
+add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
     u_int flags, const char *description, char *errbuf)
 {
        pcap_t *p;
@@ -516,7 +516,7 @@ pcap_lookupdev(errbuf)
 
 int
 pcap_lookupnet(device, netp, maskp, errbuf)
-       register char *device;
+       register const char *device;
        register bpf_u_int32 *netp, *maskp;
        register char *errbuf;
 {
index 32a21c7b121d3426e8c6ae4c46180aec6bea6576..0a46f04b2b17c515b4bb9bfc2f1db075f1db8cd1 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.54 2002-12-19 09:05:45 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.55 2002-12-22 02:36:48 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -224,7 +224,8 @@ bpf_open(pcap_t *p, char *errbuf)
  * documented).
  */
 pcap_t *
-pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
+pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
+    char *ebuf)
 {
        int fd;
        struct ifreq ifr;
index a5205a1996c19c38f9354c87ef62435943d0a1c7..5d31873082190eb2754710002d047c9fa1444d56 100644 (file)
@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.41 2002-12-19 09:05:46 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.42 2002-12-22 02:36:49 guy Exp $ (LBL)
  */
 
 #ifndef pcap_int_h
@@ -73,7 +73,7 @@ struct pcap_md {
        int     clear_promisc;  /* must clear promiscuous mode when we close */
        int     cooked;         /* using SOCK_DGRAM rather than SOCK_RAW */
        int     lo_ifindex;     /* interface index of the loopback device */
-       char    *device;        /* device name */
+       const char *device;     /* device name */
        struct pcap *next;      /* list of open promiscuous sock_packet pcaps */
 #endif
 };
@@ -235,7 +235,7 @@ int add_addr_to_iflist(pcap_if_t **, char *, u_int, struct sockaddr *,
            struct sockaddr *, size_t, char *);
 int    pcap_add_if(pcap_if_t **, char *, u_int, const char *, char *);
 struct sockaddr *dup_sockaddr(struct sockaddr *, size_t);
-int    add_or_find_if(pcap_if_t **, pcap_if_t **, char *, u_int,
+int    add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
            const char *, char *);
 
 #ifdef linux
index 2e155f3a543aa538e8b76505f067153188b5f23b..ee95513b92b374c968d3aacba3d550d1bf128283 100644 (file)
@@ -26,7 +26,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.86 2002-12-19 09:05:46 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.87 2002-12-22 02:36:49 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -179,8 +179,8 @@ typedef int         socklen_t;
  * Prototypes for internal functions
  */
 static void map_arphrd_to_dlt(pcap_t *, int, int);
-static int live_open_old(pcap_t *, char *, int, int, char *);
-static int live_open_new(pcap_t *, char *, int, int, char *);
+static int live_open_old(pcap_t *, const char *, int, int, char *);
+static int live_open_new(pcap_t *, const char *, int, int, char *);
 static int pcap_read_packet(pcap_t *, pcap_handler, u_char *);
 
 /*
@@ -219,7 +219,8 @@ static struct sock_fprog    total_fcode
  *  See also pcap(3).
  */
 pcap_t *
-pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
+pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
+    char *ebuf)
 {
        pcap_t          *handle;
        int             mtu;
@@ -1134,7 +1135,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
  *  FIXME: 0 uses to mean success (Sebastian)
  */
 static int
-live_open_new(pcap_t *handle, char *device, int promisc,
+live_open_new(pcap_t *handle, const char *device, int promisc,
              int to_ms, char *ebuf)
 {
 #ifdef HAVE_PF_PACKET_SOCKETS
@@ -1488,7 +1489,7 @@ void      pcap_close_linux( pcap_t *handle )
  *  FIXME: 0 uses to mean success (Sebastian)
  */
 static int
-live_open_old(pcap_t *handle, char *device, int promisc,
+live_open_old(pcap_t *handle, const char *device, int promisc,
              int to_ms, char *ebuf)
 {
        int             sock_fd = -1, arptype;
index 5029bd75811779fa9c56b2ca2b5723aeee6659d2..f0bc8f47e8446362b33fbc18e819fe70289d011c 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.43 2002-12-19 09:05:47 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.44 2002-12-22 02:36:49 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -202,7 +202,8 @@ nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
 }
 
 pcap_t *
-pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
+pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
+    char *ebuf)
 {
        int fd;
        struct sockaddr_nit snit;
index a8e26305ab49f9ac8b8b705157d86eb936963c96..6be5ab4ce84339eb03fd8802189addb4685c60e7 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.15 2002-12-19 09:05:47 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.16 2002-12-22 02:36:49 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -54,7 +54,8 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
 }
 
 pcap_t *
-pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
+pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
+    char *ebuf)
 {
        (void)strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE);
        return (NULL);
index 22b22c292d03cdb099ef4df0d9ada7f843f29161..8b53840d1360552402f57e680b66190fb0a425c8 100644 (file)
--- a/pcap-pf.c
+++ b/pcap-pf.c
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.70 2002-12-19 09:05:47 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.71 2002-12-22 02:36:50 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -238,7 +238,8 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps)
 }
 
 pcap_t *
-pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
+pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
+    char *ebuf)
 {
        pcap_t *p;
        short enmode;
index 2131ea0340250624cc9c82d2d3a0ca8b7096fdc1..774838db90f57849946a9f8394a3b2c2f5015950 100644 (file)
@@ -25,7 +25,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.59 2002-12-19 09:05:47 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.60 2002-12-22 02:36:50 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -219,7 +219,8 @@ nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
 }
 
 pcap_t *
-pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
+pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
+    char *ebuf)
 {
        struct strioctl si;             /* struct for ioctl() */
        struct ifreq ifr;               /* interface request struct */
index f7aaff11dc5fd1a086b903657c73bee26acd65aa..0cdddac2b8bf5362386e59c7acd2ada27b3ede30 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.38 2002-12-19 09:05:48 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.39 2002-12-22 02:36:50 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -144,7 +144,8 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps)
 
 /* XXX can't disable promiscuous */
 pcap_t *
-pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
+pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
+    char *ebuf)
 {
        int fd;
        struct sockaddr_raw sr;
index 18001d534d1d0176f07b24737fbe43329e811c28..5a5021d22e7fe7139d5442880299ff401ba3e58c 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.4 2002-12-19 09:05:48 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.5 2002-12-22 02:36:50 guy Exp $ (LBL)";
 #endif
 
 #include <pcap-int.h>
@@ -115,7 +115,8 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
 
 
 pcap_t *
-pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
+pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
+    char *ebuf)
 {
        register pcap_t *p;
        NetType type;
diff --git a/pcap.3 b/pcap.3
index 25ab372029c7779cbdbbe1c165848d98aec75c93..6cac2395d197ead2b2250e6560a5eb36191bc2b6 100644 (file)
--- a/pcap.3
+++ b/pcap.3
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.42 2002-12-21 23:38:51 guy Exp $
+.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.43 2002-12-22 02:36:51 guy Exp $
 .\"
 .\" Copyright (c) 1994, 1996, 1997
 .\"    The Regents of the University of California.  All rights reserved.
@@ -34,12 +34,12 @@ char errbuf[PCAP_ERRBUF_SIZE];
 .ft
 .LP
 .ft B
-pcap_t *pcap_open_live(char *device, int snaplen,
+pcap_t *pcap_open_live(const char *device, int snaplen,
 .ti +8
 int promisc, int to_ms, char *errbuf)
 pcap_t *pcap_open_dead(int linktype, int snaplen)
-pcap_t *pcap_open_offline(char *fname, char *errbuf)
-pcap_dumper_t *pcap_dump_open(pcap_t *p, char *fname)
+pcap_t *pcap_open_offline(const char *fname, char *errbuf)
+pcap_dumper_t *pcap_dump_open(pcap_t *p, const char *fname)
 .ft
 .LP
 .ft B
@@ -49,9 +49,9 @@ int pcap_getnonblock(pcap_t *p, char *errbuf);
 .LP
 .ft B
 int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
-void pcap_freealldevs(pcap_if_t *)
+void pcap_freealldevs(pcap_if_t *alldevs)
 char *pcap_lookupdev(char *errbuf)
-int pcap_lookupnet(char *device, bpf_u_int32 *netp,
+int pcap_lookupnet(const char *device, bpf_u_int32 *netp,
 .ti +8
 bpf_u_int32 *maskp, char *errbuf)
 .ft
diff --git a/pcap.h b/pcap.h
index 21f63aa81e8e9e3959be675ed1d960d01e3a2f8a..b8e7df9719cd874359734e0bd19ab66417edff51 100644 (file)
--- a/pcap.h
+++ b/pcap.h
@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.39 2002-12-21 23:38:52 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.40 2002-12-22 02:36:51 guy Exp $ (LBL)
  */
 
 #ifndef lib_pcap_h
@@ -166,8 +166,8 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
                             const u_char *);
 
 char   *pcap_lookupdev(char *);
-int    pcap_lookupnet(char *, bpf_u_int32 *, bpf_u_int32 *, char *);
-pcap_t *pcap_open_live(char *, int, int, int, char *);
+int    pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
+pcap_t *pcap_open_live(const char *, int, int, int, char *);
 pcap_t *pcap_open_dead(int, int);
 pcap_t *pcap_open_offline(const char *, char *);
 void   pcap_close(pcap_t *);