mirror of
https://github.com/reactos/reactos.git
synced 2026-06-16 02:15:26 +08:00
[IFMON] Add the 'set address' command to the 'interface ip' group
This is incomplete and WIP.
This commit is contained in:
@@ -19,12 +19,20 @@
|
||||
#define DISPLAY_ADRESSES 0x1
|
||||
#define DISPLAY_DNS 0x2
|
||||
|
||||
|
||||
static FN_HANDLE_CMD IpSetAddress;
|
||||
static FN_HANDLE_CMD IpShowAddresses;
|
||||
static FN_HANDLE_CMD IpShowConfig;
|
||||
static FN_HANDLE_CMD IpShowDns;
|
||||
|
||||
|
||||
static
|
||||
CMD_ENTRY
|
||||
IpSetCommands[] =
|
||||
{
|
||||
{L"address", IpSetAddress, IDS_HLP_IP_SET_ADDRESS, IDS_HLP_IP_SET_ADDRESS_EX, 0}
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
CMD_ENTRY
|
||||
IpShowCommands[] =
|
||||
@@ -39,10 +47,100 @@ static
|
||||
CMD_GROUP_ENTRY
|
||||
IpGroups[] =
|
||||
{
|
||||
{L"set", IDS_HLP_IP_SET, sizeof(IpSetCommands) / sizeof(CMD_ENTRY), 0, IpSetCommands, NULL},
|
||||
{L"show", IDS_HLP_IP_SHOW, sizeof(IpShowCommands) / sizeof(CMD_ENTRY), 0, IpShowCommands, NULL},
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
DWORD
|
||||
WINAPI
|
||||
IpSetAddress(
|
||||
LPCWSTR pwszMachine,
|
||||
LPWSTR *argv,
|
||||
DWORD dwCurrentIndex,
|
||||
DWORD dwArgCount,
|
||||
DWORD dwFlags,
|
||||
LPCVOID pvData,
|
||||
BOOL *pbDone)
|
||||
{
|
||||
TAG_TYPE pttTags[] = {{L"name", NS_REQ_ZERO, FALSE},
|
||||
{L"source", NS_REQ_ZERO, FALSE},
|
||||
{L"addr", NS_REQ_ZERO, FALSE},
|
||||
{L"mask", NS_REQ_ZERO, FALSE},
|
||||
{L"gateway", NS_REQ_ZERO, FALSE},
|
||||
{L"gwmetric", NS_REQ_ZERO, FALSE}};
|
||||
PDWORD pdwTagType = NULL;
|
||||
DWORD i;
|
||||
DWORD dwError = ERROR_SUCCESS;
|
||||
|
||||
DPRINT1("IpSetAddress()\n");
|
||||
|
||||
pdwTagType = HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
(dwArgCount - dwCurrentIndex) * sizeof(DWORD));
|
||||
if (pdwTagType == NULL)
|
||||
{
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
dwError = MatchTagsInCmdLine(hDllInstance,
|
||||
argv,
|
||||
dwCurrentIndex,
|
||||
dwArgCount,
|
||||
pttTags,
|
||||
ARRAYSIZE(pttTags),
|
||||
pdwTagType);
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("MatchTagsInCmdLine() failed (Error %lu)\n", dwError);
|
||||
HeapFree(GetProcessHeap(), 0, pdwTagType);
|
||||
return dwError;
|
||||
}
|
||||
|
||||
for (i = 0; i < (dwArgCount - dwCurrentIndex); i++)
|
||||
{
|
||||
DPRINT1("Tag %lu: %lu\n", i, pdwTagType[i]);
|
||||
|
||||
switch (pdwTagType[i])
|
||||
{
|
||||
case 0: /* name */
|
||||
DPRINT1("Tag: name (%S)\n", argv[i + dwCurrentIndex]);
|
||||
break;
|
||||
|
||||
case 1: /* source */
|
||||
DPRINT1("Tag: source (%S)\n", argv[i + dwCurrentIndex]);
|
||||
break;
|
||||
|
||||
case 2: /* addr */
|
||||
DPRINT1("Tag: addr (%S)\n", argv[i + dwCurrentIndex]);
|
||||
break;
|
||||
|
||||
case 3: /* mask */
|
||||
DPRINT1("Tag: mask (%S)\n", argv[i + dwCurrentIndex]);
|
||||
break;
|
||||
|
||||
case 4: /* gateway */
|
||||
DPRINT1("Tag: gateway (%S)\n", argv[i + dwCurrentIndex]);
|
||||
break;
|
||||
|
||||
case 5: /* gwmetric */
|
||||
DPRINT1("Tag: gwmetric (%S)\n", argv[i + dwCurrentIndex]);
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINT1("Unknown tag type %lu\n", pdwTagType[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pdwTagType)
|
||||
HeapFree(GetProcessHeap(), 0, pdwTagType);
|
||||
|
||||
return dwError;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
HRESULT
|
||||
GetInterfaceProperties(
|
||||
|
||||
@@ -6,6 +6,36 @@ BEGIN
|
||||
IDS_HLP_INTERFACE_SHOW_INTERFACE "Displays interfaces.\n"
|
||||
IDS_HLP_INTERFACE_SHOW_INTERFACE_EX "\nUsage:\n"
|
||||
|
||||
IDS_HLP_IP_SET "Sets configuration information.\n"
|
||||
IDS_HLP_IP_SET_ADDRESS "Sets the IP address or default gateway to the specified interface.\n"
|
||||
IDS_HLP_IP_SET_ADDRESS_EX "\nUsage: %1!s! [name=]<string> \n\
|
||||
[[source=]dhcp | \n\
|
||||
[source=] static [addr=]IP address [mask=]IP subnet mask]\n\
|
||||
[[gateway=]<IP address>|none [gwmetric=]integer]\n\n\
|
||||
Parameters:\n\n\
|
||||
Tag Value\n\
|
||||
name - The name of the interface.\n\
|
||||
source - One of the following values:\n\
|
||||
dhcp: Sets DHCP as the source for configuring IP\n\
|
||||
addresses for the specific interface.\n\
|
||||
static: Sets the source for configuring IP addresses\n\
|
||||
to local static configuration.\n\
|
||||
gateway - One of the following values:\n\
|
||||
<IP address>: A specific default gateway for the\n\
|
||||
static IP address you are setting.\n\
|
||||
none: No default gateways are set.\n\
|
||||
gwmetric - The metric for the default gateway. This field should\n\
|
||||
not be set if gateway is set to 'none'.\n\
|
||||
The following options are used only if source is 'static':\n\
|
||||
addr - An IP address for the specified interface.\n\
|
||||
mask - The subnet mask for the specified IP address.\n\n\
|
||||
Remarks: Used to change the IP address configuration mode from either DHCP to\n\
|
||||
static mode or static mode to DHCP. Adds IP addresses on an\n\
|
||||
interface with static IP address or adds default gateways.\n\n\
|
||||
Examples:\n\n\
|
||||
%1!s! name=""Local Area Connection"" source=dhcp\n\
|
||||
%1!s! local static 10.0.0.9 255.0.0.0 10.0.0.1 1\n\n"
|
||||
|
||||
IDS_HLP_IP_SHOW "Displays IP information.\n"
|
||||
IDS_HLP_ADDRESSES "Displays IP address configuration.\n"
|
||||
IDS_HLP_ADDRESSES_EX "\nUsage: %1!s! [[name=]string]\n\n\
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <netcfgx_undoc.h>
|
||||
#include <netcfgn_undoc.h>
|
||||
|
||||
|
||||
#include <netsh.h>
|
||||
#include <netsh_undoc.h>
|
||||
|
||||
extern HINSTANCE hDllInstance;
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
#define IDS_HLP_INTERFACE_SHOW_INTERFACE 201
|
||||
#define IDS_HLP_INTERFACE_SHOW_INTERFACE_EX 202
|
||||
|
||||
#define IDS_HLP_IP_SET 205
|
||||
#define IDS_HLP_IP_SET_ADDRESS 206
|
||||
#define IDS_HLP_IP_SET_ADDRESS_EX 207
|
||||
|
||||
|
||||
#define IDS_HLP_IP_SHOW 210
|
||||
#define IDS_HLP_ADDRESSES 211
|
||||
#define IDS_HLP_ADDRESSES_EX 212
|
||||
|
||||
Reference in New Issue
Block a user