]> The Tcpdump Group git mirrors - libpcap/commitdiff
Make the "is_loopback" field of a "pcap_if" structure a general "flags"
authorguy <guy>
Sun, 28 Oct 2001 02:31:49 +0000 (02:31 +0000)
committerguy <guy>
Sun, 28 Oct 2001 02:31:49 +0000 (02:31 +0000)
field, and make a PCAP_IF_LOOPBACK flag be the first flag bit in that
field, specifying whether the interface is a loopback interface; this
allows us to add more flags without changing the layout of the
structure.

inet.c
pcap.3
pcap.h

diff --git a/inet.c b/inet.c
index 8523ddec1b01ed3faa2706975db126147d5679e4..f5e88f1f8e335de9b201e7532113d1cc3d8ae649 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.42 2001-10-10 06:46:50 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.43 2001-10-28 02:31:49 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -198,7 +198,9 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, char *name,
                strcpy(curdev->name, name);
                curdev->description = NULL;     /* not available */
                curdev->addresses = NULL;       /* list starts out as empty */
-               curdev->is_loopback = ISLOOPBACK(name, flags);
+               curdev->flags = 0;
+               if (ISLOOPBACK(name, flags))
+                       curdev->flags |= PCAP_IF_LOOPBACK;
 
                /*
                 * Add it to the list, in the appropriate location.
@@ -245,7 +247,8 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, char *name,
                         * Is the new interface a non-loopback interface
                         * and the next interface a loopback interface?
                         */
-                       if (!curdev->is_loopback && nextdev->is_loopback) {
+                       if (!(curdev->flags & PCAP_IF_LOOPBACK) &&
+                           (nextdev->flags & PCAP_IF_LOOPBACK)) {
                                /*
                                 * Yes, we should put the new entry
                                 * before "nextdev", i.e. after "prevdev".
@@ -267,7 +270,8 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, char *name,
                         * loopback interfaces.)
                         */
                        if (this_instance < get_instance(nextdev->name) &&
-                           (!curdev->is_loopback || nextdev->is_loopback)) {
+                           (!(curdev->flags & PCAP_IF_LOOPBACK) ||
+                              (nextdev->flags & PCAP_IF_LOOPBACK))) {
                                /*
                                 * Yes - we should put the new entry
                                 * before "nextdev", i.e. after "prevdev".
@@ -943,7 +947,7 @@ pcap_lookupdev(errbuf)
        if (pcap_findalldevs(&alldevs, errbuf) == -1)
                return (NULL);
        
-       if (alldevs == NULL || alldevs->is_loopback) {
+       if (alldevs == NULL || (alldevs->flags & PCAP_IF_LOOPBACK)) {
                /*
                 * There are no devices on the list, or the first device
                 * on the list is a loopback device, which means there
diff --git a/pcap.3 b/pcap.3
index fd9dada2c163cc8da7bf6626ef7fc11d8670bfa8..951d7c708506d59a95ff1c54dc2dc8f9c2472f63 100644 (file)
--- a/pcap.3
+++ b/pcap.3
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.25 2001-10-13 06:28:53 guy Exp $
+.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.26 2001-10-28 02:31:50 guy Exp $
 .\"
 .\" Copyright (c) 1994, 1996, 1997
 .\"    The Regents of the University of California.  All rights reserved.
@@ -238,8 +238,13 @@ a pointer to a string giving a human-readable description of the device
 .B addresses
 a pointer to the first element of a list of addresses for the interface
 .TP
-.B is_loopback
-non-zero if the interface is a loopback interface
+.B flags
+interface flags:
+.RS
+.TP
+.B PCAP_IF_LOOPBACK
+set if the interface is a loopback interface
+.RE
 .RE
 .PP
 Each element of the list of addresses is of type
diff --git a/pcap.h b/pcap.h
index 88ccdcfdf2e1c9475a8018593c6deb056a83fc37..111a0a50745113c852dd0dffd5795f5485add9e1 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.32 2001-10-08 01:06:22 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.33 2001-10-28 02:31:50 guy Exp $ (LBL)
  */
 
 #ifndef lib_pcap_h
@@ -139,9 +139,11 @@ struct pcap_if {
        char *name;             /* name to hand to "pcap_open_live()" */
        char *description;      /* textual description of interface, or NULL */
        struct pcap_addr *addresses;
-       u_int is_loopback;      /* non-0 if interface is loopback */
+       u_int flags;            /* PCAP_IF_ interface flags */
 };
 
+#define PCAP_IF_LOOPBACK       0x00000001      /* interface is loopback */
+
 /*
  * Representation of an interface address.
  */