Commit 4ff7dc9f authored by Jondy Zhao's avatar Jondy Zhao

Fix add openvpn driver failed in the international environments:

  Add ipwin functioin to install a tap-window driver and rename connection name
parent d8d4fed0
...@@ -8,6 +8,12 @@ ...@@ -8,6 +8,12 @@
<surname>Zhao</surname> <surname>Zhao</surname>
</author> </author>
<revhistory> <revhistory>
<revision>
<revnumber>0.2</revnumber>
<date>2013-07-05</date>
<authorinitials>Jondy Zhao - jondy.zhao@nexedi.com</authorinitials>
<revremark>Add Cron Service and Know Issues section, fix some problems in the chapter Generating windows installer from sources.</revremark>
</revision>
<revision> <revision>
<revnumber>0.1</revnumber> <revnumber>0.1</revnumber>
<date>2013-06-20</date> <date>2013-06-20</date>
......

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ipwin", "ipwin\ipwin.vcproj", "{01FF89A6-D888-410B-A6EF-02AF59BCF503}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{01FF89A6-D888-410B-A6EF-02AF59BCF503}.Debug|Win32.ActiveCfg = Debug|Win32
{01FF89A6-D888-410B-A6EF-02AF59BCF503}.Debug|Win32.Build.0 = Debug|Win32
{01FF89A6-D888-410B-A6EF-02AF59BCF503}.Release|Win32.ActiveCfg = Release|Win32
{01FF89A6-D888-410B-A6EF-02AF59BCF503}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
/*
* Syntax:
*
* ipwin command options
*
* Get guid of interface:
*
* ipwin guid *MSLOOP re6stnet-lo
*
* Install network adapter and rename connection
*
* ipwin install "OemWin2k.inf" tap0901 re6stnet-tcp
*
* ipwin install "netloop.inf" *MSLOOP re6stnet-lo
*
* Remove network adapter
*
* ipwin remove tap0901 re6stnet-tcp
*
* Run all of testcases:
*
* ipwin test
*
*/
#include <Windows.h>
#include <tchar.h>
#include <stdio.h>
HRESULT SlaposNetCfgWinCreateNetworkInterface(IN LPCWSTR pInfPath,
IN bool bIsInfPathFile,
IN LPCWSTR pHwid,
IN LPCWSTR pConnectionName,
OUT GUID *pGuid,
OUT BSTR *pErrMsg
);
HRESULT SlaposNetCfgWinRemoveNetworkInterface(IN LPCWSTR pHwid,
IN LPCSTR pGUID,
OUT BSTR *pErrMsg
);
HRESULT SlaposNetCfgGetNetworkInterfaceGuid(IN LPCWSTR pHwid,
IN LPCWSTR pConnectionName,
OUT BSTR *pGUID,
OUT BSTR *pErrMsg
);
void usage()
{
printf("Usage: ipwin [command] [options] \n\n\
Get guid of interface:\n\
ipwin guid HWID CONNECTION-NAME\n\n\
For example,\n\
ipwin guid *MSLOOP re6stnet-lo\n\
\n\
Install network adapter and rename connection:\n\
ipwin install INF-FILE HWID CONNECTION-NAME\n\n\
For example,\n\
ipwin install \"OemWin2k.inf\" tap0901 re6stnet-tcp\n\
\n\
ipwin install \"netloop.inf\" *MSLOOP re6stnet-lo\n\
\n\
Remove network adapter:\n\
ipwin remove HWID CONNECTIION-NAME\n\n\
For example,\n\
ipwin remove tap0901 re6stnet-tcp\n\
\n\n\
Exit status:\n\
0 if OK,\n\
other value if problems\n\
\n");
}
int _tmain(int argc, TCHAR * argv[])
{
GUID guid;
BSTR pErrMsg[1024] = {0};
BSTR pGUID[512] = {0};
HRESULT hr = CoInitialize(NULL);
if (argc == 1) {
usage();
}
else if (wcscmp(argv[1], L"install") == 0) {
if (argc != 5) {
usage();
hr = E_FAIL;
}
else
hr = SlaposNetCfgWinCreateNetworkInterface(argv[2], TRUE, argv[3], argv[4], &guid, pErrMsg);
}
else if (wcscmp(argv[1], L"remove") == 0) {
if (argc != 4) {
usage();
hr = E_FAIL;
}
else {
hr = SlaposNetCfgGetNetworkInterfaceGuid(argv[2], argv[3], pGUID, pErrMsg);
if (hr == S_OK) {
hr = SlaposNetCfgWinRemoveNetworkInterface(argv[2], (LPCSTR)pGUID, pErrMsg);
}
}
}
else if (wcscmp(argv[1], L"guid") == 0) {
if (argc != 4) {
usage();
hr = E_FAIL;
}
else {
hr = SlaposNetCfgGetNetworkInterfaceGuid(argv[2], argv[3], pGUID, pErrMsg);
printf("%s\n", hr == S_OK ? pGUID : pErrMsg);
}
}
else if (wcscmp(argv[1], L"test") == 0) {
}
else {
usage();
}
CoUninitialize();
return hr;
}
<?xml version="1.0" encoding="gb2312"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="ipwin"
ProjectGUID="{01FF89A6-D888-410B-A6EF-02AF59BCF503}"
RootNamespace="ipwin"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="setupapi.lib iphlpapi.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="setupapi.lib iphlpapi.lib"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Դļ"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\ipwin.cpp"
>
</File>
<File
RelativePath=".\netcfg.cpp"
>
</File>
</Filter>
<Filter
Name="ͷļ"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\netcfgn.h"
>
</File>
<File
RelativePath=".\netcfgx.h"
>
</File>
</Filter>
<Filter
Name="Դļ"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -295,6 +295,46 @@ echo ...@@ -295,6 +295,46 @@ echo
echo Configure section config OK. echo Configure section config OK.
echo echo
# -----------------------------------------------------------
# taps: Install openvpn tap-windows drivers used by re6stnet
# -----------------------------------------------------------
#
# Adding tap-windows driver will break others, so we add all drivers
# here. Get re6stnet client count, then remove extra drivers and add
# required drivers.
if check_re6stnet_needed ; then
echo
echo Starting configure section taps ...
echo
original_connections=$(echo $(get_all_connections))
client_count=$(sed -n -e "s/^client-count *//p" $re6stnet_configure_file)
[[ -z "$client_count" ]] && client_count=10
echo " Client count: $client_count"
re6stnet_name_list="re6stnet-tcp re6stnet-udp"
for (( i=1; i<=client_count; i=i+1 )) ; do
re6stnet_name_list="$re6stnet_name_list re6stnet$i"
done
for name in $re6stnet_name_list ; do
echo "Checking interface $name ..."
if [[ ! " $original_connections " == *[\ ]$name[\ ]* ]] ; then
echo "Installing interface $name ..."
ip vpntap add dev $name || \
show_error_exit "Failed to install OpenVPN Tap-Windows Driver."
echo "Interface $name installed."
else
echo "$name has been installed."
fi
done
#
# Remove OpenVPN Tap-Windows Driver
#
# ip vpntap del dev re6stnet-x
#
echo
echo Configure section taps OK.
echo
fi
# ----------------------------------------------------------- # -----------------------------------------------------------
# re6stnet: Install required packages and register to nexedi # re6stnet: Install required packages and register to nexedi
# ----------------------------------------------------------- # -----------------------------------------------------------
...@@ -394,44 +434,6 @@ echo ...@@ -394,44 +434,6 @@ echo
echo Configure section re6stnet OK. echo Configure section re6stnet OK.
echo echo
# -----------------------------------------------------------
# taps: Install openvpn tap-windows drivers used by re6stnet
# -----------------------------------------------------------
#
# Adding tap-windows driver will break others, so we add all drivers
# here. Get re6stnet client count, then remove extra drivers and add
# required drivers.
echo
echo Starting configure section taps ...
echo
original_connections=$(echo $(get_all_connections))
client_count=$(sed -n -e "s/^client-count *//p" $re6stnet_configure_file)
[[ -z "$client_count" ]] && client_count=10
echo " Client count: $client_count"
re6stnet_name_list="re6stnet-tcp re6stnet-udp"
for (( i=1; i<=client_count; i=i+1 )) ; do
re6stnet_name_list="$re6stnet_name_list re6stnet$i"
done
for name in $re6stnet_name_list ; do
echo "Checking interface $name ..."
if [[ ! " $original_connections " == *[\ ]$name[\ ]* ]] ; then
echo "Installing interface $name ..."
ip vpntap add dev $name || \
show_error_exit "Failed to install OpenVPN Tap-Windows Driver."
echo "Interface $name installed."
else
echo "$name has been installed."
fi
done
#
# Remove OpenVPN Tap-Windows Driver
#
# ip vpntap del dev re6stnet-x
#
echo
echo Configure section taps OK.
echo
# ----------------------------------------------------------- # -----------------------------------------------------------
# runner: Create instance of slap web runner # runner: Create instance of slap web runner
# ----------------------------------------------------------- # -----------------------------------------------------------
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment