Wireshark-dev: Re: [Wireshark-dev] Problem in 'packet-f5ethtrailer.c'
From: Guy Harris <gharris@xxxxxxxxx>
Date: Thu, 19 Mar 2020 11:38:33 -0700
On Mar 19, 2020, at 7:40 AM, Gisle Vanem <gisle.vanem@xxxxxxxxx> wrote:

> I'm surprised no one has come across this compile
> error yet:
> epan/dissectors/packet-f5ethtrailer.c(482): error C2143: syntax error: missing ';' before '.'
> epan/dissectors/packet-f5ethtrailer.c(485): error C2224: left of '.S_addr' must have struct/union type
> epan/dissectors/packet-f5ethtrailer.c(487): error C2224: left of '.S_addr' must have struct/union type
> 
> (using MSVC-2019).
> 
> Reason seems simple; <winsock2.h> has snuck in somehow and
> added the wellknown "#define s_addr S_un.S_addr"

This isn't unique to Windows.  It dates back to old BSD, in which struct in_addr contained a union of multiple different types for an IP address, with some types being structures breaking up the address into host and network bits, and even included bits for IMP numbers.  s_addr was defined to be the member of the union that just defined an address as a 32-bit integer, so if you referred to the s_addr "field" of the structure it gave you the 32-bit integer value.

Some OSes, including later versions of 4.xBSD, dropped that, with struct in_addr having just a 32-bit-integer s_addr field; macOS was based on 4.4-Lite, so it worked like that, and the current *BSDs are also based on that.  Linux probably picked that up, too.

However, Illumos still has that old stuff, so Solaris probably does so as well; any code including <netinet/in.h>, directly or indirectly, could get bitten by that.

In addition, we tend to use src_, rather than s_, as a prefix for "source", and "dst_" or "dest" as a prefix for "destination", so I posted a change to rename s_addr and d_addr to src_addr and dst_addr:

	https://code.wireshark.org/review/36504

which should fix this.

(Why it's not happening with some Windows build environments is anybody's guess.  Different SDK versions?  Different #defines?)