tcp/quic lab finished
This commit is contained in:
10
network/arpicmplab/start/lib/npcap/Examples-pcap/GNUmakefile
Normal file
10
network/arpicmplab/start/lib/npcap/Examples-pcap/GNUmakefile
Normal file
@ -0,0 +1,10 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Nate Lawson <nate@rootlabs.com>
|
||||
|
||||
SUBDIRS = basic_dump basic_dump_ex iflist pcap_filter pktdump_ex readfile readfile_ex savedump sendpack UDPdump
|
||||
|
||||
all clean install uninstall: ${SUBDIRS}
|
||||
for subdir in ${SUBDIRS}; do \
|
||||
echo "Entering $$subdir"; \
|
||||
(cd $$subdir && ${MAKE} $@) \
|
||||
done;
|
||||
118
network/arpicmplab/start/lib/npcap/Examples-pcap/MakeAll.sln
Normal file
118
network/arpicmplab/start/lib/npcap/Examples-pcap/MakeAll.sln
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic_dump", "basic_dump\basic_dump.vcxproj", "{66297062-96A0-4F0E-B147-3C8384031232}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic_dump_ex", "basic_dump_ex\basic_dump_ex.vcxproj", "{92849630-6B09-409C-A7AD-E91E682558B1}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iflist", "iflist\iflist.vcxproj", "{0B27B213-4BF3-4611-B412-A2D09CDE8632}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pcap_filter", "pcap_filter\pcap_filter.vcxproj", "{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pktdump_ex", "pktdump_ex\pktdump_ex.vcxproj", "{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "readfile", "readfile\readfile.vcxproj", "{161E7606-F4CD-4A04-AB6B-5837F7818EE1}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "readfile_ex", "readfile_ex\readfile_ex.vcxproj", "{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "savedump", "savedump\savedump.vcxproj", "{1B8791CB-DD15-46BF-B0A2-879892085538}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sendpack", "sendpack\sendpack.vcxproj", "{1C376689-5F61-48E7-AE83-0DED9EE9E458}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UDPdump", "UDPdump\UDPdump.vcxproj", "{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{66297062-96A0-4F0E-B147-3C8384031232}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{66297062-96A0-4F0E-B147-3C8384031232}.Debug|x64.Build.0 = Debug|x64
|
||||
{66297062-96A0-4F0E-B147-3C8384031232}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{66297062-96A0-4F0E-B147-3C8384031232}.Debug|x86.Build.0 = Debug|Win32
|
||||
{66297062-96A0-4F0E-B147-3C8384031232}.Release|x64.ActiveCfg = Release|x64
|
||||
{66297062-96A0-4F0E-B147-3C8384031232}.Release|x64.Build.0 = Release|x64
|
||||
{66297062-96A0-4F0E-B147-3C8384031232}.Release|x86.ActiveCfg = Release|Win32
|
||||
{66297062-96A0-4F0E-B147-3C8384031232}.Release|x86.Build.0 = Release|Win32
|
||||
{92849630-6B09-409C-A7AD-E91E682558B1}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{92849630-6B09-409C-A7AD-E91E682558B1}.Debug|x64.Build.0 = Debug|x64
|
||||
{92849630-6B09-409C-A7AD-E91E682558B1}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{92849630-6B09-409C-A7AD-E91E682558B1}.Debug|x86.Build.0 = Debug|Win32
|
||||
{92849630-6B09-409C-A7AD-E91E682558B1}.Release|x64.ActiveCfg = Release|x64
|
||||
{92849630-6B09-409C-A7AD-E91E682558B1}.Release|x64.Build.0 = Release|x64
|
||||
{92849630-6B09-409C-A7AD-E91E682558B1}.Release|x86.ActiveCfg = Release|Win32
|
||||
{92849630-6B09-409C-A7AD-E91E682558B1}.Release|x86.Build.0 = Release|Win32
|
||||
{0B27B213-4BF3-4611-B412-A2D09CDE8632}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0B27B213-4BF3-4611-B412-A2D09CDE8632}.Debug|x64.Build.0 = Debug|x64
|
||||
{0B27B213-4BF3-4611-B412-A2D09CDE8632}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{0B27B213-4BF3-4611-B412-A2D09CDE8632}.Debug|x86.Build.0 = Debug|Win32
|
||||
{0B27B213-4BF3-4611-B412-A2D09CDE8632}.Release|x64.ActiveCfg = Release|x64
|
||||
{0B27B213-4BF3-4611-B412-A2D09CDE8632}.Release|x64.Build.0 = Release|x64
|
||||
{0B27B213-4BF3-4611-B412-A2D09CDE8632}.Release|x86.ActiveCfg = Release|Win32
|
||||
{0B27B213-4BF3-4611-B412-A2D09CDE8632}.Release|x86.Build.0 = Release|Win32
|
||||
{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}.Debug|x64.Build.0 = Debug|x64
|
||||
{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}.Release|x64.ActiveCfg = Release|x64
|
||||
{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}.Release|x64.Build.0 = Release|x64
|
||||
{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}.Release|x86.Build.0 = Release|Win32
|
||||
{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}.Debug|x64.Build.0 = Debug|x64
|
||||
{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}.Debug|x86.Build.0 = Debug|Win32
|
||||
{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}.Release|x64.ActiveCfg = Release|x64
|
||||
{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}.Release|x64.Build.0 = Release|x64
|
||||
{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}.Release|x86.ActiveCfg = Release|Win32
|
||||
{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}.Release|x86.Build.0 = Release|Win32
|
||||
{161E7606-F4CD-4A04-AB6B-5837F7818EE1}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{161E7606-F4CD-4A04-AB6B-5837F7818EE1}.Debug|x64.Build.0 = Debug|x64
|
||||
{161E7606-F4CD-4A04-AB6B-5837F7818EE1}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{161E7606-F4CD-4A04-AB6B-5837F7818EE1}.Debug|x86.Build.0 = Debug|Win32
|
||||
{161E7606-F4CD-4A04-AB6B-5837F7818EE1}.Release|x64.ActiveCfg = Release|x64
|
||||
{161E7606-F4CD-4A04-AB6B-5837F7818EE1}.Release|x64.Build.0 = Release|x64
|
||||
{161E7606-F4CD-4A04-AB6B-5837F7818EE1}.Release|x86.ActiveCfg = Release|Win32
|
||||
{161E7606-F4CD-4A04-AB6B-5837F7818EE1}.Release|x86.Build.0 = Release|Win32
|
||||
{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}.Debug|x64.Build.0 = Debug|x64
|
||||
{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}.Release|x64.ActiveCfg = Release|x64
|
||||
{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}.Release|x64.Build.0 = Release|x64
|
||||
{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}.Release|x86.Build.0 = Release|Win32
|
||||
{1B8791CB-DD15-46BF-B0A2-879892085538}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1B8791CB-DD15-46BF-B0A2-879892085538}.Debug|x64.Build.0 = Debug|x64
|
||||
{1B8791CB-DD15-46BF-B0A2-879892085538}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{1B8791CB-DD15-46BF-B0A2-879892085538}.Debug|x86.Build.0 = Debug|Win32
|
||||
{1B8791CB-DD15-46BF-B0A2-879892085538}.Release|x64.ActiveCfg = Release|x64
|
||||
{1B8791CB-DD15-46BF-B0A2-879892085538}.Release|x64.Build.0 = Release|x64
|
||||
{1B8791CB-DD15-46BF-B0A2-879892085538}.Release|x86.ActiveCfg = Release|Win32
|
||||
{1B8791CB-DD15-46BF-B0A2-879892085538}.Release|x86.Build.0 = Release|Win32
|
||||
{1C376689-5F61-48E7-AE83-0DED9EE9E458}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1C376689-5F61-48E7-AE83-0DED9EE9E458}.Debug|x64.Build.0 = Debug|x64
|
||||
{1C376689-5F61-48E7-AE83-0DED9EE9E458}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{1C376689-5F61-48E7-AE83-0DED9EE9E458}.Debug|x86.Build.0 = Debug|Win32
|
||||
{1C376689-5F61-48E7-AE83-0DED9EE9E458}.Release|x64.ActiveCfg = Release|x64
|
||||
{1C376689-5F61-48E7-AE83-0DED9EE9E458}.Release|x64.Build.0 = Release|x64
|
||||
{1C376689-5F61-48E7-AE83-0DED9EE9E458}.Release|x86.ActiveCfg = Release|Win32
|
||||
{1C376689-5F61-48E7-AE83-0DED9EE9E458}.Release|x86.Build.0 = Release|Win32
|
||||
{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}.Debug|x64.Build.0 = Debug|x64
|
||||
{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}.Debug|x86.Build.0 = Debug|Win32
|
||||
{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}.Release|x64.ActiveCfg = Release|x64
|
||||
{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}.Release|x64.Build.0 = Release|x64
|
||||
{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}.Release|x86.ActiveCfg = Release|Win32
|
||||
{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -0,0 +1,17 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Loris Degioanni
|
||||
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = udpdump.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap -lwsock32
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o udpdump.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} udpdump.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="udpdump.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
|
||||
* Copyright (c) 2005 - 2006 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 the Politecnico di Torino, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/*
|
||||
* we do not want the warnings about the old deprecated and unsecure CRT functions
|
||||
* since these examples can be compiled under *nix as well
|
||||
*/
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 4 bytes IP address */
|
||||
typedef struct ip_address
|
||||
{
|
||||
u_char byte1;
|
||||
u_char byte2;
|
||||
u_char byte3;
|
||||
u_char byte4;
|
||||
}ip_address;
|
||||
|
||||
/* IPv4 header */
|
||||
typedef struct ip_header
|
||||
{
|
||||
u_char ver_ihl; // Version (4 bits) + Internet header length (4 bits)
|
||||
u_char tos; // Type of service
|
||||
u_short tlen; // Total length
|
||||
u_short identification; // Identification
|
||||
u_short flags_fo; // Flags (3 bits) + Fragment offset (13 bits)
|
||||
u_char ttl; // Time to live
|
||||
u_char proto; // Protocol
|
||||
u_short crc; // Header checksum
|
||||
ip_address saddr; // Source address
|
||||
ip_address daddr; // Destination address
|
||||
u_int op_pad; // Option + Padding
|
||||
}ip_header;
|
||||
|
||||
/* UDP header*/
|
||||
typedef struct udp_header
|
||||
{
|
||||
u_short sport; // Source port
|
||||
u_short dport; // Destination port
|
||||
u_short len; // Datagram length
|
||||
u_short crc; // Checksum
|
||||
}udp_header;
|
||||
|
||||
/* prototype of the packet handler */
|
||||
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data);
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
int inum;
|
||||
int i=0;
|
||||
pcap_t *adhandle;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
u_int netmask;
|
||||
char packet_filter[] = "ip and udp";
|
||||
struct bpf_program fcode;
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Retrieve the device list */
|
||||
if(pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Print the list */
|
||||
for(d=alldevs; d; d=d->next)
|
||||
{
|
||||
printf("%d. %s", ++i, d->name);
|
||||
if (d->description)
|
||||
printf(" (%s)\n", d->description);
|
||||
else
|
||||
printf(" (No description available)\n");
|
||||
}
|
||||
|
||||
if(i==0)
|
||||
{
|
||||
printf("\nNo interfaces found! Make sure Npcap is installed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Enter the interface number (1-%d):",i);
|
||||
scanf("%d", &inum);
|
||||
|
||||
/* Check if the user specified a valid adapter */
|
||||
if(inum < 1 || inum > i)
|
||||
{
|
||||
printf("\nAdapter number out of range.\n");
|
||||
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Jump to the selected adapter */
|
||||
for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++);
|
||||
|
||||
/* Open the adapter */
|
||||
if ((adhandle= pcap_open_live(d->name, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||
1, // promiscuous mode (nonzero means promiscuous)
|
||||
1000, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter: %s\n", errbuf);
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check the link layer. We support only Ethernet for simplicity. */
|
||||
if(pcap_datalink(adhandle) != DLT_EN10MB)
|
||||
{
|
||||
fprintf(stderr,"\nThis program works only on Ethernet networks.\n");
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(d->addresses != NULL)
|
||||
/* Retrieve the mask of the first address of the interface */
|
||||
netmask=((struct sockaddr_in *)(d->addresses->netmask))->sin_addr.S_un.S_addr;
|
||||
else
|
||||
/* If the interface is without addresses we suppose to be in a C class network */
|
||||
netmask=0xffffff;
|
||||
|
||||
|
||||
//compile the filter
|
||||
if (pcap_compile(adhandle, &fcode, packet_filter, 1, netmask) <0 )
|
||||
{
|
||||
fprintf(stderr,"\nUnable to compile the packet filter. Check the syntax.\n");
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//set the filter
|
||||
if (pcap_setfilter(adhandle, &fcode)<0)
|
||||
{
|
||||
fprintf(stderr,"\nError setting the filter.\n");
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("\nlistening on %s...\n", d->description);
|
||||
|
||||
/* At this point, we don't need any more the device list. Free it */
|
||||
pcap_freealldevs(alldevs);
|
||||
|
||||
/* start the capture */
|
||||
pcap_loop(adhandle, 0, packet_handler, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback function invoked by libpcap for every incoming packet */
|
||||
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
|
||||
{
|
||||
struct tm *ltime;
|
||||
char timestr[16];
|
||||
ip_header *ih;
|
||||
udp_header *uh;
|
||||
u_int ip_len;
|
||||
u_short sport,dport;
|
||||
time_t local_tv_sec;
|
||||
|
||||
/*
|
||||
* unused parameter
|
||||
*/
|
||||
(VOID)(param);
|
||||
|
||||
/* convert the timestamp to readable format */
|
||||
local_tv_sec = header->ts.tv_sec;
|
||||
ltime=localtime(&local_tv_sec);
|
||||
strftime( timestr, sizeof timestr, "%H:%M:%S", ltime);
|
||||
|
||||
/* print timestamp and length of the packet */
|
||||
printf("%s.%.6d len:%d ", timestr, header->ts.tv_usec, header->len);
|
||||
|
||||
/* retireve the position of the ip header */
|
||||
ih = (ip_header *) (pkt_data +
|
||||
14); //length of ethernet header
|
||||
|
||||
/* retireve the position of the udp header */
|
||||
ip_len = (ih->ver_ihl & 0xf) * 4;
|
||||
uh = (udp_header *) ((u_char*)ih + ip_len);
|
||||
|
||||
/* convert from network byte order to host byte order */
|
||||
sport = ntohs( uh->sport );
|
||||
dport = ntohs( uh->dport );
|
||||
|
||||
/* print ip addresses and udp ports */
|
||||
printf("%d.%d.%d.%d.%d -> %d.%d.%d.%d.%d\n",
|
||||
ih->saddr.byte1,
|
||||
ih->saddr.byte2,
|
||||
ih->saddr.byte3,
|
||||
ih->saddr.byte4,
|
||||
sport,
|
||||
ih->daddr.byte1,
|
||||
ih->daddr.byte2,
|
||||
ih->daddr.byte3,
|
||||
ih->daddr.byte4,
|
||||
dport);
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Nate Lawson <nate@rootlabs.com>
|
||||
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = basic_dump.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o basic_dump.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} basic_dump.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
@ -0,0 +1,138 @@
|
||||
#ifdef _MSC_VER
|
||||
/*
|
||||
* we do not want the warnings about the old deprecated and unsecure CRT functions
|
||||
* since these examples can be compiled under *nix as well
|
||||
*/
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <pcap.h>
|
||||
#include <stdio.h>
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* prototype of the packet handler */
|
||||
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data);
|
||||
|
||||
int main()
|
||||
{
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
int inum;
|
||||
int i=0;
|
||||
pcap_t *adhandle;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Retrieve the device list */
|
||||
if(pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Print the list */
|
||||
for(d=alldevs; d; d=d->next)
|
||||
{
|
||||
printf("%d. %s", ++i, d->name);
|
||||
if (d->description)
|
||||
printf(" (%s)\n", d->description);
|
||||
else
|
||||
printf(" (No description available)\n");
|
||||
}
|
||||
|
||||
if(i==0)
|
||||
{
|
||||
printf("\nNo interfaces found! Make sure Npcap is installed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Enter the interface number (1-%d):",i);
|
||||
scanf("%d", &inum);
|
||||
|
||||
if(inum < 1 || inum > i)
|
||||
{
|
||||
printf("\nInterface number out of range.\n");
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Jump to the selected adapter */
|
||||
for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++);
|
||||
|
||||
/* Open the device */
|
||||
/* Open the adapter */
|
||||
if ((adhandle= pcap_open_live(d->name, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||
1, // promiscuous mode (nonzero means promiscuous)
|
||||
1000, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->name);
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("\nlistening on %s...\n", d->description);
|
||||
|
||||
/* At this point, we don't need any more the device list. Free it */
|
||||
pcap_freealldevs(alldevs);
|
||||
|
||||
/* start the capture */
|
||||
pcap_loop(adhandle, 0, packet_handler, NULL);
|
||||
|
||||
pcap_close(adhandle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Callback function invoked by libpcap for every incoming packet */
|
||||
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
|
||||
{
|
||||
struct tm *ltime;
|
||||
char timestr[16];
|
||||
time_t local_tv_sec;
|
||||
|
||||
/*
|
||||
* unused parameters
|
||||
*/
|
||||
(VOID)(param);
|
||||
(VOID)(pkt_data);
|
||||
|
||||
/* convert the timestamp to readable format */
|
||||
local_tv_sec = header->ts.tv_sec;
|
||||
ltime=localtime(&local_tv_sec);
|
||||
strftime( timestr, sizeof timestr, "%H:%M:%S", ltime);
|
||||
|
||||
printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len);
|
||||
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{66297062-96A0-4F0E-B147-3C8384031232}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="basic_dump.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,17 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Nate Lawson <nate@rootlabs.com>
|
||||
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = basic_dump_ex.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o basic_dump_ex.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} basic_dump_ex.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
@ -0,0 +1,134 @@
|
||||
#ifdef _MSC_VER
|
||||
/*
|
||||
* we do not want the warnings about the old deprecated and unsecure CRT functions
|
||||
* since these examples can be compiled under *nix as well
|
||||
*/
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <pcap.h>
|
||||
#include <stdio.h>
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
int inum;
|
||||
int i=0;
|
||||
pcap_t *adhandle;
|
||||
int res;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
struct tm *ltime;
|
||||
char timestr[16];
|
||||
struct pcap_pkthdr *header;
|
||||
const u_char *pkt_data;
|
||||
time_t local_tv_sec;
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Retrieve the device list */
|
||||
if(pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Print the list */
|
||||
for(d=alldevs; d; d=d->next)
|
||||
{
|
||||
printf("%d. %s", ++i, d->name);
|
||||
if (d->description)
|
||||
printf(" (%s)\n", d->description);
|
||||
else
|
||||
printf(" (No description available)\n");
|
||||
}
|
||||
|
||||
if(i==0)
|
||||
{
|
||||
printf("\nNo interfaces found! Make sure Npcap is installed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Enter the interface number (1-%d):",i);
|
||||
scanf("%d", &inum);
|
||||
|
||||
if(inum < 1 || inum > i)
|
||||
{
|
||||
printf("\nInterface number out of range.\n");
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Jump to the selected adapter */
|
||||
for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++);
|
||||
|
||||
/* Open the adapter */
|
||||
if ((adhandle= pcap_open_live(d->name, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||
1, // promiscuous mode (nonzero means promiscuous)
|
||||
1000, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->name);
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("\nlistening on %s...\n", d->description);
|
||||
|
||||
/* At this point, we don't need any more the device list. Free it */
|
||||
pcap_freealldevs(alldevs);
|
||||
|
||||
/* Retrieve the packets */
|
||||
while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0){
|
||||
|
||||
if(res == 0)
|
||||
/* Timeout elapsed */
|
||||
continue;
|
||||
|
||||
/* convert the timestamp to readable format */
|
||||
local_tv_sec = header->ts.tv_sec;
|
||||
ltime=localtime(&local_tv_sec);
|
||||
strftime( timestr, sizeof timestr, "%H:%M:%S", ltime);
|
||||
|
||||
printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len);
|
||||
}
|
||||
|
||||
if(res == -1){
|
||||
printf("Error reading the packets: %s\n", pcap_geterr(adhandle));
|
||||
return -1;
|
||||
}
|
||||
|
||||
pcap_close(adhandle);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{92849630-6B09-409C-A7AD-E91E682558B1}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="basic_dump_ex.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,17 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Nate Lawson <nate@rootlabs.com>
|
||||
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = iflist.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o iflist.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} iflist.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
202
network/arpicmplab/start/lib/npcap/Examples-pcap/iflist/iflist.c
Normal file
202
network/arpicmplab/start/lib/npcap/Examples-pcap/iflist/iflist.c
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
|
||||
* Copyright (c) 2005 - 2006 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 the Politecnico di Torino, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/*
|
||||
* we do not want the warnings about the old deprecated and unsecure CRT functions
|
||||
* since these examples can be compiled under *nix as well
|
||||
*/
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <pcap.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#else
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Function prototypes
|
||||
void ifprint(pcap_if_t *d);
|
||||
char *iptos(u_long in);
|
||||
char* ip6tos(struct sockaddr *sockaddr, char *address, int addrlen);
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
char errbuf[PCAP_ERRBUF_SIZE+1];
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Retrieve the device list */
|
||||
if(pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Scan the list printing every entry */
|
||||
for(d=alldevs;d;d=d->next)
|
||||
{
|
||||
ifprint(d);
|
||||
}
|
||||
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Print all the available information on the given interface */
|
||||
void ifprint(pcap_if_t *d)
|
||||
{
|
||||
pcap_addr_t *a;
|
||||
char ip6str[128];
|
||||
|
||||
/* Name */
|
||||
printf("%s\n",d->name);
|
||||
|
||||
/* Description */
|
||||
if (d->description)
|
||||
printf("\tDescription: %s\n",d->description);
|
||||
|
||||
/* Loopback Address*/
|
||||
printf("\tLoopback: %s\n",(d->flags & PCAP_IF_LOOPBACK)?"yes":"no");
|
||||
|
||||
/* IP addresses */
|
||||
for(a=d->addresses;a;a=a->next) {
|
||||
printf("\tAddress Family: #%d\n",a->addr->sa_family);
|
||||
|
||||
switch(a->addr->sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
printf("\tAddress Family Name: AF_INET\n");
|
||||
if (a->addr)
|
||||
printf("\tAddress: %s\n",iptos(((struct sockaddr_in *)a->addr)->sin_addr.s_addr));
|
||||
if (a->netmask)
|
||||
printf("\tNetmask: %s\n",iptos(((struct sockaddr_in *)a->netmask)->sin_addr.s_addr));
|
||||
if (a->broadaddr)
|
||||
printf("\tBroadcast Address: %s\n",iptos(((struct sockaddr_in *)a->broadaddr)->sin_addr.s_addr));
|
||||
if (a->dstaddr)
|
||||
printf("\tDestination Address: %s\n",iptos(((struct sockaddr_in *)a->dstaddr)->sin_addr.s_addr));
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
printf("\tAddress Family Name: AF_INET6\n");
|
||||
#ifndef __MINGW32__ /* Cygnus doesn't have IPv6 */
|
||||
if (a->addr)
|
||||
printf("\tAddress: %s\n", ip6tos(a->addr, ip6str, sizeof(ip6str)));
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("\tAddress Family Name: Unknown\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* From tcptraceroute, convert a numeric IP address to a string */
|
||||
#define IPTOSBUFFERS 12
|
||||
char *iptos(u_long in)
|
||||
{
|
||||
static char output[IPTOSBUFFERS][3*4+3+1];
|
||||
static short which;
|
||||
u_char *p;
|
||||
|
||||
p = (u_char *)∈
|
||||
which = (which + 1 == IPTOSBUFFERS ? 0 : which + 1);
|
||||
sprintf(output[which], "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
|
||||
return output[which];
|
||||
}
|
||||
|
||||
#ifndef __MINGW32__ /* Cygnus doesn't have IPv6 */
|
||||
char* ip6tos(struct sockaddr *sockaddr, char *address, int addrlen)
|
||||
{
|
||||
socklen_t sockaddrlen;
|
||||
|
||||
#ifdef WIN32
|
||||
sockaddrlen = sizeof(struct sockaddr_in6);
|
||||
#else
|
||||
sockaddrlen = sizeof(struct sockaddr_storage);
|
||||
#endif
|
||||
|
||||
|
||||
if(getnameinfo(sockaddr,
|
||||
sockaddrlen,
|
||||
address,
|
||||
addrlen,
|
||||
NULL,
|
||||
0,
|
||||
NI_NUMERICHOST) != 0) address = NULL;
|
||||
|
||||
return address;
|
||||
}
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{0B27B213-4BF3-4611-B412-A2D09CDE8632}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="iflist.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,17 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Nate Lawson <nate@rootlabs.com>
|
||||
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = pcap_filter.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o pf.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} pf.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
@ -0,0 +1,9 @@
|
||||
|
||||
CC = gcc
|
||||
INCLDIR = -I /usr/src/sys
|
||||
LIBS = -lpcap
|
||||
|
||||
pktdump: pcap_filter.o
|
||||
$(CC) $(INCLDIR) pcap_filter.o $(LIBS) -o pf
|
||||
rm *.o
|
||||
|
||||
@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
|
||||
* Copyright (c) 2005 - 2006 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 the Politecnico di Torino, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#define MAX_PRINT 80
|
||||
#define MAX_LINE 16
|
||||
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void usage();
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pcap_t *fp;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
char *source = NULL;
|
||||
char *ofilename = NULL;
|
||||
char *filter = NULL;
|
||||
int i;
|
||||
pcap_dumper_t *dumpfile;
|
||||
struct bpf_program fcode;
|
||||
bpf_u_int32 NetMask;
|
||||
int res;
|
||||
struct pcap_pkthdr *header;
|
||||
const u_char *pkt_data;
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Parse parameters */
|
||||
for(i=1;i < argc; i+= 2)
|
||||
{
|
||||
switch (argv[i] [1])
|
||||
{
|
||||
case 's':
|
||||
{
|
||||
source=argv[i+1];
|
||||
};
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
{
|
||||
ofilename=argv[i+1];
|
||||
};
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
{
|
||||
filter=argv[i+1];
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// open a capture from the network
|
||||
if (source != NULL)
|
||||
{
|
||||
if ((fp = pcap_open_live(source, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||
1, // promiscuous mode (nonzero means promiscuous)
|
||||
1000, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter.\n");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else usage();
|
||||
|
||||
if (filter != NULL)
|
||||
{
|
||||
// We should loop through the adapters returned by the pcap_findalldevs_ex()
|
||||
// in order to locate the correct one.
|
||||
//
|
||||
// Let's do things simpler: we suppose to be in a C class network ;-)
|
||||
NetMask=0xffffff;
|
||||
|
||||
//compile the filter
|
||||
if(pcap_compile(fp, &fcode, filter, 1, NetMask) < 0)
|
||||
{
|
||||
fprintf(stderr,"\nError compiling filter: wrong syntax.\n");
|
||||
|
||||
pcap_close(fp);
|
||||
return -3;
|
||||
}
|
||||
|
||||
//set the filter
|
||||
if(pcap_setfilter(fp, &fcode)<0)
|
||||
{
|
||||
fprintf(stderr,"\nError setting the filter\n");
|
||||
|
||||
pcap_close(fp);
|
||||
return -4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//open the dump file
|
||||
if (ofilename != NULL)
|
||||
{
|
||||
dumpfile= pcap_dump_open(fp, ofilename);
|
||||
|
||||
if (dumpfile == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nError opening output file\n");
|
||||
|
||||
pcap_close(fp);
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
else usage();
|
||||
|
||||
//start the capture
|
||||
while((res = pcap_next_ex( fp, &header, &pkt_data)) >= 0)
|
||||
{
|
||||
|
||||
if(res == 0)
|
||||
/* Timeout elapsed */
|
||||
continue;
|
||||
|
||||
//save the packet on the dump file
|
||||
pcap_dump((unsigned char *) dumpfile, header, pkt_data);
|
||||
|
||||
}
|
||||
|
||||
pcap_close(fp);
|
||||
pcap_dump_close(dumpfile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void usage()
|
||||
{
|
||||
|
||||
printf("\npf - Generic Packet Filter.\n");
|
||||
printf("\nUsage:\npf -s source -o output_file_name [-f filter_string]\n\n");
|
||||
exit(0);
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B9F68F6F-22AE-47A2-A3A3-1212831AF9FF}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pcap_filter.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,14 @@
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = pktdump_ex.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o pktdump_ex.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} pktdump_ex.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
|
||||
* Copyright (c) 2005 - 2006 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 the Politecnico di Torino, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/*
|
||||
* we do not want the warnings about the old deprecated and unsecure CRT functions
|
||||
* since these examples can be compiled under *nix as well
|
||||
*/
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#define LINE_LEN 16
|
||||
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pcap_if_t *alldevs, *d;
|
||||
pcap_t *fp;
|
||||
u_int inum, i=0;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
int res;
|
||||
struct pcap_pkthdr *header;
|
||||
const u_char *pkt_data;
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("pktdump_ex: prints the packets of the network using Npcap.\n");
|
||||
printf(" Usage: pktdump_ex [-s source]\n\n"
|
||||
" Examples:\n"
|
||||
" pktdump_ex -s file.acp\n"
|
||||
" pktdump_ex -s \\Device\\NPF_{C8736017-F3C3-4373-94AC-9A34B7DAD998}\n\n");
|
||||
|
||||
if(argc < 3)
|
||||
{
|
||||
printf("\nNo adapter selected: printing the device list:\n");
|
||||
/* The user didn't provide a packet source: Retrieve the local device list */
|
||||
if(pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Print the list */
|
||||
for(d=alldevs; d; d=d->next)
|
||||
{
|
||||
printf("%d. %s\n ", ++i, d->name);
|
||||
|
||||
if (d->description)
|
||||
printf(" (%s)\n", d->description);
|
||||
else
|
||||
printf(" (No description available)\n");
|
||||
}
|
||||
|
||||
if (i==0)
|
||||
{
|
||||
printf("\nNo interfaces found! Make sure Npcap is installed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Enter the interface number (1-%d):",i);
|
||||
scanf("%d", &inum);
|
||||
|
||||
if (inum < 1 || inum > i)
|
||||
{
|
||||
printf("\nInterface number out of range.\n");
|
||||
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Jump to the selected adapter */
|
||||
for (d=alldevs, i=0; i< inum-1 ;d=d->next, i++);
|
||||
|
||||
/* Open the adapter */
|
||||
if ((fp = pcap_open_live(d->name, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||
1, // promiscuous mode (nonzero means promiscuous)
|
||||
1000, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nError opening adapter\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do not check for the switch type ('-s') */
|
||||
if ((fp = pcap_open_live(argv[2], // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||
1, // promiscuous mode (nonzero means promiscuous)
|
||||
1000, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nError opening adapter\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the packets */
|
||||
while((res = pcap_next_ex( fp, &header, &pkt_data)) >= 0)
|
||||
{
|
||||
|
||||
if(res == 0)
|
||||
/* Timeout elapsed */
|
||||
continue;
|
||||
|
||||
/* print pkt timestamp and pkt len */
|
||||
printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len);
|
||||
|
||||
/* Print the packet */
|
||||
for (i=1; (i < header->caplen + 1 ) ; i++)
|
||||
{
|
||||
printf("%.2x ", pkt_data[i-1]);
|
||||
if ( (i % LINE_LEN) == 0) printf("\n");
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
if(res == -1)
|
||||
{
|
||||
printf("Error reading the packets: %s\n", pcap_geterr(fp));
|
||||
return -1;
|
||||
}
|
||||
|
||||
pcap_close(fp);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{3D62DEB4-3536-44AE-8E4B-AD6DFF1B795E}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pktdump_ex.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,17 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Nate Lawson <nate@rootlabs.com>
|
||||
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = readfile.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o readfile.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} readfile.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
@ -0,0 +1,90 @@
|
||||
#include <stdio.h>
|
||||
#include <pcap.h>
|
||||
|
||||
#define LINE_LEN 16
|
||||
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void dispatcher_handler(u_char *, const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pcap_t *fp;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(argc != 2)
|
||||
{
|
||||
printf("usage: %s filename", argv[0]);
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
/* Open the capture file */
|
||||
if ((fp = pcap_open_offline(argv[1], // name of the device
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the file %s.\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* read and dispatch packets until EOF is reached */
|
||||
pcap_loop(fp, 0, dispatcher_handler, NULL);
|
||||
|
||||
pcap_close(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void dispatcher_handler(u_char *temp1,
|
||||
const struct pcap_pkthdr *header,
|
||||
const u_char *pkt_data)
|
||||
{
|
||||
u_int i=0;
|
||||
|
||||
/*
|
||||
* unused variable
|
||||
*/
|
||||
(VOID*)temp1;
|
||||
|
||||
/* print pkt timestamp and pkt len */
|
||||
printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len);
|
||||
|
||||
/* Print the packet */
|
||||
for (i=1; (i < header->caplen + 1 ) ; i++)
|
||||
{
|
||||
printf("%.2x ", pkt_data[i-1]);
|
||||
if ( (i % LINE_LEN) == 0) printf("\n");
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{161E7606-F4CD-4A04-AB6B-5837F7818EE1}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="readfile.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,17 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Nate Lawson <nate@rootlabs.com>
|
||||
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = readfile_ex.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o readfile_ex.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} readfile_ex.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
@ -0,0 +1,85 @@
|
||||
#include <stdio.h>
|
||||
#include <pcap.h>
|
||||
|
||||
#define LINE_LEN 16
|
||||
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pcap_t *fp;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
struct pcap_pkthdr *header;
|
||||
const u_char *pkt_data;
|
||||
u_int i=0;
|
||||
int res;
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(argc != 2)
|
||||
{
|
||||
printf("usage: %s filename", argv[0]);
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
/* Open the capture file */
|
||||
if ((fp = pcap_open_offline(argv[1], // name of the device
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the file %s.\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Retrieve the packets from the file */
|
||||
while((res = pcap_next_ex(fp, &header, &pkt_data)) >= 0)
|
||||
{
|
||||
/* print pkt timestamp and pkt len */
|
||||
printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len);
|
||||
|
||||
/* Print the packet */
|
||||
for (i=1; (i < header->caplen + 1 ) ; i++)
|
||||
{
|
||||
printf("%.2x ", pkt_data[i-1]);
|
||||
if ( (i % LINE_LEN) == 0) printf("\n");
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
|
||||
if (res == -1)
|
||||
{
|
||||
printf("Error reading the packets: %s\n", pcap_geterr(fp));
|
||||
}
|
||||
|
||||
pcap_close(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="readfile_ex.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,17 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Nate Lawson <nate@rootlabs.com>
|
||||
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = savedump.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o savedump.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} savedump.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
@ -0,0 +1,140 @@
|
||||
#ifdef _MSC_VER
|
||||
/*
|
||||
* we do not want the warnings about the old deprecated and unsecure CRT functions
|
||||
* since these examples can be compiled under *nix as well
|
||||
*/
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* prototype of the packet handler */
|
||||
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
int inum;
|
||||
int i=0;
|
||||
pcap_t *adhandle;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
pcap_dumper_t *dumpfile;
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Check command line */
|
||||
if(argc != 2)
|
||||
{
|
||||
printf("usage: %s filename", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Retrieve the device list on the local machine */
|
||||
if (pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Print the list */
|
||||
for(d=alldevs; d; d=d->next)
|
||||
{
|
||||
printf("%d. %s", ++i, d->name);
|
||||
if (d->description)
|
||||
printf(" (%s)\n", d->description);
|
||||
else
|
||||
printf(" (No description available)\n");
|
||||
}
|
||||
|
||||
if(i==0)
|
||||
{
|
||||
printf("\nNo interfaces found! Make sure Npcap is installed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Enter the interface number (1-%d):",i);
|
||||
scanf("%d", &inum);
|
||||
|
||||
if(inum < 1 || inum > i)
|
||||
{
|
||||
printf("\nInterface number out of range.\n");
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Jump to the selected adapter */
|
||||
for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++);
|
||||
|
||||
|
||||
/* Open the adapter */
|
||||
if ((adhandle= pcap_open_live(d->name, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||
1, // promiscuous mode (nonzero means promiscuous)
|
||||
1000, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->name);
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open the dump file */
|
||||
dumpfile = pcap_dump_open(adhandle, argv[1]);
|
||||
|
||||
if(dumpfile==NULL)
|
||||
{
|
||||
fprintf(stderr,"\nError opening output file\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("\nlistening on %s... Press Ctrl+C to stop...\n", d->description);
|
||||
|
||||
/* At this point, we no longer need the device list. Free it */
|
||||
pcap_freealldevs(alldevs);
|
||||
|
||||
/* start the capture */
|
||||
pcap_loop(adhandle, 0, packet_handler, (unsigned char *)dumpfile);
|
||||
|
||||
pcap_close(adhandle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback function invoked by libpcap for every incoming packet */
|
||||
void packet_handler(u_char *dumpfile, const struct pcap_pkthdr *header, const u_char *pkt_data)
|
||||
{
|
||||
/* save the packet on the dump file */
|
||||
pcap_dump(dumpfile, header, pkt_data);
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{1B8791CB-DD15-46BF-B0A2-879892085538}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="savedump.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,17 @@
|
||||
# Makefile for cygwin gcc
|
||||
# Nate Lawson <nate@rootlabs.com>
|
||||
|
||||
PCAP_PATH = ../../lib
|
||||
CFLAGS = -g -O -mno-cygwin -I ../../include
|
||||
|
||||
OBJS = sendpack.o
|
||||
LIBS = -L ${PCAP_PATH} -lwpcap
|
||||
|
||||
all: ${OBJS}
|
||||
${CC} ${CFLAGS} -o sendpack.exe ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS} sendpack.exe
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -c -o $*.o $<
|
||||
@ -0,0 +1,97 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
BOOL LoadNpcapDlls()
|
||||
{
|
||||
_TCHAR npcap_dir[512];
|
||||
UINT len;
|
||||
len = GetSystemDirectory(npcap_dir, 480);
|
||||
if (!len) {
|
||||
fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pcap_t *fp;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
u_char packet[100];
|
||||
int i;
|
||||
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check the validity of the command line */
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("usage: %s interface", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Open the adapter */
|
||||
if ((fp = pcap_open_live(argv[1], // name of the device
|
||||
65536, // portion of the packet to capture. It doesn't matter in this case
|
||||
1, // promiscuous mode (nonzero means promiscuous)
|
||||
1000, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", argv[1]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */
|
||||
packet[0]=1;
|
||||
packet[1]=1;
|
||||
packet[2]=1;
|
||||
packet[3]=1;
|
||||
packet[4]=1;
|
||||
packet[5]=1;
|
||||
|
||||
/* set mac source to 2:2:2:2:2:2 */
|
||||
packet[6]=2;
|
||||
packet[7]=2;
|
||||
packet[8]=2;
|
||||
packet[9]=2;
|
||||
packet[10]=2;
|
||||
packet[11]=2;
|
||||
|
||||
/* Fill the rest of the packet */
|
||||
for(i=12;i<100;i++)
|
||||
{
|
||||
packet[i]= (u_char)i;
|
||||
}
|
||||
|
||||
/* Send down the packet */
|
||||
if (pcap_sendpacket(fp, // Adapter
|
||||
packet, // buffer with the packet
|
||||
100 // size
|
||||
) != 0)
|
||||
{
|
||||
fprintf(stderr,"\nError sending the packet: %s\n", pcap_geterr(fp));
|
||||
return 3;
|
||||
}
|
||||
|
||||
pcap_close(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{1C376689-5F61-48E7-AE83-0DED9EE9E458}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>wpcap.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<DelayLoadDLLs>wpcap.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>C:\npcap-sdk-0.1\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="sendpack.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user