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>
|
||||
198
network/arpicmplab/start/lib/npcap/Examples-remote/MakeAll.sln
Normal file
198
network/arpicmplab/start/lib/npcap/Examples-remote/MakeAll.sln
Normal file
@ -0,0 +1,198 @@
|
||||
|
||||
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}") = "iflist", "iflist\iflist.vcxproj", "{0B27B213-4BF3-4611-B412-A2D09CDE8632}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sendcap", "sendcap\sendcap.vcxproj", "{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GetMacAddress", "PacketDriver\GetMacAddress\GetMacAddress.vcxproj", "{1ED069D6-3B12-4175-A97D-7FFEBEA26628}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestPacketCapture", "PacketDriver\TestPacketCapture\TestPacketCapture.vcxproj", "{79942922-E02C-486D-9EE3-A13C0876C4C2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestPacketSend", "PacketDriver\TestPacketSend\TestPacketSend.vcxproj", "{1E3BED58-2F2C-463A-B9FD-9A55235C6840}"
|
||||
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}") = "pcap_fopen", "pcap_fopen\pcap_fopen.vcxproj", "{DD317CB5-6337-498F-A560-553B5558E133}"
|
||||
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}") = "smp_1", "smp_1\smp_1.vcxproj", "{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tcptop", "tcptop\tcptop.vcxproj", "{B671D5DF-3A80-4A21-BC01-79E3FB73D372}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UDPdump", "UDPdump\UDPdump.vcxproj", "{42E5F1D6-6E83-4C13-83CC-C6CD83478C58}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UserBridge", "UserLevelBridge\UserBridge.vcxproj", "{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic_dump", "misc\basic_dump.vcxproj", "{66297062-96A0-4F0E-B147-3C8384031232}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic_dump_ex", "misc\basic_dump_ex.vcxproj", "{92849630-6B09-409C-A7AD-E91E682558B1}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "readfile", "misc\readfile.vcxproj", "{161E7606-F4CD-4A04-AB6B-5837F7818EE1}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "readfile_ex", "misc\readfile_ex.vcxproj", "{3071DFB6-68F8-41EF-A56C-0C7A71B6967C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "savedump", "misc\savedump.vcxproj", "{1B8791CB-DD15-46BF-B0A2-879892085538}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sendpack", "misc\sendpack.vcxproj", "{1C376689-5F61-48E7-AE83-0DED9EE9E458}"
|
||||
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
|
||||
{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
|
||||
{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}.Debug|x64.Build.0 = Debug|x64
|
||||
{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}.Release|x64.ActiveCfg = Release|x64
|
||||
{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}.Release|x64.Build.0 = Release|x64
|
||||
{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}.Release|x86.Build.0 = Release|Win32
|
||||
{1ED069D6-3B12-4175-A97D-7FFEBEA26628}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1ED069D6-3B12-4175-A97D-7FFEBEA26628}.Debug|x64.Build.0 = Debug|x64
|
||||
{1ED069D6-3B12-4175-A97D-7FFEBEA26628}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{1ED069D6-3B12-4175-A97D-7FFEBEA26628}.Debug|x86.Build.0 = Debug|Win32
|
||||
{1ED069D6-3B12-4175-A97D-7FFEBEA26628}.Release|x64.ActiveCfg = Release|x64
|
||||
{1ED069D6-3B12-4175-A97D-7FFEBEA26628}.Release|x64.Build.0 = Release|x64
|
||||
{1ED069D6-3B12-4175-A97D-7FFEBEA26628}.Release|x86.ActiveCfg = Release|Win32
|
||||
{1ED069D6-3B12-4175-A97D-7FFEBEA26628}.Release|x86.Build.0 = Release|Win32
|
||||
{79942922-E02C-486D-9EE3-A13C0876C4C2}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{79942922-E02C-486D-9EE3-A13C0876C4C2}.Debug|x64.Build.0 = Debug|x64
|
||||
{79942922-E02C-486D-9EE3-A13C0876C4C2}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{79942922-E02C-486D-9EE3-A13C0876C4C2}.Debug|x86.Build.0 = Debug|Win32
|
||||
{79942922-E02C-486D-9EE3-A13C0876C4C2}.Release|x64.ActiveCfg = Release|x64
|
||||
{79942922-E02C-486D-9EE3-A13C0876C4C2}.Release|x64.Build.0 = Release|x64
|
||||
{79942922-E02C-486D-9EE3-A13C0876C4C2}.Release|x86.ActiveCfg = Release|Win32
|
||||
{79942922-E02C-486D-9EE3-A13C0876C4C2}.Release|x86.Build.0 = Release|Win32
|
||||
{1E3BED58-2F2C-463A-B9FD-9A55235C6840}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1E3BED58-2F2C-463A-B9FD-9A55235C6840}.Debug|x64.Build.0 = Debug|x64
|
||||
{1E3BED58-2F2C-463A-B9FD-9A55235C6840}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{1E3BED58-2F2C-463A-B9FD-9A55235C6840}.Debug|x86.Build.0 = Debug|Win32
|
||||
{1E3BED58-2F2C-463A-B9FD-9A55235C6840}.Release|x64.ActiveCfg = Release|x64
|
||||
{1E3BED58-2F2C-463A-B9FD-9A55235C6840}.Release|x64.Build.0 = Release|x64
|
||||
{1E3BED58-2F2C-463A-B9FD-9A55235C6840}.Release|x86.ActiveCfg = Release|Win32
|
||||
{1E3BED58-2F2C-463A-B9FD-9A55235C6840}.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
|
||||
{DD317CB5-6337-498F-A560-553B5558E133}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DD317CB5-6337-498F-A560-553B5558E133}.Debug|x64.Build.0 = Debug|x64
|
||||
{DD317CB5-6337-498F-A560-553B5558E133}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{DD317CB5-6337-498F-A560-553B5558E133}.Debug|x86.Build.0 = Debug|Win32
|
||||
{DD317CB5-6337-498F-A560-553B5558E133}.Release|x64.ActiveCfg = Release|x64
|
||||
{DD317CB5-6337-498F-A560-553B5558E133}.Release|x64.Build.0 = Release|x64
|
||||
{DD317CB5-6337-498F-A560-553B5558E133}.Release|x86.ActiveCfg = Release|Win32
|
||||
{DD317CB5-6337-498F-A560-553B5558E133}.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
|
||||
{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}.Debug|x64.Build.0 = Debug|x64
|
||||
{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}.Debug|x86.Build.0 = Debug|Win32
|
||||
{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}.Release|x64.ActiveCfg = Release|x64
|
||||
{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}.Release|x64.Build.0 = Release|x64
|
||||
{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}.Release|x86.ActiveCfg = Release|Win32
|
||||
{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}.Release|x86.Build.0 = Release|Win32
|
||||
{B671D5DF-3A80-4A21-BC01-79E3FB73D372}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B671D5DF-3A80-4A21-BC01-79E3FB73D372}.Debug|x64.Build.0 = Debug|x64
|
||||
{B671D5DF-3A80-4A21-BC01-79E3FB73D372}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B671D5DF-3A80-4A21-BC01-79E3FB73D372}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B671D5DF-3A80-4A21-BC01-79E3FB73D372}.Release|x64.ActiveCfg = Release|x64
|
||||
{B671D5DF-3A80-4A21-BC01-79E3FB73D372}.Release|x64.Build.0 = Release|x64
|
||||
{B671D5DF-3A80-4A21-BC01-79E3FB73D372}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B671D5DF-3A80-4A21-BC01-79E3FB73D372}.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
|
||||
{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}.Debug|x64.Build.0 = Debug|x64
|
||||
{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}.Debug|x86.Build.0 = Debug|Win32
|
||||
{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}.Release|x64.ActiveCfg = Release|x64
|
||||
{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}.Release|x64.Build.0 = Release|x64
|
||||
{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}.Release|x86.ActiveCfg = Release|Win32
|
||||
{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}.Release|x86.Build.0 = Release|Win32
|
||||
{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
|
||||
{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
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <Packet32.h>
|
||||
#include <ntddndis.h>
|
||||
|
||||
#define Max_Num_Adapter 10
|
||||
char AdapterList[Max_Num_Adapter][1024];
|
||||
|
||||
#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, TEXT("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
LPADAPTER lpAdapter = 0;
|
||||
int i;
|
||||
DWORD dwErrorCode;
|
||||
char AdapterName[8192];
|
||||
char *temp,*temp1;
|
||||
int AdapterNum=0,Open;
|
||||
ULONG AdapterLength;
|
||||
PPACKET_OID_DATA OidData;
|
||||
BOOLEAN Status;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Obtain the name of the adapters installed on this machine
|
||||
//
|
||||
|
||||
printf("Packet.dll test application. Library version:%s\n", PacketGetVersion());
|
||||
|
||||
printf("Adapters installed:\n");
|
||||
i=0;
|
||||
|
||||
AdapterLength = sizeof(AdapterName);
|
||||
|
||||
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE){
|
||||
printf("Unable to retrieve the list of the adapters!\n");
|
||||
return -1;
|
||||
}
|
||||
temp=AdapterName;
|
||||
temp1=AdapterName;
|
||||
|
||||
while ((*temp!='\0')||(*(temp-1)!='\0'))
|
||||
{
|
||||
if (*temp=='\0')
|
||||
{
|
||||
memcpy(AdapterList[i],temp1,temp-temp1);
|
||||
temp1=temp+1;
|
||||
i++;
|
||||
}
|
||||
temp++;
|
||||
}
|
||||
|
||||
AdapterNum=i;
|
||||
for (i=0;i<AdapterNum;i++)
|
||||
printf("\n%d- %s\n",i+1,AdapterList[i]);
|
||||
printf("\n");
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
printf("Select the number of the adapter to open : ");
|
||||
scanf_s("%d",&Open);
|
||||
if (Open>AdapterNum) printf("\nThe number must be smaller than %d",AdapterNum);
|
||||
} while (Open>AdapterNum);
|
||||
|
||||
|
||||
//
|
||||
// Open the selected adapter
|
||||
//
|
||||
|
||||
lpAdapter = PacketOpenAdapter(AdapterList[Open-1]);
|
||||
|
||||
if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE))
|
||||
{
|
||||
dwErrorCode=GetLastError();
|
||||
printf("Unable to open the adapter, Error Code : %lx\n",dwErrorCode);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate a buffer to get the MAC adress
|
||||
//
|
||||
|
||||
OidData = malloc(6 + sizeof(PACKET_OID_DATA));
|
||||
if (OidData == NULL)
|
||||
{
|
||||
printf("error allocating memory!\n");
|
||||
PacketCloseAdapter(lpAdapter);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the adapter MAC querying the NIC driver
|
||||
//
|
||||
|
||||
OidData->Oid = OID_802_3_CURRENT_ADDRESS;
|
||||
|
||||
OidData->Length = 6;
|
||||
ZeroMemory(OidData->Data, 6);
|
||||
|
||||
Status = PacketRequest(lpAdapter, FALSE, OidData);
|
||||
if(Status)
|
||||
{
|
||||
printf("The MAC address of the adapter is %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
|
||||
(OidData->Data)[0],
|
||||
(OidData->Data)[1],
|
||||
(OidData->Data)[2],
|
||||
(OidData->Data)[3],
|
||||
(OidData->Data)[4],
|
||||
(OidData->Data)[5]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error retrieving the MAC address of the adapter!\n");
|
||||
}
|
||||
|
||||
free(OidData);
|
||||
PacketCloseAdapter(lpAdapter);
|
||||
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>{1ED069D6-3B12-4175-A97D-7FFEBEA26628}</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>Packet.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>Packet.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>Packet.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>Packet.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>Packet.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>Packet.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>Packet.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>Packet.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="GetMacAddress.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,268 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <conio.h>
|
||||
|
||||
|
||||
#include <Packet32.h>
|
||||
#include <ntddndis.h>
|
||||
|
||||
#define Max_Num_Adapter 10
|
||||
|
||||
#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, TEXT("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
// Prototypes
|
||||
|
||||
void PrintPackets(LPPACKET lpPacket);
|
||||
|
||||
char AdapterList[Max_Num_Adapter][1024];
|
||||
|
||||
int main()
|
||||
{
|
||||
//define a pointer to an ADAPTER structure
|
||||
|
||||
LPADAPTER lpAdapter = 0;
|
||||
|
||||
//define a pointer to a PACKET structure
|
||||
|
||||
LPPACKET lpPacket;
|
||||
|
||||
int i;
|
||||
DWORD dwErrorCode;
|
||||
|
||||
//ascii strings
|
||||
char AdapterName[8192]; // string that contains a list of the network adapters
|
||||
char *temp,*temp1;
|
||||
|
||||
|
||||
int AdapterNum=0,Open;
|
||||
ULONG AdapterLength;
|
||||
|
||||
char buffer[256000]; // buffer to hold the data coming from the driver
|
||||
|
||||
struct bpf_stat stat;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Obtain the name of the adapters installed on this machine
|
||||
//
|
||||
printf("Packet.dll test application. Library version:%s\n", PacketGetVersion());
|
||||
|
||||
printf("Adapters installed:\n");
|
||||
i=0;
|
||||
|
||||
AdapterLength = sizeof(AdapterName);
|
||||
|
||||
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE){
|
||||
printf("Unable to retrieve the list of the adapters!\n");
|
||||
return -1;
|
||||
}
|
||||
temp=AdapterName;
|
||||
temp1=AdapterName;
|
||||
|
||||
while ((*temp!='\0')||(*(temp-1)!='\0'))
|
||||
{
|
||||
if (*temp=='\0')
|
||||
{
|
||||
memcpy(AdapterList[i],temp1,temp-temp1);
|
||||
temp1=temp+1;
|
||||
i++;
|
||||
}
|
||||
temp++;
|
||||
}
|
||||
|
||||
AdapterNum=i;
|
||||
for (i=0;i<AdapterNum;i++)
|
||||
printf("\n%d- %s\n",i+1,AdapterList[i]);
|
||||
printf("\n");
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
printf("Select the number of the adapter to open : ");
|
||||
scanf_s("%d",&Open);
|
||||
if (Open>AdapterNum) printf("\nThe number must be smaller than %d",AdapterNum);
|
||||
} while (Open>AdapterNum);
|
||||
|
||||
|
||||
|
||||
|
||||
lpAdapter = PacketOpenAdapter(AdapterList[Open-1]);
|
||||
|
||||
if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE))
|
||||
{
|
||||
dwErrorCode=GetLastError();
|
||||
printf("Unable to open the adapter, Error Code : %lx\n",dwErrorCode);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set the network adapter in promiscuous mode
|
||||
|
||||
if(PacketSetHwFilter(lpAdapter,NDIS_PACKET_TYPE_PROMISCUOUS)==FALSE){
|
||||
printf("Warning: unable to set promiscuous mode!\n");
|
||||
}
|
||||
|
||||
// set a 512K buffer in the driver
|
||||
if(PacketSetBuff(lpAdapter,512000)==FALSE){
|
||||
printf("Unable to set the kernel buffer!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set a 1 second read timeout
|
||||
if(PacketSetReadTimeout(lpAdapter,1000)==FALSE){
|
||||
printf("Warning: unable to set the read tiemout!\n");
|
||||
}
|
||||
|
||||
//allocate and initialize a packet structure that will be used to
|
||||
//receive the packets.
|
||||
if((lpPacket = PacketAllocatePacket())==NULL){
|
||||
printf("\nError: failed to allocate the LPPACKET structure.");
|
||||
return (-1);
|
||||
}
|
||||
PacketInitPacket(lpPacket,(char*)buffer,256000);
|
||||
|
||||
//main capture loop
|
||||
while(!_kbhit())
|
||||
{
|
||||
// capture the packets
|
||||
if(PacketReceivePacket(lpAdapter,lpPacket,TRUE)==FALSE){
|
||||
printf("Error: PacketReceivePacket failed");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
PrintPackets(lpPacket);
|
||||
}
|
||||
|
||||
|
||||
//print the capture statistics
|
||||
if(PacketGetStats(lpAdapter,&stat)==FALSE){
|
||||
printf("Warning: unable to get stats from the kernel!\n");
|
||||
}
|
||||
else
|
||||
printf("\n\n%d packets received.\n%d Packets lost",stat.bs_recv,stat.bs_drop);
|
||||
|
||||
PacketFreePacket(lpPacket);
|
||||
|
||||
// close the adapter and exit
|
||||
|
||||
PacketCloseAdapter(lpAdapter);
|
||||
return (0);
|
||||
}
|
||||
|
||||
// this function prints the content of a block of packets received from the driver
|
||||
|
||||
void PrintPackets(LPPACKET lpPacket)
|
||||
{
|
||||
|
||||
ULONG i, j, ulLines, ulen, ulBytesReceived;
|
||||
char *pChar, *pLine, *base;
|
||||
char *buf;
|
||||
u_int off=0;
|
||||
u_int tlen,tlen1;
|
||||
struct bpf_hdr *hdr;
|
||||
|
||||
ulBytesReceived = lpPacket->ulBytesReceived;
|
||||
|
||||
|
||||
buf = lpPacket->Buffer;
|
||||
|
||||
off=0;
|
||||
|
||||
while(off<ulBytesReceived){
|
||||
if(_kbhit())return;
|
||||
hdr=(struct bpf_hdr *)(buf+off);
|
||||
tlen1=hdr->bh_datalen;
|
||||
tlen=hdr->bh_caplen;
|
||||
printf("Packet length, captured portion: %ld, %ld\n", tlen1, tlen);
|
||||
off+=hdr->bh_hdrlen;
|
||||
|
||||
ulLines = (tlen + 15) / 16;
|
||||
|
||||
pChar =(char*)(buf+off);
|
||||
base=pChar;
|
||||
off=Packet_WORDALIGN(off+tlen);
|
||||
|
||||
for ( i=0; i<ulLines; i++ )
|
||||
{
|
||||
|
||||
pLine =pChar;
|
||||
|
||||
printf( "%p : ", (void *)(pChar - base));
|
||||
|
||||
ulen=tlen;
|
||||
ulen = ( ulen > 16 ) ? 16 : ulen;
|
||||
tlen -= ulen;
|
||||
|
||||
for ( j=0; j<ulen; j++ )
|
||||
printf( "%02x ", *(BYTE *)pChar++ );
|
||||
|
||||
if ( ulen < 16 )
|
||||
printf( "%*s", (16-ulen)*3, " " );
|
||||
|
||||
pChar = pLine;
|
||||
|
||||
for ( j=0; j<ulen; j++, pChar++ )
|
||||
printf( "%c", isprint( (unsigned char)*pChar ) ? *pChar : '.' );
|
||||
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
printf( "\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>{79942922-E02C-486D-9EE3-A13C0876C4C2}</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>Packet.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>Packet.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>Packet.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>Packet.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>Packet.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>Packet.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>Packet.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>Packet.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="TestPacketCapture.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <Packet32.h>
|
||||
|
||||
|
||||
#define Max_Num_Adapter 10
|
||||
|
||||
#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, TEXT("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Prototypes
|
||||
|
||||
void PrintPackets(LPPACKET lpPacket);
|
||||
|
||||
char AdapterList[Max_Num_Adapter][8192];
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char packetbuff[5000];
|
||||
|
||||
// define a pointer to a ADAPTER structure
|
||||
|
||||
LPADAPTER lpAdapter = 0;
|
||||
|
||||
// define a pointer to a PACKET structure
|
||||
|
||||
LPPACKET lpPacket;
|
||||
|
||||
int i,npacks,Snaplen;
|
||||
DWORD dwErrorCode;
|
||||
|
||||
//ascii strings
|
||||
char AdapterName[8192]; // string that contains a list of the network adapters
|
||||
char *temp,*temp1;
|
||||
|
||||
int AdapterNum=0,Open;
|
||||
ULONG AdapterLength;
|
||||
|
||||
float cpu_time;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("Traffic Generator v 0.9999\nCopyright 1999 Loris Degioanni (loris@netgroup-serv.polito.it)");
|
||||
printf("\nSends a set of packets to the network using packet.dll API.\n");
|
||||
|
||||
if (argc == 1){
|
||||
printf("\n\n Usage: TestpacketSend [-i adapter] -n npacks -s size");
|
||||
printf("\n size is between 60 and 1514\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
AdapterName[0]=0;
|
||||
|
||||
//get the command line parameters
|
||||
for(i=1;i<argc;i+=2){
|
||||
|
||||
switch (argv[i] [1])
|
||||
{
|
||||
|
||||
case 'i':
|
||||
sscanf_s(argv[i+1],"%s",AdapterName, (unsigned)_countof(AdapterName));
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
sscanf_s(argv[i+1],"%d",&npacks);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
sscanf_s(argv[i+1],"%d",&Snaplen);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(AdapterName[0]==0){
|
||||
|
||||
//
|
||||
// Obtain the name of the adapters installed on this machine
|
||||
//
|
||||
printf("Adapters installed:\n");
|
||||
i=0;
|
||||
|
||||
AdapterLength = sizeof(AdapterName);
|
||||
|
||||
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE){
|
||||
printf("Unable to retrieve the list of the adapters!\n");
|
||||
return -1;
|
||||
}
|
||||
temp=AdapterName;
|
||||
temp1=AdapterName;
|
||||
|
||||
while ((*temp!='\0')||(*(temp-1)!='\0'))
|
||||
{
|
||||
if (*temp=='\0')
|
||||
{
|
||||
memcpy(AdapterList[i],temp1,temp-temp1);
|
||||
temp1=temp+1;
|
||||
i++;
|
||||
}
|
||||
temp++;
|
||||
}
|
||||
|
||||
AdapterNum=i;
|
||||
for (i=0;i<AdapterNum;i++)
|
||||
printf("\n%d- %s\n",i+1,AdapterList[i]);
|
||||
printf("\n");
|
||||
|
||||
do
|
||||
{
|
||||
printf("Select the number of the adapter to open : ");scanf_s("%d",&Open);
|
||||
if (Open>AdapterNum) printf("\nThe number must be smaller than %d",AdapterNum);
|
||||
} while (Open>AdapterNum);
|
||||
|
||||
|
||||
|
||||
|
||||
lpAdapter = PacketOpenAdapter(AdapterList[Open-1]);
|
||||
|
||||
if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE))
|
||||
{
|
||||
dwErrorCode=GetLastError();
|
||||
printf("Unable to open the driver, Error Code : %lx\n",dwErrorCode);
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
lpAdapter = PacketOpenAdapter(AdapterName);
|
||||
|
||||
if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE))
|
||||
{
|
||||
dwErrorCode=GetLastError();
|
||||
printf("Unable to open the driver, Error Code : %lx\n",dwErrorCode);
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if((lpPacket = PacketAllocatePacket())==NULL){
|
||||
printf("\nError:failed to allocate the LPPACKET structure.");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
packetbuff[0]=1;
|
||||
packetbuff[1]=1;
|
||||
packetbuff[2]=1;
|
||||
packetbuff[3]=1;
|
||||
packetbuff[4]=1;
|
||||
packetbuff[5]=1;
|
||||
|
||||
packetbuff[6]=2;
|
||||
packetbuff[7]=2;
|
||||
packetbuff[8]=2;
|
||||
packetbuff[9]=2;
|
||||
packetbuff[10]=2;
|
||||
packetbuff[11]=2;
|
||||
|
||||
for(i=12;i<1514;i++){
|
||||
packetbuff[i]= (char)i;
|
||||
}
|
||||
|
||||
PacketInitPacket(lpPacket,packetbuff,Snaplen);
|
||||
// capture the packet
|
||||
|
||||
|
||||
if(PacketSetNumWrites(lpAdapter,npacks)==FALSE){
|
||||
printf("warning: Unable to send more than one packet in a single write!\n");
|
||||
}
|
||||
|
||||
printf("\n\nGenerating %d packets...",npacks);
|
||||
|
||||
cpu_time = (float)clock ();
|
||||
|
||||
if(PacketSendPacket(lpAdapter,lpPacket,TRUE)==FALSE){
|
||||
printf("Error sending the packets!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
cpu_time = (clock() - cpu_time)/CLK_TCK;
|
||||
|
||||
printf ("\n\nElapsed time: %5.3f\n", cpu_time);
|
||||
printf ("\nTotal packets generated = %d", npacks);
|
||||
printf ("\nTotal bytes generated = %d", (Snaplen+24)*npacks);
|
||||
printf ("\nTotal bits generated = %d", (Snaplen+24)*npacks*8);
|
||||
printf ("\nAverage packets per second = %d", (int)((double)npacks/cpu_time));
|
||||
printf ("\nAverage bytes per second = %d", (int)((double)((Snaplen+24)*npacks)/cpu_time));
|
||||
printf ("\nAverage bits per second = %d", (int)((double)((Snaplen+24)*npacks*8)/cpu_time));
|
||||
printf ("\n");
|
||||
|
||||
PacketFreePacket(lpPacket);
|
||||
|
||||
// close the adapter and exit
|
||||
|
||||
PacketCloseAdapter(lpAdapter);
|
||||
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>{1E3BED58-2F2C-463A-B9FD-9A55235C6840}</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>Packet.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>Packet.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>Packet.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>Packet.dll</DelayLoadDLLs>
|
||||
<AdditionalLibraryDirectories>C:\npcap-sdk-0.1\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>Packet.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>Packet.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>Packet.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>Packet.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="TestPacketSend.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,2 @@
|
||||
These files use the packet.dll API instead of wpcap.dll.
|
||||
The use of packet.dll API is strongly discouraged.
|
||||
@ -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,256 @@
|
||||
/*
|
||||
* 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 <pcap.h>
|
||||
#include <Winsock2.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Retrieve the device list */
|
||||
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &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_s("%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(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.
|
||||
PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode
|
||||
1000, // read timeout
|
||||
NULL, // remote authentication
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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 variable
|
||||
*/
|
||||
(VOID)(param);
|
||||
|
||||
/* convert the timestamp to readable format */
|
||||
local_tv_sec = header->ts.tv_sec;
|
||||
localtime_s(<ime, &local_tv_sec);
|
||||
strftime( timestr, sizeof timestr, "%H:%M:%S", <ime);
|
||||
|
||||
/* 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,492 @@
|
||||
/*
|
||||
* Copyright (c) 2005 - 2006
|
||||
* CACE Technologies, Davis, CA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of CACE Technologies nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This simple program implements a user-level bridge.
|
||||
* It opens two adapters specified by the user and starts two threads.
|
||||
* The first thread receives packets from adapter 1 and sends them down to
|
||||
* adapter 2. The second thread does the same, but in the opposite
|
||||
* direction.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <pcap.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
/* Storage data structure used to pass parameters to the threads */
|
||||
typedef struct _in_out_adapters
|
||||
{
|
||||
unsigned int state; /* Some simple state information */
|
||||
pcap_t *input_adapter;
|
||||
pcap_t *output_adapter;
|
||||
}in_out_adapters;
|
||||
|
||||
/* Prototypes */
|
||||
DWORD WINAPI CaptureAndForwardThread(LPVOID lpParameter);
|
||||
void ctrlc_handler(int sig);
|
||||
|
||||
/* This prevents the two threads to mess-up when they do printfs */
|
||||
CRITICAL_SECTION print_cs;
|
||||
|
||||
/* Thread handlers. Global because we wait on the threads from the CTRL+C handler */
|
||||
HANDLE threads[2];
|
||||
|
||||
/* This global variable tells the forwarder threads they must terminate */
|
||||
volatile int kill_forwaders = 0;
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
int main()
|
||||
{
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
int inum1, inum2;
|
||||
int i=0;
|
||||
pcap_t *adhandle1, *adhandle2;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
u_int netmask1, netmask2;
|
||||
char packet_filter[256];
|
||||
struct bpf_program fcode;
|
||||
in_out_adapters couple0, couple1;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the device list
|
||||
*/
|
||||
|
||||
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &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. ", ++i);
|
||||
if (d->description)
|
||||
printf("%s\n", d->description);
|
||||
else
|
||||
printf("<unknown adapter>\n");
|
||||
}
|
||||
|
||||
if(i==0)
|
||||
{
|
||||
printf("\nNo interfaces found! Make sure Npcap is installed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get input from the user
|
||||
*/
|
||||
|
||||
/* Get the filter*/
|
||||
printf("\nSpecify filter (hit return for no filter):");
|
||||
|
||||
fgets(packet_filter, sizeof(packet_filter), stdin);
|
||||
|
||||
/* Get the first interface number*/
|
||||
printf("\nEnter the number of the first interface to use (1-%d):",i);
|
||||
scanf_s("%d", &inum1);
|
||||
|
||||
if(inum1 < 1 || inum1 > i)
|
||||
{
|
||||
printf("\nInterface number out of range.\n");
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get the second interface number*/
|
||||
printf("Enter the number of the first interface to use (1-%d):",i);
|
||||
scanf_s("%d", &inum2);
|
||||
|
||||
if(inum2 < 1 || inum2 > i)
|
||||
{
|
||||
printf("\nInterface number out of range.\n");
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(inum1 == inum2 )
|
||||
{
|
||||
printf("\nCannot bridge packets on the same interface.\n");
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Open the specified couple of adapters
|
||||
*/
|
||||
|
||||
/* Jump to the first selected adapter */
|
||||
for(d = alldevs, i = 0; i< inum1 - 1 ;d = d->next, i++);
|
||||
|
||||
/*
|
||||
* Open the first adapter.
|
||||
* *NOTICE* the flags we are using, they are important for the behavior of the prgram:
|
||||
* - PCAP_OPENFLAG_PROMISCUOUS: tells the adapter to go in promiscuous mode.
|
||||
* This means that we are capturing all the traffic, not only the one to or from
|
||||
* this machine.
|
||||
* - PCAP_OPENFLAG_NOCAPTURE_LOCAL: prevents the adapter from capturing again the packets
|
||||
* transmitted by itself. This avoids annoying loops.
|
||||
* - PCAP_OPENFLAG_MAX_RESPONSIVENESS: configures the adapter to provide minimum latency,
|
||||
* at the cost of higher CPU usage.
|
||||
*/
|
||||
if((adhandle1 = pcap_open(d->name, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on every link layer.
|
||||
PCAP_OPENFLAG_PROMISCUOUS | // flags. We specify that we don't want to capture loopback packets, and that the driver should deliver us the packets as fast as possible
|
||||
PCAP_OPENFLAG_NOCAPTURE_LOCAL |
|
||||
PCAP_OPENFLAG_MAX_RESPONSIVENESS,
|
||||
500, // read timeout
|
||||
NULL, // remote authentication
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->description);
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(d->addresses != NULL)
|
||||
{
|
||||
/* Retrieve the mask of the first address of the interface */
|
||||
netmask1 = ((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 */
|
||||
netmask1 = 0xffffff;
|
||||
}
|
||||
|
||||
/* Jump to the second selected adapter */
|
||||
for(d = alldevs, i = 0; i< inum2 - 1 ;d = d->next, i++);
|
||||
|
||||
/* Open the second adapter */
|
||||
if((adhandle2 = pcap_open(d->name, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on every link layer.
|
||||
PCAP_OPENFLAG_PROMISCUOUS | // flags. We specify that we don't want to capture loopback packets, and that the driver should deliver us the packets as fast as possible
|
||||
PCAP_OPENFLAG_NOCAPTURE_LOCAL |
|
||||
PCAP_OPENFLAG_MAX_RESPONSIVENESS,
|
||||
500, // read timeout
|
||||
NULL, // remote authentication
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->description);
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(d->addresses != NULL)
|
||||
{
|
||||
/* Retrieve the mask of the first address of the interface */
|
||||
netmask2 = ((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 */
|
||||
netmask2 = 0xffffff;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Compile and set the filters
|
||||
*/
|
||||
|
||||
/* compile the filter for the first adapter */
|
||||
if (pcap_compile(adhandle1, &fcode, packet_filter, 1, netmask1) <0 )
|
||||
{
|
||||
fprintf(stderr,"\nUnable to compile the packet filter. Check the syntax.\n");
|
||||
|
||||
/* Close the adapters */
|
||||
pcap_close(adhandle1);
|
||||
pcap_close(adhandle2);
|
||||
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set the filter for the first adapter*/
|
||||
if (pcap_setfilter(adhandle1, &fcode)<0)
|
||||
{
|
||||
fprintf(stderr,"\nError setting the filter.\n");
|
||||
|
||||
/* Close the adapters */
|
||||
pcap_close(adhandle1);
|
||||
pcap_close(adhandle2);
|
||||
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* compile the filter for the second adapter */
|
||||
if (pcap_compile(adhandle2, &fcode, packet_filter, 1, netmask2) <0 )
|
||||
{
|
||||
fprintf(stderr,"\nUnable to compile the packet filter. Check the syntax.\n");
|
||||
|
||||
/* Close the adapters */
|
||||
pcap_close(adhandle1);
|
||||
pcap_close(adhandle2);
|
||||
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set the filter for the second adapter*/
|
||||
if (pcap_setfilter(adhandle2, &fcode)<0)
|
||||
{
|
||||
fprintf(stderr,"\nError setting the filter.\n");
|
||||
|
||||
/* Close the adapters */
|
||||
pcap_close(adhandle1);
|
||||
pcap_close(adhandle2);
|
||||
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* At this point, we don't need the device list any more. Free it */
|
||||
pcap_freealldevs(alldevs);
|
||||
|
||||
/*
|
||||
* Start the threads that will forward the packets
|
||||
*/
|
||||
|
||||
/* Initialize the critical section that will be used by the threads for console output */
|
||||
InitializeCriticalSection(&print_cs);
|
||||
|
||||
/* Init input parameters of the threads */
|
||||
couple0.state = 0;
|
||||
couple0.input_adapter = adhandle1;
|
||||
couple0.output_adapter = adhandle2;
|
||||
couple1.state = 1;
|
||||
couple1.input_adapter = adhandle2;
|
||||
couple1.output_adapter = adhandle1;
|
||||
|
||||
/* Start first thread */
|
||||
if((threads[0] = CreateThread(
|
||||
NULL,
|
||||
0,
|
||||
CaptureAndForwardThread,
|
||||
&couple0,
|
||||
0,
|
||||
NULL)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "error creating the first forward thread");
|
||||
|
||||
/* Close the adapters */
|
||||
pcap_close(adhandle1);
|
||||
pcap_close(adhandle2);
|
||||
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Start second thread */
|
||||
if((threads[1] = CreateThread(
|
||||
NULL,
|
||||
0,
|
||||
CaptureAndForwardThread,
|
||||
&couple1,
|
||||
0,
|
||||
NULL)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "error creating the second forward thread");
|
||||
|
||||
/* Kill the first thread. Not very gentle at all...*/
|
||||
TerminateThread(threads[0], 0);
|
||||
|
||||
/* Close the adapters */
|
||||
pcap_close(adhandle1);
|
||||
pcap_close(adhandle2);
|
||||
|
||||
/* Free the device list */
|
||||
pcap_freealldevs(alldevs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Install a CTRL+C handler that will do the cleanups on exit
|
||||
*/
|
||||
signal(SIGINT, ctrlc_handler);
|
||||
|
||||
/*
|
||||
* Done!
|
||||
* Wait for the Greek calends...
|
||||
*/
|
||||
printf("\nStart bridging the two adapters...\n", d->description);
|
||||
Sleep(INFINITE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* Forwarding thread.
|
||||
* Gets the packets from the input adapter and sends them to the output one.
|
||||
*******************************************************************/
|
||||
DWORD WINAPI CaptureAndForwardThread(LPVOID lpParameter)
|
||||
{
|
||||
struct pcap_pkthdr *header;
|
||||
const u_char *pkt_data;
|
||||
int res = 0;
|
||||
in_out_adapters* ad_couple = lpParameter;
|
||||
unsigned int n_fwd = 0;
|
||||
|
||||
/*
|
||||
* Loop receiving packets from the first input adapter
|
||||
*/
|
||||
|
||||
while((!kill_forwaders) && (res = pcap_next_ex(ad_couple->input_adapter, &header, &pkt_data)) >= 0)
|
||||
{
|
||||
if(res != 0) /* Note: res=0 means "read timeout elapsed"*/
|
||||
{
|
||||
/*
|
||||
* Print something, just to show when we have activity.
|
||||
* BEWARE: acquiring a critical section and printing strings with printf
|
||||
* is something inefficient that you seriously want to avoid in your packet loop!
|
||||
* However, since this is a *sample program*, we privilege visual output to efficiency.
|
||||
*/
|
||||
EnterCriticalSection(&print_cs);
|
||||
|
||||
if(ad_couple->state == 0)
|
||||
printf(">> Len: %u\n", header->caplen);
|
||||
else
|
||||
printf("<< Len: %u\n", header->caplen);
|
||||
|
||||
LeaveCriticalSection(&print_cs);
|
||||
|
||||
/*
|
||||
* Send the just received packet to the output adaper
|
||||
*/
|
||||
if(pcap_sendpacket(ad_couple->output_adapter, pkt_data, header->caplen) != 0)
|
||||
{
|
||||
EnterCriticalSection(&print_cs);
|
||||
|
||||
printf("Error sending a %u bytes packets on interface %u: %s\n",
|
||||
header->caplen,
|
||||
ad_couple->state,
|
||||
pcap_geterr(ad_couple->output_adapter));
|
||||
|
||||
LeaveCriticalSection(&print_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
n_fwd++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We're out of the main loop. Check the reason.
|
||||
*/
|
||||
if(res < 0)
|
||||
{
|
||||
EnterCriticalSection(&print_cs);
|
||||
|
||||
printf("Error capturing the packets: %s\n", pcap_geterr(ad_couple->input_adapter));
|
||||
fflush(stdout);
|
||||
|
||||
LeaveCriticalSection(&print_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
EnterCriticalSection(&print_cs);
|
||||
|
||||
printf("End of bridging on interface %u. Forwarded packets:%u\n",
|
||||
ad_couple->state,
|
||||
n_fwd);
|
||||
fflush(stdout);
|
||||
|
||||
LeaveCriticalSection(&print_cs);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* CTRL+C hanlder.
|
||||
* We order the threads to die and then we patiently wait for their
|
||||
* suicide.
|
||||
*******************************************************************/
|
||||
void ctrlc_handler(int sig)
|
||||
{
|
||||
/*
|
||||
* unused variable
|
||||
*/
|
||||
(VOID)(sig);
|
||||
|
||||
kill_forwaders = 1;
|
||||
|
||||
WaitForMultipleObjects(2,
|
||||
threads,
|
||||
TRUE, /* Wait for all the handles */
|
||||
5000); /* Timeout */
|
||||
|
||||
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>{BB73BFD4-454F-42C8-AFE6-FA890A8BD8FC}</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="UserBridge.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
|
||||
#include "pcap.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#else
|
||||
#include <winsock.h>
|
||||
#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, TEXT("\\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];
|
||||
char source[PCAP_ERRBUF_SIZE+1];
|
||||
#ifdef WIN32
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
printf("Enter the device you want to list:\n"
|
||||
"rpcap:// ==> lists interfaces in the local machine\n"
|
||||
"rpcap://hostname:port ==> lists interfaces in a remote machine\n"
|
||||
" (rpcapd daemon must be up and running\n"
|
||||
" and it must accept 'null' authentication)\n"
|
||||
"file://foldername ==> lists all pcap files in the give folder\n\n"
|
||||
"Enter your choice: ");
|
||||
|
||||
fgets(source, PCAP_ERRBUF_SIZE, stdin);
|
||||
source[PCAP_ERRBUF_SIZE] = '\0';
|
||||
|
||||
/* Retrieve the interfaces list */
|
||||
if (pcap_findalldevs_ex(source, NULL, &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);
|
||||
}
|
||||
|
||||
pcap_freealldevs(alldevs);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 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");
|
||||
if (a->addr)
|
||||
printf("\tAddress: %s\n", ip6tos(a->addr, ip6str, sizeof(ip6str)));
|
||||
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);
|
||||
_snprintf_s(output[which], sizeof(output[which]), sizeof(output[which]),"%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
|
||||
return output[which];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -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,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="iflist.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,108 @@
|
||||
#include <pcap.h>
|
||||
#include "misc.h"
|
||||
|
||||
/* 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];
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Retrieve the device list on the local machine */
|
||||
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &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_s("%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 */
|
||||
if ( (adhandle= pcap_open(d->name, // name of the device
|
||||
65536, // portion of the packet to capture
|
||||
// 65536 guarantees that the whole packet will be captured on all the link layers
|
||||
PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode
|
||||
1000, // read timeout
|
||||
NULL, // authentication on the remote machine
|
||||
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);
|
||||
|
||||
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 variables
|
||||
*/
|
||||
(VOID)(param);
|
||||
(VOID)(pkt_data);
|
||||
|
||||
/* convert the timestamp to readable format */
|
||||
local_tv_sec = header->ts.tv_sec;
|
||||
localtime_s(<ime, &local_tv_sec);
|
||||
strftime( timestr, sizeof timestr, "%H:%M:%S", <ime);
|
||||
|
||||
printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len);
|
||||
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
<?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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="basic_dump.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,99 @@
|
||||
#include "pcap.h"
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/* Retrieve the device list on the local machine */
|
||||
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &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_s("%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 */
|
||||
if ( (adhandle= pcap_open(d->name, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 guarantees that the whole packet will be captured on all the link layers
|
||||
PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode
|
||||
1000, // read timeout
|
||||
NULL, // authentication on the remote machine
|
||||
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;
|
||||
localtime_s(<ime, &local_tv_sec);
|
||||
strftime( timestr, sizeof timestr, "%H:%M:%S", <ime);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
<?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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="basic_dump_ex.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,19 @@
|
||||
#include <tchar.h>
|
||||
#include <stdio.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;
|
||||
}
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
#include <stdio.h>
|
||||
#include <pcap.h>
|
||||
#include "misc.h"
|
||||
|
||||
#define LINE_LEN 16
|
||||
|
||||
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];
|
||||
char source[PCAP_BUF_SIZE];
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(argc != 2){
|
||||
|
||||
printf("usage: %s filename", argv[0]);
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
/* Create the source string according to the new WinPcap syntax */
|
||||
if ( pcap_createsrcstr( source, // variable that will keep the source string
|
||||
PCAP_SRC_FILE, // we want to open a file
|
||||
NULL, // remote host
|
||||
NULL, // port on the remote host
|
||||
argv[1], // name of the file we want to open
|
||||
errbuf // error buffer
|
||||
) != 0)
|
||||
{
|
||||
fprintf(stderr,"\nError creating a source string\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open the capture file */
|
||||
if ( (fp= pcap_open(source, // name of the device
|
||||
65536, // portion of the packet to capture
|
||||
// 65536 guarantees that the whole packet will be captured on all the link layers
|
||||
PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode
|
||||
1000, // read timeout
|
||||
NULL, // authentication on the remote machine
|
||||
errbuf // error buffer
|
||||
) ) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the file %s.\n", source);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read and dispatch packets until EOF is reached
|
||||
pcap_loop(fp, 0, dispatcher_handler, NULL);
|
||||
|
||||
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,147 @@
|
||||
<?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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="readfile.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,81 @@
|
||||
#include <stdio.h>
|
||||
#include <pcap.h>
|
||||
#include "misc.h"
|
||||
|
||||
#define LINE_LEN 16
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pcap_t *fp;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
char source[PCAP_BUF_SIZE];
|
||||
struct pcap_pkthdr *header;
|
||||
const u_char *pkt_data;
|
||||
u_int i=0;
|
||||
int res;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(argc != 2)
|
||||
{
|
||||
printf("usage: %s filename", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create the source string according to the new WinPcap syntax */
|
||||
if ( pcap_createsrcstr( source, // variable that will keep the source string
|
||||
PCAP_SRC_FILE, // we want to open a file
|
||||
NULL, // remote host
|
||||
NULL, // port on the remote host
|
||||
argv[1], // name of the file we want to open
|
||||
errbuf // error buffer
|
||||
) != 0)
|
||||
{
|
||||
fprintf(stderr,"\nError creating a source string\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open the capture file */
|
||||
if ( (fp= pcap_open(source, // name of the device
|
||||
65536, // portion of the packet to capture
|
||||
// 65536 guarantees that the whole packet will be captured on all the link layers
|
||||
PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode
|
||||
1000, // read timeout
|
||||
NULL, // authentication on the remote machine
|
||||
errbuf // error buffer
|
||||
) ) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the file %s.\n", source);
|
||||
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));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -0,0 +1,147 @@
|
||||
<?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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="readfile_ex.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,110 @@
|
||||
#include <pcap.h>
|
||||
#include "misc.h"
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* 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_ex(PCAP_SRC_IF_STRING, NULL, &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_s("%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 */
|
||||
if ( (adhandle= pcap_open(d->name, // name of the device
|
||||
65536, // portion of the packet to capture
|
||||
// 65536 guarantees that the whole packet will be captured on all the link layers
|
||||
PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode
|
||||
1000, // read timeout
|
||||
NULL, // authentication on the remote machine
|
||||
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);
|
||||
|
||||
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,147 @@
|
||||
<?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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="savedump.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,72 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <pcap.h>
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
void main(int argc, char **argv)
|
||||
{
|
||||
pcap_t *fp;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
u_char packet[100];
|
||||
int i;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Check the validity of the command line */
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("usage: %s interface (e.g. 'rpcap://eth0')", argv[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Open the output device */
|
||||
if ( (fp= pcap_open(argv[1], // name of the device
|
||||
100, // portion of the packet to capture (only the first 100 bytes)
|
||||
PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode
|
||||
1000, // read timeout
|
||||
NULL, // authentication on the remote machine
|
||||
errbuf // error buffer
|
||||
) ) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", argv[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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, packet, 100 /* size */) != 0)
|
||||
{
|
||||
fprintf(stderr,"\nError sending the packet: %s\n", pcap_geterr(fp));
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
<?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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
<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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</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>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="sendpack.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,197 @@
|
||||
/*
|
||||
* 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, TEXT("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void usage();
|
||||
|
||||
|
||||
void 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;
|
||||
}
|
||||
|
||||
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(source,
|
||||
1514 /*snaplen*/,
|
||||
PCAP_OPENFLAG_PROMISCUOUS /*flags*/,
|
||||
20 /*read timeout*/,
|
||||
NULL /* remote authentication */,
|
||||
errbuf)
|
||||
) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the adapter.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
||||
//set the filter
|
||||
if(pcap_setfilter(fp, &fcode)<0)
|
||||
{
|
||||
fprintf(stderr,"\nError setting the filter\n");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//open the dump file
|
||||
if (ofilename != NULL)
|
||||
{
|
||||
dumpfile= pcap_dump_open(fp, ofilename);
|
||||
|
||||
if (dumpfile == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nError opening output file\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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,118 @@
|
||||
/*
|
||||
* Copyright (c) 2008 CACE Technologies, Davis (California)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of CACE Technologies nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This sample was contributed by
|
||||
* Marcin Okraszewski (Marcin.OkraszewskiATpl.compuware.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <tchar.h>
|
||||
#include <pcap.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/** Prints packet timestaps regardless of format*/
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
_TCHAR cmd[1024];
|
||||
_TCHAR tshark_path[MAX_PATH];
|
||||
_TCHAR file_path[MAX_PATH];
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( argc != 3 ) {
|
||||
_tprintf(_T("Prints packet timestaps regardless of format.\n"));
|
||||
_tprintf(_T("Usage:\n\t%s <tshark path> <trace file>\n"), argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// conversion to short path name in case there are spaces
|
||||
if ( ! GetShortPathName(argv[1], tshark_path, MAX_PATH) ||
|
||||
! GetShortPathName(argv[2], file_path, MAX_PATH) )
|
||||
{
|
||||
_tprintf(_T("Failed to convert paths to short form."));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create tshark command, which will make the trace conversion and print in libpcap format to stdout
|
||||
if ( _stprintf_s(cmd, 1024, _T("%s -r %s -w - -F libpcap"), tshark_path, file_path) < 0 ) {
|
||||
_tprintf(_T("Failed to create command\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// start tshark
|
||||
FILE *tshark_out = _tpopen(cmd, _T("rb"));
|
||||
if ( tshark_out == NULL ) {
|
||||
strerror_s(errbuf, PCAP_ERRBUF_SIZE, errno);
|
||||
printf("Failed run tshark: %s\n", errbuf);
|
||||
_tprintf(_T("Command: %s"), cmd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// open stdout from tshark
|
||||
pcap_t *pcap = pcap_fopen_offline(tshark_out, errbuf);
|
||||
if ( pcap == NULL ) {
|
||||
printf("Error opening stream from tshark: %s\n", errbuf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// print information about every packet int trace
|
||||
struct pcap_pkthdr hdr;
|
||||
while ( pcap_next(pcap, &hdr) ) {
|
||||
printf("packet: ts: %u.%06u, len: %4u, caplen: %4u\n", hdr.ts.tv_sec, hdr.ts.tv_usec, hdr.len, hdr.caplen);
|
||||
}
|
||||
|
||||
// clean up
|
||||
pcap_close(pcap);
|
||||
_pclose(tshark_out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -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>{DD317CB5-6337-498F-A560-553B5558E133}</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>_UNICODE;UNICODE;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>_UNICODE;UNICODE;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>_UNICODE;UNICODE;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>_UNICODE;UNICODE;WIN32;NDEBUG;_CONSOLE;HAVE_REMOTE;WPCAP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pcap_fopen.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
//
|
||||
// NOTE: remember to include WPCAP and HAVE_REMOTE among your
|
||||
// preprocessor definitions.
|
||||
//
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#define LINE_LEN 16
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
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://c:/temp/file.acp\n"
|
||||
" pktdump_ex -s rpcap://\\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_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf);
|
||||
return -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)
|
||||
{
|
||||
fprintf(stderr,"No interfaces found! Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Enter the interface number (1-%d):",i);
|
||||
scanf_s("%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 */
|
||||
if ( (fp= pcap_open(d->name,
|
||||
100 /*snaplen*/,
|
||||
PCAP_OPENFLAG_PROMISCUOUS /*flags*/,
|
||||
20 /*read timeout*/,
|
||||
NULL /* remote authentication */,
|
||||
errbuf)
|
||||
) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nError opening adapter\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not check for the switch type ('-s')
|
||||
if ( (fp= pcap_open(argv[2],
|
||||
100 /*snaplen*/,
|
||||
PCAP_OPENFLAG_PROMISCUOUS /*flags*/,
|
||||
20 /*read timeout*/,
|
||||
NULL /* remote authentication */,
|
||||
errbuf)
|
||||
) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nError opening source: %s\n", errbuf);
|
||||
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)
|
||||
{
|
||||
fprintf(stderr, "Error reading the packets: %s\n", pcap_geterr(fp));
|
||||
return -1;
|
||||
}
|
||||
|
||||
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,213 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
#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, TEXT("\\Npcap"));
|
||||
if (SetDllDirectory(npcap_dir) == 0) {
|
||||
fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void usage();
|
||||
|
||||
void main(int argc, char **argv)
|
||||
{
|
||||
pcap_t *indesc,*outdesc;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
char source[PCAP_BUF_SIZE];
|
||||
FILE *capfile;
|
||||
int caplen, sync;
|
||||
u_int res;
|
||||
pcap_send_queue *squeue;
|
||||
struct pcap_pkthdr *pktheader;
|
||||
u_char *pktdata;
|
||||
float cpu_time;
|
||||
u_int npacks = 0;
|
||||
errno_t fopen_error;
|
||||
|
||||
#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 || argc >= 5)
|
||||
{
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Retrieve the length of the capture file */
|
||||
fopen_error = fopen_s(&capfile, argv[1],"rb");
|
||||
if(fopen_error != 0){
|
||||
printf("Error opening the file, errno %d.\n", fopen_error);
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(capfile , 0, SEEK_END);
|
||||
caplen= ftell(capfile)- sizeof(struct pcap_file_header);
|
||||
fclose(capfile);
|
||||
|
||||
/* Chek if the timestamps must be respected */
|
||||
if(argc == 4 && argv[3][0] == 's')
|
||||
sync = TRUE;
|
||||
else
|
||||
sync = FALSE;
|
||||
|
||||
/* Open the capture */
|
||||
/* Create the source string according to the new WinPcap syntax */
|
||||
if ( pcap_createsrcstr( source, // variable that will keep the source string
|
||||
PCAP_SRC_FILE, // we want to open a file
|
||||
NULL, // remote host
|
||||
NULL, // port on the remote host
|
||||
argv[1], // name of the file we want to open
|
||||
errbuf // error buffer
|
||||
) != 0)
|
||||
{
|
||||
fprintf(stderr,"\nError creating a source string\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Open the capture file */
|
||||
if ( (indesc= pcap_open(source, 65536, PCAP_OPENFLAG_PROMISCUOUS, 1000, NULL, errbuf) ) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open the file %s.\n", source);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Open the output adapter */
|
||||
if ( (outdesc= pcap_open(argv[2], 100, PCAP_OPENFLAG_PROMISCUOUS, 1000, NULL, errbuf) ) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open adapter %s.\n", source);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check the MAC type */
|
||||
if (pcap_datalink(indesc) != pcap_datalink(outdesc))
|
||||
{
|
||||
printf("Warning: the datalink of the capture differs from the one of the selected interface.\n");
|
||||
printf("Press a key to continue, or CTRL+C to stop.\n");
|
||||
getchar();
|
||||
}
|
||||
|
||||
/* Allocate a send queue */
|
||||
squeue = pcap_sendqueue_alloc(caplen);
|
||||
|
||||
/* Fill the queue with the packets from the file */
|
||||
while ((res = pcap_next_ex( indesc, &pktheader, &pktdata)) == 1)
|
||||
{
|
||||
if (pcap_sendqueue_queue(squeue, pktheader, pktdata) == -1)
|
||||
{
|
||||
printf("Warning: packet buffer too small, not all the packets will be sent.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
npacks++;
|
||||
}
|
||||
|
||||
if (res == -1)
|
||||
{
|
||||
printf("Corrupted input file.\n");
|
||||
pcap_sendqueue_destroy(squeue);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Transmit the queue */
|
||||
|
||||
cpu_time = (float)clock ();
|
||||
|
||||
if ((res = pcap_sendqueue_transmit(outdesc, squeue, sync)) < squeue->len)
|
||||
{
|
||||
printf("An error occurred sending the packets: %s. Only %d bytes were sent\n", pcap_geterr(outdesc), res);
|
||||
}
|
||||
|
||||
cpu_time = (clock() - cpu_time)/CLK_TCK;
|
||||
|
||||
printf ("\n\nElapsed time: %5.3f\n", cpu_time);
|
||||
printf ("\nTotal packets generated = %d", npacks);
|
||||
printf ("\nAverage packets per second = %d", (int)((double)npacks/cpu_time));
|
||||
printf ("\n");
|
||||
|
||||
/* free the send queue */
|
||||
pcap_sendqueue_destroy(squeue);
|
||||
|
||||
/* Close the input file */
|
||||
pcap_close(indesc);
|
||||
|
||||
/*
|
||||
* lose the output adapter
|
||||
* IMPORTANT: remember to close the adapter, otherwise there will be no guarantee that all the
|
||||
* packets will be sent!
|
||||
*/
|
||||
pcap_close(outdesc);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void usage()
|
||||
{
|
||||
|
||||
printf("\nSendcap, sends a libpcap/tcpdump capture file to the net. Copyright (C) 2002 Loris Degioanni.\n");
|
||||
printf("\nUsage:\n");
|
||||
printf("\t sendcap file_name adapter [s]\n");
|
||||
printf("\nParameters:\n");
|
||||
printf("\nfile_name: the name of the dump file that will be sent to the network\n");
|
||||
printf("\nadapter: the device to use. Use \"WinDump -D\" for a list of valid devices\n");
|
||||
printf("\ns: if present, forces the packets to be sent synchronously, i.e. respecting the timestamps in the dump file. This option will work only under Windows NTx.\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>{D6B93A03-446A-4B13-87B8-9AA752A5CC8C}</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="sendcap.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="iflist.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
159
network/arpicmplab/start/lib/npcap/Examples-remote/smp_1/smp_1.c
Normal file
159
network/arpicmplab/start/lib/npcap/Examples-remote/smp_1/smp_1.c
Normal file
@ -0,0 +1,159 @@
|
||||
/*
|
||||
* 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 <conio.h>
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
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;
|
||||
struct pcap_pkthdr old;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("SMP_1\n");
|
||||
printf("\nThis program tests the Npcap kernel driver on SMP machines.\n");
|
||||
printf("The program tests that timestamps on the captured packets are consistent,\n");
|
||||
printf("and that the caplen is equal to the packet length.\n");
|
||||
printf("If there is an error, it will print out a message saying \"Inconsistent XXX\"\n");
|
||||
|
||||
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &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_s("%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 */
|
||||
if ( (fp= pcap_open(d->name, 65536, PCAP_OPENFLAG_PROMISCUOUS, 1000, NULL, errbuf) ) == 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;
|
||||
}
|
||||
|
||||
old.ts.tv_sec=0;
|
||||
old.ts.tv_usec=0;
|
||||
|
||||
|
||||
/* Read the packets */
|
||||
while((res = pcap_next_ex( fp, &header, &pkt_data)) >= 0){
|
||||
|
||||
if(res == 0)
|
||||
continue;
|
||||
|
||||
//check that caplen is equal to packet length
|
||||
if (header->caplen!=header->len)
|
||||
printf("Inconsistent header: CapLen %d\t Len %d\n",header->caplen,header->len);
|
||||
|
||||
//check that timestamps always grow
|
||||
if ( old.ts.tv_sec > header->ts.tv_sec || (old.ts.tv_sec == header->ts.tv_sec && old.ts.tv_usec > header->ts.tv_usec))
|
||||
printf("Inconsistent Timestamps! Old was %d.%.06d - New is %d.%.06d\n",old.ts.tv_sec,old.ts.tv_usec, header->ts.tv_sec,header->ts.tv_usec);
|
||||
|
||||
old=*header;
|
||||
|
||||
}
|
||||
|
||||
if(res == -1){
|
||||
printf("Error reading the packets: %s\n", pcap_geterr(fp));
|
||||
return -1;
|
||||
}
|
||||
|
||||
_getch();
|
||||
|
||||
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>{21F49E7F-6C58-4DA5-ABE5-A9DFB6165C83}</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="smp_1.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
void usage();
|
||||
|
||||
void dispatcher_handler(u_char *, const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
|
||||
void main(int argc, char **argv)
|
||||
{
|
||||
pcap_t *fp;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
struct timeval st_ts;
|
||||
u_int netmask;
|
||||
struct bpf_program fcode;
|
||||
|
||||
/* Load Npcap and its functions. */
|
||||
if (!LoadNpcapDlls())
|
||||
{
|
||||
fprintf(stderr, "Couldn't load Npcap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Check the validity of the command line */
|
||||
if (argc != 2)
|
||||
{
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Open the output adapter */
|
||||
if ( (fp= pcap_open(argv[1], 100, PCAP_OPENFLAG_PROMISCUOUS, 1000, NULL, errbuf) ) == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nUnable to open adapter %s.\n", errbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Don't care about netmask, it won't be used for this filter */
|
||||
netmask=0xffffff;
|
||||
|
||||
//compile the filter
|
||||
if (pcap_compile(fp, &fcode, "tcp", 1, netmask) <0 )
|
||||
{
|
||||
fprintf(stderr,"\nUnable to compile the packet filter. Check the syntax.\n");
|
||||
/* Free the device list */
|
||||
return;
|
||||
}
|
||||
|
||||
//set the filter
|
||||
if (pcap_setfilter(fp, &fcode)<0)
|
||||
{
|
||||
fprintf(stderr,"\nError setting the filter.\n");
|
||||
pcap_close(fp);
|
||||
/* Free the device list */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Put the interface in statstics mode */
|
||||
if (pcap_setmode(fp, MODE_STAT)<0)
|
||||
{
|
||||
fprintf(stderr,"\nError setting the mode.\n");
|
||||
pcap_close(fp);
|
||||
/* Free the device list */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
printf("TCP traffic summary:\n");
|
||||
|
||||
/* Start the main loop */
|
||||
pcap_loop(fp, 0, dispatcher_handler, (PUCHAR)&st_ts);
|
||||
|
||||
pcap_close(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
void dispatcher_handler(u_char *state, const struct pcap_pkthdr *header, const u_char *pkt_data)
|
||||
{
|
||||
struct timeval *old_ts = (struct timeval *)state;
|
||||
u_int delay;
|
||||
LARGE_INTEGER Bps,Pps;
|
||||
struct tm ltime;
|
||||
char timestr[16];
|
||||
time_t local_tv_sec;
|
||||
|
||||
/* Calculate the delay in microseconds from the last sample. */
|
||||
/* This value is obtained from the timestamp that the associated with the sample. */
|
||||
delay=(header->ts.tv_sec - old_ts->tv_sec) * 1000000 - old_ts->tv_usec + header->ts.tv_usec;
|
||||
/* Get the number of Bits per second */
|
||||
Bps.QuadPart=(((*(LONGLONG*)(pkt_data + 8)) * 8 * 1000000) / (delay));
|
||||
/* ^ ^
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
converts bytes in bits -- |
|
||||
|
|
||||
delay is expressed in microseconds --
|
||||
*/
|
||||
|
||||
/* Get the number of Packets per second */
|
||||
Pps.QuadPart=(((*(LONGLONG*)(pkt_data)) * 1000000) / (delay));
|
||||
|
||||
/* Convert the timestamp to readable format */
|
||||
local_tv_sec = header->ts.tv_sec;
|
||||
localtime_s(<ime, &local_tv_sec);
|
||||
strftime( timestr, sizeof timestr, "%H:%M:%S", <ime);
|
||||
|
||||
/* Print timestamp*/
|
||||
printf("%s ", timestr);
|
||||
|
||||
/* Print the samples */
|
||||
printf("BPS=%I64u ", Bps.QuadPart);
|
||||
printf("PPS=%I64u\n", Pps.QuadPart);
|
||||
|
||||
//store current timestamp
|
||||
old_ts->tv_sec=header->ts.tv_sec;
|
||||
old_ts->tv_usec=header->ts.tv_usec;
|
||||
}
|
||||
|
||||
|
||||
void usage()
|
||||
{
|
||||
|
||||
printf("\nShows the TCP traffic load, in bits per second and packets per second.\nCopyright (C) 2002 Loris Degioanni.\n");
|
||||
printf("\nUsage:\n");
|
||||
printf("\t tcptop adapter\n");
|
||||
printf("\t You can use \"WinDump -D\" if you don't know the name of your adapters.\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>{B671D5DF-3A80-4A21-BC01-79E3FB73D372}</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="tcptop.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
433
network/arpicmplab/start/lib/npcap/Include/Packet32.h
Normal file
433
network/arpicmplab/start/lib/npcap/Include/Packet32.h
Normal file
@ -0,0 +1,433 @@
|
||||
/***********************IMPORTANT NPCAP LICENSE TERMS***********************
|
||||
* *
|
||||
* Npcap is a Windows packet sniffing driver and library and is copyright *
|
||||
* (c) 2013-2020 by Insecure.Com LLC ("The Nmap Project"). All rights *
|
||||
* reserved. *
|
||||
* *
|
||||
* Even though Npcap source code is publicly available for review, it is *
|
||||
* not open source software and may not be redistributed or incorporated *
|
||||
* into other software without special permission from the Nmap Project. *
|
||||
* We fund the Npcap project by selling a commercial license which allows *
|
||||
* companies to redistribute Npcap with their products and also provides *
|
||||
* for support, warranty, and indemnification rights. For details on *
|
||||
* obtaining such a license, please contact: *
|
||||
* *
|
||||
* sales@nmap.com *
|
||||
* *
|
||||
* Free and open source software producers are also welcome to contact us *
|
||||
* for redistribution requests. However, we normally recommend that such *
|
||||
* authors instead ask your users to download and install Npcap *
|
||||
* themselves. *
|
||||
* *
|
||||
* Since the Npcap source code is available for download and review, *
|
||||
* users sometimes contribute code patches to fix bugs or add new *
|
||||
* features. By sending these changes to the Nmap Project (including *
|
||||
* through direct email or our mailing lists or submitting pull requests *
|
||||
* through our source code repository), it is understood unless you *
|
||||
* specify otherwise that you are offering the Nmap Project the *
|
||||
* unlimited, non-exclusive right to reuse, modify, and relicence your *
|
||||
* code contribution so that we may (but are not obligated to) *
|
||||
* incorporate it into Npcap. If you wish to specify special license *
|
||||
* conditions or restrictions on your contributions, just say so when you *
|
||||
* send them. *
|
||||
* *
|
||||
* This software is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
* Other copyright notices and attribution may appear below this license *
|
||||
* header. We have kept those for attribution purposes, but any license *
|
||||
* terms granted by those notices apply only to their original work, and *
|
||||
* not to any changes made by the Nmap Project or to this entire file. *
|
||||
* *
|
||||
* This header summarizes a few important aspects of the Npcap license, *
|
||||
* but is not a substitute for the full Npcap license agreement, which is *
|
||||
* in the LICENSE file included with Npcap and also available at *
|
||||
* https://github.com/nmap/npcap/blob/master/LICENSE. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
|
||||
* Copyright (c) 2005 - 2007 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @ingroup packetapi
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup packet32h Packet.dll definitions and data structures
|
||||
* Packet32.h contains the data structures and the definitions used by packet.dll.
|
||||
* The file is used both by the Win9x and the WinNTx versions of packet.dll, and can be included
|
||||
* by the applications that use the functions of this library
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __PACKET32
|
||||
#define __PACKET32
|
||||
|
||||
#include <winsock2.h>
|
||||
|
||||
#ifdef HAVE_AIRPCAP_API
|
||||
#include <airpcap.h>
|
||||
#else
|
||||
#if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_)
|
||||
#define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_
|
||||
typedef struct _AirpcapHandle* PAirpcapHandle;
|
||||
#endif /* AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ */
|
||||
#endif /* HAVE_AIRPCAP_API */
|
||||
|
||||
#ifdef HAVE_DAG_API
|
||||
#include <dagc.h>
|
||||
#endif /* HAVE_DAG_API */
|
||||
|
||||
// Libpcap/wpcap recognizes this macro and knows Npcap Packet API is provided for compilation.
|
||||
#define HAVE_NPCAP_PACKET_API
|
||||
|
||||
// Working modes, a bitfield
|
||||
// 0b00000000
|
||||
// | ||_ STAT or CAPT
|
||||
// | |__ MON (TME extensions, not supported)
|
||||
// | UNUSED
|
||||
// | UNUSED
|
||||
// |_____ DUMP (not supported)
|
||||
#define PACKET_MODE_CAPT 0x0 ///< Capture mode
|
||||
#define PACKET_MODE_STAT 0x1 ///< Statistical mode
|
||||
#define PACKET_MODE_MON 0x2 ///< Monitoring mode
|
||||
#define PACKET_MODE_DUMP 0x10 ///< Dump mode
|
||||
#define PACKET_MODE_STAT_DUMP PACKET_MODE_DUMP | PACKET_MODE_STAT ///< Statistical dump Mode
|
||||
|
||||
|
||||
/// Alignment macro. Defines the alignment size.
|
||||
#define Packet_ALIGNMENT sizeof(int)
|
||||
/// Alignment macro. Rounds up to the next even multiple of Packet_ALIGNMENT.
|
||||
#define Packet_WORDALIGN(x) (((x)+(Packet_ALIGNMENT-1))&~(Packet_ALIGNMENT-1))
|
||||
|
||||
#define NdisMediumNull -1 ///< Custom linktype: NDIS doesn't provide an equivalent
|
||||
#define NdisMediumCHDLC -2 ///< Custom linktype: NDIS doesn't provide an equivalent
|
||||
#define NdisMediumPPPSerial -3 ///< Custom linktype: NDIS doesn't provide an equivalent
|
||||
#define NdisMediumBare80211 -4 ///< Custom linktype: NDIS doesn't provide an equivalent
|
||||
#define NdisMediumRadio80211 -5 ///< Custom linktype: NDIS doesn't provide an equivalent
|
||||
#define NdisMediumPpi -6 ///< Custom linktype: NDIS doesn't provide an equivalent
|
||||
|
||||
// Loopback behaviour definitions
|
||||
#define NPF_DISABLE_LOOPBACK 1 ///< Drop the packets sent by the NPF driver
|
||||
#define NPF_ENABLE_LOOPBACK 2 ///< Capture the packets sent by the NPF driver
|
||||
|
||||
// Timestamp Modes
|
||||
#define TIMESTAMPMODE_SINGLE_SYNCHRONIZATION 0 // KeQueryPerformanceCounter
|
||||
#define TIMESTAMPMODE_QUERYSYSTEMTIME 2 // KeQuerySystemTime
|
||||
#define TIMESTAMPMODE_QUERYSYSTEMTIME_PRECISE 4 // KeQuerySystemTimePrecise, Windows 8 and newer
|
||||
|
||||
/*!
|
||||
\brief Network type structure.
|
||||
|
||||
This structure is used by the PacketGetNetType() function to return information on the current adapter's type and speed.
|
||||
*/
|
||||
typedef struct NetType
|
||||
{
|
||||
UINT LinkType; ///< The MAC of the current network adapter (see function PacketGetNetType() for more information)
|
||||
ULONGLONG LinkSpeed; ///< The speed of the network in bits per second
|
||||
}NetType;
|
||||
|
||||
|
||||
//some definitions stolen from libpcap
|
||||
|
||||
#ifndef BPF_MAJOR_VERSION
|
||||
|
||||
/*!
|
||||
\brief A BPF pseudo-assembly program.
|
||||
|
||||
The program will be injected in the kernel by the PacketSetBPF() function and applied to every incoming packet.
|
||||
*/
|
||||
struct bpf_program
|
||||
{
|
||||
UINT bf_len; ///< Indicates the number of instructions of the program, i.e. the number of struct bpf_insn that will follow.
|
||||
struct bpf_insn* bf_insns; ///< A pointer to the first instruction of the program.
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief A single BPF pseudo-instruction.
|
||||
|
||||
bpf_insn contains a single instruction for the BPF register-machine. It is used to send a filter program to the driver.
|
||||
*/
|
||||
struct bpf_insn
|
||||
{
|
||||
USHORT code; ///< Instruction type and addressing mode.
|
||||
UCHAR jt; ///< Jump if true
|
||||
UCHAR jf; ///< Jump if false
|
||||
int k; ///< Generic field used for various purposes.
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Structure that contains a couple of statistics values on the current capture.
|
||||
|
||||
It is used by packet.dll to return statistics about a capture session.
|
||||
*/
|
||||
struct bpf_stat
|
||||
{
|
||||
UINT bs_recv; ///< Number of packets that the driver received from the network adapter
|
||||
///< from the beginning of the current capture. This value includes the packets
|
||||
///< lost by the driver.
|
||||
UINT bs_drop; ///< number of packets that the driver lost from the beginning of a capture.
|
||||
///< Basically, a packet is lost when the the buffer of the driver is full.
|
||||
///< In this situation the packet cannot be stored and the driver rejects it.
|
||||
UINT ps_ifdrop; ///< drops by interface. XXX not yet supported
|
||||
UINT bs_capt; ///< number of packets that pass the filter, find place in the kernel buffer and
|
||||
///< thus reach the application.
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Packet header.
|
||||
|
||||
This structure defines the header associated with every packet delivered to the application.
|
||||
*/
|
||||
struct bpf_hdr
|
||||
{
|
||||
struct timeval bh_tstamp; ///< The timestamp associated with the captured packet.
|
||||
///< It is stored in a TimeVal structure.
|
||||
UINT bh_caplen; ///< Length of captured portion. The captured portion <b>can be different</b>
|
||||
///< from the original packet, because it is possible (with a proper filter)
|
||||
///< to instruct the driver to capture only a portion of the packets.
|
||||
UINT bh_datalen; ///< Original length of packet
|
||||
USHORT bh_hdrlen; ///< Length of bpf header (this struct plus alignment padding). In some cases,
|
||||
///< a padding could be added between the end of this structure and the packet
|
||||
///< data for performance reasons. This filed can be used to retrieve the actual data
|
||||
///< of the packet.
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Dump packet header.
|
||||
|
||||
This structure defines the header associated with the packets in a buffer to be used with PacketSendPackets().
|
||||
It is simpler than the bpf_hdr, because it corresponds to the header associated by WinPcap and libpcap to a
|
||||
packet in a dump file. This makes straightforward sending WinPcap dump files to the network.
|
||||
*/
|
||||
struct dump_bpf_hdr
|
||||
{
|
||||
struct timeval ts; ///< Time stamp of the packet
|
||||
UINT caplen; ///< Length of captured portion. The captured portion can smaller than the
|
||||
///< the original packet, because it is possible (with a proper filter) to
|
||||
///< instruct the driver to capture only a portion of the packets.
|
||||
UINT len; ///< Length of the original packet (off wire).
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
struct bpf_stat;
|
||||
|
||||
#define DOSNAMEPREFIX TEXT("Packet_") ///< Prefix added to the adapters device names to create the WinPcap devices
|
||||
#define MAX_LINK_NAME_LENGTH 64 //< Maximum length of the devices symbolic links
|
||||
#define NMAX_PACKET 65535
|
||||
|
||||
/*!
|
||||
\brief Addresses of a network adapter.
|
||||
|
||||
This structure is used by the PacketGetNetInfoEx() function to return the IP addresses associated with
|
||||
an adapter.
|
||||
*/
|
||||
typedef struct npf_if_addr
|
||||
{
|
||||
struct sockaddr_storage IPAddress; ///< IP address.
|
||||
struct sockaddr_storage SubnetMask; ///< Netmask for that address.
|
||||
struct sockaddr_storage Broadcast; ///< Broadcast address.
|
||||
}npf_if_addr;
|
||||
|
||||
|
||||
#define ADAPTER_NAME_LENGTH 256 + 12 ///< Maximum length for the name of an adapter. The value is the same used by the IP Helper API.
|
||||
#define ADAPTER_DESC_LENGTH 128 ///< Maximum length for the description of an adapter. The value is the same used by the IP Helper API.
|
||||
#define MAX_MAC_ADDR_LENGTH 8 ///< Maximum length for the link layer address of an adapter. The value is the same used by the IP Helper API.
|
||||
#define MAX_NETWORK_ADDRESSES 16 ///< Maximum length for the link layer address of an adapter. The value is the same used by the IP Helper API.
|
||||
|
||||
|
||||
typedef struct WAN_ADAPTER_INT WAN_ADAPTER; ///< Describes an opened wan (dialup, VPN...) network adapter using the NetMon API
|
||||
typedef WAN_ADAPTER* PWAN_ADAPTER; ///< Describes an opened wan (dialup, VPN...) network adapter using the NetMon API
|
||||
|
||||
#define INFO_FLAG_NDIS_ADAPTER 0 ///< Flag for ADAPTER_INFO: this is a traditional ndis adapter
|
||||
#define INFO_FLAG_NDISWAN_ADAPTER 1 ///< Flag for ADAPTER_INFO: this is a NdisWan adapter, and it's managed by WANPACKET
|
||||
#define INFO_FLAG_DAG_CARD 2 ///< Flag for ADAPTER_INFO: this is a DAG card
|
||||
#define INFO_FLAG_DAG_FILE 6 ///< Flag for ADAPTER_INFO: this is a DAG file
|
||||
#define INFO_FLAG_DONT_EXPORT 8 ///< Flag for ADAPTER_INFO: when this flag is set, the adapter will not be listed or openend by winpcap. This allows to prevent exporting broken network adapters, like for example FireWire ones.
|
||||
#define INFO_FLAG_AIRPCAP_CARD 16 ///< Flag for ADAPTER_INFO: this is an airpcap card
|
||||
#define INFO_FLAG_NPFIM_DEVICE 32
|
||||
|
||||
/*!
|
||||
\brief Describes an opened network adapter.
|
||||
|
||||
This structure is the most important for the functioning of packet.dll, but the great part of its fields
|
||||
should be ignored by the user, since the library offers functions that avoid to cope with low-level parameters
|
||||
*/
|
||||
typedef struct _ADAPTER
|
||||
{
|
||||
HANDLE hFile; ///< \internal Handle to an open instance of the NPF driver.
|
||||
CHAR SymbolicLink[MAX_LINK_NAME_LENGTH]; ///< \internal A string containing the name of the network adapter currently opened.
|
||||
int NumWrites; ///< \internal Number of times a packets written on this adapter will be repeated
|
||||
///< on the wire.
|
||||
HANDLE ReadEvent; ///< A notification event associated with the read calls on the adapter.
|
||||
///< It can be passed to standard Win32 functions (like WaitForSingleObject
|
||||
///< or WaitForMultipleObjects) to wait until the driver's buffer contains some
|
||||
///< data. It is particularly useful in GUI applications that need to wait
|
||||
///< concurrently on several events. In Windows NT/2000 the PacketSetMinToCopy()
|
||||
///< function can be used to define the minimum amount of data in the kernel buffer
|
||||
///< that will cause the event to be signalled.
|
||||
|
||||
UINT ReadTimeOut; ///< \internal The amount of time after which a read on the driver will be released and
|
||||
///< ReadEvent will be signaled, also if no packets were captured
|
||||
CHAR Name[ADAPTER_NAME_LENGTH];
|
||||
PWAN_ADAPTER pWanAdapter;
|
||||
UINT Flags; ///< Adapter's flags. Tell if this adapter must be treated in a different way, using the Netmon API or the dagc API.
|
||||
|
||||
#ifdef HAVE_AIRPCAP_API
|
||||
PAirpcapHandle AirpcapAd;
|
||||
#endif // HAVE_AIRPCAP_API
|
||||
|
||||
#ifdef HAVE_NPFIM_API
|
||||
void* NpfImHandle;
|
||||
#endif // HAVE_NPFIM_API
|
||||
|
||||
#ifdef HAVE_DAG_API
|
||||
dagc_t* pDagCard; ///< Pointer to the dagc API adapter descriptor for this adapter
|
||||
PCHAR DagBuffer; ///< Pointer to the buffer with the packets that is received from the DAG card
|
||||
struct timeval DagReadTimeout; ///< Read timeout. The dagc API requires a timeval structure
|
||||
unsigned DagFcsLen; ///< Length of the frame check sequence attached to any packet by the card. Obtained from the registry
|
||||
DWORD DagFastProcess; ///< True if the user requests fast capture processing on this card. Higher level applications can use this value to provide a faster but possibly unprecise capture (for example, libpcap doesn't convert the timestamps).
|
||||
#endif // HAVE_DAG_API
|
||||
} ADAPTER, * LPADAPTER;
|
||||
|
||||
/*!
|
||||
\brief Structure that contains a group of packets coming from the driver.
|
||||
|
||||
This structure defines the header associated with every packet delivered to the application.
|
||||
*/
|
||||
typedef struct _PACKET
|
||||
{
|
||||
HANDLE hEvent; ///< \deprecated Still present for compatibility with old applications.
|
||||
OVERLAPPED OverLapped; ///< \deprecated Still present for compatibility with old applications.
|
||||
PVOID Buffer; ///< Buffer with containing the packets. See the PacketReceivePacket() for
|
||||
///< details about the organization of the data in this buffer
|
||||
UINT Length; ///< Length of the buffer
|
||||
DWORD ulBytesReceived; ///< Number of valid bytes present in the buffer, i.e. amount of data
|
||||
///< received by the last call to PacketReceivePacket()
|
||||
BOOLEAN bIoComplete; ///< \deprecated Still present for compatibility with old applications.
|
||||
} PACKET, * LPPACKET;
|
||||
|
||||
/*!
|
||||
\brief Structure containing an OID request.
|
||||
|
||||
It is used by the PacketRequest() function to send an OID to the interface card driver.
|
||||
It can be used, for example, to retrieve the status of the error counters on the adapter, its MAC address,
|
||||
the list of the multicast groups defined on it, and so on.
|
||||
*/
|
||||
struct _PACKET_OID_DATA
|
||||
{
|
||||
ULONG Oid; ///< OID code. See the Microsoft DDK documentation or the file ntddndis.h
|
||||
///< for a complete list of valid codes.
|
||||
ULONG Length; ///< Length of the data field
|
||||
UCHAR Data[1]; ///< variable-lenght field that contains the information passed to or received
|
||||
///< from the adapter.
|
||||
};
|
||||
typedef struct _PACKET_OID_DATA PACKET_OID_DATA, * PPACKET_OID_DATA;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/*
|
||||
BOOLEAN QueryWinPcapRegistryStringA(CHAR *SubKeyName,
|
||||
CHAR *Value,
|
||||
UINT *pValueLen,
|
||||
CHAR *DefaultVal);
|
||||
BOOLEAN QueryWinPcapRegistryStringW(WCHAR *SubKeyName,
|
||||
WCHAR *Value,
|
||||
UINT *pValueLen,
|
||||
WCHAR *DefaultVal);
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// EXPORTED FUNCTIONS
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
LPCSTR PacketGetVersion();
|
||||
LPCSTR PacketGetDriverVersion();
|
||||
LPCSTR PacketGetDriverName();
|
||||
BOOLEAN PacketSetMinToCopy(LPADAPTER AdapterObject, int nbytes);
|
||||
BOOLEAN PacketSetNumWrites(LPADAPTER AdapterObject, int nwrites);
|
||||
BOOLEAN PacketSetMode(LPADAPTER AdapterObject, int mode);
|
||||
BOOLEAN PacketSetReadTimeout(LPADAPTER AdapterObject, int timeout);
|
||||
BOOLEAN PacketSetBpf(LPADAPTER AdapterObject, struct bpf_program* fp);
|
||||
BOOLEAN PacketSetLoopbackBehavior(LPADAPTER AdapterObject, UINT LoopbackBehavior);
|
||||
BOOLEAN PacketSetTimestampMode(LPADAPTER AdapterObject, ULONG mode);
|
||||
INT PacketSetSnapLen(LPADAPTER AdapterObject, int snaplen);
|
||||
BOOLEAN PacketGetStats(LPADAPTER AdapterObject, struct bpf_stat* s);
|
||||
BOOLEAN PacketGetStatsEx(LPADAPTER AdapterObject, struct bpf_stat* s);
|
||||
BOOLEAN PacketSetBuff(LPADAPTER AdapterObject, int dim);
|
||||
BOOLEAN PacketGetNetType(LPADAPTER AdapterObject, NetType* type);
|
||||
BOOLEAN PacketIsLoopbackAdapter(PCHAR AdapterName);
|
||||
int PacketIsMonitorModeSupported(PCHAR AdapterName);
|
||||
int PacketSetMonitorMode(PCHAR AdapterName, int mode);
|
||||
int PacketGetMonitorMode(PCHAR AdapterName);
|
||||
LPADAPTER PacketOpenAdapter(PCHAR AdapterName);
|
||||
BOOLEAN PacketSendPacket(LPADAPTER AdapterObject, LPPACKET pPacket, BOOLEAN Sync);
|
||||
INT PacketSendPackets(LPADAPTER AdapterObject, PVOID PacketBuff, ULONG Size, BOOLEAN Sync);
|
||||
LPPACKET PacketAllocatePacket(void);
|
||||
VOID PacketInitPacket(LPPACKET lpPacket, PVOID Buffer, UINT Length);
|
||||
VOID PacketFreePacket(LPPACKET lpPacket);
|
||||
BOOLEAN PacketReceivePacket(LPADAPTER AdapterObject, LPPACKET lpPacket, BOOLEAN Sync);
|
||||
BOOLEAN PacketSetHwFilter(LPADAPTER AdapterObject, ULONG Filter);
|
||||
BOOLEAN PacketGetAdapterNames(PCHAR pStr, PULONG BufferSize);
|
||||
BOOLEAN PacketGetNetInfoEx(PCHAR AdapterName, npf_if_addr* buffer, PLONG NEntries);
|
||||
BOOLEAN PacketRequest(LPADAPTER AdapterObject, BOOLEAN Set, PPACKET_OID_DATA OidData);
|
||||
HANDLE PacketGetReadEvent(LPADAPTER AdapterObject);
|
||||
BOOLEAN PacketSetDumpName(LPADAPTER AdapterObject, void* name, int len);
|
||||
BOOLEAN PacketSetDumpLimits(LPADAPTER AdapterObject, UINT maxfilesize, UINT maxnpacks);
|
||||
BOOLEAN PacketIsDumpEnded(LPADAPTER AdapterObject, BOOLEAN sync);
|
||||
BOOL PacketStopDriver();
|
||||
BOOL PacketStopDriver60();
|
||||
VOID PacketCloseAdapter(LPADAPTER lpAdapter);
|
||||
BOOLEAN PacketStartOem(PCHAR errorString, UINT errorStringLength);
|
||||
BOOLEAN PacketStartOemEx(PCHAR errorString, UINT errorStringLength, ULONG flags);
|
||||
PAirpcapHandle PacketGetAirPcapHandle(LPADAPTER AdapterObject);
|
||||
|
||||
//
|
||||
// Used by PacketStartOemEx
|
||||
//
|
||||
#define PACKET_START_OEM_NO_NETMON 0x00000001
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__PACKET32
|
||||
45
network/arpicmplab/start/lib/npcap/Include/pcap-bpf.h
Normal file
45
network/arpicmplab/start/lib/npcap/Include/pcap-bpf.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from the Stanford/CMU enet packet filter,
|
||||
* (net/enet.c) distributed as part of 4.3BSD, and code contributed
|
||||
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
|
||||
* Berkeley Laboratory.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* For backwards compatibility.
|
||||
*
|
||||
* Note to OS vendors: do NOT get rid of this file! Some applications
|
||||
* might expect to be able to include <pcap-bpf.h>.
|
||||
*/
|
||||
#include <pcap/bpf.h>
|
||||
40
network/arpicmplab/start/lib/npcap/Include/pcap-namedb.h
Normal file
40
network/arpicmplab/start/lib/npcap/Include/pcap-namedb.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 1996
|
||||
* The Regents of the University of 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* For backwards compatibility.
|
||||
*
|
||||
* Note to OS vendors: do NOT get rid of this file! Some applications
|
||||
* might expect to be able to include <pcap-namedb.h>.
|
||||
*/
|
||||
#include <pcap/namedb.h>
|
||||
43
network/arpicmplab/start/lib/npcap/Include/pcap.h
Normal file
43
network/arpicmplab/start/lib/npcap/Include/pcap.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* For backwards compatibility.
|
||||
*
|
||||
* Note to OS vendors: do NOT get rid of this file! Many applications
|
||||
* expect to be able to include <pcap.h>, and at least some of them
|
||||
* go through contortions in their configure scripts to try to detect
|
||||
* OSes that have "helpfully" moved pcap.h to <pcap/pcap.h> without
|
||||
* leaving behind a <pcap.h> file.
|
||||
*/
|
||||
#include <pcap/pcap.h>
|
||||
56
network/arpicmplab/start/lib/npcap/Include/pcap/bluetooth.h
Normal file
56
network/arpicmplab/start/lib/npcap/Include/pcap/bluetooth.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Paolo Abeni (Italy)
|
||||
* 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. The name of the author may not 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.
|
||||
*
|
||||
* bluetooth data struct
|
||||
* By Paolo Abeni <paolo.abeni@email.it>
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_bluetooth_h
|
||||
#define lib_pcap_bluetooth_h
|
||||
|
||||
#include <pcap/pcap-inttypes.h>
|
||||
|
||||
/*
|
||||
* Header prepended libpcap to each bluetooth h4 frame,
|
||||
* fields are in network byte order
|
||||
*/
|
||||
typedef struct _pcap_bluetooth_h4_header {
|
||||
uint32_t direction; /* if first bit is set direction is incoming */
|
||||
} pcap_bluetooth_h4_header;
|
||||
|
||||
/*
|
||||
* Header prepended libpcap to each bluetooth linux monitor frame,
|
||||
* fields are in network byte order
|
||||
*/
|
||||
typedef struct _pcap_bluetooth_linux_monitor_header {
|
||||
uint16_t adapter_id;
|
||||
uint16_t opcode;
|
||||
} pcap_bluetooth_linux_monitor_header;
|
||||
|
||||
#endif
|
||||
259
network/arpicmplab/start/lib/npcap/Include/pcap/bpf.h
Normal file
259
network/arpicmplab/start/lib/npcap/Include/pcap/bpf.h
Normal file
@ -0,0 +1,259 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from the Stanford/CMU enet packet filter,
|
||||
* (net/enet.c) distributed as part of 4.3BSD, and code contributed
|
||||
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
|
||||
* Berkeley Laboratory.
|
||||
*
|
||||
* 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 University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
* @(#)bpf.h 7.1 (Berkeley) 5/7/91
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is libpcap's cut-down version of bpf.h; it includes only
|
||||
* the stuff needed for the code generator and the userland BPF
|
||||
* interpreter, and the libpcap APIs for setting filters, etc..
|
||||
*
|
||||
* "pcap-bpf.c" will include the native OS version, as it deals with
|
||||
* the OS's BPF implementation.
|
||||
*
|
||||
* At least two programs found by Google Code Search explicitly includes
|
||||
* <pcap/bpf.h> (even though <pcap.h>/<pcap/pcap.h> includes it for you),
|
||||
* so moving that stuff to <pcap/pcap.h> would break the build for some
|
||||
* programs.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If we've already included <net/bpf.h>, don't re-define this stuff.
|
||||
* We assume BSD-style multiple-include protection in <net/bpf.h>,
|
||||
* which is true of all but the oldest versions of FreeBSD and NetBSD,
|
||||
* or Tru64 UNIX-style multiple-include protection (or, at least,
|
||||
* Tru64 UNIX 5.x-style; I don't have earlier versions available to check),
|
||||
* or AIX-style multiple-include protection (or, at least, AIX 5.x-style;
|
||||
* I don't have earlier versions available to check), or QNX-style
|
||||
* multiple-include protection (as per GitHub pull request #394).
|
||||
*
|
||||
* We do not check for BPF_MAJOR_VERSION, as that's defined by
|
||||
* <linux/filter.h>, which is directly or indirectly included in some
|
||||
* programs that also include pcap.h, and <linux/filter.h> doesn't
|
||||
* define stuff we need.
|
||||
*
|
||||
* This also provides our own multiple-include protection.
|
||||
*/
|
||||
#if !defined(_NET_BPF_H_) && !defined(_NET_BPF_H_INCLUDED) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h)
|
||||
#define lib_pcap_bpf_h
|
||||
|
||||
#include <pcap/funcattrs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* BSD style release date */
|
||||
#define BPF_RELEASE 199606
|
||||
|
||||
#ifdef MSDOS /* must be 32-bit */
|
||||
typedef long bpf_int32;
|
||||
typedef unsigned long bpf_u_int32;
|
||||
#else
|
||||
typedef int bpf_int32;
|
||||
typedef u_int bpf_u_int32;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Alignment macros. BPF_WORDALIGN rounds up to the next
|
||||
* even multiple of BPF_ALIGNMENT.
|
||||
*
|
||||
* Tcpdump's print-pflog.c uses this, so we define it here.
|
||||
*/
|
||||
#ifndef __NetBSD__
|
||||
#define BPF_ALIGNMENT sizeof(bpf_int32)
|
||||
#else
|
||||
#define BPF_ALIGNMENT sizeof(long)
|
||||
#endif
|
||||
#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
|
||||
|
||||
/*
|
||||
* Structure for "pcap_compile()", "pcap_setfilter()", etc..
|
||||
*/
|
||||
struct bpf_program {
|
||||
u_int bf_len;
|
||||
struct bpf_insn *bf_insns;
|
||||
};
|
||||
|
||||
#include <pcap/dlt.h>
|
||||
|
||||
/*
|
||||
* The instruction encodings.
|
||||
*
|
||||
* Please inform tcpdump-workers@lists.tcpdump.org if you use any
|
||||
* of the reserved values, so that we can note that they're used
|
||||
* (and perhaps implement it in the reference BPF implementation
|
||||
* and encourage its implementation elsewhere).
|
||||
*/
|
||||
|
||||
/*
|
||||
* The upper 8 bits of the opcode aren't used. BSD/OS used 0x8000.
|
||||
*/
|
||||
|
||||
/* instruction classes */
|
||||
#define BPF_CLASS(code) ((code) & 0x07)
|
||||
#define BPF_LD 0x00
|
||||
#define BPF_LDX 0x01
|
||||
#define BPF_ST 0x02
|
||||
#define BPF_STX 0x03
|
||||
#define BPF_ALU 0x04
|
||||
#define BPF_JMP 0x05
|
||||
#define BPF_RET 0x06
|
||||
#define BPF_MISC 0x07
|
||||
|
||||
/* ld/ldx fields */
|
||||
#define BPF_SIZE(code) ((code) & 0x18)
|
||||
#define BPF_W 0x00
|
||||
#define BPF_H 0x08
|
||||
#define BPF_B 0x10
|
||||
/* 0x18 reserved; used by BSD/OS */
|
||||
#define BPF_MODE(code) ((code) & 0xe0)
|
||||
#define BPF_IMM 0x00
|
||||
#define BPF_ABS 0x20
|
||||
#define BPF_IND 0x40
|
||||
#define BPF_MEM 0x60
|
||||
#define BPF_LEN 0x80
|
||||
#define BPF_MSH 0xa0
|
||||
/* 0xc0 reserved; used by BSD/OS */
|
||||
/* 0xe0 reserved; used by BSD/OS */
|
||||
|
||||
/* alu/jmp fields */
|
||||
#define BPF_OP(code) ((code) & 0xf0)
|
||||
#define BPF_ADD 0x00
|
||||
#define BPF_SUB 0x10
|
||||
#define BPF_MUL 0x20
|
||||
#define BPF_DIV 0x30
|
||||
#define BPF_OR 0x40
|
||||
#define BPF_AND 0x50
|
||||
#define BPF_LSH 0x60
|
||||
#define BPF_RSH 0x70
|
||||
#define BPF_NEG 0x80
|
||||
#define BPF_MOD 0x90
|
||||
#define BPF_XOR 0xa0
|
||||
/* 0xb0 reserved */
|
||||
/* 0xc0 reserved */
|
||||
/* 0xd0 reserved */
|
||||
/* 0xe0 reserved */
|
||||
/* 0xf0 reserved */
|
||||
|
||||
#define BPF_JA 0x00
|
||||
#define BPF_JEQ 0x10
|
||||
#define BPF_JGT 0x20
|
||||
#define BPF_JGE 0x30
|
||||
#define BPF_JSET 0x40
|
||||
/* 0x50 reserved; used on BSD/OS */
|
||||
/* 0x60 reserved */
|
||||
/* 0x70 reserved */
|
||||
/* 0x80 reserved */
|
||||
/* 0x90 reserved */
|
||||
/* 0xa0 reserved */
|
||||
/* 0xb0 reserved */
|
||||
/* 0xc0 reserved */
|
||||
/* 0xd0 reserved */
|
||||
/* 0xe0 reserved */
|
||||
/* 0xf0 reserved */
|
||||
#define BPF_SRC(code) ((code) & 0x08)
|
||||
#define BPF_K 0x00
|
||||
#define BPF_X 0x08
|
||||
|
||||
/* ret - BPF_K and BPF_X also apply */
|
||||
#define BPF_RVAL(code) ((code) & 0x18)
|
||||
#define BPF_A 0x10
|
||||
/* 0x18 reserved */
|
||||
|
||||
/* misc */
|
||||
#define BPF_MISCOP(code) ((code) & 0xf8)
|
||||
#define BPF_TAX 0x00
|
||||
/* 0x08 reserved */
|
||||
/* 0x10 reserved */
|
||||
/* 0x18 reserved */
|
||||
/* #define BPF_COP 0x20 NetBSD "coprocessor" extensions */
|
||||
/* 0x28 reserved */
|
||||
/* 0x30 reserved */
|
||||
/* 0x38 reserved */
|
||||
/* #define BPF_COPX 0x40 NetBSD "coprocessor" extensions */
|
||||
/* also used on BSD/OS */
|
||||
/* 0x48 reserved */
|
||||
/* 0x50 reserved */
|
||||
/* 0x58 reserved */
|
||||
/* 0x60 reserved */
|
||||
/* 0x68 reserved */
|
||||
/* 0x70 reserved */
|
||||
/* 0x78 reserved */
|
||||
#define BPF_TXA 0x80
|
||||
/* 0x88 reserved */
|
||||
/* 0x90 reserved */
|
||||
/* 0x98 reserved */
|
||||
/* 0xa0 reserved */
|
||||
/* 0xa8 reserved */
|
||||
/* 0xb0 reserved */
|
||||
/* 0xb8 reserved */
|
||||
/* 0xc0 reserved; used on BSD/OS */
|
||||
/* 0xc8 reserved */
|
||||
/* 0xd0 reserved */
|
||||
/* 0xd8 reserved */
|
||||
/* 0xe0 reserved */
|
||||
/* 0xe8 reserved */
|
||||
/* 0xf0 reserved */
|
||||
/* 0xf8 reserved */
|
||||
|
||||
/*
|
||||
* The instruction data structure.
|
||||
*/
|
||||
struct bpf_insn {
|
||||
u_short code;
|
||||
u_char jt;
|
||||
u_char jf;
|
||||
bpf_u_int32 k;
|
||||
};
|
||||
|
||||
/*
|
||||
* Macros for insn array initializers.
|
||||
*/
|
||||
#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
|
||||
#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
|
||||
|
||||
PCAP_API int bpf_validate(const struct bpf_insn *, int);
|
||||
PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
|
||||
|
||||
/*
|
||||
* Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
|
||||
*/
|
||||
#define BPF_MEMWORDS 16
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined(_NET_BPF_H_) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h) */
|
||||
@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from the Stanford/CMU enet packet filter,
|
||||
* (net/enet.c) distributed as part of 4.3BSD, and code contributed
|
||||
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
|
||||
* Berkeley Laboratory.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_can_socketcan_h
|
||||
#define lib_pcap_can_socketcan_h
|
||||
|
||||
#include <pcap/pcap-inttypes.h>
|
||||
|
||||
/*
|
||||
* SocketCAN header, as per Documentation/networking/can.txt in the
|
||||
* Linux source.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t can_id;
|
||||
uint8_t payload_length;
|
||||
uint8_t pad;
|
||||
uint8_t reserved1;
|
||||
uint8_t reserved2;
|
||||
} pcap_can_socketcan_hdr;
|
||||
|
||||
#endif
|
||||
163
network/arpicmplab/start/lib/npcap/Include/pcap/compiler-tests.h
Normal file
163
network/arpicmplab/start/lib/npcap/Include/pcap/compiler-tests.h
Normal file
@ -0,0 +1,163 @@
|
||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_compiler_tests_h
|
||||
#define lib_pcap_compiler_tests_h
|
||||
|
||||
/*
|
||||
* This was introduced by Clang:
|
||||
*
|
||||
* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
|
||||
*
|
||||
* in some version (which version?); it has been picked up by GCC 5.0.
|
||||
*/
|
||||
#ifndef __has_attribute
|
||||
/*
|
||||
* It's a macro, so you can check whether it's defined to check
|
||||
* whether it's supported.
|
||||
*
|
||||
* If it's not, define it to always return 0, so that we move on to
|
||||
* the fallback checks.
|
||||
*/
|
||||
#define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Note that the C90 spec's "6.8.1 Conditional inclusion" and the
|
||||
* C99 spec's and C11 spec's "6.10.1 Conditional inclusion" say:
|
||||
*
|
||||
* Prior to evaluation, macro invocations in the list of preprocessing
|
||||
* tokens that will become the controlling constant expression are
|
||||
* replaced (except for those macro names modified by the defined unary
|
||||
* operator), just as in normal text. If the token "defined" is
|
||||
* generated as a result of this replacement process or use of the
|
||||
* "defined" unary operator does not match one of the two specified
|
||||
* forms prior to macro replacement, the behavior is undefined.
|
||||
*
|
||||
* so you shouldn't use defined() in a #define that's used in #if or
|
||||
* #elif. Some versions of Clang, for example, will warn about this.
|
||||
*
|
||||
* Instead, we check whether the pre-defined macros for particular
|
||||
* compilers are defined and, if not, define the "is this version XXX
|
||||
* or a later version of this compiler" macros as 0.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Check whether this is GCC major.minor or a later release, or some
|
||||
* compiler that claims to be "just like GCC" of that version or a
|
||||
* later release.
|
||||
*/
|
||||
|
||||
#if ! defined(__GNUC__)
|
||||
#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
|
||||
#else
|
||||
#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \
|
||||
(__GNUC__ > (major) || \
|
||||
(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check whether this is Clang major.minor or a later release.
|
||||
*/
|
||||
|
||||
#if !defined(__clang__)
|
||||
#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
|
||||
#else
|
||||
#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \
|
||||
(__clang_major__ > (major) || \
|
||||
(__clang_major__ == (major) && __clang_minor__ >= (minor)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check whether this is Sun C/SunPro C/Oracle Studio major.minor
|
||||
* or a later release.
|
||||
*
|
||||
* The version number in __SUNPRO_C is encoded in hex BCD, with the
|
||||
* uppermost hex digit being the major version number, the next
|
||||
* one or two hex digits being the minor version number, and
|
||||
* the last digit being the patch version.
|
||||
*
|
||||
* It represents the *compiler* version, not the product version;
|
||||
* see
|
||||
*
|
||||
* https://sourceforge.net/p/predef/wiki/Compilers/
|
||||
*
|
||||
* for a partial mapping, which we assume continues for later
|
||||
* 12.x product releases.
|
||||
*/
|
||||
|
||||
#if ! defined(__SUNPRO_C)
|
||||
#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
|
||||
#else
|
||||
#define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \
|
||||
(((minor) >= 10) ? \
|
||||
(((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
|
||||
(((major) << 8) | ((minor) << 4)))
|
||||
#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \
|
||||
(__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check whether this is IBM XL C major.minor or a later release.
|
||||
*
|
||||
* The version number in __xlC__ has the major version in the
|
||||
* upper 8 bits and the minor version in the lower 8 bits.
|
||||
*/
|
||||
|
||||
#if ! defined(__xlC__)
|
||||
#define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
|
||||
#else
|
||||
#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \
|
||||
(__xlC__ >= (((major) << 8) | (minor)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check whether this is HP aC++/HP C major.minor or a later release.
|
||||
*
|
||||
* The version number in __HP_aCC is encoded in zero-padded decimal BCD,
|
||||
* with the "A." stripped off, the uppermost two decimal digits being
|
||||
* the major version number, the next two decimal digits being the minor
|
||||
* version number, and the last two decimal digits being the patch version.
|
||||
* (Strip off the A., remove the . between the major and minor version
|
||||
* number, and add two digits of patch.)
|
||||
*/
|
||||
|
||||
#if ! defined(__HP_aCC)
|
||||
#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
|
||||
#else
|
||||
#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \
|
||||
(__HP_aCC >= ((major)*10000 + (minor)*100))
|
||||
#endif
|
||||
|
||||
#endif /* lib_pcap_compiler_tests_h */
|
||||
1434
network/arpicmplab/start/lib/npcap/Include/pcap/dlt.h
Normal file
1434
network/arpicmplab/start/lib/npcap/Include/pcap/dlt.h
Normal file
File diff suppressed because it is too large
Load Diff
263
network/arpicmplab/start/lib/npcap/Include/pcap/funcattrs.h
Normal file
263
network/arpicmplab/start/lib/npcap/Include/pcap/funcattrs.h
Normal file
@ -0,0 +1,263 @@
|
||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_funcattrs_h
|
||||
#define lib_pcap_funcattrs_h
|
||||
|
||||
#include <pcap/compiler-tests.h>
|
||||
|
||||
/*
|
||||
* Attributes to apply to functions and their arguments, using various
|
||||
* compiler-specific extensions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* PCAP_API_DEF must be used when defining *data* exported from
|
||||
* libpcap. It can be used when defining *functions* exported
|
||||
* from libpcap, but it doesn't have to be used there. It
|
||||
* should not be used in declarations in headers.
|
||||
*
|
||||
* PCAP_API must be used when *declaring* data or functions
|
||||
* exported from libpcap; PCAP_API_DEF won't work on all platforms.
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
/*
|
||||
* For Windows:
|
||||
*
|
||||
* when building libpcap:
|
||||
*
|
||||
* if we're building it as a DLL, we have to declare API
|
||||
* functions with __declspec(dllexport);
|
||||
*
|
||||
* if we're building it as a static library, we don't want
|
||||
* to do so.
|
||||
*
|
||||
* when using libpcap:
|
||||
*
|
||||
* if we're using the DLL, calls to its functions are a
|
||||
* little more efficient if they're declared with
|
||||
* __declspec(dllimport);
|
||||
*
|
||||
* if we're not using the dll, we don't want to declare
|
||||
* them that way.
|
||||
*
|
||||
* So:
|
||||
*
|
||||
* if pcap_EXPORTS is defined, we define PCAP_API_DEF as
|
||||
* __declspec(dllexport);
|
||||
*
|
||||
* if PCAP_DLL is defined, we define PCAP_API_DEF as
|
||||
* __declspec(dllimport);
|
||||
*
|
||||
* otherwise, we define PCAP_API_DEF as nothing.
|
||||
*/
|
||||
#if defined(pcap_EXPORTS)
|
||||
/*
|
||||
* We're compiling libpcap as a DLL, so we should export functions
|
||||
* in our API.
|
||||
*/
|
||||
#define PCAP_API_DEF __declspec(dllexport)
|
||||
#elif defined(PCAP_DLL)
|
||||
/*
|
||||
* We're using libpcap as a DLL, so the calls will be a little more
|
||||
* efficient if we explicitly import the functions.
|
||||
*/
|
||||
#define PCAP_API_DEF __declspec(dllimport)
|
||||
#else
|
||||
/*
|
||||
* Either we're building libpcap as a static library, or we're using
|
||||
* it as a static library, or we don't know for certain that we're
|
||||
* using it as a dynamic library, so neither import nor export the
|
||||
* functions explicitly.
|
||||
*/
|
||||
#define PCAP_API_DEF
|
||||
#endif
|
||||
#elif defined(MSDOS)
|
||||
/* XXX - does this need special treatment? */
|
||||
#define PCAP_API_DEF
|
||||
#else /* UN*X */
|
||||
#ifdef pcap_EXPORTS
|
||||
/*
|
||||
* We're compiling libpcap as a (dynamic) shared library, so we should
|
||||
* export functions in our API. The compiler might be configured not
|
||||
* to export functions from a shared library by default, so we might
|
||||
* have to explicitly mark functions as exported.
|
||||
*/
|
||||
#if PCAP_IS_AT_LEAST_GNUC_VERSION(3,4) \
|
||||
|| PCAP_IS_AT_LEAST_XL_C_VERSION(12,0)
|
||||
/*
|
||||
* GCC 3.4 or later, or some compiler asserting compatibility with
|
||||
* GCC 3.4 or later, or XL C 13.0 or later, so we have
|
||||
* __attribute__((visibility()).
|
||||
*/
|
||||
#define PCAP_API_DEF __attribute__((visibility("default")))
|
||||
#elif PCAP_IS_AT_LEAST_SUNC_VERSION(5,5)
|
||||
/*
|
||||
* Sun C 5.5 or later, so we have __global.
|
||||
* (Sun C 5.9 and later also have __attribute__((visibility()),
|
||||
* but there's no reason to prefer it with Sun C.)
|
||||
*/
|
||||
#define PCAP_API_DEF __global
|
||||
#else
|
||||
/*
|
||||
* We don't have anything to say.
|
||||
*/
|
||||
#define PCAP_API_DEF
|
||||
#endif
|
||||
#else
|
||||
/*
|
||||
* We're not building libpcap.
|
||||
*/
|
||||
#define PCAP_API_DEF
|
||||
#endif
|
||||
#endif /* _WIN32/MSDOS/UN*X */
|
||||
|
||||
#define PCAP_API PCAP_API_DEF extern
|
||||
|
||||
/*
|
||||
* PCAP_NORETURN, before a function declaration, means "this function
|
||||
* never returns". (It must go before the function declaration, e.g.
|
||||
* "extern PCAP_NORETURN func(...)" rather than after the function
|
||||
* declaration, as the MSVC version has to go before the declaration.)
|
||||
*
|
||||
* PCAP_NORETURN_DEF, before a function *definition*, means "this
|
||||
* function never returns"; it would be used only for static functions
|
||||
* that are defined before any use, and thus have no declaration.
|
||||
* (MSVC doesn't support that; I guess the "decl" in "__declspec"
|
||||
* means "declaration", and __declspec doesn't work with definitions.)
|
||||
*/
|
||||
#if __has_attribute(noreturn) \
|
||||
|| PCAP_IS_AT_LEAST_GNUC_VERSION(2,5) \
|
||||
|| PCAP_IS_AT_LEAST_SUNC_VERSION(5,9) \
|
||||
|| PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \
|
||||
|| PCAP_IS_AT_LEAST_HP_C_VERSION(6,10)
|
||||
/*
|
||||
* Compiler with support for __attribute((noreturn)), or GCC 2.5 or
|
||||
* later, or some compiler asserting compatibility with GCC 2.5 or
|
||||
* later, or Solaris Studio 12 (Sun C 5.9) or later, or IBM XL C 10.1
|
||||
* or later (do any earlier versions of XL C support this?), or HP aCC
|
||||
* A.06.10 or later.
|
||||
*/
|
||||
#define PCAP_NORETURN __attribute((noreturn))
|
||||
#define PCAP_NORETURN_DEF __attribute((noreturn))
|
||||
#elif defined(_MSC_VER)
|
||||
/*
|
||||
* MSVC.
|
||||
*/
|
||||
#define PCAP_NORETURN __declspec(noreturn)
|
||||
#define PCAP_NORETURN_DEF
|
||||
#else
|
||||
#define PCAP_NORETURN
|
||||
#define PCAP_NORETURN_DEF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PCAP_PRINTFLIKE(x,y), after a function declaration, means "this function
|
||||
* does printf-style formatting, with the xth argument being the format
|
||||
* string and the yth argument being the first argument for the format
|
||||
* string".
|
||||
*/
|
||||
#if __has_attribute(__format__) \
|
||||
|| PCAP_IS_AT_LEAST_GNUC_VERSION(2,3) \
|
||||
|| PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \
|
||||
|| PCAP_IS_AT_LEAST_HP_C_VERSION(6,10)
|
||||
/*
|
||||
* Compiler with support for it, or GCC 2.3 or later, or some compiler
|
||||
* asserting compatibility with GCC 2.3 or later, or IBM XL C 10.1
|
||||
* and later (do any earlier versions of XL C support this?),
|
||||
* or HP aCC A.06.10 and later.
|
||||
*/
|
||||
#define PCAP_PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
|
||||
#else
|
||||
#define PCAP_PRINTFLIKE(x,y)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PCAP_DEPRECATED(func, msg), after a function declaration, marks the
|
||||
* function as deprecated.
|
||||
*
|
||||
* The first argument is the name of the function; the second argument is
|
||||
* a string giving the warning message to use if the compiler supports that.
|
||||
*
|
||||
* (Thank you, Microsoft, for requiring the function name.)
|
||||
*/
|
||||
#if __has_attribute(deprecated) \
|
||||
|| PCAP_IS_AT_LEAST_GNUC_VERSION(4,5) \
|
||||
|| PCAP_IS_AT_LEAST_SUNC_VERSION(5,13)
|
||||
/*
|
||||
* Compiler that supports __has_attribute and __attribute__((deprecated)),
|
||||
* or GCC 4.5 or later, or Sun/Oracle C 12.4 (Sun C 5.13) or later.
|
||||
*
|
||||
* Those support __attribute__((deprecated(msg))) (we assume, perhaps
|
||||
* incorrectly, that anything that supports __has_attribute() is
|
||||
* recent enough to support __attribute__((deprecated(msg)))).
|
||||
*/
|
||||
#define PCAP_DEPRECATED(func, msg) __attribute__((deprecated(msg)))
|
||||
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(3,1)
|
||||
/*
|
||||
* GCC 3.1 through 4.4.
|
||||
*
|
||||
* Those support __attribute__((deprecated)) but not
|
||||
* __attribute__((deprecated(msg))).
|
||||
*/
|
||||
#define PCAP_DEPRECATED(func, msg) __attribute__((deprecated))
|
||||
#elif (defined(_MSC_VER) && (_MSC_VER >= 1500)) && !defined(BUILDING_PCAP)
|
||||
/*
|
||||
* MSVC from Visual Studio 2008 or later, and we're not building
|
||||
* libpcap itself.
|
||||
*
|
||||
* If we *are* building libpcap, we don't want this, as it'll warn
|
||||
* us even if we *define* the function.
|
||||
*/
|
||||
#define PCAP_DEPRECATED(func, msg) __pragma(deprecated(func))
|
||||
#else
|
||||
#define PCAP_DEPRECATED(func, msg)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* For flagging arguments as format strings in MSVC.
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
#include <sal.h>
|
||||
#if _MSC_VER > 1400
|
||||
#define PCAP_FORMAT_STRING(p) _Printf_format_string_ p
|
||||
#else
|
||||
#define PCAP_FORMAT_STRING(p) __format_string p
|
||||
#endif
|
||||
#else
|
||||
#define PCAP_FORMAT_STRING(p) p
|
||||
#endif
|
||||
|
||||
#endif /* lib_pcap_funcattrs_h */
|
||||
43
network/arpicmplab/start/lib/npcap/Include/pcap/ipnet.h
Normal file
43
network/arpicmplab/start/lib/npcap/Include/pcap/ipnet.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from the Stanford/CMU enet packet filter,
|
||||
* (net/enet.c) distributed as part of 4.3BSD, and code contributed
|
||||
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
|
||||
* Berkeley Laboratory.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
#define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
|
||||
#define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
|
||||
|
||||
#define IPNET_OUTBOUND 1
|
||||
#define IPNET_INBOUND 2
|
||||
83
network/arpicmplab/start/lib/npcap/Include/pcap/namedb.h
Normal file
83
network/arpicmplab/start/lib/npcap/Include/pcap/namedb.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 1996
|
||||
* The Regents of the University of 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_namedb_h
|
||||
#define lib_pcap_namedb_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* As returned by the pcap_next_etherent()
|
||||
* XXX this stuff doesn't belong in this interface, but this
|
||||
* library already must do name to address translation, so
|
||||
* on systems that don't have support for /etc/ethers, we
|
||||
* export these hooks since they're already being used by
|
||||
* some applications (such as tcpdump) and already being
|
||||
* marked as exported in some OSes offering libpcap (such
|
||||
* as Debian).
|
||||
*/
|
||||
struct pcap_etherent {
|
||||
u_char addr[6];
|
||||
char name[122];
|
||||
};
|
||||
#ifndef PCAP_ETHERS_FILE
|
||||
#define PCAP_ETHERS_FILE "/etc/ethers"
|
||||
#endif
|
||||
PCAP_API struct pcap_etherent *pcap_next_etherent(FILE *);
|
||||
PCAP_API u_char *pcap_ether_hostton(const char*);
|
||||
PCAP_API u_char *pcap_ether_aton(const char *);
|
||||
|
||||
PCAP_API bpf_u_int32 **pcap_nametoaddr(const char *);
|
||||
PCAP_API struct addrinfo *pcap_nametoaddrinfo(const char *);
|
||||
PCAP_API bpf_u_int32 pcap_nametonetaddr(const char *);
|
||||
|
||||
PCAP_API int pcap_nametoport(const char *, int *, int *);
|
||||
PCAP_API int pcap_nametoportrange(const char *, int *, int *, int *);
|
||||
PCAP_API int pcap_nametoproto(const char *);
|
||||
PCAP_API int pcap_nametoeproto(const char *);
|
||||
PCAP_API int pcap_nametollc(const char *);
|
||||
/*
|
||||
* If a protocol is unknown, PROTO_UNDEF is returned.
|
||||
* Also, pcap_nametoport() returns the protocol along with the port number.
|
||||
* If there are ambiguous entried in /etc/services (i.e. domain
|
||||
* can be either tcp or udp) PROTO_UNDEF is returned.
|
||||
*/
|
||||
#define PROTO_UNDEF -1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
94
network/arpicmplab/start/lib/npcap/Include/pcap/nflog.h
Normal file
94
network/arpicmplab/start/lib/npcap/Include/pcap/nflog.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Petar Alilovic,
|
||||
* Faculty of Electrical Engineering and Computing, University of Zagreb
|
||||
* All rights reserved
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_nflog_h
|
||||
#define lib_pcap_nflog_h
|
||||
|
||||
#include <pcap/pcap-inttypes.h>
|
||||
|
||||
/*
|
||||
* Structure of an NFLOG header and TLV parts, as described at
|
||||
* https://www.tcpdump.org/linktypes/LINKTYPE_NFLOG.html
|
||||
*
|
||||
* The NFLOG header is big-endian.
|
||||
*
|
||||
* The TLV length and type are in host byte order. The value is either
|
||||
* big-endian or is an array of bytes in some externally-specified byte
|
||||
* order (text string, link-layer address, link-layer header, packet
|
||||
* data, etc.).
|
||||
*/
|
||||
typedef struct nflog_hdr {
|
||||
uint8_t nflog_family; /* address family */
|
||||
uint8_t nflog_version; /* version */
|
||||
uint16_t nflog_rid; /* resource ID */
|
||||
} nflog_hdr_t;
|
||||
|
||||
typedef struct nflog_tlv {
|
||||
uint16_t tlv_length; /* tlv length */
|
||||
uint16_t tlv_type; /* tlv type */
|
||||
/* value follows this */
|
||||
} nflog_tlv_t;
|
||||
|
||||
typedef struct nflog_packet_hdr {
|
||||
uint16_t hw_protocol; /* hw protocol */
|
||||
uint8_t hook; /* netfilter hook */
|
||||
uint8_t pad; /* padding to 32 bits */
|
||||
} nflog_packet_hdr_t;
|
||||
|
||||
typedef struct nflog_hwaddr {
|
||||
uint16_t hw_addrlen; /* address length */
|
||||
uint16_t pad; /* padding to 32-bit boundary */
|
||||
uint8_t hw_addr[8]; /* address, up to 8 bytes */
|
||||
} nflog_hwaddr_t;
|
||||
|
||||
typedef struct nflog_timestamp {
|
||||
uint64_t sec;
|
||||
uint64_t usec;
|
||||
} nflog_timestamp_t;
|
||||
|
||||
/*
|
||||
* TLV types.
|
||||
*/
|
||||
#define NFULA_PACKET_HDR 1 /* nflog_packet_hdr_t */
|
||||
#define NFULA_MARK 2 /* packet mark from skbuff */
|
||||
#define NFULA_TIMESTAMP 3 /* nflog_timestamp_t for skbuff's time stamp */
|
||||
#define NFULA_IFINDEX_INDEV 4 /* ifindex of device on which packet received (possibly bridge group) */
|
||||
#define NFULA_IFINDEX_OUTDEV 5 /* ifindex of device on which packet transmitted (possibly bridge group) */
|
||||
#define NFULA_IFINDEX_PHYSINDEV 6 /* ifindex of physical device on which packet received (not bridge group) */
|
||||
#define NFULA_IFINDEX_PHYSOUTDEV 7 /* ifindex of physical device on which packet transmitted (not bridge group) */
|
||||
#define NFULA_HWADDR 8 /* nflog_hwaddr_t for hardware address */
|
||||
#define NFULA_PAYLOAD 9 /* packet payload */
|
||||
#define NFULA_PREFIX 10 /* text string - null-terminated, count includes NUL */
|
||||
#define NFULA_UID 11 /* UID owning socket on which packet was sent/received */
|
||||
#define NFULA_SEQ 12 /* sequence number of packets on this NFLOG socket */
|
||||
#define NFULA_SEQ_GLOBAL 13 /* sequence number of pakets on all NFLOG sockets */
|
||||
#define NFULA_GID 14 /* GID owning socket on which packet was sent/received */
|
||||
#define NFULA_HWTYPE 15 /* ARPHRD_ type of skbuff's device */
|
||||
#define NFULA_HWHEADER 16 /* skbuff's MAC-layer header */
|
||||
#define NFULA_HWLEN 17 /* length of skbuff's MAC-layer header */
|
||||
|
||||
#endif
|
||||
128
network/arpicmplab/start/lib/npcap/Include/pcap/pcap-inttypes.h
Normal file
128
network/arpicmplab/start/lib/npcap/Include/pcap/pcap-inttypes.h
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy)
|
||||
* Copyright (c) 2005 - 2009 CACE Technologies, Inc. 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 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.
|
||||
*/
|
||||
#ifndef pcap_pcap_inttypes_h
|
||||
#define pcap_pcap_inttypes_h
|
||||
|
||||
/*
|
||||
* Get the integer types and PRi[doux]64 values from C99 <inttypes.h>
|
||||
* defined, by hook or by crook.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
/*
|
||||
* Compiler is MSVC.
|
||||
*/
|
||||
#if _MSC_VER >= 1800
|
||||
/*
|
||||
* VS 2013 or newer; we have <inttypes.h>.
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
/*
|
||||
* Earlier VS; we have to define this stuff ourselves.
|
||||
*/
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed int int32_t;
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
typedef unsigned _int64 uint64_t;
|
||||
typedef _int64 int64_t;
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef long long int64_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* These may be defined by <inttypes.h>.
|
||||
*
|
||||
* XXX - for MSVC, we always want the _MSC_EXTENSIONS versions.
|
||||
* What about other compilers? If, as the MinGW Web site says MinGW
|
||||
* does, the other compilers just use Microsoft's run-time library,
|
||||
* then they should probably use the _MSC_EXTENSIONS even if the
|
||||
* compiler doesn't define _MSC_EXTENSIONS.
|
||||
*
|
||||
* XXX - we currently aren't using any of these, but this allows
|
||||
* their use in the future.
|
||||
*/
|
||||
#ifndef PRId64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRId64 "I64d"
|
||||
#else
|
||||
#define PRId64 "lld"
|
||||
#endif
|
||||
#endif /* PRId64 */
|
||||
|
||||
#ifndef PRIo64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRIo64 "I64o"
|
||||
#else
|
||||
#define PRIo64 "llo"
|
||||
#endif
|
||||
#endif /* PRIo64 */
|
||||
|
||||
#ifndef PRIx64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRIx64 "I64x"
|
||||
#else
|
||||
#define PRIx64 "llx"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PRIu64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRIu64 "I64u"
|
||||
#else
|
||||
#define PRIu64 "llu"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MSVC's support library doesn't support %zu to print a size_t until
|
||||
* Visual Studio 2017, but supports %Iu earlier, so use that.
|
||||
*/
|
||||
#define PRIsize "Iu"
|
||||
#elif defined(__MINGW32__) || !defined(_WIN32)
|
||||
/*
|
||||
* Compiler is MinGW or target is UN*X or MS-DOS. Just use
|
||||
* <inttypes.h>.
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
|
||||
/*
|
||||
* Assume the support library supports %zu; it's required by C99.
|
||||
*/
|
||||
#define PRIsize "zu"
|
||||
#endif
|
||||
|
||||
#endif /* pcap/pcap-inttypes.h */
|
||||
976
network/arpicmplab/start/lib/npcap/Include/pcap/pcap.h
Normal file
976
network/arpicmplab/start/lib/npcap/Include/pcap/pcap.h
Normal file
@ -0,0 +1,976 @@
|
||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Remote packet capture mechanisms and extensions from WinPcap:
|
||||
*
|
||||
* Copyright (c) 2002 - 2003
|
||||
* NetGroup, Politecnico di Torino (Italy)
|
||||
* 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 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_pcap_h
|
||||
#define lib_pcap_pcap_h
|
||||
|
||||
#include <pcap/funcattrs.h>
|
||||
|
||||
#include <pcap/pcap-inttypes.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <winsock2.h> /* u_int, u_char etc. */
|
||||
#include <io.h> /* _get_osfhandle() */
|
||||
#elif defined(MSDOS)
|
||||
#include <sys/types.h> /* u_int, u_char etc. */
|
||||
#include <sys/socket.h>
|
||||
#else /* UN*X */
|
||||
#include <sys/types.h> /* u_int, u_char etc. */
|
||||
#include <sys/time.h>
|
||||
#endif /* _WIN32/MSDOS/UN*X */
|
||||
|
||||
#include <pcap/socket.h> /* for SOCKET, as the active-mode rpcap APIs use it */
|
||||
|
||||
#ifndef PCAP_DONT_INCLUDE_PCAP_BPF_H
|
||||
#include <pcap/bpf.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Version number of the current version of the pcap file format.
|
||||
*
|
||||
* NOTE: this is *NOT* the version number of the libpcap library.
|
||||
* To fetch the version information for the version of libpcap
|
||||
* you're using, use pcap_lib_version().
|
||||
*/
|
||||
#define PCAP_VERSION_MAJOR 2
|
||||
#define PCAP_VERSION_MINOR 4
|
||||
|
||||
#define PCAP_ERRBUF_SIZE 256
|
||||
|
||||
/*
|
||||
* Compatibility for systems that have a bpf.h that
|
||||
* predates the bpf typedefs for 64-bit support.
|
||||
*/
|
||||
#if BPF_RELEASE - 0 < 199406
|
||||
typedef int bpf_int32;
|
||||
typedef u_int bpf_u_int32;
|
||||
#endif
|
||||
|
||||
typedef struct pcap pcap_t;
|
||||
typedef struct pcap_dumper pcap_dumper_t;
|
||||
typedef struct pcap_if pcap_if_t;
|
||||
typedef struct pcap_addr pcap_addr_t;
|
||||
|
||||
/*
|
||||
* The first record in the file contains saved values for some
|
||||
* of the flags used in the printout phases of tcpdump.
|
||||
* Many fields here are 32 bit ints so compilers won't insert unwanted
|
||||
* padding; these files need to be interchangeable across architectures.
|
||||
*
|
||||
* Do not change the layout of this structure, in any way (this includes
|
||||
* changes that only affect the length of fields in this structure).
|
||||
*
|
||||
* Also, do not change the interpretation of any of the members of this
|
||||
* structure, in any way (this includes using values other than
|
||||
* LINKTYPE_ values, as defined in "savefile.c", in the "linktype"
|
||||
* field).
|
||||
*
|
||||
* Instead:
|
||||
*
|
||||
* introduce a new structure for the new format, if the layout
|
||||
* of the structure changed;
|
||||
*
|
||||
* send mail to "tcpdump-workers@lists.tcpdump.org", requesting
|
||||
* a new magic number for your new capture file format, and, when
|
||||
* you get the new magic number, put it in "savefile.c";
|
||||
*
|
||||
* use that magic number for save files with the changed file
|
||||
* header;
|
||||
*
|
||||
* make the code in "savefile.c" capable of reading files with
|
||||
* the old file header as well as files with the new file header
|
||||
* (using the magic number to determine the header format).
|
||||
*
|
||||
* Then supply the changes by forking the branch at
|
||||
*
|
||||
* https://github.com/the-tcpdump-group/libpcap/issues
|
||||
*
|
||||
* and issuing a pull request, so that future versions of libpcap and
|
||||
* programs that use it (such as tcpdump) will be able to read your new
|
||||
* capture file format.
|
||||
*/
|
||||
struct pcap_file_header {
|
||||
bpf_u_int32 magic;
|
||||
u_short version_major;
|
||||
u_short version_minor;
|
||||
bpf_int32 thiszone; /* gmt to local correction */
|
||||
bpf_u_int32 sigfigs; /* accuracy of timestamps */
|
||||
bpf_u_int32 snaplen; /* max length saved portion of each pkt */
|
||||
bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */
|
||||
};
|
||||
|
||||
/*
|
||||
* Macros for the value returned by pcap_datalink_ext().
|
||||
*
|
||||
* If LT_FCS_LENGTH_PRESENT(x) is true, the LT_FCS_LENGTH(x) macro
|
||||
* gives the FCS length of packets in the capture.
|
||||
*/
|
||||
#define LT_FCS_LENGTH_PRESENT(x) ((x) & 0x04000000)
|
||||
#define LT_FCS_LENGTH(x) (((x) & 0xF0000000) >> 28)
|
||||
#define LT_FCS_DATALINK_EXT(x) ((((x) & 0xF) << 28) | 0x04000000)
|
||||
|
||||
typedef enum {
|
||||
PCAP_D_INOUT = 0,
|
||||
PCAP_D_IN,
|
||||
PCAP_D_OUT
|
||||
} pcap_direction_t;
|
||||
|
||||
/*
|
||||
* Generic per-packet information, as supplied by libpcap.
|
||||
*
|
||||
* The time stamp can and should be a "struct timeval", regardless of
|
||||
* whether your system supports 32-bit tv_sec in "struct timeval",
|
||||
* 64-bit tv_sec in "struct timeval", or both if it supports both 32-bit
|
||||
* and 64-bit applications. The on-disk format of savefiles uses 32-bit
|
||||
* tv_sec (and tv_usec); this structure is irrelevant to that. 32-bit
|
||||
* and 64-bit versions of libpcap, even if they're on the same platform,
|
||||
* should supply the appropriate version of "struct timeval", even if
|
||||
* that's not what the underlying packet capture mechanism supplies.
|
||||
*/
|
||||
struct pcap_pkthdr {
|
||||
struct timeval ts; /* time stamp */
|
||||
bpf_u_int32 caplen; /* length of portion present */
|
||||
bpf_u_int32 len; /* length this packet (off wire) */
|
||||
};
|
||||
|
||||
/*
|
||||
* As returned by the pcap_stats()
|
||||
*/
|
||||
struct pcap_stat {
|
||||
u_int ps_recv; /* number of packets received */
|
||||
u_int ps_drop; /* number of packets dropped */
|
||||
u_int ps_ifdrop; /* drops by interface -- only supported on some platforms */
|
||||
#ifdef _WIN32
|
||||
u_int ps_capt; /* number of packets that reach the application */
|
||||
u_int ps_sent; /* number of packets sent by the server on the network */
|
||||
u_int ps_netdrop; /* number of packets lost on the network */
|
||||
#endif /* _WIN32 */
|
||||
};
|
||||
|
||||
#ifdef MSDOS
|
||||
/*
|
||||
* As returned by the pcap_stats_ex()
|
||||
*/
|
||||
struct pcap_stat_ex {
|
||||
u_long rx_packets; /* total packets received */
|
||||
u_long tx_packets; /* total packets transmitted */
|
||||
u_long rx_bytes; /* total bytes received */
|
||||
u_long tx_bytes; /* total bytes transmitted */
|
||||
u_long rx_errors; /* bad packets received */
|
||||
u_long tx_errors; /* packet transmit problems */
|
||||
u_long rx_dropped; /* no space in Rx buffers */
|
||||
u_long tx_dropped; /* no space available for Tx */
|
||||
u_long multicast; /* multicast packets received */
|
||||
u_long collisions;
|
||||
|
||||
/* detailed rx_errors: */
|
||||
u_long rx_length_errors;
|
||||
u_long rx_over_errors; /* receiver ring buff overflow */
|
||||
u_long rx_crc_errors; /* recv'd pkt with crc error */
|
||||
u_long rx_frame_errors; /* recv'd frame alignment error */
|
||||
u_long rx_fifo_errors; /* recv'r fifo overrun */
|
||||
u_long rx_missed_errors; /* recv'r missed packet */
|
||||
|
||||
/* detailed tx_errors */
|
||||
u_long tx_aborted_errors;
|
||||
u_long tx_carrier_errors;
|
||||
u_long tx_fifo_errors;
|
||||
u_long tx_heartbeat_errors;
|
||||
u_long tx_window_errors;
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Item in a list of interfaces.
|
||||
*/
|
||||
struct pcap_if {
|
||||
struct pcap_if *next;
|
||||
char *name; /* name to hand to "pcap_open_live()" */
|
||||
char *description; /* textual description of interface, or NULL */
|
||||
struct pcap_addr *addresses;
|
||||
bpf_u_int32 flags; /* PCAP_IF_ interface flags */
|
||||
};
|
||||
|
||||
#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */
|
||||
#define PCAP_IF_UP 0x00000002 /* interface is up */
|
||||
#define PCAP_IF_RUNNING 0x00000004 /* interface is running */
|
||||
#define PCAP_IF_WIRELESS 0x00000008 /* interface is wireless (*NOT* necessarily Wi-Fi!) */
|
||||
#define PCAP_IF_CONNECTION_STATUS 0x00000030 /* connection status: */
|
||||
#define PCAP_IF_CONNECTION_STATUS_UNKNOWN 0x00000000 /* unknown */
|
||||
#define PCAP_IF_CONNECTION_STATUS_CONNECTED 0x00000010 /* connected */
|
||||
#define PCAP_IF_CONNECTION_STATUS_DISCONNECTED 0x00000020 /* disconnected */
|
||||
#define PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE 0x00000030 /* not applicable */
|
||||
|
||||
/*
|
||||
* Representation of an interface address.
|
||||
*/
|
||||
struct pcap_addr {
|
||||
struct pcap_addr *next;
|
||||
struct sockaddr *addr; /* address */
|
||||
struct sockaddr *netmask; /* netmask for that address */
|
||||
struct sockaddr *broadaddr; /* broadcast address for that address */
|
||||
struct sockaddr *dstaddr; /* P2P destination address for that address */
|
||||
};
|
||||
|
||||
typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
|
||||
const u_char *);
|
||||
|
||||
/*
|
||||
* Error codes for the pcap API.
|
||||
* These will all be negative, so you can check for the success or
|
||||
* failure of a call that returns these codes by checking for a
|
||||
* negative value.
|
||||
*/
|
||||
#define PCAP_ERROR -1 /* generic error code */
|
||||
#define PCAP_ERROR_BREAK -2 /* loop terminated by pcap_breakloop */
|
||||
#define PCAP_ERROR_NOT_ACTIVATED -3 /* the capture needs to be activated */
|
||||
#define PCAP_ERROR_ACTIVATED -4 /* the operation can't be performed on already activated captures */
|
||||
#define PCAP_ERROR_NO_SUCH_DEVICE -5 /* no such device exists */
|
||||
#define PCAP_ERROR_RFMON_NOTSUP -6 /* this device doesn't support rfmon (monitor) mode */
|
||||
#define PCAP_ERROR_NOT_RFMON -7 /* operation supported only in monitor mode */
|
||||
#define PCAP_ERROR_PERM_DENIED -8 /* no permission to open the device */
|
||||
#define PCAP_ERROR_IFACE_NOT_UP -9 /* interface isn't up */
|
||||
#define PCAP_ERROR_CANTSET_TSTAMP_TYPE -10 /* this device doesn't support setting the time stamp type */
|
||||
#define PCAP_ERROR_PROMISC_PERM_DENIED -11 /* you don't have permission to capture in promiscuous mode */
|
||||
#define PCAP_ERROR_TSTAMP_PRECISION_NOTSUP -12 /* the requested time stamp precision is not supported */
|
||||
|
||||
/*
|
||||
* Warning codes for the pcap API.
|
||||
* These will all be positive and non-zero, so they won't look like
|
||||
* errors.
|
||||
*/
|
||||
#define PCAP_WARNING 1 /* generic warning code */
|
||||
#define PCAP_WARNING_PROMISC_NOTSUP 2 /* this device doesn't support promiscuous mode */
|
||||
#define PCAP_WARNING_TSTAMP_TYPE_NOTSUP 3 /* the requested time stamp type is not supported */
|
||||
|
||||
/*
|
||||
* Value to pass to pcap_compile() as the netmask if you don't know what
|
||||
* the netmask is.
|
||||
*/
|
||||
#define PCAP_NETMASK_UNKNOWN 0xffffffff
|
||||
|
||||
/*
|
||||
* We're deprecating pcap_lookupdev() for various reasons (not
|
||||
* thread-safe, can behave weirdly with WinPcap). Callers
|
||||
* should use pcap_findalldevs() and use the first device.
|
||||
*/
|
||||
PCAP_API char *pcap_lookupdev(char *)
|
||||
PCAP_DEPRECATED(pcap_lookupdev, "use 'pcap_findalldevs' and use the first device");
|
||||
|
||||
PCAP_API int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
|
||||
|
||||
PCAP_API pcap_t *pcap_create(const char *, char *);
|
||||
PCAP_API int pcap_set_snaplen(pcap_t *, int);
|
||||
PCAP_API int pcap_set_promisc(pcap_t *, int);
|
||||
PCAP_API int pcap_can_set_rfmon(pcap_t *);
|
||||
PCAP_API int pcap_set_rfmon(pcap_t *, int);
|
||||
PCAP_API int pcap_set_timeout(pcap_t *, int);
|
||||
PCAP_API int pcap_set_tstamp_type(pcap_t *, int);
|
||||
PCAP_API int pcap_set_immediate_mode(pcap_t *, int);
|
||||
PCAP_API int pcap_set_buffer_size(pcap_t *, int);
|
||||
PCAP_API int pcap_set_tstamp_precision(pcap_t *, int);
|
||||
PCAP_API int pcap_get_tstamp_precision(pcap_t *);
|
||||
PCAP_API int pcap_activate(pcap_t *);
|
||||
|
||||
PCAP_API int pcap_list_tstamp_types(pcap_t *, int **);
|
||||
PCAP_API void pcap_free_tstamp_types(int *);
|
||||
PCAP_API int pcap_tstamp_type_name_to_val(const char *);
|
||||
PCAP_API const char *pcap_tstamp_type_val_to_name(int);
|
||||
PCAP_API const char *pcap_tstamp_type_val_to_description(int);
|
||||
|
||||
#ifdef __linux__
|
||||
PCAP_API int pcap_set_protocol_linux(pcap_t *, int);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Time stamp types.
|
||||
* Not all systems and interfaces will necessarily support all of these.
|
||||
*
|
||||
* A system that supports PCAP_TSTAMP_HOST is offering time stamps
|
||||
* provided by the host machine, rather than by the capture device,
|
||||
* but not committing to any characteristics of the time stamp;
|
||||
* it will not offer any of the PCAP_TSTAMP_HOST_ subtypes.
|
||||
*
|
||||
* PCAP_TSTAMP_HOST_LOWPREC is a time stamp, provided by the host machine,
|
||||
* that's low-precision but relatively cheap to fetch; it's normally done
|
||||
* using the system clock, so it's normally synchronized with times you'd
|
||||
* fetch from system calls.
|
||||
*
|
||||
* PCAP_TSTAMP_HOST_HIPREC is a time stamp, provided by the host machine,
|
||||
* that's high-precision; it might be more expensive to fetch. It might
|
||||
* or might not be synchronized with the system clock, and might have
|
||||
* problems with time stamps for packets received on different CPUs,
|
||||
* depending on the platform.
|
||||
*
|
||||
* PCAP_TSTAMP_ADAPTER is a high-precision time stamp supplied by the
|
||||
* capture device; it's synchronized with the system clock.
|
||||
*
|
||||
* PCAP_TSTAMP_ADAPTER_UNSYNCED is a high-precision time stamp supplied by
|
||||
* the capture device; it's not synchronized with the system clock.
|
||||
*
|
||||
* Note that time stamps synchronized with the system clock can go
|
||||
* backwards, as the system clock can go backwards. If a clock is
|
||||
* not in sync with the system clock, that could be because the
|
||||
* system clock isn't keeping accurate time, because the other
|
||||
* clock isn't keeping accurate time, or both.
|
||||
*
|
||||
* Note that host-provided time stamps generally correspond to the
|
||||
* time when the time-stamping code sees the packet; this could
|
||||
* be some unknown amount of time after the first or last bit of
|
||||
* the packet is received by the network adapter, due to batching
|
||||
* of interrupts for packet arrival, queueing delays, etc..
|
||||
*/
|
||||
#define PCAP_TSTAMP_HOST 0 /* host-provided, unknown characteristics */
|
||||
#define PCAP_TSTAMP_HOST_LOWPREC 1 /* host-provided, low precision */
|
||||
#define PCAP_TSTAMP_HOST_HIPREC 2 /* host-provided, high precision */
|
||||
#define PCAP_TSTAMP_ADAPTER 3 /* device-provided, synced with the system clock */
|
||||
#define PCAP_TSTAMP_ADAPTER_UNSYNCED 4 /* device-provided, not synced with the system clock */
|
||||
|
||||
/*
|
||||
* Time stamp resolution types.
|
||||
* Not all systems and interfaces will necessarily support all of these
|
||||
* resolutions when doing live captures; all of them can be requested
|
||||
* when reading a savefile.
|
||||
*/
|
||||
#define PCAP_TSTAMP_PRECISION_MICRO 0 /* use timestamps with microsecond precision, default */
|
||||
#define PCAP_TSTAMP_PRECISION_NANO 1 /* use timestamps with nanosecond precision */
|
||||
|
||||
PCAP_API pcap_t *pcap_open_live(const char *, int, int, int, char *);
|
||||
PCAP_API pcap_t *pcap_open_dead(int, int);
|
||||
PCAP_API pcap_t *pcap_open_dead_with_tstamp_precision(int, int, u_int);
|
||||
PCAP_API pcap_t *pcap_open_offline_with_tstamp_precision(const char *, u_int, char *);
|
||||
PCAP_API pcap_t *pcap_open_offline(const char *, char *);
|
||||
#ifdef _WIN32
|
||||
PCAP_API pcap_t *pcap_hopen_offline_with_tstamp_precision(intptr_t, u_int, char *);
|
||||
PCAP_API pcap_t *pcap_hopen_offline(intptr_t, char *);
|
||||
/*
|
||||
* If we're building libpcap, these are internal routines in savefile.c,
|
||||
* so we must not define them as macros.
|
||||
*
|
||||
* If we're not building libpcap, given that the version of the C runtime
|
||||
* with which libpcap was built might be different from the version
|
||||
* of the C runtime with which an application using libpcap was built,
|
||||
* and that a FILE structure may differ between the two versions of the
|
||||
* C runtime, calls to _fileno() must use the version of _fileno() in
|
||||
* the C runtime used to open the FILE *, not the version in the C
|
||||
* runtime with which libpcap was built. (Maybe once the Universal CRT
|
||||
* rules the world, this will cease to be a problem.)
|
||||
*/
|
||||
#ifndef BUILDING_PCAP
|
||||
#define pcap_fopen_offline_with_tstamp_precision(f,p,b) \
|
||||
pcap_hopen_offline_with_tstamp_precision(_get_osfhandle(_fileno(f)), p, b)
|
||||
#define pcap_fopen_offline(f,b) \
|
||||
pcap_hopen_offline(_get_osfhandle(_fileno(f)), b)
|
||||
#endif
|
||||
#else /*_WIN32*/
|
||||
PCAP_API pcap_t *pcap_fopen_offline_with_tstamp_precision(FILE *, u_int, char *);
|
||||
PCAP_API pcap_t *pcap_fopen_offline(FILE *, char *);
|
||||
#endif /*_WIN32*/
|
||||
|
||||
PCAP_API void pcap_close(pcap_t *);
|
||||
PCAP_API int pcap_loop(pcap_t *, int, pcap_handler, u_char *);
|
||||
PCAP_API int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *);
|
||||
PCAP_API const u_char *pcap_next(pcap_t *, struct pcap_pkthdr *);
|
||||
PCAP_API int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **);
|
||||
PCAP_API void pcap_breakloop(pcap_t *);
|
||||
PCAP_API int pcap_stats(pcap_t *, struct pcap_stat *);
|
||||
PCAP_API int pcap_setfilter(pcap_t *, struct bpf_program *);
|
||||
PCAP_API int pcap_setdirection(pcap_t *, pcap_direction_t);
|
||||
PCAP_API int pcap_getnonblock(pcap_t *, char *);
|
||||
PCAP_API int pcap_setnonblock(pcap_t *, int, char *);
|
||||
PCAP_API int pcap_inject(pcap_t *, const void *, size_t);
|
||||
PCAP_API int pcap_sendpacket(pcap_t *, const u_char *, int);
|
||||
PCAP_API const char *pcap_statustostr(int);
|
||||
PCAP_API const char *pcap_strerror(int);
|
||||
PCAP_API char *pcap_geterr(pcap_t *);
|
||||
PCAP_API void pcap_perror(pcap_t *, const char *);
|
||||
PCAP_API int pcap_compile(pcap_t *, struct bpf_program *, const char *, int,
|
||||
bpf_u_int32);
|
||||
PCAP_API int pcap_compile_nopcap(int, int, struct bpf_program *,
|
||||
const char *, int, bpf_u_int32);
|
||||
PCAP_API void pcap_freecode(struct bpf_program *);
|
||||
PCAP_API int pcap_offline_filter(const struct bpf_program *,
|
||||
const struct pcap_pkthdr *, const u_char *);
|
||||
PCAP_API int pcap_datalink(pcap_t *);
|
||||
PCAP_API int pcap_datalink_ext(pcap_t *);
|
||||
PCAP_API int pcap_list_datalinks(pcap_t *, int **);
|
||||
PCAP_API int pcap_set_datalink(pcap_t *, int);
|
||||
PCAP_API void pcap_free_datalinks(int *);
|
||||
PCAP_API int pcap_datalink_name_to_val(const char *);
|
||||
PCAP_API const char *pcap_datalink_val_to_name(int);
|
||||
PCAP_API const char *pcap_datalink_val_to_description(int);
|
||||
PCAP_API const char *pcap_datalink_val_to_description_or_dlt(int);
|
||||
PCAP_API int pcap_snapshot(pcap_t *);
|
||||
PCAP_API int pcap_is_swapped(pcap_t *);
|
||||
PCAP_API int pcap_major_version(pcap_t *);
|
||||
PCAP_API int pcap_minor_version(pcap_t *);
|
||||
PCAP_API int pcap_bufsize(pcap_t *);
|
||||
|
||||
/* XXX */
|
||||
PCAP_API FILE *pcap_file(pcap_t *);
|
||||
PCAP_API int pcap_fileno(pcap_t *);
|
||||
|
||||
#ifdef _WIN32
|
||||
PCAP_API int pcap_wsockinit(void);
|
||||
#endif
|
||||
|
||||
PCAP_API pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
|
||||
#ifdef _WIN32
|
||||
PCAP_API pcap_dumper_t *pcap_dump_hopen(pcap_t *, intptr_t);
|
||||
/*
|
||||
* If we're building libpcap, this is an internal routine in sf-pcap.c, so
|
||||
* we must not define it as a macro.
|
||||
*
|
||||
* If we're not building libpcap, given that the version of the C runtime
|
||||
* with which libpcap was built might be different from the version
|
||||
* of the C runtime with which an application using libpcap was built,
|
||||
* and that a FILE structure may differ between the two versions of the
|
||||
* C runtime, calls to _fileno() must use the version of _fileno() in
|
||||
* the C runtime used to open the FILE *, not the version in the C
|
||||
* runtime with which libpcap was built. (Maybe once the Universal CRT
|
||||
* rules the world, this will cease to be a problem.)
|
||||
*/
|
||||
#ifndef BUILDING_PCAP
|
||||
#define pcap_dump_fopen(p,f) \
|
||||
pcap_dump_hopen(p, _get_osfhandle(_fileno(f)))
|
||||
#endif
|
||||
#else /*_WIN32*/
|
||||
PCAP_API pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp);
|
||||
#endif /*_WIN32*/
|
||||
PCAP_API pcap_dumper_t *pcap_dump_open_append(pcap_t *, const char *);
|
||||
PCAP_API FILE *pcap_dump_file(pcap_dumper_t *);
|
||||
PCAP_API long pcap_dump_ftell(pcap_dumper_t *);
|
||||
PCAP_API int64_t pcap_dump_ftell64(pcap_dumper_t *);
|
||||
PCAP_API int pcap_dump_flush(pcap_dumper_t *);
|
||||
PCAP_API void pcap_dump_close(pcap_dumper_t *);
|
||||
PCAP_API void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
PCAP_API int pcap_findalldevs(pcap_if_t **, char *);
|
||||
PCAP_API void pcap_freealldevs(pcap_if_t *);
|
||||
|
||||
/*
|
||||
* We return a pointer to the version string, rather than exporting the
|
||||
* version string directly.
|
||||
*
|
||||
* On at least some UNIXes, if you import data from a shared library into
|
||||
* an program, the data is bound into the program binary, so if the string
|
||||
* in the version of the library with which the program was linked isn't
|
||||
* the same as the string in the version of the library with which the
|
||||
* program is being run, various undesirable things may happen (warnings,
|
||||
* the string being the one from the version of the library with which the
|
||||
* program was linked, or even weirder things, such as the string being the
|
||||
* one from the library but being truncated).
|
||||
*
|
||||
* On Windows, the string is constructed at run time.
|
||||
*/
|
||||
PCAP_API const char *pcap_lib_version(void);
|
||||
|
||||
/*
|
||||
* On at least some versions of NetBSD and QNX, we don't want to declare
|
||||
* bpf_filter() here, as it's also be declared in <net/bpf.h>, with a
|
||||
* different signature, but, on other BSD-flavored UN*Xes, it's not
|
||||
* declared in <net/bpf.h>, so we *do* want to declare it here, so it's
|
||||
* declared when we build pcap-bpf.c.
|
||||
*/
|
||||
#if !defined(__NetBSD__) && !defined(__QNX__)
|
||||
PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
|
||||
#endif
|
||||
PCAP_API int bpf_validate(const struct bpf_insn *f, int len);
|
||||
PCAP_API char *bpf_image(const struct bpf_insn *, int);
|
||||
PCAP_API void bpf_dump(const struct bpf_program *, int);
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
/*
|
||||
* Win32 definitions
|
||||
*/
|
||||
|
||||
/*!
|
||||
\brief A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit().
|
||||
*/
|
||||
struct pcap_send_queue
|
||||
{
|
||||
u_int maxlen; /* Maximum size of the queue, in bytes. This
|
||||
variable contains the size of the buffer field. */
|
||||
u_int len; /* Current size of the queue, in bytes. */
|
||||
char *buffer; /* Buffer containing the packets to be sent. */
|
||||
};
|
||||
|
||||
typedef struct pcap_send_queue pcap_send_queue;
|
||||
|
||||
/*!
|
||||
\brief This typedef is a support for the pcap_get_airpcap_handle() function
|
||||
*/
|
||||
#if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_)
|
||||
#define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_
|
||||
typedef struct _AirpcapHandle *PAirpcapHandle;
|
||||
#endif
|
||||
|
||||
PCAP_API int pcap_setbuff(pcap_t *p, int dim);
|
||||
PCAP_API int pcap_setmode(pcap_t *p, int mode);
|
||||
PCAP_API int pcap_setmintocopy(pcap_t *p, int size);
|
||||
|
||||
PCAP_API HANDLE pcap_getevent(pcap_t *p);
|
||||
|
||||
PCAP_API int pcap_oid_get_request(pcap_t *, bpf_u_int32, void *, size_t *);
|
||||
PCAP_API int pcap_oid_set_request(pcap_t *, bpf_u_int32, const void *, size_t *);
|
||||
|
||||
PCAP_API pcap_send_queue* pcap_sendqueue_alloc(u_int memsize);
|
||||
|
||||
PCAP_API void pcap_sendqueue_destroy(pcap_send_queue* queue);
|
||||
|
||||
PCAP_API int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data);
|
||||
|
||||
PCAP_API u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync);
|
||||
|
||||
PCAP_API struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size);
|
||||
|
||||
PCAP_API int pcap_setuserbuffer(pcap_t *p, int size);
|
||||
|
||||
PCAP_API int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks);
|
||||
|
||||
PCAP_API int pcap_live_dump_ended(pcap_t *p, int sync);
|
||||
|
||||
PCAP_API int pcap_start_oem(char* err_str, int flags);
|
||||
|
||||
PCAP_API PAirpcapHandle pcap_get_airpcap_handle(pcap_t *p);
|
||||
|
||||
#define MODE_CAPT 0
|
||||
#define MODE_STAT 1
|
||||
#define MODE_MON 2
|
||||
|
||||
#elif defined(MSDOS)
|
||||
|
||||
/*
|
||||
* MS-DOS definitions
|
||||
*/
|
||||
|
||||
PCAP_API int pcap_stats_ex (pcap_t *, struct pcap_stat_ex *);
|
||||
PCAP_API void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait);
|
||||
PCAP_API u_long pcap_mac_packets (void);
|
||||
|
||||
#else /* UN*X */
|
||||
|
||||
/*
|
||||
* UN*X definitions
|
||||
*/
|
||||
|
||||
PCAP_API int pcap_get_selectable_fd(pcap_t *);
|
||||
PCAP_API struct timeval *pcap_get_required_select_timeout(pcap_t *);
|
||||
|
||||
#endif /* _WIN32/MSDOS/UN*X */
|
||||
|
||||
/*
|
||||
* Remote capture definitions.
|
||||
*
|
||||
* These routines are only present if libpcap has been configured to
|
||||
* include remote capture support.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The maximum buffer size in which address, port, interface names are kept.
|
||||
*
|
||||
* In case the adapter name or such is larger than this value, it is truncated.
|
||||
* This is not used by the user; however it must be aware that an hostname / interface
|
||||
* name longer than this value will be truncated.
|
||||
*/
|
||||
#define PCAP_BUF_SIZE 1024
|
||||
|
||||
/*
|
||||
* The type of input source, passed to pcap_open().
|
||||
*/
|
||||
#define PCAP_SRC_FILE 2 /* local savefile */
|
||||
#define PCAP_SRC_IFLOCAL 3 /* local network interface */
|
||||
#define PCAP_SRC_IFREMOTE 4 /* interface on a remote host, using RPCAP */
|
||||
|
||||
/*
|
||||
* The formats allowed by pcap_open() are the following:
|
||||
* - file://path_and_filename [opens a local file]
|
||||
* - rpcap://devicename [opens the selected device devices available on the local host, without using the RPCAP protocol]
|
||||
* - rpcap://host/devicename [opens the selected device available on a remote host]
|
||||
* - rpcap://host:port/devicename [opens the selected device available on a remote host, using a non-standard port for RPCAP]
|
||||
* - adaptername [to open a local adapter; kept for compability, but it is strongly discouraged]
|
||||
* - (NULL) [to open the first local adapter; kept for compability, but it is strongly discouraged]
|
||||
*
|
||||
* The formats allowed by the pcap_findalldevs_ex() are the following:
|
||||
* - file://folder/ [lists all the files in the given folder]
|
||||
* - rpcap:// [lists all local adapters]
|
||||
* - rpcap://host:port/ [lists the devices available on a remote host]
|
||||
*
|
||||
* Referring to the 'host' and 'port' parameters, they can be either numeric or literal. Since
|
||||
* IPv6 is fully supported, these are the allowed formats:
|
||||
*
|
||||
* - host (literal): e.g. host.foo.bar
|
||||
* - host (numeric IPv4): e.g. 10.11.12.13
|
||||
* - host (numeric IPv4, IPv6 style): e.g. [10.11.12.13]
|
||||
* - host (numeric IPv6): e.g. [1:2:3::4]
|
||||
* - port: can be either numeric (e.g. '80') or literal (e.g. 'http')
|
||||
*
|
||||
* Here you find some allowed examples:
|
||||
* - rpcap://host.foo.bar/devicename [everything literal, no port number]
|
||||
* - rpcap://host.foo.bar:1234/devicename [everything literal, with port number]
|
||||
* - rpcap://10.11.12.13/devicename [IPv4 numeric, no port number]
|
||||
* - rpcap://10.11.12.13:1234/devicename [IPv4 numeric, with port number]
|
||||
* - rpcap://[10.11.12.13]:1234/devicename [IPv4 numeric with IPv6 format, with port number]
|
||||
* - rpcap://[1:2:3::4]/devicename [IPv6 numeric, no port number]
|
||||
* - rpcap://[1:2:3::4]:1234/devicename [IPv6 numeric, with port number]
|
||||
* - rpcap://[1:2:3::4]:http/devicename [IPv6 numeric, with literal port number]
|
||||
*/
|
||||
|
||||
/*
|
||||
* URL schemes for capture source.
|
||||
*/
|
||||
/*
|
||||
* This string indicates that the user wants to open a capture from a
|
||||
* local file.
|
||||
*/
|
||||
#define PCAP_SRC_FILE_STRING "file://"
|
||||
/*
|
||||
* This string indicates that the user wants to open a capture from a
|
||||
* network interface. This string does not necessarily involve the use
|
||||
* of the RPCAP protocol. If the interface required resides on the local
|
||||
* host, the RPCAP protocol is not involved and the local functions are used.
|
||||
*/
|
||||
#define PCAP_SRC_IF_STRING "rpcap://"
|
||||
|
||||
/*
|
||||
* Flags to pass to pcap_open().
|
||||
*/
|
||||
|
||||
/*
|
||||
* Specifies whether promiscuous mode is to be used.
|
||||
*/
|
||||
#define PCAP_OPENFLAG_PROMISCUOUS 0x00000001
|
||||
|
||||
/*
|
||||
* Specifies, for an RPCAP capture, whether the data transfer (in
|
||||
* case of a remote capture) has to be done with UDP protocol.
|
||||
*
|
||||
* If it is '1' if you want a UDP data connection, '0' if you want
|
||||
* a TCP data connection; control connection is always TCP-based.
|
||||
* A UDP connection is much lighter, but it does not guarantee that all
|
||||
* the captured packets arrive to the client workstation. Moreover,
|
||||
* it could be harmful in case of network congestion.
|
||||
* This flag is meaningless if the source is not a remote interface.
|
||||
* In that case, it is simply ignored.
|
||||
*/
|
||||
#define PCAP_OPENFLAG_DATATX_UDP 0x00000002
|
||||
|
||||
/*
|
||||
* Specifies wheether the remote probe will capture its own generated
|
||||
* traffic.
|
||||
*
|
||||
* In case the remote probe uses the same interface to capture traffic
|
||||
* and to send data back to the caller, the captured traffic includes
|
||||
* the RPCAP traffic as well. If this flag is turned on, the RPCAP
|
||||
* traffic is excluded from the capture, so that the trace returned
|
||||
* back to the collector is does not include this traffic.
|
||||
*
|
||||
* Has no effect on local interfaces or savefiles.
|
||||
*/
|
||||
#define PCAP_OPENFLAG_NOCAPTURE_RPCAP 0x00000004
|
||||
|
||||
/*
|
||||
* Specifies whether the local adapter will capture its own generated traffic.
|
||||
*
|
||||
* This flag tells the underlying capture driver to drop the packets
|
||||
* that were sent by itself. This is useful when building applications
|
||||
* such as bridges that should ignore the traffic they just sent.
|
||||
*
|
||||
* Supported only on Windows.
|
||||
*/
|
||||
#define PCAP_OPENFLAG_NOCAPTURE_LOCAL 0x00000008
|
||||
|
||||
/*
|
||||
* This flag configures the adapter for maximum responsiveness.
|
||||
*
|
||||
* In presence of a large value for nbytes, WinPcap waits for the arrival
|
||||
* of several packets before copying the data to the user. This guarantees
|
||||
* a low number of system calls, i.e. lower processor usage, i.e. better
|
||||
* performance, which is good for applications like sniffers. If the user
|
||||
* sets the PCAP_OPENFLAG_MAX_RESPONSIVENESS flag, the capture driver will
|
||||
* copy the packets as soon as the application is ready to receive them.
|
||||
* This is suggested for real time applications (such as, for example,
|
||||
* a bridge) that need the best responsiveness.
|
||||
*
|
||||
* The equivalent with pcap_create()/pcap_activate() is "immediate mode".
|
||||
*/
|
||||
#define PCAP_OPENFLAG_MAX_RESPONSIVENESS 0x00000010
|
||||
|
||||
/*
|
||||
* Remote authentication methods.
|
||||
* These are used in the 'type' member of the pcap_rmtauth structure.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NULL authentication.
|
||||
*
|
||||
* The 'NULL' authentication has to be equal to 'zero', so that old
|
||||
* applications can just put every field of struct pcap_rmtauth to zero,
|
||||
* and it does work.
|
||||
*/
|
||||
#define RPCAP_RMTAUTH_NULL 0
|
||||
/*
|
||||
* Username/password authentication.
|
||||
*
|
||||
* With this type of authentication, the RPCAP protocol will use the username/
|
||||
* password provided to authenticate the user on the remote machine. If the
|
||||
* authentication is successful (and the user has the right to open network
|
||||
* devices) the RPCAP connection will continue; otherwise it will be dropped.
|
||||
*
|
||||
* *******NOTE********: the username and password are sent over the network
|
||||
* to the capture server *IN CLEAR TEXT*. Don't use this on a network
|
||||
* that you don't completely control! (And be *really* careful in your
|
||||
* definition of "completely"!)
|
||||
*/
|
||||
#define RPCAP_RMTAUTH_PWD 1
|
||||
|
||||
/*
|
||||
* This structure keeps the information needed to autheticate the user
|
||||
* on a remote machine.
|
||||
*
|
||||
* The remote machine can either grant or refuse the access according
|
||||
* to the information provided.
|
||||
* In case the NULL authentication is required, both 'username' and
|
||||
* 'password' can be NULL pointers.
|
||||
*
|
||||
* This structure is meaningless if the source is not a remote interface;
|
||||
* in that case, the functions which requires such a structure can accept
|
||||
* a NULL pointer as well.
|
||||
*/
|
||||
struct pcap_rmtauth
|
||||
{
|
||||
/*
|
||||
* \brief Type of the authentication required.
|
||||
*
|
||||
* In order to provide maximum flexibility, we can support different types
|
||||
* of authentication based on the value of this 'type' variable. The currently
|
||||
* supported authentication methods are defined into the
|
||||
* \link remote_auth_methods Remote Authentication Methods Section\endlink.
|
||||
*/
|
||||
int type;
|
||||
/*
|
||||
* \brief Zero-terminated string containing the username that has to be
|
||||
* used on the remote machine for authentication.
|
||||
*
|
||||
* This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication
|
||||
* and it can be NULL.
|
||||
*/
|
||||
char *username;
|
||||
/*
|
||||
* \brief Zero-terminated string containing the password that has to be
|
||||
* used on the remote machine for authentication.
|
||||
*
|
||||
* This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication
|
||||
* and it can be NULL.
|
||||
*/
|
||||
char *password;
|
||||
};
|
||||
|
||||
/*
|
||||
* This routine can open a savefile, a local device, or a device on
|
||||
* a remote machine running an RPCAP server.
|
||||
*
|
||||
* For opening a savefile, the pcap_open_offline routines can be used,
|
||||
* and will work just as well; code using them will work on more
|
||||
* platforms than code using pcap_open() to open savefiles.
|
||||
*
|
||||
* For opening a local device, pcap_open_live() can be used; it supports
|
||||
* most of the capabilities that pcap_open() supports, and code using it
|
||||
* will work on more platforms than code using pcap_open(). pcap_create()
|
||||
* and pcap_activate() can also be used; they support all capabilities
|
||||
* that pcap_open() supports, except for the Windows-only
|
||||
* PCAP_OPENFLAG_NOCAPTURE_LOCAL, and support additional capabilities.
|
||||
*
|
||||
* For opening a remote capture, pcap_open() is currently the only
|
||||
* API available.
|
||||
*/
|
||||
PCAP_API pcap_t *pcap_open(const char *source, int snaplen, int flags,
|
||||
int read_timeout, struct pcap_rmtauth *auth, char *errbuf);
|
||||
PCAP_API int pcap_createsrcstr(char *source, int type, const char *host,
|
||||
const char *port, const char *name, char *errbuf);
|
||||
PCAP_API int pcap_parsesrcstr(const char *source, int *type, char *host,
|
||||
char *port, char *name, char *errbuf);
|
||||
|
||||
/*
|
||||
* This routine can scan a directory for savefiles, list local capture
|
||||
* devices, or list capture devices on a remote machine running an RPCAP
|
||||
* server.
|
||||
*
|
||||
* For scanning for savefiles, it can be used on both UN*X systems and
|
||||
* Windows systems; for each directory entry it sees, it tries to open
|
||||
* the file as a savefile using pcap_open_offline(), and only includes
|
||||
* it in the list of files if the open succeeds, so it filters out
|
||||
* files for which the user doesn't have read permission, as well as
|
||||
* files that aren't valid savefiles readable by libpcap.
|
||||
*
|
||||
* For listing local capture devices, it's just a wrapper around
|
||||
* pcap_findalldevs(); code using pcap_findalldevs() will work on more
|
||||
* platforms than code using pcap_findalldevs_ex().
|
||||
*
|
||||
* For listing remote capture devices, pcap_findalldevs_ex() is currently
|
||||
* the only API available.
|
||||
*/
|
||||
PCAP_API int pcap_findalldevs_ex(const char *source,
|
||||
struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf);
|
||||
|
||||
/*
|
||||
* Sampling methods.
|
||||
*
|
||||
* These allow pcap_loop(), pcap_dispatch(), pcap_next(), and pcap_next_ex()
|
||||
* to see only a sample of packets, rather than all packets.
|
||||
*
|
||||
* Currently, they work only on Windows local captures.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Specifies that no sampling is to be done on the current capture.
|
||||
*
|
||||
* In this case, no sampling algorithms are applied to the current capture.
|
||||
*/
|
||||
#define PCAP_SAMP_NOSAMP 0
|
||||
|
||||
/*
|
||||
* Specifies that only 1 out of N packets must be returned to the user.
|
||||
*
|
||||
* In this case, the 'value' field of the 'pcap_samp' structure indicates the
|
||||
* number of packets (minus 1) that must be discarded before one packet got
|
||||
* accepted.
|
||||
* In other words, if 'value = 10', the first packet is returned to the
|
||||
* caller, while the following 9 are discarded.
|
||||
*/
|
||||
#define PCAP_SAMP_1_EVERY_N 1
|
||||
|
||||
/*
|
||||
* Specifies that we have to return 1 packet every N milliseconds.
|
||||
*
|
||||
* In this case, the 'value' field of the 'pcap_samp' structure indicates
|
||||
* the 'waiting time' in milliseconds before one packet got accepted.
|
||||
* In other words, if 'value = 10', the first packet is returned to the
|
||||
* caller; the next returned one will be the first packet that arrives
|
||||
* when 10ms have elapsed.
|
||||
*/
|
||||
#define PCAP_SAMP_FIRST_AFTER_N_MS 2
|
||||
|
||||
/*
|
||||
* This structure defines the information related to sampling.
|
||||
*
|
||||
* In case the sampling is requested, the capturing device should read
|
||||
* only a subset of the packets coming from the source. The returned packets
|
||||
* depend on the sampling parameters.
|
||||
*
|
||||
* WARNING: The sampling process is applied *after* the filtering process.
|
||||
* In other words, packets are filtered first, then the sampling process
|
||||
* selects a subset of the 'filtered' packets and it returns them to the
|
||||
* caller.
|
||||
*/
|
||||
struct pcap_samp
|
||||
{
|
||||
/*
|
||||
* Method used for sampling; see above.
|
||||
*/
|
||||
int method;
|
||||
|
||||
/*
|
||||
* This value depends on the sampling method defined.
|
||||
* For its meaning, see above.
|
||||
*/
|
||||
int value;
|
||||
};
|
||||
|
||||
/*
|
||||
* New functions.
|
||||
*/
|
||||
PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p);
|
||||
|
||||
/*
|
||||
* RPCAP active mode.
|
||||
*/
|
||||
|
||||
/* Maximum length of an host name (needed for the RPCAP active mode) */
|
||||
#define RPCAP_HOSTLIST_SIZE 1024
|
||||
|
||||
PCAP_API SOCKET pcap_remoteact_accept(const char *address, const char *port,
|
||||
const char *hostlist, char *connectinghost,
|
||||
struct pcap_rmtauth *auth, char *errbuf);
|
||||
PCAP_API int pcap_remoteact_list(char *hostlist, char sep, int size,
|
||||
char *errbuf);
|
||||
PCAP_API int pcap_remoteact_close(const char *host, char *errbuf);
|
||||
PCAP_API void pcap_remoteact_cleanup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* lib_pcap_pcap_h */
|
||||
149
network/arpicmplab/start/lib/npcap/Include/pcap/sll.h
Normal file
149
network/arpicmplab/start/lib/npcap/Include/pcap/sll.h
Normal file
@ -0,0 +1,149 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from the Stanford/CMU enet packet filter,
|
||||
* (net/enet.c) distributed as part of 4.3BSD, and code contributed
|
||||
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
|
||||
* Berkeley Laboratory.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* For captures on Linux cooked sockets, we construct a fake header
|
||||
* that includes:
|
||||
*
|
||||
* a 2-byte "packet type" which is one of:
|
||||
*
|
||||
* LINUX_SLL_HOST packet was sent to us
|
||||
* LINUX_SLL_BROADCAST packet was broadcast
|
||||
* LINUX_SLL_MULTICAST packet was multicast
|
||||
* LINUX_SLL_OTHERHOST packet was sent to somebody else
|
||||
* LINUX_SLL_OUTGOING packet was sent *by* us;
|
||||
*
|
||||
* a 2-byte Ethernet protocol field;
|
||||
*
|
||||
* a 2-byte link-layer type;
|
||||
*
|
||||
* a 2-byte link-layer address length;
|
||||
*
|
||||
* an 8-byte source link-layer address, whose actual length is
|
||||
* specified by the previous value.
|
||||
*
|
||||
* All fields except for the link-layer address are in network byte order.
|
||||
*
|
||||
* DO NOT change the layout of this structure, or change any of the
|
||||
* LINUX_SLL_ values below. If you must change the link-layer header
|
||||
* for a "cooked" Linux capture, introduce a new DLT_ type (ask
|
||||
* "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it
|
||||
* a value that collides with a value already being used), and use the
|
||||
* new header in captures of that type, so that programs that can
|
||||
* handle DLT_LINUX_SLL captures will continue to handle them correctly
|
||||
* without any change, and so that capture files with different headers
|
||||
* can be told apart and programs that read them can dissect the
|
||||
* packets in them.
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_sll_h
|
||||
#define lib_pcap_sll_h
|
||||
|
||||
#include <pcap/pcap-inttypes.h>
|
||||
|
||||
/*
|
||||
* A DLT_LINUX_SLL fake link-layer header.
|
||||
*/
|
||||
#define SLL_HDR_LEN 16 /* total header length */
|
||||
#define SLL_ADDRLEN 8 /* length of address field */
|
||||
|
||||
struct sll_header {
|
||||
uint16_t sll_pkttype; /* packet type */
|
||||
uint16_t sll_hatype; /* link-layer address type */
|
||||
uint16_t sll_halen; /* link-layer address length */
|
||||
uint8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */
|
||||
uint16_t sll_protocol; /* protocol */
|
||||
};
|
||||
|
||||
/*
|
||||
* A DLT_LINUX_SLL2 fake link-layer header.
|
||||
*/
|
||||
#define SLL2_HDR_LEN 20 /* total header length */
|
||||
|
||||
struct sll2_header {
|
||||
uint16_t sll2_protocol; /* protocol */
|
||||
uint16_t sll2_reserved_mbz; /* reserved - must be zero */
|
||||
uint32_t sll2_if_index; /* 1-based interface index */
|
||||
uint16_t sll2_hatype; /* link-layer address type */
|
||||
uint8_t sll2_pkttype; /* packet type */
|
||||
uint8_t sll2_halen; /* link-layer address length */
|
||||
uint8_t sll2_addr[SLL_ADDRLEN]; /* link-layer address */
|
||||
};
|
||||
|
||||
/*
|
||||
* The LINUX_SLL_ values for "sll_pkttype" and LINUX_SLL2_ values for
|
||||
* "sll2_pkttype"; these correspond to the PACKET_ values on Linux,
|
||||
* which are defined by a header under include/uapi in the current
|
||||
* kernel source, and are thus not going to change on Linux. We
|
||||
* define them here so that they're available even on systems other
|
||||
* than Linux.
|
||||
*/
|
||||
#define LINUX_SLL_HOST 0
|
||||
#define LINUX_SLL_BROADCAST 1
|
||||
#define LINUX_SLL_MULTICAST 2
|
||||
#define LINUX_SLL_OTHERHOST 3
|
||||
#define LINUX_SLL_OUTGOING 4
|
||||
|
||||
/*
|
||||
* The LINUX_SLL_ values for "sll_protocol" and LINUX_SLL2_ values for
|
||||
* "sll2_protocol"; these correspond to the ETH_P_ values on Linux, but
|
||||
* are defined here so that they're available even on systems other than
|
||||
* Linux. We assume, for now, that the ETH_P_ values won't change in
|
||||
* Linux; if they do, then:
|
||||
*
|
||||
* if we don't translate them in "pcap-linux.c", capture files
|
||||
* won't necessarily be readable if captured on a system that
|
||||
* defines ETH_P_ values that don't match these values;
|
||||
*
|
||||
* if we do translate them in "pcap-linux.c", that makes life
|
||||
* unpleasant for the BPF code generator, as the values you test
|
||||
* for in the kernel aren't the values that you test for when
|
||||
* reading a capture file, so the fixup code run on BPF programs
|
||||
* handed to the kernel ends up having to do more work.
|
||||
*
|
||||
* Add other values here as necessary, for handling packet types that
|
||||
* might show up on non-Ethernet, non-802.x networks. (Not all the ones
|
||||
* in the Linux "if_ether.h" will, I suspect, actually show up in
|
||||
* captures.)
|
||||
*/
|
||||
#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */
|
||||
#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */
|
||||
#define LINUX_SLL_P_CAN 0x000C /* CAN frames, with SocketCAN pseudo-headers */
|
||||
#define LINUX_SLL_P_CANFD 0x000D /* CAN FD frames, with SocketCAN pseudo-headers */
|
||||
|
||||
#endif
|
||||
93
network/arpicmplab/start/lib/npcap/Include/pcap/socket.h
Normal file
93
network/arpicmplab/start/lib/npcap/Include/pcap/socket.h
Normal file
@ -0,0 +1,93 @@
|
||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_socket_h
|
||||
#define lib_pcap_socket_h
|
||||
|
||||
/*
|
||||
* Some minor differences between sockets on various platforms.
|
||||
* We include whatever sockets are needed for Internet-protocol
|
||||
* socket access on UN*X and Windows.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
/* Need windef.h for defines used in winsock2.h under MingW32 */
|
||||
#ifdef __MINGW32__
|
||||
#include <windef.h>
|
||||
#endif
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/*
|
||||
* Winsock doesn't have this UN*X type; it's used in the UN*X
|
||||
* sockets API.
|
||||
*
|
||||
* XXX - do we need to worry about UN*Xes so old that *they*
|
||||
* don't have it, either?
|
||||
*/
|
||||
typedef int socklen_t;
|
||||
|
||||
/*
|
||||
* Winsock doesn't have this POSIX type; it's used for the
|
||||
* tv_usec value of struct timeval.
|
||||
*/
|
||||
typedef long suseconds_t;
|
||||
#else /* _WIN32 */
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h> /* for struct addrinfo/getaddrinfo() */
|
||||
#include <netinet/in.h> /* for sockaddr_in, in BSD at least */
|
||||
#include <arpa/inet.h>
|
||||
|
||||
/*!
|
||||
* \brief In Winsock, a socket handle is of type SOCKET; in UN*X, it's
|
||||
* a file descriptor, and therefore a signed integer.
|
||||
* We define SOCKET to be a signed integer on UN*X, so that it can
|
||||
* be used on both platforms.
|
||||
*/
|
||||
#ifndef SOCKET
|
||||
#define SOCKET int
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief In Winsock, the error return if socket() fails is INVALID_SOCKET;
|
||||
* in UN*X, it's -1.
|
||||
* We define INVALID_SOCKET to be -1 on UN*X, so that it can be used on
|
||||
* both platforms.
|
||||
*/
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#endif /* lib_pcap_socket_h */
|
||||
143
network/arpicmplab/start/lib/npcap/Include/pcap/usb.h
Normal file
143
network/arpicmplab/start/lib/npcap/Include/pcap/usb.h
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Paolo Abeni (Italy)
|
||||
* 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. The name of the author may not 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.
|
||||
*
|
||||
* Basic USB data struct
|
||||
* By Paolo Abeni <paolo.abeni@email.it>
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_usb_h
|
||||
#define lib_pcap_usb_h
|
||||
|
||||
#include <pcap/pcap-inttypes.h>
|
||||
|
||||
/*
|
||||
* possible transfer mode
|
||||
*/
|
||||
#define URB_TRANSFER_IN 0x80
|
||||
#define URB_ISOCHRONOUS 0x0
|
||||
#define URB_INTERRUPT 0x1
|
||||
#define URB_CONTROL 0x2
|
||||
#define URB_BULK 0x3
|
||||
|
||||
/*
|
||||
* possible event type
|
||||
*/
|
||||
#define URB_SUBMIT 'S'
|
||||
#define URB_COMPLETE 'C'
|
||||
#define URB_ERROR 'E'
|
||||
|
||||
/*
|
||||
* USB setup header as defined in USB specification.
|
||||
* Appears at the front of each Control S-type packet in DLT_USB captures.
|
||||
*/
|
||||
typedef struct _usb_setup {
|
||||
uint8_t bmRequestType;
|
||||
uint8_t bRequest;
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
uint16_t wLength;
|
||||
} pcap_usb_setup;
|
||||
|
||||
/*
|
||||
* Information from the URB for Isochronous transfers.
|
||||
*/
|
||||
typedef struct _iso_rec {
|
||||
int32_t error_count;
|
||||
int32_t numdesc;
|
||||
} iso_rec;
|
||||
|
||||
/*
|
||||
* Header prepended by linux kernel to each event.
|
||||
* Appears at the front of each packet in DLT_USB_LINUX captures.
|
||||
*/
|
||||
typedef struct _usb_header {
|
||||
uint64_t id;
|
||||
uint8_t event_type;
|
||||
uint8_t transfer_type;
|
||||
uint8_t endpoint_number;
|
||||
uint8_t device_address;
|
||||
uint16_t bus_id;
|
||||
char setup_flag;/*if !=0 the urb setup header is not present*/
|
||||
char data_flag; /*if !=0 no urb data is present*/
|
||||
int64_t ts_sec;
|
||||
int32_t ts_usec;
|
||||
int32_t status;
|
||||
uint32_t urb_len;
|
||||
uint32_t data_len; /* amount of urb data really present in this event*/
|
||||
pcap_usb_setup setup;
|
||||
} pcap_usb_header;
|
||||
|
||||
/*
|
||||
* Header prepended by linux kernel to each event for the 2.6.31
|
||||
* and later kernels; for the 2.6.21 through 2.6.30 kernels, the
|
||||
* "iso_rec" information, and the fields starting with "interval"
|
||||
* are zeroed-out padding fields.
|
||||
*
|
||||
* Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures.
|
||||
*/
|
||||
typedef struct _usb_header_mmapped {
|
||||
uint64_t id;
|
||||
uint8_t event_type;
|
||||
uint8_t transfer_type;
|
||||
uint8_t endpoint_number;
|
||||
uint8_t device_address;
|
||||
uint16_t bus_id;
|
||||
char setup_flag;/*if !=0 the urb setup header is not present*/
|
||||
char data_flag; /*if !=0 no urb data is present*/
|
||||
int64_t ts_sec;
|
||||
int32_t ts_usec;
|
||||
int32_t status;
|
||||
uint32_t urb_len;
|
||||
uint32_t data_len; /* amount of urb data really present in this event*/
|
||||
union {
|
||||
pcap_usb_setup setup;
|
||||
iso_rec iso;
|
||||
} s;
|
||||
int32_t interval; /* for Interrupt and Isochronous events */
|
||||
int32_t start_frame; /* for Isochronous events */
|
||||
uint32_t xfer_flags; /* copy of URB's transfer flags */
|
||||
uint32_t ndesc; /* number of isochronous descriptors */
|
||||
} pcap_usb_header_mmapped;
|
||||
|
||||
/*
|
||||
* Isochronous descriptors; for isochronous transfers there might be
|
||||
* one or more of these at the beginning of the packet data. The
|
||||
* number of descriptors is given by the "ndesc" field in the header;
|
||||
* as indicated, in older kernels that don't put the descriptors at
|
||||
* the beginning of the packet, that field is zeroed out, so that field
|
||||
* can be trusted even in captures from older kernels.
|
||||
*/
|
||||
typedef struct _usb_isodesc {
|
||||
int32_t status;
|
||||
uint32_t offset;
|
||||
uint32_t len;
|
||||
uint8_t pad[4];
|
||||
} usb_isodesc;
|
||||
|
||||
#endif
|
||||
46
network/arpicmplab/start/lib/npcap/Include/pcap/vlan.h
Normal file
46
network/arpicmplab/start/lib/npcap/Include/pcap/vlan.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_vlan_h
|
||||
#define lib_pcap_vlan_h
|
||||
|
||||
#include <pcap/pcap-inttypes.h>
|
||||
|
||||
struct vlan_tag {
|
||||
uint16_t vlan_tpid; /* ETH_P_8021Q */
|
||||
uint16_t vlan_tci; /* VLAN TCI */
|
||||
};
|
||||
|
||||
#define VLAN_TAG_LEN 4
|
||||
|
||||
#endif
|
||||
BIN
network/arpicmplab/start/lib/npcap/Lib/Packet.lib
Normal file
BIN
network/arpicmplab/start/lib/npcap/Lib/Packet.lib
Normal file
Binary file not shown.
BIN
network/arpicmplab/start/lib/npcap/Lib/wpcap.lib
Normal file
BIN
network/arpicmplab/start/lib/npcap/Lib/wpcap.lib
Normal file
Binary file not shown.
BIN
network/arpicmplab/start/lib/npcap/Lib/x64/Packet.lib
Normal file
BIN
network/arpicmplab/start/lib/npcap/Lib/x64/Packet.lib
Normal file
Binary file not shown.
BIN
network/arpicmplab/start/lib/npcap/Lib/x64/wpcap.lib
Normal file
BIN
network/arpicmplab/start/lib/npcap/Lib/x64/wpcap.lib
Normal file
Binary file not shown.
16
network/arpicmplab/start/lib/npcap/Npcap_Guide.html
Normal file
16
network/arpicmplab/start/lib/npcap/Npcap_Guide.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="refresh" content="0; url=./docs/index.html">
|
||||
<title>Npcap Guide</title>
|
||||
<script type="text/javascript">
|
||||
window.location.href='./docs/index.html';
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>The Npcap Guide is located <a href="./docs/index.html">in the "docs" directory</a>.
|
||||
You can also find the latest version of the Guide <a href="https://npcap.org/guide/">on Npcap.org</a>.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
253
network/arpicmplab/start/lib/npcap/docs/index.html
Normal file
253
network/arpicmplab/start/lib/npcap/docs/index.html
Normal file
@ -0,0 +1,253 @@
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Npcap: Nmap Project's packet sniffing library for Windows</title><meta name="generator" content="DocBook XSL Stylesheets V1.79.2"><meta name="description" content="A guide to Npcap, a packet capture and network analysis framework for Windows, for users and software developers. Npcap is a modern, safe, and compatible update to WinPcap."><link rel="home" href="index.html" title="Npcap: Nmap Project's packet sniffing library for Windows"><link rel="next" href="npcap-users-guide.html" title="Npcap Users' Guide"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Npcap: Nmap Project's packet sniffing library for Windows</th></tr><tr><td width="20%" align="left"><EFBFBD></td><th width="60%" align="center"><EFBFBD></th><td width="20%" align="right"><EFBFBD><a accesskey="n" href="npcap-users-guide.html">Next</a></td></tr></table><hr></div><div class="article"><div class="titlepage"><div><div><h2 class="title"><a name="npcap"></a>Npcap: Nmap Project's packet sniffing library for Windows</h2></div><div><div class="abstract"><p class="title"><b>Abstract</b></p>
|
||||
<p>A guide to Npcap, a packet capture and network analysis framework for Windows, for users and software developers. Npcap is a modern, safe, and compatible update to WinPcap.</p>
|
||||
</div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="sect1"><a href="index.html#npcap-intro">Introduction</a></span></dt><dd><dl><dt><span class="sect2"><a href="index.html#npcap-description">What is Npcap?</a></span></dt><dt><span class="sect2"><a href="index.html#npcap-winpcap">Npcap and WinPcap</a></span></dt><dt><span class="sect2"><a href="index.html#id562734">Purpose of this manual</a></span></dt><dt><span class="sect2"><a href="index.html#id562788">Terminology</a></span></dt><dt><span class="sect2"><a href="index.html#npcap-license">Npcap License</a></span></dt><dt><span class="sect2"><a href="index.html#npcap-download">Obtaining Npcap</a></span></dt><dt><span class="sect2"><a href="index.html#npcap-guide-copyright">Acknowledgements and copyright</a></span></dt></dl></dd><dt><span class="sect1"><a href="npcap-users-guide.html">Npcap Users' Guide</a></span></dt><dd><dl><dt><span class="sect2"><a href="npcap-users-guide.html#npcap-installation">Installation</a></span></dt><dt><span class="sect2"><a href="npcap-users-guide.html#npcap-feature-dot11-wireshark">How to use Wireshark to capture raw 802.11 traffic in <span class="quote">“<span class="quote">Monitor Mode</span>”</span></a></span></dt><dt><span class="sect2"><a href="npcap-users-guide.html#npcap-qa">Q & A</a></span></dt><dt><span class="sect2"><a href="npcap-users-guide.html#npcap-issues">Reporting Bugs</a></span></dt></dl></dd><dt><span class="sect1"><a href="npcap-devguide.html">Developing software with Npcap</a></span></dt><dd><dl><dt><span class="sect2"><a href="npcap-devguide.html#npcap-development">Using the Npcap SDK</a></span></dt><dt><span class="sect2"><a href="npcap-devguide.html#npcap-examples">Examples</a></span></dt><dt><span class="sect2"><a href="npcap-devguide.html#npcap-devguide-updating">Updating WinPcap software to Npcap</a></span></dt><dt><span class="sect2"><a href="npcap-devguide.html#npcap-detect">How to detect what version Npcap/WinPcap you are using?</a></span></dt><dt><span class="sect2"><a href="npcap-devguide.html#npcap-feature-native">For software that want to use Npcap first when Npcap and WinPcap coexist</a></span></dt><dt><span class="sect2"><a href="npcap-devguide.html#npcap-feature-loopback">For software that uses Npcap loopback feature</a></span></dt><dt><span class="sect2"><a href="npcap-devguide.html#npcap-feature-dot11">For software that uses Npcap raw 802.11 feature</a></span></dt><dt><span class="sect2"><a href="npcap-devguide.html#npcap-api">The Npcap API</a></span></dt></dl></dd><dt><span class="sect1"><a href="npcap-tutorial.html">Npcap Development Tutorial</a></span></dt><dd><dl><dt><span class="sect2"><a href="npcap-tutorial.html#npcap-tutorial-devlist">Obtaining the device list</a></span></dt><dt><span class="sect2"><a href="npcap-tutorial.html#npcap-tutorial-devdetails">Obtaining advanced information about installed devices</a></span></dt><dt><span class="sect2"><a href="npcap-tutorial.html#npcap-tutorial-openadapter">Opening an adapter and capturing the packets</a></span></dt><dt><span class="sect2"><a href="npcap-tutorial.html#npcap-tutorial-pcap-next-ex">Capturing the packets without the callback</a></span></dt><dt><span class="sect2"><a href="npcap-tutorial.html#npcap-tutorial-filtering">Filtering the traffic</a></span></dt><dt><span class="sect2"><a href="npcap-tutorial.html#npcap-tutorial-interpreting">Interpreting the packets</a></span></dt><dt><span class="sect2"><a href="npcap-tutorial.html#npcap-tutorial-offline">Handling offline dump files</a></span></dt><dt><span class="sect2"><a href="npcap-tutorial.html#npcap-tutorial-sending">Sending Packets</a></span></dt><dt><span class="sect2"><a href="npcap-tutorial.html#npcap-tutorial-statistics">Gathering Statistics on the network traffic</a></span></dt></dl></dd><dt><span class="sect1"><a href="npcap-internals.html">Npcap internals</a></span></dt><dd><dl><dt><span class="sect2"><a href="npcap-internals.html#npcap-structure">Npcap structure</a></span></dt><dt><span class="sect2"><a href="npcap-internals.html#npcap-internals-driver">Npcap driver internals</a></span></dt><dt><span class="sect2"><a href="npcap-internals.html#npcap-internals-references">Further reading</a></span></dt></dl></dd></dl></div>
|
||||
|
||||
<a class="indexterm" name="npcap-indexterm"></a>
|
||||
|
||||
<div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="npcap-intro"></a>Introduction</h2></div></div></div>
|
||||
|
||||
|
||||
<p>This Manual describes the programming interface and the source code of
|
||||
Npcap. It provides detailed descriptions of the functions and structures
|
||||
exported to programmers, along with complete documentation of the Npcap
|
||||
internals. Several tutorials and examples are provided as well.</p>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-description"></a>What is Npcap?</h3></div></div></div>
|
||||
|
||||
|
||||
<p>Npcap is an architecture for packet capture and network analysis for
|
||||
Windows operating systems, consisting of a software library and a network
|
||||
driver.</p>
|
||||
|
||||
<p>Most networking applications access the network through widely-used
|
||||
operating system primitives such as sockets. It is easy to access data on
|
||||
the network with this approach since the operating system copes with the
|
||||
low level details (protocol handling, packet reassembly, etc.) and
|
||||
provides a familiar interface that is similar to the one used to read and
|
||||
write files.</p>
|
||||
|
||||
<p>Sometimes, however, the <span class="quote">“<span class="quote">easy way</span>”</span> is not up to the task,
|
||||
since some applications require direct access to packets on the network.
|
||||
That is, they need access to the <span class="quote">“<span class="quote">raw</span>”</span> data on the network
|
||||
without the interposition of protocol processing by the operating
|
||||
system.</p>
|
||||
|
||||
<p>The purpose of Npcap is to give this kind of access to Windows
|
||||
applications. It provides facilities to:</p>
|
||||
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">capture raw packets, both the ones destined to the machine where
|
||||
it's running and the ones exchanged by other hosts (on shared media)</li><li class="listitem">filter the packets according to user-specified rules before
|
||||
dispatching them to the application</li><li class="listitem">transmit raw packets to the network</li><li class="listitem">gather statistical information on the network traffic</li></ul></div>
|
||||
|
||||
<p>This set of capabilities is obtained by means of a device driver,
|
||||
which is installed inside the networking portion of the Windows kernel,
|
||||
plus a couple of DLLs.</p>
|
||||
|
||||
<p>All of these features are exported through a powerful programming
|
||||
interface, easily usable by applications. The main goal of this manual is
|
||||
to document this interface, with the help of several examples.</p>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="id562445"></a>What kind of programs use Npcap?</h4></div></div></div>
|
||||
|
||||
|
||||
<p>The Npcap programming interface can be used by many types of
|
||||
network tools for analysis, troubleshooting, security and monitoring.
|
||||
In particular, classical tools that rely on Npcap are:</p>
|
||||
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">network and protocol analyzers</li><li class="listitem">network monitors</li><li class="listitem">traffic loggers</li><li class="listitem">traffic generators</li><li class="listitem">user-level bridges and routers</li><li class="listitem">network intrusion detection systems (NIDS)</li><li class="listitem">network scanners</li><li class="listitem">security tools</li></ul></div>
|
||||
</div>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="id562468"></a>What Npcap can't do</h4></div></div></div>
|
||||
|
||||
|
||||
<p>Npcap receives and sends the packets independently from the host
|
||||
protocols, like TCP/IP. This means that it isn't able to block, filter or
|
||||
manipulate the traffic generated by other programs on the same machine: it
|
||||
simply <span class="quote">“<span class="quote">sniffs</span>”</span> the packets that transit on the wire. Therefore, it does not
|
||||
provide the appropriate support for applications like traffic shapers, QoS
|
||||
schedulers and personal firewalls. </p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-winpcap"></a>Npcap and WinPcap</h3></div></div></div>
|
||||
|
||||
|
||||
<p>Npcap is an update of <a class="ulink" href="http://www.winpcap.org/" target="_top">WinPcap</a>
|
||||
to the <a class="ulink" href="https://msdn.microsoft.com/en-us/library/windows/hardware/ff565492(v=vs.85).aspx" target="_top">NDIS 6 Light-Weight Filter (LWF)</a> API.
|
||||
It supports <span class="command"><strong>Windows 7, 8, 8.1, and 10</strong></span>. It is developed
|
||||
by the <a class="ulink" href="http://nmap.org/" target="_top">Nmap Project</a>
|
||||
as a continuation of the project started by Yang Luo
|
||||
under <a class="ulink" href="https://www.google-melange.com/gsoc/project/details/google/gsoc2013/hsluoyz/5727390428823552" target="_top">Google Summer of Code 2013</a> and
|
||||
<a class="ulink" href="https://www.google-melange.com/gsoc/project/details/google/gsoc2015/hsluoyz/5723971634855936" target="_top">2015</a>.
|
||||
It also received many helpful tests from <a class="ulink" href="https://www.wireshark.org/" target="_top">Wireshark</a>
|
||||
and <a class="ulink" href="http://www.netscantools.com/" target="_top">NetScanTools</a>.
|
||||
</p>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-features"></a>Feature comparison with WinPcap</h4></div></div></div>
|
||||
|
||||
|
||||
<p>Npcap carries on the WinPcap legacy, but is not without its own
|
||||
innovations. Here are some of the most exciting improvements and new
|
||||
features that Npcap adds:</p>
|
||||
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="emphasis"><em>NDIS 6 Support</em></span>: Npcap makes use of the new NDIS Lightweight Filter driver introduced in
|
||||
NDIS 6.0. This driver type is faster and has less overhead
|
||||
than the legacy <a class="ulink" href="https://msdn.microsoft.com/en-us/library/windows/hardware/ff557012(v=vs.85).aspx" target="_top">NDIS 5 Intermediate Driver</a>
|
||||
type used by WinPcap.
|
||||
</p></li><li class="listitem"><p><span class="emphasis"><em>Latest libpcap API Support</em></span>: Npcap provides support
|
||||
for the latest <a class="ulink" href="https://github.com/the-tcpdump-group/libpcap" target="_top">libpcap API</a>
|
||||
by accepting libpcap as a <a class="ulink" href="https://git-scm.com/docs/git-submodule" target="_top">Git submodule</a>.
|
||||
The latest libpcap 1.8 has integrated more fascinating features and functions than the
|
||||
<a class="ulink" href="https://www.winpcap.org/misc/changelog.htm" target="_top">deprecated libpcap 1.0.0 shipped by WinPcap</a>.
|
||||
Moreover, since Linux already has a good support for latest libpcap API, using
|
||||
Npcap on Windows facilitates your software to base on the same API on both Windows and Linux.</p></li><li class="listitem"><p><span class="emphasis"><em><span class="quote">“<span class="quote">Admin-only Mode</span>”</span> Support</em></span>: Npcap supports to restrict its
|
||||
use to Administrators for safety purpose. If Npcap is installed with
|
||||
the option <span class="quote">“<span class="quote">Restrict Npcap driver's access to Administrators only</span>”</span> checked,
|
||||
when a non-Admin user tries to start a user software (Nmap, Wireshark, etc),
|
||||
the <a class="ulink" href="http://windows.microsoft.com/en-us/windows/what-is-user-account-control#1TC=windows-7" target="_top">User Account Control (UAC)</a>
|
||||
dialog will prompt asking for Administrator privilege. Only when the end
|
||||
user chooses Yes, the driver can be accessed. This is similar to UNIX
|
||||
where you need root access to capture packets.</p></li><li class="listitem"><p><span class="emphasis"><em>Loopback Packet Capture</em></span>: Npcap is able to
|
||||
see Windows loopback packets using the
|
||||
<a class="ulink" href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa366510(v=vs.85).aspx" target="_top">
|
||||
Windows Filtering Platform (WFP)</a>. Npcap supplies an
|
||||
interface named <span class="quote">“<span class="quote">NPF_Loopback</span>”</span>, with the description <span class="quote">“<span class="quote">Adapter for loopback capture.</span>”</span>
|
||||
If you are a Wireshark user, choose this adapter
|
||||
to capture, you will see all loopback traffic the same way as other
|
||||
non-loopback adapters. Try it by typing in commands like <span class="command"><strong>ping 127.0.0.1</strong></span>
|
||||
(IPv4) or <span class="command"><strong>ping ::1</strong></span> (IPv6).</p></li><li class="listitem"><p><span class="emphasis"><em>Loopback Packet Injection</em></span>: Besides loopback packet
|
||||
capturing, Npcap can also send out loopback packets using the
|
||||
<a class="ulink" href="https://msdn.microsoft.com/en-us/library/windows/hardware/ff556958(v=vs.85).aspx" target="_top">Winsock Kernel (WSK)</a>
|
||||
technique. A user software (e.g. Nmap) can just send packets
|
||||
on the <span class="quote">“<span class="quote">NPF_Loopback</span>”</span> device using
|
||||
<code class="function">pcap_inject()</code> or
|
||||
<code class="function">PacketSendPacket</code> just like on a standard
|
||||
interface. Npcap
|
||||
will automatically remove the packet's DLT_NULL header and
|
||||
inject the payload into Windows TCP/IP stack.</p></li><li class="listitem"><p><span class="emphasis"><em>Raw 802.11 Packets Capture Support</em></span>: Npcap is able to see
|
||||
<span class="emphasis"><em>802.11</em></span> packets instead of <span class="emphasis"><em>fake Ethernet</em></span> packets on ordinary wireless
|
||||
adapters. You need to select the <code class="option">Support raw 802.11 traffic (and monitor
|
||||
mode) for wireless adapters</code> option in the installation wizard to enable
|
||||
this feature. When your adapter is in <span class="quote">“<span class="quote">Monitor Mode</span>”</span>, Npcap will supply all
|
||||
<span class="emphasis"><em>802.11 data + control + management</em></span> packets with radiotap headers. When
|
||||
your adapter is in <span class="quote">“<span class="quote">Managed Mode</span>”</span>, Npcap will only supply <span class="emphasis"><em>Ethernet</em></span>
|
||||
packets. Npcap directly supports to use Wireshark to capture in <span class="quote">“<span class="quote">Monitor Mode</span>”</span>.
|
||||
Meantime, Npcap also provides the <code class="filename">WlanHelper.exe</code>
|
||||
tool to help you switch to <span class="quote">“<span class="quote">Monitor Mode</span>”</span> on your own. See more details
|
||||
about this feature in section
|
||||
<span class="quote">“<span class="quote"><a class="link" href="npcap-devguide.html#npcap-feature-dot11" title="For software that uses Npcap raw 802.11 feature">For software that uses Npcap raw 802.11 feature</a></span>”</span>.
|
||||
See more details about radiotap here:
|
||||
<a class="ulink" href="http://www.radiotap.org/" target="_top">http://www.radiotap.org/</a></p></li><li class="listitem"><p><span class="emphasis"><em><span class="quote">“<span class="quote">WinPcap API-compatible Mode</span>”</span>
|
||||
Support</em></span>: <span class="quote">“<span class="quote">WinPcap API-compatible Mode</span>”</span> makes Npcap a
|
||||
strict WinPcap replacement by using the same DLL location and service name as
|
||||
WinPcap. This is useful for testing or migrating from software that only uses
|
||||
WinPcap, but because Npcap is masquerading as WinPcap, software will not be
|
||||
able to be aware of and use Npcap's newer features. It's notable that before
|
||||
installing in this mode, any existing WinPcap installation will be
|
||||
uninstalled and replaced.
|
||||
</p></li></ul></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="id562734"></a>Purpose of this manual</h3></div></div></div>
|
||||
|
||||
|
||||
<p>The purpose of this manual is to provide a comprehensive and easy way
|
||||
to browse the documentation of the Npcap architecture. You will find
|
||||
three main sections: <a class="xref" href="npcap-users-guide.html" title="Npcap Users' Guide">the section called “Npcap Users' Guide”</a>,
|
||||
<a class="xref" href="npcap-devguide.html" title="Developing software with Npcap">the section called “Developing software with Npcap”</a>,
|
||||
and <a class="xref" href="npcap-internals.html" title="Npcap internals">the section called “Npcap internals”</a>.</p>
|
||||
|
||||
<p><a class="xref" href="npcap-users-guide.html" title="Npcap Users' Guide">the section called “Npcap Users' Guide”</a> is for end users of Npcap, and
|
||||
primarily concerns installation options, hardware compatibility, and bug
|
||||
reporting procedures.</p>
|
||||
|
||||
<p><a class="xref" href="npcap-devguide.html" title="Developing software with Npcap">the section called “Developing software with Npcap”</a> is for programmers who need to use
|
||||
Npcap from an application: it contains information about functions and
|
||||
data structures exported by the Npcap API, a manual for writing packet
|
||||
filters, and information on how to include it in an application. A
|
||||
tutorial with several code samples is provided as well; it can be used to
|
||||
learn the basics of the Npcap API using a step-by-step approach, but it
|
||||
also offers code snippets that demonstrate advanced features.</p>
|
||||
|
||||
<p><a class="xref" href="npcap-internals.html" title="Npcap internals">the section called “Npcap internals”</a> is intended for Npcap developers
|
||||
and maintainers, or for people who are curious about how this system
|
||||
works: it provides a general description of the Npcap architecture and
|
||||
explains how it works. Additionally, it documents the complete device
|
||||
driver structure, the source code, the Packet.dll interface and the
|
||||
low-level Npcap API. If you want to understand what happens inside Npcap
|
||||
or if you need to extend it, this is the section you will want to
|
||||
read.</p>
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="id562788"></a>Terminology</h3></div></div></div>
|
||||
|
||||
|
||||
<p>We call Npcap an <em class="wordasword">architecture</em> rather than
|
||||
<em class="wordasword">library</em> because packet capture is a low level
|
||||
mechanism that requires a strict interaction with the network adapter and
|
||||
with the operating system, in particular with its networking
|
||||
implementation, so a simple library is not sufficient.</p>
|
||||
|
||||
<p>For consistency with the literature, we will use the term
|
||||
<em class="wordasword">packet</em> even though
|
||||
<em class="wordasword">frame</em> is more accurate since the capture process
|
||||
is done at the data-link layer and the data-link header is included in
|
||||
the captured data.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-license"></a>Npcap License</h3></div></div></div>
|
||||
|
||||
|
||||
<p>Even though Npcap source code is publicly available for review, it is
|
||||
not open source software and may not be redistributed without special
|
||||
permission from the Nmap Project. The
|
||||
<a class="ulink" href="https://github.com/nmap/npcap/blob/master/LICENSE" target="_top">Npcap License</a>
|
||||
allows end users to download, install, and use Npcap from our site for
|
||||
free. Software providers (open source or otherwise) which want to use
|
||||
Npcap functionality are welcome to point their users to npcap.org for
|
||||
those users to download and install.</p>
|
||||
<p>We fund the Npcap project by selling licenses to companies who wish
|
||||
to redistribute Npcap within their products. The
|
||||
<a class="ulink" href="https://nmap.org/npcap/oem/" target="_top">Npcap OEM edition</a> allows
|
||||
companies to silently and seamlessly install Npcap during their product's
|
||||
installation rather than asking users to download and install Npcap
|
||||
themselves. The Npcap OEM commercial license also includes support,
|
||||
updates and indemnification. This is similar to the commercial licenses
|
||||
we offer for embedding <a class="ulink" href="https://nmap.org/" target="_top">Nmap</a> in
|
||||
commercial software. More details are available from <a class="ulink" href="https://nmap.org/npcap/oem/" target="_top">the Npcap OEM page</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-download"></a>Obtaining Npcap</h3></div></div></div>
|
||||
|
||||
|
||||
<p>The latest Npcap release can always be found
|
||||
<a class="ulink" href="https://nmap.org/npcap/#download" target="_top">on the Npcap
|
||||
website</a> as an executable installer and as a source code
|
||||
archive.</p>
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-guide-copyright"></a>Acknowledgements and copyright</h3></div></div></div>
|
||||
|
||||
|
||||
<p>Portions of this guide were adapted from the WinPcap documentation.
|
||||
Copyright <20> 2002-2005 Politecnico di Torino. Copyright <20>
|
||||
2005-2010 CACE Technologies. Copyright <20> 2010-2013 Riverbed
|
||||
Technology. Copyright <20> 2020 Insecure.Com, LLC. All rights
|
||||
reserved.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><EFBFBD></td><td width="20%" align="center"><EFBFBD></td><td width="40%" align="right"><EFBFBD><a accesskey="n" href="npcap-users-guide.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><EFBFBD></td><td width="20%" align="center"><EFBFBD></td><td width="40%" align="right" valign="top"><EFBFBD>Npcap Users' Guide</td></tr></table></div></body></html>
|
||||
705
network/arpicmplab/start/lib/npcap/docs/npcap-devguide.html
Normal file
705
network/arpicmplab/start/lib/npcap/docs/npcap-devguide.html
Normal file
@ -0,0 +1,705 @@
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Developing software with Npcap</title><meta name="generator" content="DocBook XSL Stylesheets V1.79.2"><meta name="description" content="Writing software that captures or injects network traffic is easy with Npcap. This guide describes the Npcap SDK, WinPcap compatibility, and the Npcap API."><link rel="home" href="index.html" title="Npcap: Nmap Project's packet sniffing library for Windows"><link rel="up" href="index.html" title="Npcap: Nmap Project's packet sniffing library for Windows"><link rel="prev" href="npcap-users-guide.html" title="Npcap Users' Guide"><link rel="next" href="npcap-tutorial.html" title="Npcap Development Tutorial"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Developing software with Npcap</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="npcap-users-guide.html">Prev</a><EFBFBD></td><th width="60%" align="center"><EFBFBD></th><td width="20%" align="right"><EFBFBD><a accesskey="n" href="npcap-tutorial.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="npcap-devguide"></a>Developing software with Npcap</h2></div><div><div class="abstract"><p class="title"><b>Abstract</b></p>
|
||||
<p> Writing software that captures or injects network traffic is easy
|
||||
with Npcap. This guide describes the Npcap SDK, WinPcap compatibility,
|
||||
and the Npcap API.</p>
|
||||
</div></div></div></div>
|
||||
|
||||
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-development"></a>Using the Npcap SDK</h3></div></div></div>
|
||||
|
||||
|
||||
<p>
|
||||
To build software that uses Npcap, use the latest version of the Npcap Software Development Kit (SDK).
|
||||
The latest SDK can be downloaded on <a class="ulink" href="http://npcap.org/#download" target="_top">Npcap.org</a>.
|
||||
Updates to the SDK are much less frequent than updates to the Npcap binaries.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-examples"></a>Examples</h3></div></div></div>
|
||||
|
||||
|
||||
<p>
|
||||
Examples of applications using Npcap are available <a class="ulink" href="https://github.com/nmap/npcap/tree/master/Examples" target="_top">in the Examples directory</a> in the source distribution.
|
||||
Several of these examples are explored in more depth in the <a class="xref" href="npcap-tutorial.html" title="Npcap Development Tutorial">the section called “Npcap Development Tutorial”</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Npcap developer Yang Luo has also provided an example:
|
||||
<a class="ulink" href="https://github.com/hsluoyz/UserBridge/" target="_top">UserBridge</a>,
|
||||
which is a tool to redirect all packets from one interface to another.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-devguide-updating"></a>Updating WinPcap software to Npcap</h3></div></div></div>
|
||||
|
||||
<p>
|
||||
For the most part, Npcap is completely compatible with software written
|
||||
for WinPcap. Minor changes need to be made to <a class="xref" href="npcap-devguide.html#npcap-feature-native-dll" title="DLL loading">the section called “DLL loading”</a> and in some
|
||||
cases <a class="xref" href="npcap-devguide.html#npcap-feature-native-servicename" title="Service name">the section called “Service name”</a>. However, there have been many improvements to the libpcap
|
||||
API between the last release of WinPcap and the current release of Npcap.
|
||||
Reviewing the changes may help improve performance, reliability, and
|
||||
maintainability of software that uses Npcap.
|
||||
</p>
|
||||
|
||||
<p>Apart from the libpcap API, WinPcap exported a few functions used by
|
||||
<a class="ulink" href="https://www.winpcap.org/windump/" target="_top">WinDump</a> that were
|
||||
related to porting a Unix-style tool to Windows but unrelated to packet
|
||||
capture. Those functions were not documented in the WinPcap
|
||||
documentation, have never been included in libpcap, and are therefore not
|
||||
in the Npcap API: <code class="code">getservent</code>, <code class="code">endservent</code>, and
|
||||
<code class="code">eproto_db</code>.</p>
|
||||
|
||||
<p>One other function exported by WinPcap, <code class="code">wsockinit</code>, is
|
||||
available via the Npcap API as <code class="code">pcap_wsockinit</code>. It calls
|
||||
<code class="code">WSAStartup</code> for Windows Sockets version 1.1 and ensures that
|
||||
<code class="code">WSACleanup</code> is called when the process ends.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-detect"></a>How to detect what version Npcap/WinPcap you are using?</h3></div></div></div>
|
||||
|
||||
|
||||
<p>
|
||||
Sometimes, our user software needs to detect the existence of Npcap/WinPcap
|
||||
at install-time or run-time. Although Npcap's GUI installer has the ability
|
||||
to handle this, you may want to handle it by yourself in some conditions,
|
||||
like you run Npcap installer in silent-mode. The run-time detection is even
|
||||
more useful. Your software probably has some functions that rely on Npcap's
|
||||
particular features (like loopback capture). You need to know if you
|
||||
are running on top of Npcap or the legacy WinPcap to control whether to
|
||||
switch your functions on. Fortunately, Npcap provides you some methods to
|
||||
detect Npcap/WinPcap at install-time and run-time.
|
||||
</p>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-detect-version"></a>Npcap version</h4></div></div></div>
|
||||
|
||||
|
||||
<p> Npcap has a version number that is independent of WinPcap. The last
|
||||
release of WinPcap was version 4.1.3, but Npcap started over counting
|
||||
versions from 0.00. In order to make it clear to the installers and other
|
||||
software that Npcap is newer and more advanced, the executable
|
||||
<span class="quote">“<span class="quote">file version</span>”</span> was advanced to <span class="quote">“<span class="quote">5.0.0.000</span>”</span> at
|
||||
that point. The major version will always be <span class="quote">“<span class="quote">5</span>”</span> to
|
||||
distinguish Npcap from WinPcap. The minor version is Npcap's major
|
||||
version; the revision is Npcap's minor version; and the build number is
|
||||
an encoding of the build date. So a file version of
|
||||
<span class="quote">“<span class="quote">5.0.92.612</span>”</span> is Npcap 0.92, built on June 12th.</p>
|
||||
</div>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-detect-install-time"></a>Install-time detection</h4></div></div></div>
|
||||
|
||||
|
||||
<p>
|
||||
You can check the existence of <code class="filename">C:\Program Files\Npcap\NPFInstall.exe</code> to
|
||||
detect Npcap's existence. If Npcap exists, you can check the file version of
|
||||
<code class="filename">C:\Program Files\Npcap\NPFInstall.exe</code> to detect Npcap e-version. The
|
||||
e-version also gives you the version. The NSIS code is shown below. <code class="varname">$inst_ver</code>
|
||||
is an e-version string like <span class="quote">“<span class="quote">5.0.7.424</span>”</span>
|
||||
</p>
|
||||
<pre class="screen">
|
||||
GetDllVersion "C:\Program Files\Npcap\NPFInstall.exe" $R0 $R1
|
||||
IntOp $R2 $R0 / 0x00010000
|
||||
IntOp $R3 $R0 & 0x0000FFFF
|
||||
IntOp $R4 $R1 / 0x00010000
|
||||
IntOp $R5 $R1 & 0x0000FFFF
|
||||
StrCpy $inst_ver "$R2.$R3.$R4.$R5"
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
You can check the installation options of an already installed Npcap by reading the registry
|
||||
key: <code class="filename">HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\npcap\Parameters</code>.
|
||||
The entries like <code class="filename">AdminOnly</code>,
|
||||
<code class="filename">LoopbackSupport</code>, <code class="filename">DltNull</code>,<code class="filename">Dot11Support</code>,
|
||||
<code class="filename">VlanSupport</code>, <code class="filename">WinPcapCompatible</code>, etc.
|
||||
are <code class="code">REG_DWORD</code> type. A 0x00000001 value
|
||||
indicates the installation option is <span class="emphasis"><em>CHECKED</em></span>.
|
||||
</p>
|
||||
<p>Note: Prior to Npcap 0.93, these values were stored in the
|
||||
<code class="filename">Services\npcap</code> key directly.</p>
|
||||
</div>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-detect-run-time"></a>Run-time detection</h4></div></div></div>
|
||||
|
||||
|
||||
<p>
|
||||
Npcap and WinPcap can be installed together on a system. Which capture
|
||||
library is used by the user software relies on the DLL loading path. If
|
||||
Npcap's <code class="filename">wpcap.dll</code> is loaded first, then you are using
|
||||
Npcap, vice versa. However, it's difficult and fragile to check the DLL
|
||||
loading path by yourself. Fortunately, you can use
|
||||
<code class="function">pcap_lib_version</code> to get the Npcap/WinPcap version
|
||||
string.
|
||||
</p>
|
||||
|
||||
<pre class="screen">
|
||||
char *pcap_version = pcap_lib_version();
|
||||
printf("%s", pcap_version);
|
||||
// Npcap output: "Npcap version 0.92, based on libpcap version 1.8.1"
|
||||
// WinPcap output: "WinPcap version 4.1.3"
|
||||
</pre>
|
||||
|
||||
<p>Npcap requires the <code class="varname">npcap</code> service to be running. If
|
||||
installed in <span class="quote">“<span class="quote">WinPcap Compatible Mode</span>”</span>, the
|
||||
<code class="varname">npf</code> service can be started instead. Given that
|
||||
<code class="varname">npcap</code> service is always installed
|
||||
in both modes, a good practice is just trying the <code class="varname">npcap</code> service first.
|
||||
If it fails, then try the <code class="varname">npf</code> service. This is also what most of our users
|
||||
do in their software based on our investigation. A code sample from Nmap is
|
||||
<a class="ulink" href="https://github.com/nmap/nmap/blob/8c8e4a08c6c6b7abd2343e5921aafb6077bdb257/mswin32/winfix.cc#L322-L328" target="_top">here</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-feature-native"></a>For software that want to use Npcap first when Npcap and WinPcap coexist</h3></div></div></div>
|
||||
|
||||
|
||||
<p>
|
||||
Prerequisite: Uncheck the <code class="option">Install Npcap in WinPcap API-compatible Mode</code> option at
|
||||
install-time (which is by default).
|
||||
</p>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-native-dll"></a>DLL loading</h4></div></div></div>
|
||||
|
||||
|
||||
<p>Npcap installs its DLLs into <code class="filename">C:\Windows\System32\Npcap\</code>
|
||||
instead of WinPcap's <code class="filename">C:\Windows\System32\</code>. Because of how Windows'
|
||||
<a class="ulink" href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms686203(v=vs.85).aspx" target="_top">DLL search path</a> works,
|
||||
your application will use WinPcap first by default when Npcap and WinPcap coexist,
|
||||
as <code class="filename">C:\Windows\System32\</code> is prior to <code class="filename">C:\Windows\System32\Npcap\</code>.
|
||||
So when Npcap and WinPcap coexist, an application that want to use Npcap instead
|
||||
of WinPcap must make <code class="filename">C:\Windows\System32\Npcap\</code> precedent to the
|
||||
<code class="filename">C:\Windows\System32\</code> in the DLL search path. Here are two ways
|
||||
to modify this search path to make your application load Npcap's DLLs first,
|
||||
based on how your application links Npcap/WinPcap's library
|
||||
(<code class="filename">wpcap.dll</code>).</p>
|
||||
|
||||
<div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="npcap-feature-native-dll-implicitly"></a>If the application <span class="emphasis"><em>implicitly</em></span> links <code class="filename">wpcap.dll</code></h5></div></div></div>
|
||||
|
||||
|
||||
<p>Implicit linking means that either you specified <code class="filename">wpcap.lib</code>
|
||||
in your <code class="option">Project Properties</code> -> <code class="option">Configuration Properties</code>
|
||||
-> <code class="option">Linker</code> -> <code class="option">Input</code> -> <code class="option">Additional Dependencies</code> in Visual Studio,
|
||||
or specified <code class="code">#pragma comment(linker, "wpcap.lib")</code> in your code.</p>
|
||||
|
||||
<p>You need to do the following two steps:</p>
|
||||
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Specify <code class="filename">wpcap.dll</code> as a delay-loaded DLL: In
|
||||
Visual Studio, open the <code class="option">Project Properties</code> window. Go to:
|
||||
<code class="option">Configuration Properties</code> -> <code class="option">Linker</code> -> <code class="option">Input</code>
|
||||
-> <code class="option">Delay Loaded Dlls</code>. Enter <code class="filename">wpcap.dll</code>
|
||||
in that option.</p></li><li class="listitem"><p>Before calling any <code class="filename">wpcap.dll</code> functions,
|
||||
call <code class="function">SetDllDirectory</code> to add <code class="filename">C:\Windows\System32\Npcap\</code>
|
||||
to DLL search path.</p></li></ul></div>
|
||||
|
||||
|
||||
<p><a class="ulink" href="https://github.com/hsluoyz/WinDump/" target="_top">Here</a>
|
||||
is an example called WinDump, a simple packet capture tool using Npcap/WinPcap.
|
||||
And <a class="ulink" href="https://github.com/hsluoyz/WinDump/commit/dffe2eaa520fc3b449ec0a90dcfa24f96359bbfa" target="_top">this commit</a>
|
||||
makes it able to use Npcap first when Npcap and WinPcap coexist.</p>
|
||||
</div>
|
||||
|
||||
<div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="npcap-feature-native-dll-explicitly"></a>If the application <span class="emphasis"><em>explicitly</em></span> links <code class="filename">wpcap.dll</code></h5></div></div></div>
|
||||
|
||||
|
||||
<p>Explicit linking means that you explicitly called <code class="function">LoadLibrary</code>
|
||||
to load <code class="filename">wpcap.dll</code> and called <code class="function">GetProcAddress</code> to get the
|
||||
function pointers.</p>
|
||||
|
||||
<p>You need to do the following one step:</p>
|
||||
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Before calling <code class="function">LoadLibrary</code> to load <code class="filename">wpcap.dll</code>,
|
||||
call <code class="function">SetDllDirectory</code> to add <code class="filename">C:\Windows\System32\Npcap\</code>
|
||||
to DLL search path.</p></li></ul></div>
|
||||
|
||||
<p>The function <code class="function">init_npcap_dll_path</code> is provided in the following example:
|
||||
<a class="ulink" href="https://github.com/hsluoyz/WinDump/commit/dffe2eaa520fc3b449ec0a90dcfa24f96359bbfa" target="_top">WinDump</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-native-servicename"></a>Service name</h4></div></div></div>
|
||||
|
||||
|
||||
<p>Because Npcap is a NDIS 6 LWF filter driver it is designed to run
|
||||
at system boot, so software will generally not need to start it,
|
||||
unlike WinPcap which was often installed in a demand-start
|
||||
configuration.</p>
|
||||
|
||||
<p>Npcap uses service name <span class="quote">“<span class="quote">npcap</span>”</span> instead of WinPcap's <span class="quote">“<span class="quote">npf</span>”</span> with
|
||||
<span class="quote">“<span class="quote">WinPcap Compatible Mode</span>”</span> OFF. So applications using
|
||||
<span class="command"><strong>net start npf</strong></span> for starting service must change to this:
|
||||
run <span class="command"><strong>net start npcap</strong></span> first, if it fails, then try
|
||||
<span class="command"><strong>net start npf</strong></span>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-feature-loopback"></a>For software that uses Npcap loopback feature</h3></div></div></div>
|
||||
|
||||
|
||||
<p>
|
||||
Npcap 0.9983 and newer support loopback traffic capture and injection without requiring a particular installation option.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Npcap's loopback adapter device is reported by
|
||||
<code class="function">pcap_findalldevs()</code> as
|
||||
<span class="quote">“<span class="quote">\Device\NPF_Loopback</span>”</span>. This name is always available even
|
||||
if <span class="quote">“<span class="quote">Legacy loopback support</span>”</span> was chosen at install time,
|
||||
which puts the name of the legacy loopback adapter in the
|
||||
<code class="filename">LoopbackAdapter</code> REG_SZ value of the
|
||||
<code class="filename">HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\npcap\Parameters</code>.
|
||||
Registry key.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Traffic captured and injected on the loopback adapter uses the
|
||||
<code class="varname">DLT_NULL</code> data link type, which consists of a 4-byte
|
||||
header in host byte order that is either 2 for IPv4 packets or 24 for
|
||||
IPv6 packets.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The MTU of <span class="quote">“<span class="quote">Npcap Loopback Adapter</span>”</span> is hard-coded to 65536 by Npcap. Software
|
||||
using Npcap should get this value automatically and no special handling is needed. This value is
|
||||
arbitrary and does not imply a limitation on the Windows loopback stack,
|
||||
so it may be possible to capture packets with a size larger than the adapter's MTU.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Don't try to make OID requests to <span class="quote">“<span class="quote">Npcap Loopback Adapter</span>”</span> except
|
||||
<code class="varname">OID_GEN_MAXIMUM_TOTAL_SIZE</code> (MTU). Those requests will still succeed like
|
||||
other adapters do, but they only make sense for NDIS adapters and Npcap doesn't even use the
|
||||
NDIS way to handle the loopback traffic. The only handled OID request by Npcap is
|
||||
<code class="varname">OID_GEN_MAXIMUM_TOTAL_SIZE</code>. If you query its value, you will always get
|
||||
65550 (65536 + 14). If you try to set its value, the operation will always fail.
|
||||
</p>
|
||||
|
||||
<p>If you use IP Helper API to get adapter list, you will get an interface named
|
||||
like <span class="quote">“<span class="quote">Loopback Pseudo-Interface 1</span>”</span>. This interface is a DUMMY interface by Microsoft
|
||||
and can't be seen in NDIS layer. And it also takes the 127.0.0.1/::1 IP address. A good practice
|
||||
for software is replacing the <code class="varname">AdapterName</code> of the
|
||||
<span class="quote">“<span class="quote">Loopback Pseudo-Interface 1</span>”</span> entry with
|
||||
<span class="quote">“<span class="quote">NPF_Loopback</span>”</span>, as Nmap does in its enhancements to
|
||||
libdnet.</p>
|
||||
|
||||
<p><span class="quote">“<span class="quote">Legacy loopback support</span>”</span> installs a copy of the
|
||||
Microsft KM-TEST loopback adapter named <span class="quote">“<span class="quote">Npcap Loopback
|
||||
Adapter</span>”</span> for software that expects to find the loopback adapter
|
||||
via ordinary Windows API calls. The features and operation are no
|
||||
different from standard loopback support, but the
|
||||
name of the adapter will be written to the
|
||||
<code class="filename">LoopbackAdapter</code> Registry value.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-feature-dot11"></a>For software that uses Npcap raw 802.11 feature</h3></div></div></div>
|
||||
|
||||
|
||||
<p>
|
||||
Prerequisite: Check the <code class="option">Support raw 802.11 traffic (and monitor mode) for wireless adapters</code> option at install-time.
|
||||
</p>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-dot11-steps"></a>Steps</h4></div></div></div>
|
||||
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Install the latest version Npcap with the
|
||||
<code class="option">Support raw 802.11 traffic (and monitor mode) for wireless
|
||||
adapters</code> option checked in the installation wizard. With this
|
||||
option checked, Npcap will see packets with <span class="emphasis"><em>Radiotap +
|
||||
802.11</em></span> headers for wireless adapters. Otherwise, Npcap will
|
||||
see packets with <span class="emphasis"><em>fake Ethernet</em></span> headers for wireless
|
||||
adapters.</p></li><li class="listitem"><p>Run <code class="filename">WlanHelper.exe</code> with
|
||||
<span class="emphasis"><em>Administrator privilege</em></span>. If you use
|
||||
<code class="option">-i</code>, follow the interactive prompts to choose your
|
||||
wireless adapter and select <span class="quote">“<span class="quote">Network Monitor</span>”</span> mode.
|
||||
<code class="filename">WlanHelper.exe</code> also supports parameters to be used
|
||||
in an API manner, run <span class="command"><strong>WlanHelper.exe -h</strong></span> for
|
||||
details.</p></li><li class="listitem"><p>Use the Npcap API from your user software as usual. For
|
||||
example, launch Wireshark and capture on the wireless adapter, viewingall
|
||||
802.11 packets (<span class="emphasis"><em>data + control + management</em></span>).
|
||||
</p></li><li class="listitem"><p>If you need to return to <span class="quote">“<span class="quote">Managed Mode</span>”</span>, run
|
||||
<span class="command"><strong>WlanHelper.exe</strong></span> again, following the prompts or
|
||||
selecting the appropriate command-line options to switch off the
|
||||
<span class="quote">“<span class="quote">Monitor Mode</span>”</span>.</p></li></ul></div>
|
||||
</div>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-dot11-tips"></a>Tips</h4></div></div></div>
|
||||
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>You can use <code class="filename">WlanHelper.exe</code> tool to
|
||||
switch on the <span class="quote">“<span class="quote">Monitor Mode</span>”</span> in order to see
|
||||
<span class="emphasis"><em>802.11 control and management</em></span> packets. You
|
||||
can also use the <code class="code">pcap_set_rfmon</code> function within your
|
||||
code, as Wireshark does.
|
||||
</p></li><li class="listitem"><p>Switching on the <span class="quote">“<span class="quote">Monitor Mode</span>”</span> will
|
||||
disconnect your wireless network from the AP, you can switch back to
|
||||
<span class="quote">“<span class="quote">Managed Mode</span>”</span> using the same
|
||||
<code class="filename">WlanHelper.exe</code> tool.</p></li><li class="listitem"><p>The <code class="filename">WlanHelper.exe</code> tool is
|
||||
installed to <span class="quote">“<span class="quote">%SYSTEMROOT%\System32\Npcap</span>”</span> after installing Npcap.</p></li></ul></div>
|
||||
</div>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-dot11-terminology"></a>Terminology</h4></div></div></div>
|
||||
|
||||
<p>
|
||||
<span class="quote">“<span class="quote">Managed Mode</span>”</span> (for Linux) = <span class="quote">“<span class="quote">Extensible Station Mode</span>”</span> (aka <span class="quote">“<span class="quote">ExtSTA</span>”</span>, for Windows)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span class="quote">“<span class="quote">Monitor Mode</span>”</span> (for Linux) = <span class="quote">“<span class="quote">Network Monitor Mode</span>”</span> (aka <span class="quote">“<span class="quote">NetMon</span>”</span>, for Windows)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span class="quote">“<span class="quote">Master Mode</span>”</span> (for Linux) = <span class="quote">“<span class="quote">Extensible Access Point</span>”</span> (aka <span class="quote">“<span class="quote">ExtAP</span>”</span>, for Windows)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-dot11-wlanhelper"></a>WlanHelper</h4></div></div></div>
|
||||
|
||||
<p>
|
||||
WlanHelper is used to set/get the operation mode (like <span class="quote">“<span class="quote">Monitor
|
||||
Mode</span>”</span>) for a wireless adapter on Windows. WlanHelper tries to
|
||||
follow the grammar of <code class="filename">iwconfig</code>, a wireless
|
||||
management tool for Linux. So if you rename
|
||||
<code class="filename">WlanHelper.exe</code> to <code class="filename">iwconfig.exe</code>,
|
||||
your command lines for WlanHelper will be exactly the same with the
|
||||
iwconfig tool.
|
||||
|
||||
</p>
|
||||
|
||||
<div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="npcap-feature-dot11-wlanhelper-usage"></a>WlanHelper's Usage</h5></div></div></div>
|
||||
|
||||
<p>
|
||||
Note: <span class="command"><strong>WlanHelper</strong></span> must run under <span class="emphasis"><em>Administrator privilege</em></span>.
|
||||
</p>
|
||||
|
||||
<div class="sect5"><div class="titlepage"><div><div><h6 class="title"><a name="npcap-feature-dot11-wlanhelper-usage-interactive"></a>Interactive way</h6></div></div></div>
|
||||
|
||||
<p>
|
||||
Run <span class="command"><strong>WlanHelper</strong></span> with the <code class="option">-i</code> option.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="sect5"><div class="titlepage"><div><div><h6 class="title"><a name="npcap-feature-dot11-wlanhelper-usage-api"></a>Command-line API way</h6></div></div></div>
|
||||
|
||||
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Run <span class="command"><strong>netsh wlan show interfaces</strong></span>, get the <code class="option">Name</code> or <code class="option">GUID</code> for the interface.</p></li><li class="listitem"><p>Run <span class="command"><strong>WlanHelper -h</strong></span> to see the man page.</p></li></ul></div>
|
||||
<div class="example"><a name="npcap-ex-wlanhelper-man"></a><p class="title"><b>Example<EFBFBD>1.<2E>WlanHelper Man</b></p><div class="example-contents">
|
||||
|
||||
<pre class="screen">
|
||||
C:\> <strong class="userinput"><code>WlanHelper.exe</code></strong>
|
||||
WlanHelper for Npcap 0.91 ( http://npcap.org )
|
||||
Usage: WlanHelper [Commands]
|
||||
or: WlanHelper {Interface Name or GUID} [Options]
|
||||
|
||||
OPTIONS:
|
||||
mode : Get interface operation mode
|
||||
mode <managed|monitor|master|..> : Set interface operation mode
|
||||
modes : Get all operation modes supported by the interface, comma-separated
|
||||
channel : Get interface channel
|
||||
channel <1-14> : Set interface channel (only works in monitor mode)
|
||||
freq : Get interface frequency
|
||||
freq <VALUE> : Set interface frequency (only works in monitor mode)
|
||||
modu : Get interface modulation
|
||||
modu <dsss|fhss|irbaseband|ofdm|hrdsss|erp|ht|vht|ihv (VALUE)|..> : Set interface modulation
|
||||
modus : Get all modulations supported by the interface, comma-separated
|
||||
|
||||
COMMANDS:
|
||||
-i : Enter the interactive mode
|
||||
-h : Print this help summary page
|
||||
|
||||
OPERATION MODES:
|
||||
managed : The Extensible Station (ExtSTA) operation mode
|
||||
monitor : The Network Monitor (NetMon) operation mode
|
||||
master : The Extensible Access Point (ExtAP) operation mode (supported from Windows 7 and later)
|
||||
wfd_device : The Wi-Fi Direct Device operation mode (supported from Windows 8 and later)
|
||||
wfd_owner : The Wi-Fi Direct Group Owner operation mode (supported from Windows 8 and later)
|
||||
wfd_client : The Wi-Fi Direct Client operation mode (supported from Windows 8 and later)
|
||||
|
||||
802.11 MODULATIONS (https://en.wikipedia.org/wiki/IEEE_802.11):
|
||||
802.11-1997 : dsss, fhss
|
||||
802.11a : ofdm
|
||||
802.11b : dsss
|
||||
802.11g : ofdm
|
||||
802.11n : mimo-ofdm
|
||||
802.11ac : mimo-ofdm
|
||||
|
||||
EXAMPLES:
|
||||
WlanHelper Wi-Fi mode
|
||||
WlanHelper 42dfd47a-2764-43ac-b58e-3df569c447da channel 11
|
||||
WlanHelper 42dfd47a-2764-43ac-b58e-3df569c447da freq 2
|
||||
WlanHelper "Wireless Network Connection" mode monitor
|
||||
|
||||
SEE THE MAN PAGE (https://github.com/nmap/npcap) FOR MORE OPTIONS AND EXAMPLES
|
||||
</pre>
|
||||
</div></div><br class="example-break">
|
||||
<p>
|
||||
An example:
|
||||
</p>
|
||||
<div class="example"><a name="npcap-ex-wlanhelper-api"></a><p class="title"><b>Example<EFBFBD>2.<2E>WlanHelper API Usage</b></p><div class="example-contents">
|
||||
|
||||
<pre class="screen">
|
||||
C:\> <strong class="userinput"><code>netsh wlan show interfaces</code></strong>
|
||||
|
||||
There is 1 interface on the system:
|
||||
|
||||
Name : <em class="replaceable"><code>Wi-Fi</code></em>
|
||||
Description : Qualcomm Atheros AR9485WB-EG Wireless Network Adapter
|
||||
GUID : <em class="replaceable"><code>42dfd47a-2764-43ac-b58e-3df569c447da</code></em>
|
||||
Physical address : a4:db:30:d9:3a:9a
|
||||
State : connected
|
||||
SSID : LUO-PC_Network
|
||||
BSSID : d8:15:0d:72:8c:18
|
||||
Network type : Infrastructure
|
||||
Radio type : 802.11n
|
||||
Authentication : WPA2-Personal
|
||||
Cipher : CCMP
|
||||
Connection mode : Auto Connect
|
||||
Channel : 1
|
||||
Receive rate (Mbps) : 150
|
||||
Transmit rate (Mbps) : 150
|
||||
Signal : 100%
|
||||
Profile : LUO-PC_Network
|
||||
|
||||
Hosted network status : Not available
|
||||
|
||||
C:\> <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode</code></strong>
|
||||
managed
|
||||
C:\> <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode monitor</code></strong>
|
||||
Success
|
||||
C:\> <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode </code></strong>
|
||||
monitor
|
||||
C:\> <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode managed</code></strong>
|
||||
Success
|
||||
C:\> <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode</code></strong>
|
||||
managed
|
||||
</pre>
|
||||
</div></div><br class="example-break">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-api"></a>The Npcap API</h3></div></div></div>
|
||||
|
||||
<p>The Npcap API is exported by <code class="filename">wpcap.dll</code> and is the
|
||||
Windows port of <a class="ulink" href="https://www.tcpdump.org/" target="_top">libpcap</a>.
|
||||
The API and functions are described in
|
||||
<a class="ulink" href="wpcap/pcap.html" target="_top">the pcap(1) man page</a>.
|
||||
</p>
|
||||
<div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-api-extensions"></a>Extensions to libpcap for Windows</h3></div></div></div>
|
||||
|
||||
<p>
|
||||
There are a few extensions to libpcap that exist only on Windows.
|
||||
Software that uses these extensions will not be portable to non-Windows
|
||||
systems. The following is a brief list of these extensions and their purpose.
|
||||
</p>
|
||||
<div class="variablelist"><dl class="variablelist"><dt><span class="term">
|
||||
<code class="code">pcap_setbuff</code>
|
||||
</span></dt><dd>
|
||||
<p>
|
||||
Sets the size of the kernel buffer associated with an adapter.
|
||||
</p>
|
||||
<code class="code">int pcap_setbuff(pcap_t *p, int dim);</code>
|
||||
<p><code class="literal">dim</code> specifies the size of the buffer in
|
||||
bytes. The return value is 0 when the call succeeds, -1 otherwise.
|
||||
If an old buffer was already created with a previous call to
|
||||
<code class="literal">pcap_setbuff()</code>, it is deleted and its content is
|
||||
discarded. <a class="ulink" href="wpcap/pcap_open_live.html" target="_top">pcap_open_live()</a> creates
|
||||
a 1 MByte buffer by default.
|
||||
</p>
|
||||
<p>
|
||||
<span class="emphasis"><em>Portability note:</em></span> libpcap provides the <a class="ulink" href="wpcap/pcap_set_buffer_size.html" target="_top">pcap_set_buffer_size()</a>
|
||||
function for setting the kernel buffer size. This removes the need
|
||||
to use the non-portable <code class="literal">pcap_setbuff()</code> for this
|
||||
purpose.
|
||||
</p>
|
||||
</dd><dt><span class="term">
|
||||
<code class="code">pcap_setmode</code>
|
||||
</span></dt><dd>
|
||||
<p>Sets the working mode of the interface.</p>
|
||||
<code class="code">int pcap_setmode(pcap_t *p, int mode);</code>
|
||||
<p>
|
||||
Valid values for mode are <code class="literal">MODE_CAPT</code> (default
|
||||
capture mode) and <code class="literal">MODE_STAT</code> (statistical mode).
|
||||
See <a class="xref" href="npcap-tutorial.html#npcap-tutorial-statistics" title="Gathering Statistics on the network traffic">the section called “Gathering Statistics on the network traffic”</a> for details about
|
||||
statistical mode.
|
||||
</p>
|
||||
</dd><dt><span class="term">
|
||||
<code class="code">pcap_setmintocopy</code>
|
||||
</span></dt><dd>
|
||||
<p>
|
||||
Sets the minumum amount of data received by the kernel in a single call.
|
||||
</p>
|
||||
<code class="code">int pcap_setmintocopy(pcap_t *p, int size);</code>
|
||||
|
||||
<p>
|
||||
This function changes the minimum amount of data in the
|
||||
kernel buffer that causes a read from the application to return
|
||||
(unless the timeout expires). If the value of
|
||||
<code class="literal">size</code> is large, the kernel is forced to wait the
|
||||
arrival of several packets before
|
||||
copying the data to the user. This guarantees a low number of
|
||||
system calls, i.e. low processor usage, and is a good setting for
|
||||
applications like packet-sniffers and protocol analyzers. Vice
|
||||
versa, in presence of a small value for this variable, the kernel
|
||||
will copy the packets as soon as the application is ready to
|
||||
receive them. This is useful for real time applications that need
|
||||
the best responsiveness from the kernel. <a class="ulink" href="wpcap/pcap_open_live.html" target="_top">pcap_open_live()</a> sets a
|
||||
default <code class="literal">size</code> value of 16000 bytes.
|
||||
</p>
|
||||
<p>
|
||||
<span class="emphasis"><em>Portability note:</em></span> libpcap provides the <a class="ulink" href="wpcap/pcap_set_immediate_mode.html" target="_top">pcap_set_immediate_mode()</a>
|
||||
function for applications that need to receive packets as soon as
|
||||
they arrive. This removes the need to use the non-portable
|
||||
<code class="literal">pcap_setmintocopy()</code> for this purpose.
|
||||
</p>
|
||||
</dd><dt><span class="term">
|
||||
<code class="code">pcap_getevent</code>
|
||||
</span></dt><dd>
|
||||
<p>Returns the handle of the event associated with the interface.</p>
|
||||
<code class="code">HANDLE pcap_getevent(pcap_t *p);</code>
|
||||
|
||||
<p> This event can be passed to functions like
|
||||
<code class="literal">WaitForSingleObject()</code> or
|
||||
<code class="literal">WaitForMultipleObjects()</code> to wait until the
|
||||
driver's buffer contains some data without performing a read.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span class="emphasis"><em>Portability note:</em></span> This function is the Windows
|
||||
alternative to <a class="ulink" href="wpcap/pcap_get_selectable_fd.html" target="_top">pcap_get_selectable_fd()</a>,
|
||||
which is only available on UNIX-like systems. Most applications
|
||||
will not need an event loop that waits on multiple packet capture
|
||||
handles.
|
||||
</p>
|
||||
</dd><dt><span class="term">
|
||||
<code class="code">pcap_oid_get_request</code> and <code class="code">pcap_oid_set_request</code>
|
||||
</span></dt><dd>
|
||||
<p>Send an OID request to the underlying NDIS drivers</p>
|
||||
<code class="code">int pcap_oid_get_request(pcap_t *, bpf_u_int32, void *, size_t *);</code>
|
||||
<code class="code">int pcap_oid_set_request(pcap_t *, bpf_u_int32, const void *, size_t *);</code>
|
||||
</dd><dt><span class="term">
|
||||
Queuing sent packets with <code class="code">pcap_send_queue</code>
|
||||
</span></dt><dd>
|
||||
<p>
|
||||
Npcap has the ability to queue multiple raw packets for
|
||||
transmission on the network in a single call. This is more
|
||||
efficient than issuing a series of
|
||||
<code class="literal">pcap_sendpacket()</code>, because the packets are
|
||||
buffered in the kernel driver, so the number of context switches is
|
||||
reduced.
|
||||
</p>
|
||||
<code class="code">pcap_send_queue* pcap_sendqueue_alloc(u_int memsize);</code>
|
||||
<code class="code">void pcap_sendqueue_destroy(pcap_send_queue* queue);</code>
|
||||
<p>Allocate a send queue as a buffer of <code class="literal">memsize</code>
|
||||
bytes. The <code class="literal">pcap_send_queue</code> allocated can be
|
||||
freed with <code class="literal">pcap_sendqueue_destroy()</code>.</p>
|
||||
<code class="code">int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data);</code>
|
||||
<p>
|
||||
<code class="literal">pcap_sendqueue_queue()</code> adds a packet at the end
|
||||
of the send queue pointed by the <code class="literal">queue</code>
|
||||
parameter. <code class="literal">pkt_header</code> points to a
|
||||
<code class="literal">pcap_pkthdr</code> structure with the timestamp and the
|
||||
length of the packet, <code class="literal">pkt_data</code> points to a
|
||||
buffer with the data of the packet.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The <code class="literal">pcap_pkthdr</code> structure is the same used by
|
||||
Npcap and libpcap to store the packets in a file, therefore sending
|
||||
a capture file is straightforward. 'Raw packet' means that the
|
||||
sending application will have to include the protocol headers,
|
||||
since every packet is sent to the network 'as is'. The CRC of the
|
||||
packets needs not to be calculated, because it will be
|
||||
transparently added by the network interface.
|
||||
</p>
|
||||
<code class="code">u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync);</code>
|
||||
<p>
|
||||
This function transmits the content of a queue to the wire.
|
||||
<code class="literal">p</code> is a pointer to the adapter on which the
|
||||
packets will be sent, <code class="literal">queue</code> points to a
|
||||
<code class="literal">pcap_send_queue</code> structure containing the packets
|
||||
to send), <code class="literal">sync</code> determines if the send operation
|
||||
must be synchronized: if it is non-zero, the packets are sent
|
||||
respecting the timestamps, otherwise they are sent as fast as
|
||||
possible.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The return value is the amount of bytes actually sent. If it is
|
||||
smaller than the <code class="literal">size</code> parameter, an error
|
||||
occurred during the send. The error can be caused by a
|
||||
driver/adapter problem or by an inconsistent/bogus send queue.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span class="emphasis"><em>Performance note:</em></span> When <code class="literal">sync</code>
|
||||
is set to <code class="literal">TRUE</code>, the packets are synchronized in
|
||||
the kernel with a high precision timestamp. This requires a
|
||||
non-negligible amount of CPU, but allows normally to send the
|
||||
packets with a precision of some microseconds (depending on the
|
||||
accuracy of the performance counter of the machine). Such a
|
||||
precision cannot be reached sending the packets with
|
||||
<code class="literal">pcap_sendpacket()</code>.
|
||||
</p>
|
||||
</dd><dt><span class="term">
|
||||
<code class="code">pcap_stats_ex</code>
|
||||
</span></dt><dd>
|
||||
<code class="code">struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size);</code>
|
||||
<p>
|
||||
<code class="literal">pcap_stats_ex()</code> extends the
|
||||
<code class="literal">pcap_stats()</code> allowing to return more statistical
|
||||
parameters than the old call. One of the advantages of
|
||||
this new call is that the <code class="literal">pcap_stat</code> structure is
|
||||
not allocated by the user; instead, it is returned back by the
|
||||
system. This allow to extend the <code class="literal">pcap_stat</code>
|
||||
structure without affecting backward compatibility on older
|
||||
applications. These will simply check at the values of the members
|
||||
at the beginning of the structure, while only newest applications
|
||||
are able to read new statistical values, which are appended in
|
||||
tail.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To be sure not to read a piece of memory which has not been allocated
|
||||
by the system, the variable <code class="literal">pcap_stat_size</code> will
|
||||
return back the size of the structure <code class="literal">pcap_stat</code>
|
||||
allocated by the system.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<code class="literal">p</code>: pointer to the <code class="literal">pcap_t</code>
|
||||
currently in use. <code class="literal">pcap_stat_size</code>: pointer to an
|
||||
integer that will contain (when the function returns back) the size
|
||||
of the structure <code class="literal">pcap_stat</code> as it has been
|
||||
allocated by the system.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The function returns a pointer to a pcap_stat structure, that will
|
||||
contain the statistics related to the current device. The return
|
||||
value is <code class="literal">NULL</code> in case of errors, and the error
|
||||
text can be obtained with <code class="literal">pcap_perror()</code> or
|
||||
<code class="literal">pcap_geterr()</code>.
|
||||
</p>
|
||||
</dd><dt><span class="term">
|
||||
<code class="code">pcap_setuserbuffer</code>
|
||||
</span></dt><dd>
|
||||
<p>Sets the size of the buffer that accepts packets from the kernel driver.</p>
|
||||
<code class="code">int pcap_setuserbuffer(pcap_t *p, int size);</code>
|
||||
|
||||
<p>
|
||||
The size of the packet buffer is a parameter that can sensibly
|
||||
influence the performance of the capture process, since this buffer
|
||||
will contain the packets received from the the Npcap driver. The
|
||||
driver is able to return several packets using a single read call,
|
||||
and the number of packets transferable to the application in a call
|
||||
is limited only by the size of this buffer. Therefore setting a
|
||||
larger buffer siz can noticeably decrease the number of system
|
||||
calls, reducing the impact of the capture process on the processor.
|
||||
</p>
|
||||
</dd></dl></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="npcap-users-guide.html">Prev</a><EFBFBD></td><td width="20%" align="center"><EFBFBD></td><td width="40%" align="right"><EFBFBD><a accesskey="n" href="npcap-tutorial.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Npcap Users' Guide<64></td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"><EFBFBD>Npcap Development Tutorial</td></tr></table></div></body></html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user