Wireshark-dev: [Wireshark-dev] Messy capture_if_details_dlg_win32.c

From: Gisle Vanem <gvanem@xxxxxxxxxxxx>
Date: Wed, 24 Nov 2010 20:13:29 +0100
I'm not very happy about all the #ifdef-ing in capture_if_details_dlg_win32.c.
Isn't it possible to do away with those by using unique names for possibly missing constants and typedefs (structs and enums)? Like:

typedef unsigned short ws_eth_sa_family_t;
...

struct ws_sockaddr_storage {
   ws_eth_sa_family_t  __ss_family;     /* address family */
 ...
};
#define sockaddr_storage ws_sockaddr_storage

#include <Packet32.h>

And with the enums. E.g.:

enum network_infrastructure {
_Ndis802_11IBSS,
...
};

...

static const value_string win32_802_11_infra_mode_vals[] = {
 { _Ndis802_11IBSS,           "Ad Hoc" },


Likewise with all the constants:

#ifndef NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA     0x00000001
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED      0x00000002
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND      0x00000004
...
#endif

I think we could ass-u-me that if e.g. NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
isn't defined, neither are the other defines in that block. Hence we could do away with
all the _MSC_VER checks and make it completely compiler/SDK unaware. How about it?

--gv