diff --git a/dll/win32/ifmon/ip.c b/dll/win32/ifmon/ip.c index 7b49a914c51..9c9538fa0f5 100644 --- a/dll/win32/ifmon/ip.c +++ b/dll/win32/ifmon/ip.c @@ -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( diff --git a/dll/win32/ifmon/lang/en-US.rc b/dll/win32/ifmon/lang/en-US.rc index d594cf0f3e4..30845e5ff1a 100644 --- a/dll/win32/ifmon/lang/en-US.rc +++ b/dll/win32/ifmon/lang/en-US.rc @@ -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=] \n\ + [[source=]dhcp | \n\ + [source=] static [addr=]IP address [mask=]IP subnet mask]\n\ + [[gateway=]|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\ + : 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\ diff --git a/dll/win32/ifmon/precomp.h b/dll/win32/ifmon/precomp.h index 724c541fffd..f7af481b077 100644 --- a/dll/win32/ifmon/precomp.h +++ b/dll/win32/ifmon/precomp.h @@ -23,8 +23,8 @@ #include #include - #include +#include extern HINSTANCE hDllInstance; diff --git a/dll/win32/ifmon/resource.h b/dll/win32/ifmon/resource.h index d9862b006fa..a5ba29a7b75 100644 --- a/dll/win32/ifmon/resource.h +++ b/dll/win32/ifmon/resource.h @@ -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