ipconfig: Implement gateway address output.

oldstable
Andrew Nguyen 2010-09-27 04:30:59 -05:00 committed by Alexandre Julliard
parent 7df2d4b231
commit 11d332c37c
3 changed files with 44 additions and 2 deletions

View File

@ -44,4 +44,5 @@ STRINGTABLE
STRING_DHCP_ENABLED, "DHCP enabled"
STRING_YES, "Yes"
STRING_NO, "No"
STRING_DEFAULT_GATEWAY, "Default gateway"
}

View File

@ -130,6 +130,17 @@ static void print_field(int msg, const WCHAR *value)
ipconfig_printfW(formatW, field, value);
}
static void print_value(const WCHAR *value)
{
static const WCHAR formatW[] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
'%','s','\n',0};
ipconfig_printfW(formatW, value);
}
static BOOL socket_address_to_string(WCHAR *buf, DWORD len, SOCKET_ADDRESS *addr)
{
return WSAAddressToStringW(addr->lpSockaddr,
@ -155,8 +166,10 @@ static void print_basic_information(void)
for (p = adapters; p; p = p->Next)
{
static const WCHAR newlineW[] = {'\n',0};
static const WCHAR emptyW[] = {0};
IP_ADAPTER_UNICAST_ADDRESS *addr;
IP_ADAPTER_GATEWAY_ADDRESS_LH *gateway;
WCHAR addr_buf[54];
ipconfig_message_printfW(STRING_ADAPTER_FRIENDLY, iftype_to_string(p->IfType), p->FriendlyName);
@ -170,7 +183,20 @@ static void print_basic_information(void)
/* FIXME: Output corresponding subnet mask. */
}
/* FIXME: Output default gateway address. */
if (p->FirstGatewayAddress)
{
if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &p->FirstGatewayAddress->Address))
print_field(STRING_DEFAULT_GATEWAY, addr_buf);
for (gateway = p->FirstGatewayAddress->Next; gateway; gateway = gateway->Next)
{
if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &gateway->Address))
print_value(addr_buf);
}
}
else
print_field(STRING_DEFAULT_GATEWAY, emptyW);
ipconfig_printfW(newlineW);
}
}
@ -245,6 +271,7 @@ static const WCHAR *boolean_to_string(int value)
static void print_full_information(void)
{
static const WCHAR newlineW[] = {'\n',0};
static const WCHAR emptyW[] = {0};
FIXED_INFO *info;
IP_ADAPTER_ADDRESSES *adapters;
@ -290,6 +317,7 @@ static void print_full_information(void)
{
IP_ADAPTER_UNICAST_ADDRESS *addr;
WCHAR physaddr_buf[3 * MAX_ADAPTER_ADDRESS_LENGTH];
IP_ADAPTER_GATEWAY_ADDRESS_LH *gateway;
WCHAR addr_buf[54];
ipconfig_message_printfW(STRING_ADAPTER_FRIENDLY, iftype_to_string(p->IfType), p->FriendlyName);
@ -308,7 +336,19 @@ static void print_full_information(void)
/* FIXME: Output corresponding subnet mask. */
}
/* FIXME: Output default gateway address. */
if (p->FirstGatewayAddress)
{
if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &p->FirstGatewayAddress->Address))
print_field(STRING_DEFAULT_GATEWAY, addr_buf);
for (gateway = p->FirstGatewayAddress->Next; gateway; gateway = gateway->Next)
{
if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &gateway->Address))
print_value(addr_buf);
}
}
else
print_field(STRING_DEFAULT_GATEWAY, emptyW);
ipconfig_printfW(newlineW);
}

View File

@ -40,3 +40,4 @@
#define STRING_DHCP_ENABLED 117
#define STRING_YES 118
#define STRING_NO 119
#define STRING_DEFAULT_GATEWAY 120