g_warning("pcapng_read_section_header_block: SHB (little endian) V%u.%u, len %u",
pn->version_major, pn->version_minor, bh->block_total_length);
- break;
+ break;
case(0x4D3C2B1A):
/* this seems pcapng with swapped byte order */
pn->byte_swapped = TRUE;
case(8): /* if_speed */
if(oh.option_length == 8) {
wblock->data.if_descr.if_speed = *((guint64 *)option_content);
- /* XXX - need 64 bit byte swap */
- /*if(pn->byte_swapped)
- wblock->data.if_descr.if_speed = BSWAP64(wblock->data.if_descr.if_speed);*/
+ if(pn->byte_swapped)
+ wblock->data.if_descr.if_speed = BSWAP64(wblock->data.if_descr.if_speed);
g_warning("pcapng_read_if_descr_block: if_speed %" G_GINT64_MODIFIER "u (bps)", wblock->data.if_descr.if_speed);
} else {
extern gint wtap_num_file_types;
-/* Macros to byte-swap 32-bit and 16-bit quantities. */
+/* 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) | \