tcpdump mailing list archives
Re: [PATCH] [REPOST] enforce host byte order on
From: Guy Harris <guy () alum mit edu>
Date: Mon, 29 Jan 2007 12:31:16 -0800
Abeni Paolo wrote:
The patch contained in the previous post does conatain an offset error while accessing the linux usb header struct. The one attached here should fix the issue. Please give it a review, since this sort of thing is a bit tricky.
Checked in.
I was tempted by implementing and using an OFFSETOF() macro like: #define OFFSETOF(TYPE, MEMBER) (((size_t) &((TYPE *)0)->MEMBER) + sizeof(((TYPE *)0)->MEMBER)) It will help to avoid the error I incurred in (substituting hard-coded offset values, with compiler generated ones), but I feared some portabilty issue across different compiler. What do you think?
I suspect most if not all platforms on which libpcap/WinPcap is built support ANSI C, so offsetof() is available.
The structure itself (the part that precedes the pcap_usb_setup structure) appears to put all values on their natural boundaries, so it should be the same on 32-bit and 64-bit platforms (and its length is a multiple of 8, so compilers such as, I think, some ARM GCC versions that pad structures to a multiple of 4 bytes won't pad it), so it should be OK on all the compilers we use.
- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- [PATCH] [REPOST] enforce host byte order on usb header Abeni Paolo (Jan 22)
- Re: [PATCH] [REPOST] enforce host byte order on Guy Harris (Jan 29)