Commit 7beac5ad authored by Jondy Zhao's avatar Jondy Zhao

ipwin: add command to show ipv6 default route

ip: support to show ipv6 default route
parent 61de57f1
......@@ -56,7 +56,7 @@ HRESULT SlaposNetCfgGetNetworkConnectionName(IN LPCWSTR pGUID,
OUT BSTR *pName,
OUT BSTR *pErrMsg
);
HRESULT SlaposIPv6ShowRoute(int verbose);
HRESULT SlaposIPv6ShowRoute(int mode);
void Usage()
{
......@@ -109,6 +109,9 @@ Available command:\n\
\n\
Print IPv6 route information:\n\
ipwin ipv6 show route\n\
\n\
Print IPv6 default route information:\n\
ipwin ipv6 show route default\n\
\n\
\n\
Exit status:\n\
......@@ -344,7 +347,12 @@ int _tmain(int argc, TCHAR * argv[])
Usage();
hr = E_FAIL;
}
else if (argc == 5) {
// Only show default route
hr = SlaposIPv6ShowRoute(0);
}
else {
// Show all ipv6 route
hr = SlaposIPv6ShowRoute(1);
}
}
......
......@@ -1364,7 +1364,7 @@ HRESULT SlaposNetCfgGetNetworkConnectionName(IN LPCWSTR pGUID,
return hrc;
}
HRESULT SlaposIPv6ShowRoute(int verbose)
HRESULT SlaposIPv6ShowRoute(int mode)
{
int i;
ULONG NumEntries = -1;
......@@ -1398,10 +1398,22 @@ HRESULT SlaposIPv6ShowRoute(int verbose)
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");
if (mode == 1) {
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");
}
else if (mode == 0) {
// Print default route
if (IN6_IS_ADDR_UNSPECIFIED(&((pRow2 -> DestinationPrefix).Prefix.Ipv6.sin6_addr)))
printf("default proto %d metric %d mtu %s advmss %s\n",
pRow2 -> Protocol,
pRow2 -> Metric,
"unknown",
"unknown"
);
}
}
FreeMibTable(pIpForwardTable2);
return S_OK;
......
......@@ -581,6 +581,9 @@ elif [[ $object == "route" ]] ; then
if [[ $command != "show" ]] ; then
prefix=$1
shift
elif [[ "$1" == "default" ]] ; then
ipwin ipv6 show route default
exit $?
fi
while [[ "$1" != "" ]] ; do
......
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