diff options
author | 2015-01-10 12:21:12 +0100 | |
---|---|---|
committer | 2015-01-10 12:21:12 +0100 | |
commit | c4fa7719b1d79734d15da03ade1068c83dc6f8bf (patch) | |
tree | 9bbeb26117114ce0a52a15b0be43577bef2bd493 /3rdparty/winpcap/Examples-remote/pcap_fopen | |
parent | e427c5471b902c18b073d24ca012d3945b11176a (diff) |
Added integral version of WinPcap SDK (nw)
Diffstat (limited to '3rdparty/winpcap/Examples-remote/pcap_fopen')
-rw-r--r-- | 3rdparty/winpcap/Examples-remote/pcap_fopen/pcap_fopen.cpp | 94 | ||||
-rw-r--r-- | 3rdparty/winpcap/Examples-remote/pcap_fopen/pcap_fopen.vcproj | 364 |
2 files changed, 458 insertions, 0 deletions
diff --git a/3rdparty/winpcap/Examples-remote/pcap_fopen/pcap_fopen.cpp b/3rdparty/winpcap/Examples-remote/pcap_fopen/pcap_fopen.cpp new file mode 100644 index 00000000000..0476e40edd5 --- /dev/null +++ b/3rdparty/winpcap/Examples-remote/pcap_fopen/pcap_fopen.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2008 CACE Technologies, Davis (California) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of CACE Technologies nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This sample was contributed by + * Marcin Okraszewski (Marcin.OkraszewskiATpl.compuware.com) + * + */ + +#include <tchar.h> +#include <pcap.h> +#include <stdio.h> + +/** Prints packet timestaps regardless of format*/ +int _tmain(int argc, _TCHAR* argv[]) +{ + char errbuf[PCAP_ERRBUF_SIZE]; + wchar_t cmd[1024]; + wchar_t tshark_path[MAX_PATH]; + wchar_t file_path[MAX_PATH]; + + if ( argc != 3 ) { + wprintf(L"Prints packet timestaps regardless of format.\n"); + wprintf(L"Usage:\n\t%ls <tshark path> <trace file>\n", argv[0]); + return 1; + } + + // conversion to short path name in case there are spaces + if ( ! GetShortPathNameW(argv[1], tshark_path, MAX_PATH) || + ! GetShortPathNameW(argv[2], file_path, MAX_PATH) ) + { + printf("Failed to convert paths to short form."); + return 1; + } + + // create tshark command, which will make the trace conversion and print in libpcap format to stdout + if ( swprintf_s(cmd, 1024, L"%ls -r %ls -w - -F libpcap", tshark_path, file_path) < 0 ) { + wprintf(L"Failed to create command\n"); + return 1; + } + + // start tshark + FILE *tshark_out = _wpopen(cmd, L"rb"); + if ( tshark_out == NULL ) { + strerror_s(errbuf, PCAP_ERRBUF_SIZE, errno); + printf("Failed run tshark: %s\n", errbuf); + wprintf(L"Command: %ls", cmd); + return 1; + } + + // open stdout from tshark + pcap_t *pcap = pcap_fopen_offline(tshark_out, errbuf); + if ( pcap == NULL ) { + printf("Error opening stream from tshark: %s\n", errbuf); + return 1; + } + + // print information about every packet int trace + struct pcap_pkthdr hdr; + while ( pcap_next(pcap, &hdr) ) { + printf("packet: ts: %u.%06u, len: %4u, caplen: %4u\n", hdr.ts.tv_sec, hdr.ts.tv_usec, hdr.len, hdr.caplen); + } + + // clean up + pcap_close(pcap); + _pclose(tshark_out); + return 0; +} + diff --git a/3rdparty/winpcap/Examples-remote/pcap_fopen/pcap_fopen.vcproj b/3rdparty/winpcap/Examples-remote/pcap_fopen/pcap_fopen.vcproj new file mode 100644 index 00000000000..73f4c6e027b --- /dev/null +++ b/3rdparty/winpcap/Examples-remote/pcap_fopen/pcap_fopen.vcproj @@ -0,0 +1,364 @@ +<?xml version="1.0" encoding="windows-1250"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="pcap_fopen" + ProjectGUID="{DD317CB5-6337-498F-A560-553B5558E133}" + RootNamespace="pcap_fopen" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)\$(ConfigurationName)\x86" + IntermediateDirectory="$(SolutionDir)\$(ConfigurationName)\x86" + ConfigurationType="1" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../Include" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="wpcap.lib" + LinkIncremental="2" + AdditionalLibraryDirectories="../../Lib" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="$(SolutionDir)\$(ConfigurationName)\x64" + IntermediateDirectory="$(SolutionDir)\$(ConfigurationName)\x64" + ConfigurationType="1" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../Include" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="wpcap.lib" + LinkIncremental="2" + AdditionalLibraryDirectories="../../Lib/x64" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)\$(ConfigurationName)\x86" + IntermediateDirectory="$(SolutionDir)\$(ConfigurationName)\x86" + ConfigurationType="1" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../Include" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="wpcap.lib" + LinkIncremental="1" + AdditionalLibraryDirectories="../../Lib" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="$(SolutionDir)\$(ConfigurationName)\x64" + IntermediateDirectory="$(SolutionDir)\$(ConfigurationName)\x64" + ConfigurationType="1" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../Include" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="wpcap.lib" + LinkIncremental="1" + AdditionalLibraryDirectories="../../Lib/x64" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\pcap_fopen.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> |