Commit e732f14e authored by Jondy Zhao's avatar Jondy Zhao

ipwin: add option to get ipv6 route after windows vista

parent 8fd5bb63
......@@ -16,7 +16,7 @@ GOTO END
:ARCH_X86
IF EXIST %VCVARSALL%. (
CALL %VCVARSALL%
cl /D"UNICODE" /D"_UNICODE" ipwin.cpp netcfg.cpp setupapi.lib iphlpapi.lib advapi32.lib
cl /D"UNICODE" /D"_UNICODE" ipwin.cpp netcfg.cpp setupapi.lib iphlpapi.lib advapi32.lib ws2_32.lib
GOTO END )
ECHO.
......@@ -32,7 +32,7 @@ IF EXIST %SETENV%. (
SETLOCAL ENABLEDELAYEDEXPANSION
SETLOCAL ENABLEDELAYEDEXPANSION
CALL %SETENV%
cl /D"UNICODE" /D"_UNICODE" ipwin.cpp netcfg.cpp setupapi.lib iphlpapi.lib advapi32.lib
cl /D"UNICODE" /D"_UNICODE" ipwin.cpp netcfg.cpp setupapi.lib iphlpapi.lib advapi32.lib ws2_32.lib
GOTO END )
ECHO.
......
......@@ -56,6 +56,8 @@ HRESULT SlaposNetCfgGetNetworkConnectionName(IN LPCWSTR pGUID,
OUT BSTR *pName,
OUT BSTR *pErrMsg
);
HRESULT SlaposIPv6ShowRoute(int verbose);
void Usage()
{
printf("Usage: ipwin [command] [options] \n\
......@@ -65,6 +67,7 @@ Available command:\n\
remove Remove network adapter\n\
guid Get GUID of interface by name\n\
name Get name by GUID\n\
ipv6 Get information of IPv6\n\
codepage Get Windows CodePage\n\
\n\
*install\n\
......@@ -74,7 +77,7 @@ Available command:\n\
ipwin install INF-FILE HWID CONNECTION-NAME\n\
\n\
For example,\n\
ipwin install \"OemWin2k.inf\" tap0901 re6stnet-tcp\n\
ipwin install \"C:/openvpn/driver/OemWin2k.inf\" tap0901 re6stnet-tcp\n\
\n\
ipwin install \"netloop.inf\" *MSLOOP re6stnet-lo\n\
\n\
......@@ -102,6 +105,16 @@ Available command:\n\
For example,\n\
ipwin name {610B0F3F-06A7-47EF-A38D-EF55503C481F}\n\
\n\
*ipv6\n\
\n\
Print IPv6 route information:\n\
ipwin ipv6 show route\n\
\n\
\n\
Exit status:\n\
0 if OK,\n\
other value if problems\n\
\n\
*codepage\n\
\n\
Get codepage of Windows:\n\
......@@ -326,6 +339,15 @@ int _tmain(int argc, TCHAR * argv[])
printf("%s", hr == S_OK ? pGUID : pErrMsg);
}
}
else if (wcscmp(argv[1], L"ipv6") == 0) {
if (argc < 4) {
Usage();
hr = E_FAIL;
}
else {
hr = SlaposIPv6ShowRoute(1);
}
}
else if (wcscmp(argv[1], L"codepage") == 0) {
hr = PrintCodePage(0);
}
......
......@@ -11,6 +11,7 @@
#include <Windows.h>
#include <Setupapi.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <devguid.h>
#include <stdio.h>
......@@ -1337,3 +1338,50 @@ HRESULT SlaposNetCfgGetNetworkConnectionName(IN LPCWSTR pGUID,
return hrc;
}
HRESULT SlaposIPv6ShowRoute(int verbose)
{
int i;
ULONG NumEntries = -1;
#if _WIN32_WINNT < _WIN32_WINNT_VISTA
fprintf(stderr, "Error: unsupported platform\n");
return E_FAIL;
#else
PMIB_IPFORWARD_TABLE2 pIpForwardTable2;
PMIB_IPFORWARD_ROW2 pRow2;
char prefix[200], gateway[200];
char ifname[IF_NAMESIZE];
if (NO_ERROR == GetIpForwardTable2(AF_INET6,
&pIpForwardTable2
)) {
NumEntries = pIpForwardTable2->NumEntries;
pRow2 = pIpForwardTable2 -> Table;
for (i = 0; i < NumEntries; i++, pRow2 ++) {
// Ignore invalid route
if (pRow2 -> Loopback || IN6_IS_ADDR_UNSPECIFIED(&((pRow2 -> NextHop).Ipv6.sin6_addr)))
continue;
inet_ntop(AF_INET6,
(PVOID)(&((pRow2 -> DestinationPrefix).Prefix.Ipv6.sin6_addr)),
prefix,
200
);
inet_ntop(AF_INET6,
(PVOID)(&((pRow2 -> NextHop).Ipv6.sin6_addr)),
gateway,
200
);
if_indextoname(pRow2 -> InterfaceIndex, ifname);
printf("Prefix : %s/%d\n", prefix, (pRow2 -> DestinationPrefix).PrefixLength);
printf("Interface %d : %s\n", (unsigned int)(pRow2 -> InterfaceIndex), ifname);
printf("Gateway : %s\n", gateway);
printf("\n");
}
FreeMibTable(pIpForwardTable2);
return S_OK;
}
fprintf(stderr, "GetIpForwardTable2 error\n");
return E_FAIL;
#endif
}
......@@ -49,6 +49,7 @@ echo ""
# ======================================================================
# Constants
# ======================================================================
declare -r slapos_prefix=slapboot-
declare -r slapos_client_home=~/.slapos
declare -r client_configure_file=$slapos_client_home/slapos.cfg
declare -r client_certificate_file=$slapos_client_home/certificate
......@@ -58,10 +59,16 @@ declare -r node_certificate_file=/etc/opt/slapos/ssl/computer.crt
declare -r node_key_file=/etc/opt/slapos/ssl/computer.key
declare -r node_configure_file=/etc/opt/slapos/slapos.cfg
declare -r slapos_ifname=slapboot-re6stnet-lo
declare -r ipv4_local_network=10.202.29.0/24
declare -r ipv6_local_address=2001:67c:1254:e:32::1
declare -r slapos_user_basename=slapboot-user
declare -r slapos_administrator=${slapos_prefix:-slap}root
declare -r slapos_user_basename=${slapos_prefix:-slap}user
declare -r slapos_ifname=${slapos_prefix}re6stnet-lo
declare -r re6stnet_service_name=${slapos_prefix}re6stnet
declare -r cron_service_name=${slapos_prefix}cron
declare -r syslog_service_name=${slapos_prefix}syslog-ng
declare -r cygserver_service_name=${slapos_prefix}cygserver
declare -r slapos_installer_software=http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/slapos-windows-installer/software.cfg
declare -r cygwin_home=$(cygpath -a $(cygpath -w /)\\.. | sed -e "s%/$%%")
......
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