2010-08-16 09:54:00 +02:00
|
|
|
/*
|
|
|
|
* IP configuration utility
|
|
|
|
*
|
2010-08-16 09:54:10 +02:00
|
|
|
* Copyright 2008 Andrew Riedi
|
2010-08-16 09:54:00 +02:00
|
|
|
* Copyright 2010 Andrew Nguyen
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2017-05-10 16:29:11 +02:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2019-04-29 10:49:31 +02:00
|
|
|
#include <stdio.h>
|
2011-05-19 14:10:09 +02:00
|
|
|
#include <winsock2.h>
|
2010-08-16 09:54:00 +02:00
|
|
|
#include <windows.h>
|
2010-08-17 04:27:32 +02:00
|
|
|
#include <iphlpapi.h>
|
2010-08-16 09:54:00 +02:00
|
|
|
|
2010-08-16 09:54:10 +02:00
|
|
|
#include "ipconfig.h"
|
|
|
|
|
2011-11-19 15:11:58 +01:00
|
|
|
static int ipconfig_vprintfW(const WCHAR *msg, __ms_va_list va_args)
|
2010-08-16 09:54:10 +02:00
|
|
|
{
|
|
|
|
int wlen;
|
|
|
|
DWORD count, ret;
|
|
|
|
WCHAR msg_buffer[8192];
|
|
|
|
|
2011-11-19 15:11:58 +01:00
|
|
|
wlen = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, msg, 0, 0, msg_buffer,
|
2018-07-24 00:01:29 +02:00
|
|
|
ARRAY_SIZE(msg_buffer), &va_args);
|
2010-08-16 09:54:10 +02:00
|
|
|
|
|
|
|
ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), msg_buffer, wlen, &count, NULL);
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
char *msgA;
|
|
|
|
|
2011-08-24 14:29:31 +02:00
|
|
|
/* On Windows WriteConsoleW() fails if the output is redirected. So fall
|
|
|
|
* back to WriteFile(), assuming the console encoding is still the right
|
|
|
|
* one in that case.
|
|
|
|
*/
|
2010-08-16 09:54:10 +02:00
|
|
|
len = WideCharToMultiByte(GetConsoleOutputCP(), 0, msg_buffer, wlen,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
msgA = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
if (!msgA)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
WideCharToMultiByte(GetConsoleOutputCP(), 0, msg_buffer, wlen, msgA, len,
|
|
|
|
NULL, NULL);
|
|
|
|
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msgA, len, &count, FALSE);
|
|
|
|
HeapFree(GetProcessHeap(), 0, msgA);
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2017-11-02 10:20:57 +01:00
|
|
|
static int WINAPIV ipconfig_printfW(const WCHAR *msg, ...)
|
2010-08-17 04:27:32 +02:00
|
|
|
{
|
2011-11-19 15:11:58 +01:00
|
|
|
__ms_va_list va_args;
|
2010-08-17 04:27:32 +02:00
|
|
|
int len;
|
|
|
|
|
2011-11-19 15:11:58 +01:00
|
|
|
__ms_va_start(va_args, msg);
|
2010-08-17 04:27:32 +02:00
|
|
|
len = ipconfig_vprintfW(msg, va_args);
|
2011-11-19 15:11:58 +01:00
|
|
|
__ms_va_end(va_args);
|
2010-08-17 04:27:32 +02:00
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2017-11-02 10:20:57 +01:00
|
|
|
static int WINAPIV ipconfig_message_printfW(int msg, ...)
|
2010-08-17 04:27:32 +02:00
|
|
|
{
|
2011-11-19 15:11:58 +01:00
|
|
|
__ms_va_list va_args;
|
2010-08-17 04:27:32 +02:00
|
|
|
WCHAR msg_buffer[8192];
|
|
|
|
int len;
|
|
|
|
|
2018-07-24 00:01:29 +02:00
|
|
|
LoadStringW(GetModuleHandleW(NULL), msg, msg_buffer, ARRAY_SIZE(msg_buffer));
|
2010-08-17 04:27:32 +02:00
|
|
|
|
2011-11-19 15:11:58 +01:00
|
|
|
__ms_va_start(va_args, msg);
|
2010-08-17 04:27:32 +02:00
|
|
|
len = ipconfig_vprintfW(msg_buffer, va_args);
|
2011-11-19 15:11:58 +01:00
|
|
|
__ms_va_end(va_args);
|
2010-08-17 04:27:32 +02:00
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2010-08-16 09:54:10 +02:00
|
|
|
static int ipconfig_message(int msg)
|
|
|
|
{
|
|
|
|
WCHAR msg_buffer[8192];
|
|
|
|
|
2018-07-24 00:01:29 +02:00
|
|
|
LoadStringW(GetModuleHandleW(NULL), msg, msg_buffer, ARRAY_SIZE(msg_buffer));
|
2010-08-17 04:27:32 +02:00
|
|
|
|
2020-10-21 01:02:41 +02:00
|
|
|
return ipconfig_printfW(L"%1", msg_buffer);
|
2010-08-16 09:54:10 +02:00
|
|
|
}
|
|
|
|
|
2010-08-17 04:27:32 +02:00
|
|
|
static const WCHAR *iftype_to_string(DWORD type)
|
|
|
|
{
|
|
|
|
static WCHAR msg_buffer[50];
|
|
|
|
|
|
|
|
int msg;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case IF_TYPE_ETHERNET_CSMACD:
|
|
|
|
/* The loopback adapter appears as an Ethernet device. */
|
|
|
|
case IF_TYPE_SOFTWARE_LOOPBACK:
|
|
|
|
msg = STRING_ETHERNET;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
msg = STRING_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2018-07-24 00:01:29 +02:00
|
|
|
LoadStringW(GetModuleHandleW(NULL), msg, msg_buffer, ARRAY_SIZE(msg_buffer));
|
2010-08-17 04:27:32 +02:00
|
|
|
|
|
|
|
return msg_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_field(int msg, const WCHAR *value)
|
|
|
|
{
|
2020-10-21 01:02:41 +02:00
|
|
|
WCHAR field[] = L". . . . . . . . . . . . . . . . . ";
|
2018-07-24 00:01:29 +02:00
|
|
|
WCHAR name_buffer[ARRAY_SIZE(field)];
|
2010-08-17 04:27:32 +02:00
|
|
|
|
2018-07-24 00:01:29 +02:00
|
|
|
LoadStringW(GetModuleHandleW(NULL), msg, name_buffer, ARRAY_SIZE(name_buffer));
|
2019-04-29 10:49:31 +02:00
|
|
|
memcpy(field, name_buffer, sizeof(WCHAR) * min(lstrlenW(name_buffer), ARRAY_SIZE(field) - 1));
|
2010-08-17 04:27:32 +02:00
|
|
|
|
2020-10-21 01:02:41 +02:00
|
|
|
ipconfig_printfW(L" %1: %2\n", field, value);
|
2010-08-17 04:27:32 +02:00
|
|
|
}
|
|
|
|
|
2010-09-27 11:30:59 +02:00
|
|
|
static void print_value(const WCHAR *value)
|
|
|
|
{
|
2020-10-21 01:02:41 +02:00
|
|
|
ipconfig_printfW(L" %1\n", value);
|
2010-09-27 11:30:59 +02:00
|
|
|
}
|
|
|
|
|
2010-09-27 11:30:49 +02:00
|
|
|
static BOOL socket_address_to_string(WCHAR *buf, DWORD len, SOCKET_ADDRESS *addr)
|
|
|
|
{
|
|
|
|
return WSAAddressToStringW(addr->lpSockaddr,
|
|
|
|
addr->iSockaddrLength, NULL,
|
|
|
|
buf, &len) == 0;
|
|
|
|
}
|
|
|
|
|
2010-08-17 04:27:32 +02:00
|
|
|
static void print_basic_information(void)
|
|
|
|
{
|
|
|
|
IP_ADAPTER_ADDRESSES *adapters;
|
|
|
|
ULONG out = 0;
|
|
|
|
|
2010-10-11 17:54:47 +02:00
|
|
|
if (GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS,
|
|
|
|
NULL, NULL, &out) == ERROR_BUFFER_OVERFLOW)
|
2010-08-17 04:27:32 +02:00
|
|
|
{
|
|
|
|
adapters = HeapAlloc(GetProcessHeap(), 0, out);
|
|
|
|
if (!adapters)
|
|
|
|
exit(1);
|
|
|
|
|
2010-10-11 17:54:47 +02:00
|
|
|
if (GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS,
|
|
|
|
NULL, adapters, &out) == ERROR_SUCCESS)
|
2010-08-17 04:27:32 +02:00
|
|
|
{
|
|
|
|
IP_ADAPTER_ADDRESSES *p;
|
|
|
|
|
|
|
|
for (p = adapters; p; p = p->Next)
|
|
|
|
{
|
|
|
|
IP_ADAPTER_UNICAST_ADDRESS *addr;
|
2010-09-27 11:30:59 +02:00
|
|
|
IP_ADAPTER_GATEWAY_ADDRESS_LH *gateway;
|
2010-09-27 11:30:49 +02:00
|
|
|
WCHAR addr_buf[54];
|
2010-08-17 04:27:32 +02:00
|
|
|
|
|
|
|
ipconfig_message_printfW(STRING_ADAPTER_FRIENDLY, iftype_to_string(p->IfType), p->FriendlyName);
|
2020-10-21 01:02:41 +02:00
|
|
|
ipconfig_printfW(L"\n");
|
2010-08-17 04:27:32 +02:00
|
|
|
print_field(STRING_CONN_DNS_SUFFIX, p->DnsSuffix);
|
|
|
|
|
|
|
|
for (addr = p->FirstUnicastAddress; addr; addr = addr->Next)
|
|
|
|
{
|
2013-11-18 16:00:10 +01:00
|
|
|
if (addr->Address.lpSockaddr->sa_family == AF_INET &&
|
2018-07-24 00:01:29 +02:00
|
|
|
socket_address_to_string(addr_buf, ARRAY_SIZE(addr_buf), &addr->Address))
|
2010-08-17 04:27:32 +02:00
|
|
|
print_field(STRING_IP_ADDRESS, addr_buf);
|
2013-11-18 16:00:10 +01:00
|
|
|
else if (addr->Address.lpSockaddr->sa_family == AF_INET6 &&
|
2018-07-24 00:01:29 +02:00
|
|
|
socket_address_to_string(addr_buf, ARRAY_SIZE(addr_buf), &addr->Address))
|
2013-11-18 16:00:10 +01:00
|
|
|
print_field(STRING_IP6_ADDRESS, addr_buf);
|
2010-08-17 04:27:32 +02:00
|
|
|
/* FIXME: Output corresponding subnet mask. */
|
|
|
|
}
|
|
|
|
|
2010-09-27 11:30:59 +02:00
|
|
|
if (p->FirstGatewayAddress)
|
|
|
|
{
|
2018-07-24 00:01:29 +02:00
|
|
|
if (socket_address_to_string(addr_buf, ARRAY_SIZE(addr_buf), &p->FirstGatewayAddress->Address))
|
2010-09-27 11:30:59 +02:00
|
|
|
print_field(STRING_DEFAULT_GATEWAY, addr_buf);
|
|
|
|
|
|
|
|
for (gateway = p->FirstGatewayAddress->Next; gateway; gateway = gateway->Next)
|
|
|
|
{
|
2018-07-24 00:01:29 +02:00
|
|
|
if (socket_address_to_string(addr_buf, ARRAY_SIZE(addr_buf), &gateway->Address))
|
2010-09-27 11:30:59 +02:00
|
|
|
print_value(addr_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-10-21 01:02:41 +02:00
|
|
|
print_field(STRING_DEFAULT_GATEWAY, L"");
|
2010-09-27 11:30:59 +02:00
|
|
|
|
2020-10-21 01:02:41 +02:00
|
|
|
ipconfig_printfW(L"\n");
|
2010-08-17 04:27:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, adapters);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-17 04:28:11 +02:00
|
|
|
static const WCHAR *nodetype_to_string(DWORD type)
|
|
|
|
{
|
|
|
|
static WCHAR msg_buffer[50];
|
|
|
|
|
|
|
|
int msg;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case BROADCAST_NODETYPE:
|
|
|
|
msg = STRING_BROADCAST;
|
|
|
|
break;
|
|
|
|
case PEER_TO_PEER_NODETYPE:
|
|
|
|
msg = STRING_PEER_TO_PEER;
|
|
|
|
break;
|
|
|
|
case MIXED_NODETYPE:
|
|
|
|
msg = STRING_MIXED;
|
|
|
|
break;
|
|
|
|
case HYBRID_NODETYPE:
|
|
|
|
msg = STRING_HYBRID;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
msg = STRING_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2018-07-24 00:01:29 +02:00
|
|
|
LoadStringW(GetModuleHandleW(NULL), msg, msg_buffer, ARRAY_SIZE(msg_buffer));
|
2010-08-17 04:28:11 +02:00
|
|
|
|
|
|
|
return msg_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *physaddr_to_string(WCHAR *buf, BYTE *addr, DWORD len)
|
|
|
|
{
|
|
|
|
if (!len)
|
|
|
|
*buf = '\0';
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WCHAR *p = buf;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
for (i = 0; i < len - 1; i++)
|
|
|
|
{
|
2020-10-21 01:02:41 +02:00
|
|
|
swprintf(p, 4, L"%02X-", addr[i]);
|
2010-08-17 04:28:11 +02:00
|
|
|
p += 3;
|
|
|
|
}
|
2020-10-21 01:02:41 +02:00
|
|
|
swprintf(p, 3, L"%02X", addr[i]);
|
2010-08-17 04:28:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2010-09-07 12:01:22 +02:00
|
|
|
static const WCHAR *boolean_to_string(int value)
|
|
|
|
{
|
|
|
|
static WCHAR msg_buffer[15];
|
|
|
|
|
|
|
|
LoadStringW(GetModuleHandleW(NULL), value ? STRING_YES : STRING_NO,
|
2018-07-24 00:01:29 +02:00
|
|
|
msg_buffer, ARRAY_SIZE(msg_buffer));
|
2010-09-07 12:01:22 +02:00
|
|
|
|
|
|
|
return msg_buffer;
|
|
|
|
}
|
|
|
|
|
2010-08-17 04:28:11 +02:00
|
|
|
static void print_full_information(void)
|
|
|
|
{
|
|
|
|
FIXED_INFO *info;
|
|
|
|
IP_ADAPTER_ADDRESSES *adapters;
|
|
|
|
ULONG out = 0;
|
|
|
|
|
|
|
|
if (GetNetworkParams(NULL, &out) == ERROR_BUFFER_OVERFLOW)
|
|
|
|
{
|
|
|
|
info = HeapAlloc(GetProcessHeap(), 0, out);
|
|
|
|
if (!info)
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
if (GetNetworkParams(info, &out) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WCHAR hostnameW[MAX_HOSTNAME_LEN + 4];
|
|
|
|
|
2018-07-24 00:01:29 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, info->HostName, -1, hostnameW, ARRAY_SIZE(hostnameW));
|
2010-08-17 04:28:11 +02:00
|
|
|
print_field(STRING_HOSTNAME, hostnameW);
|
|
|
|
|
|
|
|
/* FIXME: Output primary DNS suffix. */
|
|
|
|
|
|
|
|
print_field(STRING_NODE_TYPE, nodetype_to_string(info->NodeType));
|
2010-09-07 12:01:22 +02:00
|
|
|
print_field(STRING_IP_ROUTING, boolean_to_string(info->EnableRouting));
|
2010-08-17 04:28:11 +02:00
|
|
|
|
|
|
|
/* FIXME: Output WINS proxy status and DNS suffix search list. */
|
|
|
|
|
2020-10-21 01:02:41 +02:00
|
|
|
ipconfig_printfW(L"\n");
|
2010-08-17 04:28:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, info);
|
|
|
|
}
|
|
|
|
|
2010-10-11 17:54:47 +02:00
|
|
|
if (GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS,
|
|
|
|
NULL, NULL, &out) == ERROR_BUFFER_OVERFLOW)
|
2010-08-17 04:28:11 +02:00
|
|
|
{
|
|
|
|
adapters = HeapAlloc(GetProcessHeap(), 0, out);
|
|
|
|
if (!adapters)
|
|
|
|
exit(1);
|
|
|
|
|
2010-10-11 17:54:47 +02:00
|
|
|
if (GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS,
|
|
|
|
NULL, adapters, &out) == ERROR_SUCCESS)
|
2010-08-17 04:28:11 +02:00
|
|
|
{
|
|
|
|
IP_ADAPTER_ADDRESSES *p;
|
|
|
|
|
|
|
|
for (p = adapters; p; p = p->Next)
|
|
|
|
{
|
|
|
|
IP_ADAPTER_UNICAST_ADDRESS *addr;
|
|
|
|
WCHAR physaddr_buf[3 * MAX_ADAPTER_ADDRESS_LENGTH];
|
2010-09-27 11:30:59 +02:00
|
|
|
IP_ADAPTER_GATEWAY_ADDRESS_LH *gateway;
|
2010-09-27 11:30:49 +02:00
|
|
|
WCHAR addr_buf[54];
|
2010-08-17 04:28:11 +02:00
|
|
|
|
|
|
|
ipconfig_message_printfW(STRING_ADAPTER_FRIENDLY, iftype_to_string(p->IfType), p->FriendlyName);
|
2020-10-21 01:02:41 +02:00
|
|
|
ipconfig_printfW(L"\n");
|
2010-08-17 04:28:11 +02:00
|
|
|
print_field(STRING_CONN_DNS_SUFFIX, p->DnsSuffix);
|
|
|
|
print_field(STRING_DESCRIPTION, p->Description);
|
|
|
|
print_field(STRING_PHYS_ADDR, physaddr_to_string(physaddr_buf, p->PhysicalAddress, p->PhysicalAddressLength));
|
2017-05-10 16:29:11 +02:00
|
|
|
print_field(STRING_DHCP_ENABLED, boolean_to_string(p->u1.Flags & IP_ADAPTER_DHCP_ENABLED));
|
2010-08-17 04:28:11 +02:00
|
|
|
|
|
|
|
/* FIXME: Output autoconfiguration status. */
|
|
|
|
|
|
|
|
for (addr = p->FirstUnicastAddress; addr; addr = addr->Next)
|
|
|
|
{
|
2013-01-05 16:38:00 +01:00
|
|
|
if (addr->Address.lpSockaddr->sa_family == AF_INET &&
|
2018-07-24 00:01:29 +02:00
|
|
|
socket_address_to_string(addr_buf, ARRAY_SIZE(addr_buf), &addr->Address))
|
2010-08-17 04:28:11 +02:00
|
|
|
print_field(STRING_IP_ADDRESS, addr_buf);
|
2013-01-05 16:38:00 +01:00
|
|
|
else if (addr->Address.lpSockaddr->sa_family == AF_INET6 &&
|
2018-07-24 00:01:29 +02:00
|
|
|
socket_address_to_string(addr_buf, ARRAY_SIZE(addr_buf), &addr->Address))
|
2013-01-05 16:38:00 +01:00
|
|
|
print_field(STRING_IP6_ADDRESS, addr_buf);
|
2010-08-17 04:28:11 +02:00
|
|
|
/* FIXME: Output corresponding subnet mask. */
|
|
|
|
}
|
|
|
|
|
2010-09-27 11:30:59 +02:00
|
|
|
if (p->FirstGatewayAddress)
|
|
|
|
{
|
2018-07-24 00:01:29 +02:00
|
|
|
if (socket_address_to_string(addr_buf, ARRAY_SIZE(addr_buf), &p->FirstGatewayAddress->Address))
|
2010-09-27 11:30:59 +02:00
|
|
|
print_field(STRING_DEFAULT_GATEWAY, addr_buf);
|
|
|
|
|
|
|
|
for (gateway = p->FirstGatewayAddress->Next; gateway; gateway = gateway->Next)
|
|
|
|
{
|
2018-07-24 00:01:29 +02:00
|
|
|
if (socket_address_to_string(addr_buf, ARRAY_SIZE(addr_buf), &gateway->Address))
|
2010-09-27 11:30:59 +02:00
|
|
|
print_value(addr_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-10-21 01:02:41 +02:00
|
|
|
print_field(STRING_DEFAULT_GATEWAY, L"");
|
2010-08-17 04:28:11 +02:00
|
|
|
|
2020-10-21 01:02:41 +02:00
|
|
|
ipconfig_printfW(L"\n");
|
2010-08-17 04:28:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, adapters);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-17 17:05:47 +02:00
|
|
|
int __cdecl wmain(int argc, WCHAR *argv[])
|
2010-08-16 09:54:00 +02:00
|
|
|
{
|
2010-08-17 04:27:32 +02:00
|
|
|
WSADATA data;
|
|
|
|
|
|
|
|
if (WSAStartup(MAKEWORD(2, 2), &data))
|
|
|
|
return 1;
|
|
|
|
|
2010-08-16 09:54:10 +02:00
|
|
|
if (argc > 1)
|
|
|
|
{
|
2020-10-21 01:02:41 +02:00
|
|
|
if (!lstrcmpW(L"/?", argv[1]))
|
2010-08-16 09:54:10 +02:00
|
|
|
{
|
|
|
|
ipconfig_message(STRING_USAGE);
|
2010-08-17 04:27:32 +02:00
|
|
|
WSACleanup();
|
2010-08-16 09:54:10 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2020-10-21 01:02:41 +02:00
|
|
|
else if (!wcsicmp(L"/all", argv[1]))
|
2010-08-16 09:54:10 +02:00
|
|
|
{
|
|
|
|
if (argv[2])
|
|
|
|
{
|
|
|
|
ipconfig_message(STRING_INVALID_CMDLINE);
|
|
|
|
ipconfig_message(STRING_USAGE);
|
2010-08-17 04:27:32 +02:00
|
|
|
WSACleanup();
|
2010-08-16 09:54:10 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-08-17 04:28:11 +02:00
|
|
|
print_full_information();
|
2010-08-16 09:54:10 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ipconfig_message(STRING_INVALID_CMDLINE);
|
|
|
|
ipconfig_message(STRING_USAGE);
|
2010-08-17 04:27:32 +02:00
|
|
|
WSACleanup();
|
2010-08-16 09:54:10 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2010-08-17 04:27:32 +02:00
|
|
|
else
|
|
|
|
print_basic_information();
|
2010-08-16 09:54:10 +02:00
|
|
|
|
2010-08-17 04:27:32 +02:00
|
|
|
WSACleanup();
|
2010-08-16 09:54:00 +02:00
|
|
|
return 0;
|
|
|
|
}
|