On Tue, Sep 1, 2009 at 12:43 PM, Henri Verbeethverbeet@gmail.com wrote:
2009/9/1 Ismael Barros² razielmine@gmail.com:
Is there any standard way to deal with this cases? Any example in the codebase?
For packing, look for "#include <pshpack1.h>" and "#include <poppack.h>" in some of the headers. For byte ordering look at how htonl etc. are defined in include/winsock.h, but you'll want the opposite since the data uses x86 byte ordering.
I've been looking into iphlpapi/ip.h (just learned bit fields exist...); would this implementation be fine?
#include "pshpack1.h"
typedef struct tagDPSP_MSG_HEADER { #ifdef WORDS_BIGENDIAN DWORD size:20; DWORD token:12; #else DWORD token:12; DWORD size:20; #endif SOCKADDR_IN SockAddr; } DPSP_MSG_HEADER, *LPDPSP_MSG_HEADER; typedef const DPSP_MSG_HEADER* LPCDPSP_MSG_HEADER;
/* DPSP_MSG_HEADER->token */ #define DPSP_MSG_TOKEN_REMOTE 0xFAB #define DPSP_MSG_TOKEN_FORWARDED 0xCAB #define DPSP_MSG_TOKEN_SERVER 0xBAB
#include "poppack.h"