[Snort-devel] Win32/MingW patches

Daniel Roelker droelker at ...402...
Mon Dec 20 14:02:01 EST 2004


Thanks, we'll take a look at these and get them in the official 2.3
release.

Dan

On Mon, 2004-12-20 at 07:48, Gisle Vanem wrote:
> I've sent patches for MingW once before, but got no response.
> 
> The attached diff-file reduces the number of warning on MingW/gcc and 
> fixes some build-problems for MSVC too; E.g. no <sys/socket.h> etc. on 
> MSVC/MingW.
> 
> --gv
> ----
> 

> diff -u3 -Hb -r snort-latest/src/decode.h src/decode.h
> --- snort-latest/src/decode.h	Tue Dec 14 19:15:17 2004
> +++ src/decode.h	Wed Dec 15 18:06:53 2004
> @@ -558,7 +558,7 @@
>  /* Start Token Ring Data Structures */
> 
> 
> -#ifdef WIN32
> +#ifdef _MSC_VER
>      /* Visual C++ pragma to disable warning messages about nonstandard bit field type */
>      #pragma warning( disable : 4214 )
>  #endif
> @@ -578,7 +578,7 @@
>   * a bit more split up
>   */
> 
> -#ifdef WIN32
> +#ifdef _MSC_VER
>    /* Visual C++ pragma to disable warning messages about nonstandard bit field type */
>    #pragma warning( disable : 4214 )
>  #endif
> @@ -610,7 +610,7 @@
>      u_int16_t bcast_len_dir_lf_res; /* broadcast/res/framesize/direction */
>      u_int16_t rseg[8];
>  }       Trh_mr;
> -#ifdef WIN32
> +#ifdef _MSC_VER
>    /* Visual C++ pragma to enable warning messages about nonstandard bit field type */
>    #pragma warning( default : 4214 )
>  #endif
> @@ -624,7 +624,7 @@
>      u_int8_t saddr[TR_ALEN];    /* dst address */
>  }        Trh_hdr;
> 
> -#ifdef WIN32
> +#ifdef _MSC_VER
>      /* Visual C++ pragma to enable warning messages about nonstandard bit field type */
>      #pragma warning( default : 4214 )
>  #endif
> @@ -722,7 +722,7 @@
>  #define LINUX_SLL_P_802_2       0x0004  /* 802.2 frames (not D/I/X Ethernet) */
> 
> 
> -#ifdef WIN32
> +#ifdef _MSC_VER
>    /* Visual C++ pragma to disable warning messages
>     * about nonstandard bit field type
>     */
> @@ -738,7 +738,7 @@
>      u_int16_t vth_pri_cfi_vlan;
>      u_int16_t vth_proto;  /* protocol field... */
>  } VlanTagHdr;
> -#ifdef WIN32
> +#ifdef _MSC_VER
>    /* Visual C++ pragma to enable warning messages about nonstandard bit field type */
>    #pragma warning( default : 4214 )
>  #endif
> @@ -788,7 +788,7 @@
> 
>  /* Can't add any fields not in the real header here
>     because of how the decoder uses structure overlaying */
> -#ifdef WIN32
> +#ifdef _MSC_VER
>    /* Visual C++ pragma to disable warning messages
>     * about nonstandard bit field type
>     */
> @@ -816,7 +816,7 @@
>      struct in_addr ip_src;  /* source IP */
>      struct in_addr ip_dst;  /* dest IP */
>  }      IPHdr;
> -#ifdef WIN32
> +#ifdef _MSC_VER
>    /* Visual C++ pragma to enable warning messages about nonstandard bit field type */
>    #pragma warning( default : 4214 )
>  #endif
> @@ -824,7 +824,7 @@
> 
>  /* Can't add any fields not in the real header here
>     because of how the decoder uses structure overlaying */
> -#ifdef WIN32
> +#ifdef _MSC_VER
>    /* Visual C++ pragma to disable warning
>     * messages about nonstandard bit field type
>     */
> @@ -853,7 +853,7 @@
>      u_int16_t th_urp;       /* urgent pointer */
> 
>  }       TCPHdr;
> -#ifdef WIN32
> +#ifdef _MSC_VER
>    /* Visual C++ pragma to enable warning messages
>     * about nonstandard bit field type
>     */
> diff -u3 -Hb -r snort-latest/src/preprocessors/portscan.c src/preprocessors/portscan.c
> --- snort-latest/src/preprocessors/portscan.c	Wed Oct 13 21:15:14 2004
> +++ src/preprocessors/portscan.c	Fri Nov 12 16:30:55 2004
> @@ -79,9 +79,11 @@
>  #include <stdlib.h>
>  #include <string.h>
>  #include <sys/types.h>
> +#ifndef WIN32
>  #include <sys/socket.h>
>  #include <netinet/in.h>
>  #include <arpa/inet.h>
> +#endif
> 
>  #include "portscan.h"
>  #include "decode.h"
> diff -u3 -Hb -r snort-latest/src/win32/WIN32-Includes/config.h src/win32/WIN32-Includes/config.h
> --- snort-latest/src/win32/WIN32-Includes/config.h	Wed Oct 13 19:15:19 2004
> +++ src/win32/WIN32-Includes/config.h	Fri Oct 29 15:42:46 2004
> @@ -97,15 +97,30 @@
> 
>  #include <winsock2.h>
>  #include <windows.h>
> +
> +#ifdef _MSC_VER
>  #pragma warning( disable : 4028 )
> +#endif
> +
>  #include <io.h>
>  #include <process.h>
> +
> +#ifdef _MSC_VER
>  #pragma warning( default : 4028 )
> +#endif
> +
>  #include <sys/timeb.h>
>  #include <direct.h>
>  #include <getopt.h>
> +
> +#ifndef __MINGW32__
>  typedef int            pid_t;
> +#endif
> +
> +#ifndef _SSIZE_T_      /* MingW */
>  typedef SSIZE_T        ssize_t;
> +#endif
> +
>  #include "win32/WIN32-Includes/rpc/types.h"
> 
>  #undef interface
> @@ -149,8 +164,15 @@
>  #define SIGUSR2 31               /* user defined signal 2 */
>  #define SIGPIPE 13               /* write on a pipe with no one to read it */
>  // #define EEXIST                   17              /* File exists */
> +
> +#ifndef W_OK
>  #define W_OK                     0x02    /* test for write permission */
> +#endif
> +
> +#ifndef R_OK
>  #define R_OK                     0x04    /* test for read permission */
> +#endif
> +
>  #define S_ISDIR(x)               (((x) & 0170000) == 0040000)    /* directory */
>  #define S_IRWXU                  0000700                 /* RWX mask for owner */
>  #define S_IRWXG                  0000070                 /* RWX mask for group */
> @@ -251,5 +273,6 @@
>  #endif  /* ENABLE_WIN32_SERVICE */
> 
> 
> -#endif __CONFIG_H__
> +#endif
> +
> 
> diff -u3 -Hb -r snort-latest/src/win32/WIN32-Includes/stdint.h src/win32/WIN32-Includes/stdint.h
> --- snort-latest/src/win32/WIN32-Includes/stdint.h	Wed Dec 03 14:22:23 2003
> +++ src/win32/WIN32-Includes/stdint.h	Wed Oct 13 01:10:47 2004
> @@ -28,6 +28,9 @@
>   * in the performance code (perf*.c/h).  So, we'll use
>   * signed values instead.
>   */
> +#if defined(__GNUC__) && !defined(__int64)
> +#define __int64 long long
> +#endif
> 
>  typedef char               int8_t;
>  typedef short              int16_t;
> @@ -39,15 +42,15 @@
>  typedef unsigned long      uint32_t;
>  typedef   signed __int64   uint64_t;
> 
> -
>  typedef uint8_t            u_int8_t;
>  typedef uint16_t           u_int16_t;
> +
> +#ifndef HAVE_U_INT32_T
>  typedef uint32_t           u_int32_t;
> +#define HAVE_U_INT32_T
> +#endif
> 
>  #define UINT64             uint64_t
>  typedef uint64_t           uint64;
> 
> -
> -
> -
>  #endif
> \ No newline at end of file
> diff -u3 -Hb -r snort-latest/src/win32/WIN32-Includes/syslog.h src/win32/WIN32-Includes/syslog.h
> --- snort-latest/src/win32/WIN32-Includes/syslog.h	Mon Oct 20 14:03:43 2003
> +++ src/win32/WIN32-Includes/syslog.h	Tue Mar 16 13:36:01 2004
> @@ -207,6 +207,8 @@
>   * for utilities to have to include one of them to include syslog.h, so we get
>   * _BSD_VA_LIST_ from <machine/ansi.h> and use it.
>   */
> +#include <stdarg.h>
> +
>  #ifndef WIN32
>  #include <machine/ansi.h>
>  #include <sys/cdefs.h>
-- 
Daniel Roelker
Lead Snort Developer
Sourcefire, Inc.





More information about the Snort-devel mailing list