Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Problem in 'packet-f5ethtrailer.c'

From: João Valverde <joao.valverde@xxxxxxxxxxxxxxxxxx>
Date: Fri, 20 Mar 2020 15:09:02 +0000


On 19/03/20 18:38, Guy Harris wrote:
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.

Because POSIX defines struct in_addr as an opaque structure with an s_addr element, some BSD Socket implementations get creative with the use of unions and use a macro definition for "s_addr", which is terribly bad practice and a tremendously ugly botch.