aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2013-11-29 19:21:20 +0000
committerJakub Zawadzki <darkjames-ws@darkjames.pl>2013-11-29 19:21:20 +0000
commitd99fdfda639e78feffa3d9a1a6c758ae90539442 (patch)
tree87b591d02048464feebc32f8cf1dc784c7229b17
parent5ac6474c945133a8415fb3be917859e5d42b6256 (diff)
Replace macros: BSWAP16, BSWAP32, BSWAP64 with glib-version.
XXX, people are not aware that expression of this macros might be evaluated multiple times, like: - BSWAP16(tvb_get_letohs(tvb, off)) : \ + GUINT16_SWAP_LE_BE(tvb_get_letohs(tvb, off)) : \ Should be tvb_get_ntohs() called? svn path=/trunk/; revision=53653
-rw-r--r--dumpcap.c17
-rw-r--r--epan/dissectors/packet-ieee80211.c2
-rw-r--r--epan/dissectors/packet-null.c10
-rw-r--r--wiretap/csids.c2
-rw-r--r--wiretap/i4btrace.c26
-rw-r--r--wiretap/libpcap.c16
-rw-r--r--wiretap/pcapng.c84
-rw-r--r--wiretap/wtap-int.h19
-rw-r--r--wsutil/pint.h11
9 files changed, 77 insertions, 110 deletions
diff --git a/dumpcap.c b/dumpcap.c
index 8965b015e8..90961fc826 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -70,7 +70,6 @@
#include <errno.h>
#include <wsutil/crash_info.h>
-#include <wsutil/pint.h>
#ifndef HAVE_GETOPT
#include "wsutil/wsgetopt.h"
@@ -1694,10 +1693,10 @@ cap_pipe_adjust_header(gboolean byte_swapped, struct pcap_hdr *hdr, struct pcapr
{
if (byte_swapped) {
/* Byte-swap the record header fields. */
- rechdr->ts_sec = BSWAP32(rechdr->ts_sec);
- rechdr->ts_usec = BSWAP32(rechdr->ts_usec);
- rechdr->incl_len = BSWAP32(rechdr->incl_len);
- rechdr->orig_len = BSWAP32(rechdr->orig_len);
+ rechdr->ts_sec = GUINT32_SWAP_LE_BE(rechdr->ts_sec);
+ rechdr->ts_usec = GUINT32_SWAP_LE_BE(rechdr->ts_usec);
+ rechdr->incl_len = GUINT32_SWAP_LE_BE(rechdr->incl_len);
+ rechdr->orig_len = GUINT32_SWAP_LE_BE(rechdr->orig_len);
}
/* In file format version 2.3, the "incl_len" and "orig_len" fields were
@@ -2278,10 +2277,10 @@ cap_pipe_open_live(char *pipename,
if (pcap_opts->cap_pipe_byte_swapped) {
/* Byte-swap the header fields about which we care. */
- hdr->version_major = BSWAP16(hdr->version_major);
- hdr->version_minor = BSWAP16(hdr->version_minor);
- hdr->snaplen = BSWAP32(hdr->snaplen);
- hdr->network = BSWAP32(hdr->network);
+ hdr->version_major = GUINT16_SWAP_LE_BE(hdr->version_major);
+ hdr->version_minor = GUINT16_SWAP_LE_BE(hdr->version_minor);
+ hdr->snaplen = GUINT32_SWAP_LE_BE(hdr->snaplen);
+ hdr->network = GUINT32_SWAP_LE_BE(hdr->network);
}
pcap_opts->linktype = hdr->network;
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index 21f2cc574b..5a7d290d1b 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -251,7 +251,7 @@ typedef struct mimo_control
* must be valid variables.
*/
#define FETCH_FCF(off) (wlan_broken_fc ? \
- BSWAP16(tvb_get_letohs(tvb, off)) : \
+ GUINT16_SWAP_LE_BE(tvb_get_letohs(tvb, off)) : \
tvb_get_letohs(tvb, off))
/*
diff --git a/epan/dissectors/packet-null.c b/epan/dissectors/packet-null.c
index cbcf193b2a..1ba8c4695c 100644
--- a/epan/dissectors/packet-null.c
+++ b/epan/dissectors/packet-null.c
@@ -29,8 +29,6 @@
#include <glib.h>
#include <string.h>
-#include <wsutil/pint.h>
-
#include <epan/packet.h>
#include "packet-null.h"
#include <epan/atalk-utils.h>
@@ -294,7 +292,7 @@ capture_null( const guchar *pd, int len, packet_counts *ld )
null_header >>= 16;
} else {
/* Byte-swap it. */
- null_header = BSWAP32(null_header);
+ null_header = GUINT32_SWAP_LE_BE(null_header);
}
} else {
/*
@@ -308,7 +306,7 @@ capture_null( const guchar *pd, int len, packet_counts *ld )
* type; that's in the lower 16 bits of "null_header", but
* is byte-swapped.
*/
- null_header = BSWAP16(null_header & 0xFFFF);
+ null_header = GUINT16_SWAP_LE_BE(null_header & 0xFFFF);
}
}
@@ -394,7 +392,7 @@ dissect_null(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
null_header >>= 16;
} else {
/* Byte-swap it. */
- null_header = BSWAP32(null_header);
+ null_header = GUINT32_SWAP_LE_BE(null_header);
}
} else {
/*
@@ -408,7 +406,7 @@ dissect_null(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* type; that's in the lower 16 bits of "null_header", but
* is byte-swapped.
*/
- null_header = BSWAP16(null_header & 0xFFFF);
+ null_header = GUINT16_SWAP_LE_BE(null_header & 0xFFFF);
}
}
diff --git a/wiretap/csids.c b/wiretap/csids.c
index abfc1b31e1..7a372ca788 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -117,7 +117,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
/* maybe this is just a byteswapped version. the iplen ipflags */
/* and ipid are swapped. We cannot use the normal swaps because */
/* we don't know the host */
- iplen = BSWAP16(iplen);
+ iplen = GUINT16_SWAP_LE_BE(iplen);
if( iplen <= hdr.caplen ) {
/* we know this format */
byteswap = TRUE;
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index ccdce4db12..d6d1074ffe 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -73,11 +73,11 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
/*
* OK, try byte-swapping the header fields.
*/
- hdr.length = BSWAP32(hdr.length);
- hdr.unit = BSWAP32(hdr.unit);
- hdr.type = BSWAP32(hdr.type);
- hdr.dir = BSWAP32(hdr.dir);
- hdr.trunc = BSWAP32(hdr.trunc);
+ hdr.length = GUINT32_SWAP_LE_BE(hdr.length);
+ hdr.unit = GUINT32_SWAP_LE_BE(hdr.unit);
+ hdr.type = GUINT32_SWAP_LE_BE(hdr.type);
+ hdr.dir = GUINT32_SWAP_LE_BE(hdr.dir);
+ hdr.trunc = GUINT32_SWAP_LE_BE(hdr.trunc);
if (!I4B_HDR_IS_OK(hdr)) {
/*
* It doesn't look valid in either byte order.
@@ -164,14 +164,14 @@ i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
/*
* Byte-swap the header.
*/
- hdr.length = BSWAP32(hdr.length);
- hdr.unit = BSWAP32(hdr.unit);
- hdr.type = BSWAP32(hdr.type);
- hdr.dir = BSWAP32(hdr.dir);
- hdr.trunc = BSWAP32(hdr.trunc);
- hdr.count = BSWAP32(hdr.count);
- hdr.ts_sec = BSWAP32(hdr.ts_sec);
- hdr.ts_usec = BSWAP32(hdr.ts_usec);
+ hdr.length = GUINT32_SWAP_LE_BE(hdr.length);
+ hdr.unit = GUINT32_SWAP_LE_BE(hdr.unit);
+ hdr.type = GUINT32_SWAP_LE_BE(hdr.type);
+ hdr.dir = GUINT32_SWAP_LE_BE(hdr.dir);
+ hdr.trunc = GUINT32_SWAP_LE_BE(hdr.trunc);
+ hdr.count = GUINT32_SWAP_LE_BE(hdr.count);
+ hdr.ts_sec = GUINT32_SWAP_LE_BE(hdr.ts_sec);
+ hdr.ts_usec = GUINT32_SWAP_LE_BE(hdr.ts_usec);
}
if (hdr.length < sizeof(hdr)) {
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index 907f2311f9..dd246cd65f 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -172,10 +172,10 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
if (byte_swapped) {
/* Byte-swap the header fields about which we care. */
- hdr.version_major = BSWAP16(hdr.version_major);
- hdr.version_minor = BSWAP16(hdr.version_minor);
- hdr.snaplen = BSWAP32(hdr.snaplen);
- hdr.network = BSWAP32(hdr.network);
+ hdr.version_major = GUINT16_SWAP_LE_BE(hdr.version_major);
+ hdr.version_minor = GUINT16_SWAP_LE_BE(hdr.version_minor);
+ hdr.snaplen = GUINT32_SWAP_LE_BE(hdr.snaplen);
+ hdr.network = GUINT32_SWAP_LE_BE(hdr.network);
}
if (hdr.version_major < 2) {
/* We only support version 2.0 and later. */
@@ -792,10 +792,10 @@ adjust_header(wtap *wth, struct pcaprec_hdr *hdr)
libpcap = (libpcap_t *)wth->priv;
if (libpcap->byte_swapped) {
/* Byte-swap the record header fields. */
- hdr->ts_sec = BSWAP32(hdr->ts_sec);
- hdr->ts_usec = BSWAP32(hdr->ts_usec);
- hdr->incl_len = BSWAP32(hdr->incl_len);
- hdr->orig_len = BSWAP32(hdr->orig_len);
+ hdr->ts_sec = GUINT32_SWAP_LE_BE(hdr->ts_sec);
+ hdr->ts_usec = GUINT32_SWAP_LE_BE(hdr->ts_usec);
+ hdr->incl_len = GUINT32_SWAP_LE_BE(hdr->incl_len);
+ hdr->orig_len = GUINT32_SWAP_LE_BE(hdr->orig_len);
}
/* Swap the "incl_len" and "orig_len" fields, if necessary. */
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index c96fc84afd..cb953fd5f6 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -407,8 +407,8 @@ pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh,
}
block_read = sizeof (*oh);
if (pn->byte_swapped) {
- oh->option_code = BSWAP16(oh->option_code);
- oh->option_length = BSWAP16(oh->option_length);
+ oh->option_code = GUINT16_SWAP_LE_BE(oh->option_code);
+ oh->option_length = GUINT16_SWAP_LE_BE(oh->option_length);
}
/* sanity check: don't run past the end of the block */
@@ -519,11 +519,11 @@ pcapng_read_section_header_block(FILE_T fh, gboolean first_block,
case(0x4D3C2B1A):
/* this seems pcapng with swapped byte order */
pn->byte_swapped = TRUE;
- pn->version_major = BSWAP16(shb.version_major);
- pn->version_minor = BSWAP16(shb.version_minor);
+ pn->version_major = GUINT16_SWAP_LE_BE(shb.version_major);
+ pn->version_minor = GUINT16_SWAP_LE_BE(shb.version_minor);
/* tweak the block length to meet current swapping that we know now */
- bh->block_total_length = BSWAP32(bh->block_total_length);
+ bh->block_total_length = GUINT32_SWAP_LE_BE(bh->block_total_length);
pcapng_debug3("pcapng_read_section_header_block: SHB (big endian) V%u.%u, len %u",
pn->version_major, pn->version_minor, bh->block_total_length);
@@ -576,7 +576,7 @@ pcapng_read_section_header_block(FILE_T fh, gboolean first_block,
/* 64bit section_length (currently unused) */
if (pn->byte_swapped) {
- wblock->data.section.section_length = BSWAP64(shb.section_length);
+ wblock->data.section.section_length = GUINT64_SWAP_LE_BE(shb.section_length);
} else {
wblock->data.section.section_length = shb.section_length;
}
@@ -717,8 +717,8 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
/* mandatory values */
if (pn->byte_swapped) {
- wblock->data.if_descr.link_type = BSWAP16(idb.linktype);
- wblock->data.if_descr.snap_len = BSWAP32(idb.snaplen);
+ wblock->data.if_descr.link_type = GUINT16_SWAP_LE_BE(idb.linktype);
+ wblock->data.if_descr.snap_len = GUINT32_SWAP_LE_BE(idb.snaplen);
} else {
wblock->data.if_descr.link_type = idb.linktype;
wblock->data.if_descr.snap_len = idb.snaplen;
@@ -828,7 +828,7 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
*/
memcpy(&wblock->data.if_descr.if_speed, option_content, sizeof(guint64));
if (pn->byte_swapped)
- wblock->data.if_descr.if_speed = BSWAP64(wblock->data.if_descr.if_speed);
+ wblock->data.if_descr.if_speed = GUINT64_SWAP_LE_BE(wblock->data.if_descr.if_speed);
pcapng_debug1("pcapng_read_if_descr_block: if_speed %" G_GINT64_MODIFIER "u (bps)", wblock->data.if_descr.if_speed);
} else {
pcapng_debug1("pcapng_read_if_descr_block: if_speed length %u not 8 as expected", oh.option_length);
@@ -993,12 +993,12 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
block_read = bytes_read;
if (pn->byte_swapped) {
- packet.interface_id = BSWAP32(epb.interface_id);
+ packet.interface_id = GUINT32_SWAP_LE_BE(epb.interface_id);
packet.drops_count = -1; /* invalid */
- packet.ts_high = BSWAP32(epb.timestamp_high);
- packet.ts_low = BSWAP32(epb.timestamp_low);
- packet.cap_len = BSWAP32(epb.captured_len);
- packet.packet_len = BSWAP32(epb.packet_len);
+ packet.ts_high = GUINT32_SWAP_LE_BE(epb.timestamp_high);
+ packet.ts_low = GUINT32_SWAP_LE_BE(epb.timestamp_low);
+ packet.cap_len = GUINT32_SWAP_LE_BE(epb.captured_len);
+ packet.packet_len = GUINT32_SWAP_LE_BE(epb.packet_len);
} else {
packet.interface_id = epb.interface_id;
packet.drops_count = -1; /* invalid */
@@ -1031,12 +1031,12 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
block_read = bytes_read;
if (pn->byte_swapped) {
- packet.interface_id = BSWAP16(pb.interface_id);
- packet.drops_count = BSWAP16(pb.drops_count);
- packet.ts_high = BSWAP32(pb.timestamp_high);
- packet.ts_low = BSWAP32(pb.timestamp_low);
- packet.cap_len = BSWAP32(pb.captured_len);
- packet.packet_len = BSWAP32(pb.packet_len);
+ packet.interface_id = GUINT16_SWAP_LE_BE(pb.interface_id);
+ packet.drops_count = GUINT16_SWAP_LE_BE(pb.drops_count);
+ packet.ts_high = GUINT32_SWAP_LE_BE(pb.timestamp_high);
+ packet.ts_low = GUINT32_SWAP_LE_BE(pb.timestamp_low);
+ packet.cap_len = GUINT32_SWAP_LE_BE(pb.captured_len);
+ packet.packet_len = GUINT32_SWAP_LE_BE(pb.packet_len);
} else {
packet.interface_id = pb.interface_id;
packet.drops_count = pb.drops_count;
@@ -1235,7 +1235,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
wblock->packet_header->presence_flags |= WTAP_HAS_PACK_FLAGS;
memcpy(&wblock->packet_header->pack_flags, option_content, sizeof(guint32));
if (pn->byte_swapped)
- wblock->packet_header->pack_flags = BSWAP32(wblock->packet_header->pack_flags);
+ wblock->packet_header->pack_flags = GUINT32_SWAP_LE_BE(wblock->packet_header->pack_flags);
if (wblock->packet_header->pack_flags & 0x000001E0) {
/* The FCS length is present */
fcslen = (wblock->packet_header->pack_flags & 0x000001E0) >> 5;
@@ -1257,7 +1257,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
wblock->packet_header->presence_flags |= WTAP_HAS_DROP_COUNT;
memcpy(&wblock->packet_header->drop_count, option_content, sizeof(guint64));
if (pn->byte_swapped)
- wblock->packet_header->drop_count = BSWAP64(wblock->packet_header->drop_count);
+ wblock->packet_header->drop_count = GUINT64_SWAP_LE_BE(wblock->packet_header->drop_count);
pcapng_debug1("pcapng_read_packet_block: drop_count %" G_GINT64_MODIFIER "u", wblock->packet_header->drop_count);
} else {
@@ -1340,7 +1340,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
int_data = g_array_index(pn->interface_data, interface_data_t, 0);
if (pn->byte_swapped) {
- simple_packet.packet_len = BSWAP32(spb.packet_len);
+ simple_packet.packet_len = GUINT32_SWAP_LE_BE(spb.packet_len);
} else {
simple_packet.packet_len = spb.packet_len;
}
@@ -1577,8 +1577,8 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
block_read += bytes_read;
if (pn->byte_swapped) {
- nrb.record_type = BSWAP16(nrb.record_type);
- nrb.record_len = BSWAP16(nrb.record_len);
+ nrb.record_type = GUINT16_SWAP_LE_BE(nrb.record_type);
+ nrb.record_len = GUINT16_SWAP_LE_BE(nrb.record_len);
}
if (to_read - block_read < nrb.record_len + PADDING4(nrb.record_len)) {
@@ -1635,7 +1635,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
memcpy(&v4_addr,
buffer_start_ptr(&nrb_rec), 4);
if (pn->byte_swapped)
- v4_addr = BSWAP32(v4_addr);
+ v4_addr = GUINT32_SWAP_LE_BE(v4_addr);
for (namep = (char *)buffer_start_ptr(&nrb_rec) + 4, record_len = nrb.record_len - 4;
record_len != 0;
namep += namelen, record_len -= namelen) {
@@ -1793,9 +1793,9 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
block_read = bytes_read;
if (pn->byte_swapped) {
- wblock->data.if_stats.interface_id = BSWAP32(isb.interface_id);
- wblock->data.if_stats.ts_high = BSWAP32(isb.timestamp_high);
- wblock->data.if_stats.ts_low = BSWAP32(isb.timestamp_low);
+ wblock->data.if_stats.interface_id = GUINT32_SWAP_LE_BE(isb.interface_id);
+ wblock->data.if_stats.ts_high = GUINT32_SWAP_LE_BE(isb.timestamp_high);
+ wblock->data.if_stats.ts_low = GUINT32_SWAP_LE_BE(isb.timestamp_low);
} else {
wblock->data.if_stats.interface_id = isb.interface_id;
wblock->data.if_stats.ts_high = isb.timestamp_high;
@@ -1861,8 +1861,8 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
memcpy(&high, option_content, sizeof(guint32));
memcpy(&low, option_content + sizeof(guint32), sizeof(guint32));
if (pn->byte_swapped) {
- high = BSWAP32(high);
- low = BSWAP32(low);
+ high = GUINT32_SWAP_LE_BE(high);
+ low = GUINT32_SWAP_LE_BE(low);
}
wblock->data.if_stats.isb_starttime = (guint64)high;
wblock->data.if_stats.isb_starttime <<= 32;
@@ -1882,8 +1882,8 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
memcpy(&high, option_content, sizeof(guint32));
memcpy(&low, option_content + sizeof(guint32), sizeof(guint32));
if (pn->byte_swapped) {
- high = BSWAP32(high);
- low = BSWAP32(low);
+ high = GUINT32_SWAP_LE_BE(high);
+ low = GUINT32_SWAP_LE_BE(low);
}
wblock->data.if_stats.isb_endtime = (guint64)high;
wblock->data.if_stats.isb_endtime <<= 32;
@@ -1900,7 +1900,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
*/
memcpy(&wblock->data.if_stats.isb_ifrecv, option_content, sizeof(guint64));
if (pn->byte_swapped)
- wblock->data.if_stats.isb_ifrecv = BSWAP64(wblock->data.if_stats.isb_ifrecv);
+ wblock->data.if_stats.isb_ifrecv = GUINT64_SWAP_LE_BE(wblock->data.if_stats.isb_ifrecv);
pcapng_debug1("pcapng_read_interface_statistics_block: isb_ifrecv %" G_GINT64_MODIFIER "u", wblock->data.if_stats.isb_ifrecv);
} else {
pcapng_debug1("pcapng_read_interface_statistics_block: isb_ifrecv length %u not 8 as expected", oh.option_length);
@@ -1913,7 +1913,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
*/
memcpy(&wblock->data.if_stats.isb_ifdrop, option_content, sizeof(guint64));
if (pn->byte_swapped)
- wblock->data.if_stats.isb_ifdrop = BSWAP64(wblock->data.if_stats.isb_ifdrop);
+ wblock->data.if_stats.isb_ifdrop = GUINT64_SWAP_LE_BE(wblock->data.if_stats.isb_ifdrop);
pcapng_debug1("pcapng_read_interface_statistics_block: isb_ifdrop %" G_GINT64_MODIFIER "u", wblock->data.if_stats.isb_ifdrop);
} else {
pcapng_debug1("pcapng_read_interface_statistics_block: isb_ifdrop length %u not 8 as expected", oh.option_length);
@@ -1926,7 +1926,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
*/
memcpy(&wblock->data.if_stats.isb_filteraccept, option_content, sizeof(guint64));
if (pn->byte_swapped)
- wblock->data.if_stats.isb_ifdrop = BSWAP64(wblock->data.if_stats.isb_filteraccept);
+ wblock->data.if_stats.isb_ifdrop = GUINT64_SWAP_LE_BE(wblock->data.if_stats.isb_filteraccept);
pcapng_debug1("pcapng_read_interface_statistics_block: isb_filteraccept %" G_GINT64_MODIFIER "u", wblock->data.if_stats.isb_filteraccept);
} else {
pcapng_debug1("pcapng_read_interface_statistics_block: isb_filteraccept length %u not 8 as expected", oh.option_length);
@@ -1939,7 +1939,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
*/
memcpy(&wblock->data.if_stats.isb_osdrop, option_content, sizeof(guint64));
if (pn->byte_swapped)
- wblock->data.if_stats.isb_osdrop = BSWAP64(wblock->data.if_stats.isb_osdrop);
+ wblock->data.if_stats.isb_osdrop = GUINT64_SWAP_LE_BE(wblock->data.if_stats.isb_osdrop);
pcapng_debug1("pcapng_read_interface_statistics_block: isb_osdrop %" G_GINT64_MODIFIER "u", wblock->data.if_stats.isb_osdrop);
} else {
pcapng_debug1("pcapng_read_interface_statistics_block: isb_osdrop length %u not 8 as expected", oh.option_length);
@@ -1952,7 +1952,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
*/
memcpy(&wblock->data.if_stats.isb_usrdeliv, option_content, sizeof(guint64));
if (pn->byte_swapped)
- wblock->data.if_stats.isb_usrdeliv = BSWAP64(wblock->data.if_stats.isb_osdrop);
+ wblock->data.if_stats.isb_usrdeliv = GUINT64_SWAP_LE_BE(wblock->data.if_stats.isb_osdrop);
pcapng_debug1("pcapng_read_interface_statistics_block: isb_usrdeliv %" G_GINT64_MODIFIER "u", wblock->data.if_stats.isb_usrdeliv);
} else {
pcapng_debug1("pcapng_read_interface_statistics_block: isb_usrdeliv length %u not 8 as expected", oh.option_length);
@@ -2028,8 +2028,8 @@ pcapng_read_block(FILE_T fh, gboolean first_block, pcapng_t *pn, wtapng_block_t
block_read = bytes_read;
if (pn->byte_swapped) {
- bh.block_type = BSWAP32(bh.block_type);
- bh.block_total_length = BSWAP32(bh.block_total_length);
+ bh.block_type = GUINT32_SWAP_LE_BE(bh.block_type);
+ bh.block_total_length = GUINT32_SWAP_LE_BE(bh.block_total_length);
}
wblock->type = bh.block_type;
@@ -2095,7 +2095,7 @@ pcapng_read_block(FILE_T fh, gboolean first_block, pcapng_t *pn, wtapng_block_t
block_read += bytes_read;
if (pn->byte_swapped)
- block_total_length = BSWAP32(block_total_length);
+ block_total_length = GUINT32_SWAP_LE_BE(block_total_length);
if (!(block_total_length == bh.block_total_length)) {
*err = WTAP_ERR_BAD_FILE;
@@ -2249,7 +2249,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
file_seek(wth->fh, saved_offset, SEEK_SET, err);
if (pn.byte_swapped) {
- bh.block_type = BSWAP32(bh.block_type);
+ bh.block_type = GUINT32_SWAP_LE_BE(bh.block_type);
}
pcapng_debug1("pcapng_open: Check for more IDB:s block_type 0x%x", bh.block_type);
diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h
index 4d6195a2be..c0206eb6db 100644
--- a/wiretap/wtap-int.h
+++ b/wiretap/wtap-int.h
@@ -121,25 +121,6 @@ gint64 wtap_dump_file_tell(wtap_dumper *wdh, int *err);
extern gint wtap_num_file_types;
-/* Macros to byte-swap 64-bit, 32-bit and 16-bit quantities. */
-#define BSWAP64(x) \
- ((((x)&G_GINT64_CONSTANT(0xFF00000000000000U))>>56) | \
- (((x)&G_GINT64_CONSTANT(0x00FF000000000000U))>>40) | \
- (((x)&G_GINT64_CONSTANT(0x0000FF0000000000U))>>24) | \
- (((x)&G_GINT64_CONSTANT(0x000000FF00000000U))>>8) | \
- (((x)&G_GINT64_CONSTANT(0x00000000FF000000U))<<8) | \
- (((x)&G_GINT64_CONSTANT(0x0000000000FF0000U))<<24) | \
- (((x)&G_GINT64_CONSTANT(0x000000000000FF00U))<<40) | \
- (((x)&G_GINT64_CONSTANT(0x00000000000000FFU))<<56))
-#define BSWAP32(x) \
- ((((x)&0xFF000000)>>24) | \
- (((x)&0x00FF0000)>>8) | \
- (((x)&0x0000FF00)<<8) | \
- (((x)&0x000000FF)<<24))
-#define BSWAP16(x) \
- ((((x)&0xFF00)>>8) | \
- (((x)&0x00FF)<<8))
-
/* Macros to byte-swap possibly-unaligned 64-bit, 32-bit and 16-bit quantities;
* they take a pointer to the quantity, and byte-swap it in place.
*/
diff --git a/wsutil/pint.h b/wsutil/pint.h
index ba3b4a1493..9d4ff81f00 100644
--- a/wsutil/pint.h
+++ b/wsutil/pint.h
@@ -139,15 +139,4 @@
((guint8*)(p))[3] = (guint8)((v) >> 0); \
}
-
-/* Macros to byte-swap 32-bit and 16-bit quantities. */
-#define BSWAP32(x) \
- ((((x)&0xFF000000)>>24) | \
- (((x)&0x00FF0000)>>8) | \
- (((x)&0x0000FF00)<<8) | \
- (((x)&0x000000FF)<<24))
-#define BSWAP16(x) \
- ((((x)&0xFF00)>>8) | \
- (((x)&0x00FF)<<8))
-
#endif /* PINT_H */