From: Luigi Rizzo Date: Thu, 23 Jan 2014 16:24:03 +0000 (+0100) Subject: lib/pcap-file: add 'ovs_' prefix to pcap functions X-Git-Tag: sliver-openvswitch-2.1.90-1~8^2~41 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=50aa0364d0740b2158f48d40a5be04d47354a1e9;p=sliver-openvswitch.git lib/pcap-file: add 'ovs_' prefix to pcap functions This is done to avoid collisions and confusions with libpcap symbols, like pcap_read() Signed-off-by: Luigi Rizzo Signed-off-by: Daniele Di Proietto Signed-off-by: Ben Pfaff --- diff --git a/AUTHORS b/AUTHORS index 8ee9ce48c..08ebdba7f 100644 --- 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 diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index b2a7572e4..7fb806476 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -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; diff --git a/lib/pcap-file.c b/lib/pcap-file.c index 4e3e7db92..fdff33ca0 100644 --- a/lib/pcap-file.c +++ b/lib/pcap-file.c @@ -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; diff --git a/lib/pcap-file.h b/lib/pcap-file.h index ef491e547..5d79ccbea 100644 --- a/lib/pcap-file.h +++ b/lib/pcap-file.h @@ -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 *); /* Extracting TCP stream data from an Ethernet packet capture. */ diff --git a/tests/test-flows.c b/tests/test-flows.c index 99a9e697f..291003527 100644 --- a/tests/test-flows.c +++ b/tests/test-flows.c @@ -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) { diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index e8453f303..69dd34fa4 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -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) {