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