Self test almost builds, now need skeleton EthernetTap implementation for Windows.

This commit is contained in:
Adam Ierymenko 2013-08-14 11:19:21 -04:00
parent 1f9a7e26ba
commit 150a53eb17
13 changed files with 51 additions and 61 deletions

3
.gitignore vendored
View File

@ -10,3 +10,6 @@ mac-tap/tuntap/tap.kext
/ipch
/ZeroTierOne.v11.suo
/ZeroTierOne.opensdf
/vsprojects/SelfTest/Debug
/vsprojects/SelfTest/SelfTest.vcxproj.user
/Debug

View File

@ -47,10 +47,21 @@ int KISSDB_open(
uint64_t *httmp;
uint64_t *hash_tables_rea;
#ifdef _WIN32
db->f = (FILE *)0;
fopen_s(&db->f,path,((mode == KISSDB_OPEN_MODE_RWREPLACE) ? "w+b" : (((mode == KISSDB_OPEN_MODE_RDWR)||(mode == KISSDB_OPEN_MODE_RWCREAT)) ? "r+b" : "rb")));
#else
db->f = fopen(path,((mode == KISSDB_OPEN_MODE_RWREPLACE) ? "w+b" : (((mode == KISSDB_OPEN_MODE_RDWR)||(mode == KISSDB_OPEN_MODE_RWCREAT)) ? "r+b" : "rb")));
#endif
if (!db->f) {
if (mode == KISSDB_OPEN_MODE_RWCREAT)
if (mode == KISSDB_OPEN_MODE_RWCREAT) {
#ifdef _WIN32
db->f = (FILE *)0;
fopen_s(&db->f,path,"w+b");
#else
db->f = fopen(path,"w+b");
#endif
}
if (!db->f)
return KISSDB_ERROR_IO;
}

View File

@ -44,8 +44,8 @@
namespace ZeroTier {
const Demarc::Port Demarc::ANY_PORT;
const Demarc::Port Demarc::NULL_PORT;
const Demarc::Port Demarc::ANY_PORT = (Port)0xffffffffffffffffULL;
const Demarc::Port Demarc::NULL_PORT = (Port)0;
Demarc::Demarc(const RuntimeEnvironment *renv) :
_r(renv)

View File

@ -64,12 +64,12 @@ public:
/**
* Port identifier used to refer to any port
*/
static const Port ANY_PORT = (Port)0xffffffffffffffffULL;
static const Port ANY_PORT;
/**
* Port identifier used to refer to null port / port not found
*/
static const Port NULL_PORT = (Port)0;
static const Port NULL_PORT;
Demarc(const RuntimeEnvironment *renv);
~Demarc();

View File

@ -351,7 +351,7 @@ Node::ReasonForTermination Node::run()
// Make sure networks.d exists
#ifdef __WINDOWS__
CreateDirectory((_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d").c_str(),NULL);
CreateDirectoryA((_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d").c_str(),NULL);
#else
mkdir((_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d").c_str(),0700);
#endif

View File

@ -220,11 +220,11 @@ std::map<std::string,bool> Utils::listDirectory(const char *path)
#ifdef __WINDOWS__
HANDLE hFind;
WIN32_FIND_DATA ffd;
if ((hFind = FindFirstFile((std::string(path) + "\\*").c_str(),&ffd)) != INVALID_HANDLE_VALUE) {
WIN32_FIND_DATAA ffd;
if ((hFind = FindFirstFileA((std::string(path) + "\\*").c_str(),&ffd)) != INVALID_HANDLE_VALUE) {
do {
r[std::string(ffd.cFileName)] = ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
} while (FindNextFile(hFind,&ffd));
} while (FindNextFileA(hFind,&ffd));
FindClose(hFind);
}
#else

View File

@ -75,7 +75,7 @@ public:
throw()
{
#ifdef __WINDOWS__
return (DeleteFile(path) != FALSE);
return (DeleteFileA(path) != FALSE);
#else
return (unlink(path) == 0);
#endif

View File

@ -51,6 +51,10 @@
#include <openssl/rand.h>
#ifdef __WINDOWS__
#include <tchar.h>
#endif
using namespace ZeroTier;
// ---------------------------------------------------------------------------
@ -394,12 +398,16 @@ static int testRateLimiter()
return 0;
}
#ifdef __WINDOWS__
int _tmain(int argc, _TCHAR* argv[])
#else
int main(int argc,char **argv)
#endif
{
int r = 0;
_initLibCrypto();
srand(time(0));
srand((unsigned int)time(0));
r |= testCrypto();
r |= testPacket();

View File

@ -1,11 +0,0 @@
// SelfTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}

View File

@ -47,7 +47,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -57,6 +57,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(SolutionDir)\ext\bin\libcrypto\win32-vs2012\libeay32.lib;wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -119,10 +120,12 @@
<ClInclude Include="..\..\node\Topology.hpp" />
<ClInclude Include="..\..\node\UdpSocket.hpp" />
<ClInclude Include="..\..\node\Utils.hpp" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\ext\kissdb\kissdb.c" />
<ClCompile Include="..\..\ext\lz4\lz4.c" />
<ClCompile Include="..\..\ext\lz4\lz4hc.c" />
<ClCompile Include="..\..\node\Defaults.cpp" />
<ClCompile Include="..\..\node\Demarc.cpp" />
<ClCompile Include="..\..\node\EllipticCurveKeyPair.cpp" />
@ -145,11 +148,7 @@
<ClCompile Include="..\..\node\Topology.cpp" />
<ClCompile Include="..\..\node\UdpSocket.cpp" />
<ClCompile Include="..\..\node\Utils.cpp" />
<ClCompile Include="SelfTest.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\selftest.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -15,9 +15,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -149,12 +146,6 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SelfTest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Defaults.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -221,5 +212,17 @@
<ClCompile Include="..\..\node\Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\selftest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\kissdb\kissdb.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\lz4\lz4.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\lz4\lz4hc.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -1,8 +0,0 @@
// stdafx.cpp : source file that includes just the standard includes
// SelfTest.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

View File

@ -1,15 +0,0 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here