lib/pcap-file: add 'ovs_' prefix to pcap functions
authorLuigi Rizzo <rizzo@iet.unipi.it>
Thu, 23 Jan 2014 16:24:03 +0000 (17:24 +0100)
committerBen Pfaff <blp@nicira.com>
Thu, 23 Jan 2014 16:41:05 +0000 (08:41 -0800)
This is done to avoid collisions and confusions with libpcap symbols,
like pcap_read()

Signed-off-by: Luigi Rizzo <rizzo@iet.unipi.it>
Signed-off-by: Daniele Di Proietto <daniele.di.proietto@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
AUTHORS
lib/netdev-dummy.c
lib/pcap-file.c
lib/pcap-file.h
tests/test-flows.c
utilities/ovs-ofctl.c

diff --git a/AUTHORS b/AUTHORS
index 8ee9ce4..08ebdba 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -74,6 +74,7 @@ Leo Alterman            lalterman@nicira.com
 Linda Sun               lsun@vmware.com
 Lorand Jakab            lojakab@cisco.com
 Luca Giraudo            lgiraudo@nicira.com
+Luigi Rizzo             rizzo@iet.unipi.it
 Mark Hamilton           mhamilton@nicira.com
 Martin Casado           casado@nicira.com
 Mehak Mahajan           mmahajan@nicira.com
index b2a7572..7fb8064 100644 (file)
@@ -384,16 +384,16 @@ netdev_dummy_set_config(struct netdev *netdev_, const struct smap *args)
     netdev->rx_pcap = netdev->tx_pcap = NULL;
     pcap = smap_get(args, "pcap");
     if (pcap) {
-        netdev->rx_pcap = netdev->tx_pcap = pcap_open(pcap, "ab");
+        netdev->rx_pcap = netdev->tx_pcap = ovs_pcap_open(pcap, "ab");
     } else {
         const char *rx_pcap = smap_get(args, "rx_pcap");
         const char *tx_pcap = smap_get(args, "tx_pcap");
 
         if (rx_pcap) {
-            netdev->rx_pcap = pcap_open(rx_pcap, "ab");
+            netdev->rx_pcap = ovs_pcap_open(rx_pcap, "ab");
         }
         if (tx_pcap) {
-            netdev->tx_pcap = pcap_open(tx_pcap, "ab");
+            netdev->tx_pcap = ovs_pcap_open(tx_pcap, "ab");
         }
     }
 
@@ -548,7 +548,7 @@ netdev_dummy_send(struct netdev *netdev, const void *buffer, size_t size)
         struct ofpbuf packet;
 
         ofpbuf_use_const(&packet, buffer, size);
-        pcap_write(dev->tx_pcap, &packet);
+        ovs_pcap_write(dev->tx_pcap, &packet);
         fflush(dev->tx_pcap);
     }
 
@@ -814,7 +814,7 @@ netdev_dummy_queue_packet(struct netdev_dummy *dummy, struct ofpbuf *packet)
     struct netdev_rx_dummy *rx, *prev;
 
     if (dummy->rx_pcap) {
-        pcap_write(dummy->rx_pcap, packet);
+        ovs_pcap_write(dummy->rx_pcap, packet);
         fflush(dummy->rx_pcap);
     }
     prev = NULL;
index 4e3e7db..fdff33c 100644 (file)
@@ -53,7 +53,7 @@ struct pcaprec_hdr {
 BUILD_ASSERT_DECL(sizeof(struct pcaprec_hdr) == 16);
 
 FILE *
-pcap_open(const char *file_name, const char *mode)
+ovs_pcap_open(const char *file_name, const char *mode)
 {
     struct stat s;
     FILE *file;
@@ -75,7 +75,7 @@ pcap_open(const char *file_name, const char *mode)
 
     switch (mode[0]) {
     case 'r':
-        error = pcap_read_header(file);
+        error = ovs_pcap_read_header(file);
         if (error) {
             errno = error;
             fclose(file);
@@ -84,12 +84,12 @@ pcap_open(const char *file_name, const char *mode)
         break;
 
     case 'w':
-        pcap_write_header(file);
+        ovs_pcap_write_header(file);
         break;
 
     case 'a':
         if (!fstat(fileno(file), &s) && !s.st_size) {
-            pcap_write_header(file);
+            ovs_pcap_write_header(file);
         }
         break;
 
@@ -100,7 +100,7 @@ pcap_open(const char *file_name, const char *mode)
 }
 
 int
-pcap_read_header(FILE *file)
+ovs_pcap_read_header(FILE *file)
 {
     struct pcap_hdr ph;
     if (fread(&ph, sizeof ph, 1, file) != 1) {
@@ -117,7 +117,7 @@ pcap_read_header(FILE *file)
 }
 
 void
-pcap_write_header(FILE *file)
+ovs_pcap_write_header(FILE *file)
 {
     /* The pcap reader is responsible for figuring out endianness based on the
      * magic number, so the lack of htonX calls here is intentional. */
@@ -133,7 +133,7 @@ pcap_write_header(FILE *file)
 }
 
 int
-pcap_read(FILE *file, struct ofpbuf **bufp, long long int *when)
+ovs_pcap_read(FILE *file, struct ofpbuf **bufp, long long int *when)
 {
     struct pcaprec_hdr prh;
     struct ofpbuf *buf;
@@ -190,7 +190,7 @@ pcap_read(FILE *file, struct ofpbuf **bufp, long long int *when)
 }
 
 void
-pcap_write(FILE *file, struct ofpbuf *buf)
+ovs_pcap_write(FILE *file, struct ofpbuf *buf)
 {
     struct pcaprec_hdr prh;
     struct timeval tv;
index ef491e5..5d79ccb 100644 (file)
@@ -23,11 +23,11 @@ struct flow;
 struct ofpbuf;
 
 /* PCAP file reading and writing. */
-FILE *pcap_open(const char *file_name, const char *mode);
-int pcap_read_header(FILE *);
-void pcap_write_header(FILE *);
-int pcap_read(FILE *, struct ofpbuf **, long long int *when);
-void pcap_write(FILE *, struct ofpbuf *);
+FILE *ovs_pcap_open(const char *file_name, const char *mode);
+int ovs_pcap_read_header(FILE *);
+void ovs_pcap_write_header(FILE *);
+int ovs_pcap_read(FILE *, struct ofpbuf **, long long int *when);
+void ovs_pcap_write(FILE *, struct ofpbuf *);
 \f
 /* Extracting TCP stream data from an Ethernet packet capture. */
 
index 99a9e69..2910035 100644 (file)
@@ -48,7 +48,7 @@ main(int argc OVS_UNUSED, char *argv[])
         ovs_fatal(errno, "failed to open fd 3 for reading");
     }
 
-    retval = pcap_read_header(pcap);
+    retval = ovs_pcap_read_header(pcap);
     if (retval) {
         ovs_fatal(retval > 0 ? retval : 0, "reading pcap header failed");
     }
@@ -61,7 +61,7 @@ main(int argc OVS_UNUSED, char *argv[])
         union flow_in_port in_port_;
         n++;
 
-        retval = pcap_read(pcap, &packet, NULL);
+        retval = ovs_pcap_read(pcap, &packet, NULL);
         if (retval == EOF) {
             ovs_fatal(0, "unexpected end of file reading pcap file");
         } else if (retval) {
index e8453f3..69dd34f 100644 (file)
@@ -1852,7 +1852,7 @@ ofctl_ofp_parse_pcap(int argc OVS_UNUSED, char *argv[])
     int error;
     bool first;
 
-    file = pcap_open(argv[1], "rb");
+    file = ovs_pcap_open(argv[1], "rb");
     if (!file) {
         ovs_fatal(errno, "%s: open failed", argv[1]);
     }
@@ -1864,7 +1864,7 @@ ofctl_ofp_parse_pcap(int argc OVS_UNUSED, char *argv[])
         long long int when;
         struct flow flow;
 
-        error = pcap_read(file, &packet, &when);
+        error = ovs_pcap_read(file, &packet, &when);
         if (error) {
             break;
         }
@@ -3199,7 +3199,7 @@ ofctl_parse_pcap(int argc OVS_UNUSED, char *argv[])
 {
     FILE *pcap;
 
-    pcap = pcap_open(argv[1], "rb");
+    pcap = ovs_pcap_open(argv[1], "rb");
     if (!pcap) {
         ovs_fatal(errno, "%s: open failed", argv[1]);
     }
@@ -3209,7 +3209,7 @@ ofctl_parse_pcap(int argc OVS_UNUSED, char *argv[])
         struct flow flow;
         int error;
 
-        error = pcap_read(pcap, &packet, NULL);
+        error = ovs_pcap_read(pcap, &packet, NULL);
         if (error == EOF) {
             break;
         } else if (error) {