commit d0045cfcca7a090333676783d75ccfab07d9748d
parent d18261049462812ef8346b7dbf1b5654c0e78c1b
Author: Jordan Ritter <jpr5@darkridge.com>
Date: Thu, 24 Jul 2014 09:28:43 -0700
Update VS2012 configuration, builds on Win32 again
- use ws2tcpip.h, packet.lib to get inet_ntop
- removed support/inet_ntop.[ch] -- no longer necessary
- update gitignore to nuke MSFT turds
Diffstat:
6 files changed, 138 insertions(+), 205 deletions(-)
diff --git a/ngrep.c b/ngrep.c
@@ -53,8 +53,8 @@
#include <io.h>
#include <getopt.h>
#include <winsock2.h>
+#include <ws2tcpip.h>
#include <types.h>
-#include <inet_ntop.h>
#include <config.h>
#define strcasecmp stricmp
diff --git a/win32/.gitignore b/win32/.gitignore
@@ -0,0 +1,6 @@
+*.sdf
+*.opensdf
+*.suo
+*.vcxproj.*
+Debug/
+Release/
diff --git a/win32/ngrep.sln b/win32/ngrep.sln
@@ -1,21 +1,19 @@
-Microsoft Visual Studio Solution File, Format Version 7.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ngrep", "ngrep.vcproj", "{CC0C01CE-0AC3-4F93-9DC8-792862344DBA}"
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ngrep", "ngrep.vcxproj", "{CC0C01CE-0AC3-4F93-9DC8-792862344DBA}"
EndProject
Global
- GlobalSection(SolutionConfiguration) = preSolution
- ConfigName.0 = Debug
- ConfigName.1 = Release
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
EndGlobalSection
- GlobalSection(ProjectDependencies) = postSolution
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {CC0C01CE-0AC3-4F93-9DC8-792862344DBA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CC0C01CE-0AC3-4F93-9DC8-792862344DBA}.Debug|Win32.Build.0 = Debug|Win32
+ {CC0C01CE-0AC3-4F93-9DC8-792862344DBA}.Release|Win32.ActiveCfg = Release|Win32
+ {CC0C01CE-0AC3-4F93-9DC8-792862344DBA}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {CC0C01CE-0AC3-4F93-9DC8-792862344DBA}.Debug.ActiveCfg = Debug|Win32
- {CC0C01CE-0AC3-4F93-9DC8-792862344DBA}.Debug.Build.0 = Debug|Win32
- {CC0C01CE-0AC3-4F93-9DC8-792862344DBA}.Release.ActiveCfg = Release|Win32
- {CC0C01CE-0AC3-4F93-9DC8-792862344DBA}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
diff --git a/win32/ngrep.vcxproj b/win32/ngrep.vcxproj
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{CC0C01CE-0AC3-4F93-9DC8-792862344DBA}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>Debug\</OutDir>
+ <IntDir>Debug\</IntDir>
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>Release\</OutDir>
+ <IntDir>Release\</IntDir>
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>support;..\regex-0.12;..\..\WpdPack\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>STDC_HEADERS;WPCAP;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader />
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ws2_32.lib;wpcap.lib;packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)ngrep.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\WpdPack\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)ngrep.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>support;..\regex-0.12;..\..\WpdPack\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>STDC_HEADERS;_CRT_SECURE_NO_WARNINGS;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader />
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ws2_32.lib;wpcap.lib;packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)ngrep.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\WpdPack\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="support\getopt.c" />
+ <ClCompile Include="..\ngrep.c" />
+ <ClCompile Include="..\regex-0.12\regex.c">
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">REGEX_MALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">REGEX_MALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="support\config.h" />
+ <ClInclude Include="support\getopt.h" />
+ <ClInclude Include="..\ngrep.h" />
+ <ClInclude Include="..\..\WpdPack\Include\pcap.h" />
+ <ClInclude Include="..\regex-0.12\regex.h" />
+ <ClInclude Include="support\types.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>+
\ No newline at end of file
diff --git a/win32/support/inet_ntop.c b/win32/support/inet_ntop.c
@@ -1,184 +0,0 @@
-/*
- * This is Win32-specific support functionality for inet_ntop(),
- * which is missing from Win32. The code was used from FreeBSD:
- *
- * $FreeBSD: /repoman/r/ncvs/src/lib/libc/net/inet_ntop.c,v 1.6.2.2 2002/12/16 15:19:35 robert Exp $"
- */
-
-/* Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#include <winsock2.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "types.h"
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
-static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
-
-/* char *
- * inet_ntop(af, src, dst, size)
- * convert a network format address to presentation format.
- * return:
- * pointer to presentation format address (`dst'), or NULL (see errno).
- * author:
- * Paul Vixie, 1996.
- */
-const char *inet_ntop(int af, const void *src, char *dst, size_t size) {
- switch (af) {
- case AF_INET:
- return (inet_ntop4(src, dst, size));
- case AF_INET6:
- return (inet_ntop6(src, dst, size));
- }
-
- errno = WSAEAFNOSUPPORT;
- return (NULL);
-}
-
-/* const char *
- * inet_ntop4(src, dst, size)
- * format an IPv4 address, more or less like inet_ntoa()
- * return:
- * `dst' (as a const)
- * notes:
- * (1) uses no statics
- * (2) takes a u_char* not an in_addr as input
- * author:
- * Paul Vixie, 1996.
- */
-static const char *inet_ntop4(const u_char *src, char *dst, size_t size) {
- static const char fmt[] = "%u.%u.%u.%u";
-
- if ((size_t)_snprintf(dst, size, fmt, src[0], src[1], src[2], src[3])
- >= size) {
- errno = ENOSPC;
- return (NULL);
- }
-
- return (dst);
-}
-
-/* const char *
- * inet_ntop6(src, dst, size)
- * convert IPv6 binary address into presentation (printable) format
- * author:
- * Paul Vixie, 1996.
- */
-static const char *inet_ntop6(const u_char *src, char *dst, size_t size) {
- /*
- * Note that int32_t and int16_t need only be "at least" large enough
- * to contain a value of the specified size. On some systems, like
- * Crays, there is no such thing as an integer variable with 16 bits.
- * Keep this in mind if you think this function should have been coded
- * to use pointer overlays. All the world's not a VAX.
- */
- char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
- struct { int base, len; } best, cur;
- u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
- int i;
-
- /*
- * Preprocess:
- * Copy the input (bytewise) array into a wordwise array.
- * Find the longest run of 0x00's in src[] for :: shorthanding.
- */
- memset(words, '\0', sizeof words);
- for (i = 0; i < NS_IN6ADDRSZ; i++)
- words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
-
- best.base = -1;
- cur.base = -1;
-
- for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
- if (words[i] == 0) {
- if (cur.base == -1)
- cur.base = i, cur.len = 1;
- else
- cur.len++;
- } else
- if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- cur.base = -1;
- }
-
- if (cur.base != -1)
- if (best.base == -1 || cur.len > best.len)
- best = cur;
-
- if (best.base != -1 && best.len < 2)
- best.base = -1;
-
- /*
- * Format the result.
- */
- tp = tmp;
-
- for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
-
- /* Are we inside the best run of 0x00's? */
- if (best.base != -1 && i >= best.base
- && i < (best.base + best.len)) {
- if (i == best.base)
- *tp++ = ':';
- continue;
- }
-
- /* Are we following an initial run of 0x00s or any real hex? */
- if (i != 0)
- *tp++ = ':';
-
- /* Is this address an encapsulated IPv4? */
- if (i == 6 && best.base == 0 &&
- (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
- if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
- return (NULL);
-
- tp += strlen(tp);
-
- break;
- }
-
- tp += sprintf(tp, "%x", words[i]);
- }
-
- /* Was it a trailing run of 0x00's? */
- if (best.base != -1 && (best.base + best.len) ==
- (NS_IN6ADDRSZ / NS_INT16SZ))
- *tp++ = ':';
-
- *tp++ = '\0';
-
- /*
- * Check for overflow, copy, and we're done.
- */
-
- if ((size_t)(tp - tmp) > size) {
- errno = ENOSPC;
- return (NULL);
- }
-
- strcpy(dst, tmp);
- return (dst);
-}
diff --git a/win32/support/inet_ntop.h b/win32/support/inet_ntop.h
@@ -1,5 +0,0 @@
-/*
- * Compatibility header, supporting Win32-specific inet_ntop() implementation.
- */
-
-int inet_ntop(int af, const void *src, char *dst, size_t size);