[Winpcap-users] Various fixups

Ouroborus ouroborus at softhome.net
Sat Dec 17 18:55:09 GMT 2005


gai_strerror: This stuff is ripped straight from Microsoft's Platform SDK then modified slightly to get it to compile correctly. Given the size and content of the functions, it should be easy to rework them enough to fit them under the BSD license. Ultimately, it really should be included in MingW's w32api headers, thus making it a moot point. (I'm working on it, but it'll probably be at least 6 months before it shows up in the MingW releases.)

3. This was to fix a warning that was crashing gcc for me. The warning was that the bpf_stat structure was being defined inline. As far as I can tell, it's one of the bpf_* structures that's only defined in Packet32.h (some are defined again in bpf-pcap.h) and even then it's defined only when BPF_MAJOR_VERSION is NOT defined. There should be only one place where the bpf_* structures (or any structure) are defined, really, but this works just as well as the other bpf_* structures in bpf_pcap.h work.

5. Given your comment on this, this step should be instead to fixup the GNUmakefile to use wpcap.def instead of wpcap_no_extensions.def as pcap_findalldevs_ex is already included in the former. Doing this may cause issues with other functions that are included in one def and not the other. I'll test this later today.

As for Cygnus, I have no idea. If somebody out there could test this stuff under Cygnus and report on it, that would be great.
  ----- Original Message ----- 
  From: Gianluca Varenni 
  To: winpcap-users at winpcap.org 
  Sent: Friday, December 16, 2005 10:15 PM
  Subject: [spam] Re: [Winpcap-users] Various fixups (was: libpcap.a)


  Hi Ouroborus.

  Some comments about your patches
  1. Ok.
  2. and 7. Sounds reasonable. Where did you take the implementation of gai_strerrorA/W from? If we want to include it into the main WinPcap source code, its license should be compatible with the WinPcap one (i.e. BSD).
  3. Uhm, sounds quite strange. What's the problem if you don't perform this patch?
  4. It's right. I knew about this issue (it generates a compilation warning) but I was quite lazy in fixing it...
  5. You should probably use wpcap.def (wpcap_no_extensions.def was created to remove some of the exports from the standard wpcap.def)
  6. It seems reasonable. I need to check if this file is used by libpcap on the other supported OSes.

  Will this patch work on cygnus, as well?

  Have a nice day
  GV


  ----- Original Message ----- 
    From: Ouroborus 
    To: winpcap-users at winpcap.org 
    Sent: Friday, December 16, 2005 9:46 PM
    Subject: [Winpcap-users] Various fixups (was: libpcap.a)


    I finally got the first step of the tutorial to compile with MingW. This took a number (7) of fixes:


    1. Add "-DHAVE_REMOTE" to "CFLAGS" in the relevant make files


    2. Add "../libpcap/Win32/Src/gai_strerror.o" to the object list in wpcapsrc_3_1\wpcap\PRJ\GNUmakefile


    3. Copy "struct bpf_stat {...};" from wpcapsrc_3_1\Common\Packet32.h to wpcapsrc_3_1\wpcap\libpcap\pcap-bpf.h


    4. Comment out "#define IN_MULTICAST..." from wpcap\libpcap\Win32\Include\ip6_misc.h


    5. Add 'pcap_findalldevs_ex' to Wpcap_no_extensions.def'


    6. Change line 678 in wpcapsrc_3_1\wpcap\libpcap\inet.c as per:
    ### Begin ###
    678c678,679
    <    (char*)tUstr += strlen(tAstr) + 1;;
    ---
    > //   (char*)tUstr += strlen(tAstr) + 1;;
    >    tUstr = (WCHAR*)(((char*)tUstr) + strlen(tAstr) + 1);
    ### End ###


    7. Add file wpcapsrc_3_1\wpcap\libpcap\Win32\Src\gai_strerror.c:
    ### Begin ###
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>

    #define GAI_STRERROR_BUFFER_SIZE 1024
    //#define WS2TCPIP_INLINE extern inline
    #define WS2TCPIP_INLINE __stdcall

    WS2TCPIP_INLINE
    char *
    gai_strerrorA(
        IN int ecode)
    {
        DWORD dwMsgLen;
        static char buff[GAI_STRERROR_BUFFER_SIZE + 1];

        dwMsgLen = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM
                                 |FORMAT_MESSAGE_IGNORE_INSERTS
                                 |FORMAT_MESSAGE_MAX_WIDTH_MASK,
                                  NULL,
                                  ecode,
                                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                                  (LPSTR)buff,
                                  GAI_STRERROR_BUFFER_SIZE,
                                  NULL);

        return buff;
    }

    WS2TCPIP_INLINE
    WCHAR *
    gai_strerrorW(
        IN int ecode
        )
    {
        DWORD dwMsgLen;
        static WCHAR buff[GAI_STRERROR_BUFFER_SIZE + 1];

        dwMsgLen = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
                                 |FORMAT_MESSAGE_IGNORE_INSERTS
                                 |FORMAT_MESSAGE_MAX_WIDTH_MASK,
                                  NULL,
                                  ecode,
                                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                                  (LPWSTR)buff,
                                  GAI_STRERROR_BUFFER_SIZE,
                                  NULL);

        return buff;
    }
    ### End ### 



----------------------------------------------------------------------------


    _______________________________________________
    Winpcap-users mailing list
    Winpcap-users at winpcap.org
    https://www.winpcap.org/mailman/listinfo/winpcap-users



------------------------------------------------------------------------------


  _______________________________________________
  Winpcap-users mailing list
  Winpcap-users at winpcap.org
  https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20051217/986805c1/attachment-0001.htm


More information about the Winpcap-users mailing list