ReactOS 0.4.17-dev-357-ga8f14ff
ip.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS IF Monitor DLL
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: IP context functions
5 * COPYRIGHT: Copyright 2025 Eric Kohl <eric.kohl@reactos.org>
6 */
7
8#include "precomp.h"
9
10#include <guiddef.h>
11#include <devguid.h>
12
13#define NDEBUG
14#include <debug.h>
15
16#include "guid.h"
17#include "resource.h"
18
19#define BUFFER_SIZE 128
20
21#define DISPLAY_ADRESSES 0x1
22#define DISPLAY_DNS 0x2
23
24#define SOURCE_UNCHANGED 0
25#define SOURCE_STATIC 1
26#define SOURCE_DHCP 2
27
28#define GATEWAY_NONE 1
29
30#define REGISTER_NONE 1
31#define REGISTER_PRIMARY 2
32#define REGISTER_BOTH 3
33
34#define ADDRESS_ALL 1
35
36static FN_HANDLE_CMD IpAddAddress;
37static FN_HANDLE_CMD IpAddDns;
38static FN_HANDLE_CMD IpDeleteAddress;
39static FN_HANDLE_CMD IpDeleteArpCache;
40static FN_HANDLE_CMD IpDeleteDns;
41static FN_HANDLE_CMD IpSetAddress;
42static FN_HANDLE_CMD IpSetDns;
43static FN_HANDLE_CMD IpShowAddresses;
44static FN_HANDLE_CMD IpShowConfig;
45static FN_HANDLE_CMD IpShowDns;
46static FN_HANDLE_CMD IpReset;
47
48static
51{
54};
55
56static
59{
63};
64
65static
68{
71};
72
73static
76{
80};
81
82static
85{
86 {L"add", IDS_HLP_IP_ADD, sizeof(IpAddCommands) / sizeof(CMD_ENTRY), 0, IpAddCommands, NULL},
87 {L"delete", IDS_HLP_IP_DELETE, sizeof(IpDeleteCommands) / sizeof(CMD_ENTRY), 0, IpDeleteCommands, NULL},
88 {L"set", IDS_HLP_IP_SET, sizeof(IpSetCommands) / sizeof(CMD_ENTRY), 0, IpSetCommands, NULL},
89 {L"show", IDS_HLP_IP_SHOW, sizeof(IpShowCommands) / sizeof(CMD_ENTRY), 0, IpShowCommands, NULL},
90};
91
92static
95{
97};
98
99
100static
104 PTCPIP_PROPERTIES *ppProperties)
105{
106 INetCfg *pNetCfg = NULL;
107 INetCfgLock *pNetCfgLock = NULL;
108 INetCfgClass *pNetCfgClass = NULL;
109 INetCfgComponent *pTcpipComponent = NULL;
110 INetCfgComponentPrivate *pTcpipComponentPrivate = NULL;
111 ITcpipProperties *pTcpipProperties = NULL;
112
113 BOOL fWriteLocked = FALSE, fInitialized = FALSE;
114 HRESULT hr;
115
116 DPRINT("GetInterfaceProperties()\n");
117
119 if (hr != S_OK)
120 {
121 DPRINT1("CoInitialize failed\n");
122 goto exit;
123 }
124
126 NULL,
127 CLSCTX_INPROC_SERVER,
129 (PVOID*)&pNetCfg);
130 if (hr != S_OK)
131 {
132 DPRINT1("CoCreateInstance failed\n");
133 goto exit;
134 }
135
136 /* Acquire the write-lock */
137 hr = INetCfg_QueryInterface(pNetCfg,
139 (PVOID*)&pNetCfgLock);
140 if (hr != S_OK)
141 {
142 DPRINT1("QueryInterface failed\n");
143 goto exit;
144 }
145
146 hr = INetCfgLock_AcquireWriteLock(pNetCfgLock, 5000,
147 L"NetSh",
148 NULL);
149 if (hr != S_OK)
150 {
151 DPRINT1("AcquireWriteLock failed\n");
152 goto exit;
153 }
154
155 fWriteLocked = TRUE;
156
157 /* Initialize the network configuration */
158 hr = INetCfg_Initialize(pNetCfg, NULL);
159 if (hr != S_OK)
160 {
161 DPRINT1("Initialize failed\n");
162 goto exit;
163 }
164
165 fInitialized = TRUE;
166
167 GUID ClassGuid = GUID_DEVCLASS_NETTRANS;
168 hr = INetCfg_QueryNetCfgClass(pNetCfg, &ClassGuid, &IID_INetCfgClass, (PVOID*)&pNetCfgClass);
169 if (hr != S_OK)
170 {
171 DPRINT1("INetCfg_QueryNetCfgClass failed!\n");
172 goto exit;
173 }
174
175 hr = INetCfgClass_FindComponent(pNetCfgClass, L"MS_TCPIP", &pTcpipComponent);
176 if (hr != S_OK)
177 {
178 DPRINT1("INetCfgClass_FindComponent failed\n");
179 goto exit;
180 }
181
182 hr = INetCfgComponent_QueryInterface(pTcpipComponent, &IID_INetCfgComponentPrivate, (PVOID*)&pTcpipComponentPrivate);
183 if (hr != S_OK)
184 {
185 DPRINT1("INetCfgComponent_QueryInterface failed\n");
186 goto exit;
187 }
188
189 hr = INetCfgComponentPrivate_Unknown1(pTcpipComponentPrivate, &IID_ITcpipProperties, (PVOID*)&pTcpipProperties);
190 if (hr != S_OK)
191 {
192 DPRINT1("INetCfgComponentPrivate_Unknown1 failed\n");
193 goto exit;
194 }
195
196 PTCPIP_PROPERTIES pInfo = NULL;
197 hr = ITcpipProperties_Unknown1(pTcpipProperties, InterfaceGuid, &pInfo);
198 if (hr != S_OK)
199 {
200 DPRINT1("ITcpipProperties_Unknown1 failed\n");
201 }
202 else
203 {
204 DPRINT("pInfo: %p\n", pInfo);
205 DPRINT("dwDhcp: %lx\n", pInfo->dwDhcp);
206 DPRINT("IpAddress: %p\n", pInfo->pszIpAddress);
207 DPRINT("IpAddress: %S\n", pInfo->pszIpAddress);
208 DPRINT("SubnetMask: %p\n", pInfo->pszSubnetMask);
209 DPRINT("SubnetMask: %S\n", pInfo->pszSubnetMask);
210 DPRINT("Parameters: %p\n", pInfo->pszParameters);
211 DPRINT("Parameters: %S\n", pInfo->pszParameters);
212
213 *ppProperties = pInfo;
214 }
215
216 DPRINT("Done!\n");
217exit:
218 if (pTcpipProperties)
219 ITcpipProperties_Release(pTcpipProperties);
220
221 if (pTcpipComponentPrivate)
222 INetCfgComponentPrivate_Release(pTcpipComponentPrivate);
223
224 if (pTcpipComponent != NULL)
225 INetCfgComponent_Release(pTcpipComponent);
226
227 if (pNetCfgClass != NULL)
228 INetCfgClass_Release(pNetCfgClass);
229
230 if (fInitialized)
231 INetCfg_Uninitialize(pNetCfg);
232
233 if (fWriteLocked)
234 INetCfgLock_ReleaseWriteLock(pNetCfgLock);
235
236 if (pNetCfgLock != NULL)
237 INetCfgLock_Release(pNetCfgLock);
238
239 if (pNetCfg != NULL)
240 INetCfg_Release(pNetCfg);
241
243
244 DPRINT("GetInterfaceProperties() done!\n");
245
246 return hr;
247}
248
249
250static
254 PTCPIP_PROPERTIES pProperties)
255{
256 INetCfg *pNetCfg = NULL;
257 INetCfgLock *pNetCfgLock = NULL;
258 INetCfgClass *pNetCfgClass = NULL;
259 INetCfgComponent *pTcpipComponent = NULL;
260 INetCfgComponentPrivate *pTcpipComponentPrivate = NULL;
261 ITcpipProperties *pTcpipProperties = NULL;
262
263 BOOL fWriteLocked = FALSE, fInitialized = FALSE;
264 HRESULT hr;
265
266 DPRINT("SetInterfaceProperties()\n");
267
268 DPRINT("dwDhcp: %lx\n", pProperties->dwDhcp);
269 DPRINT("IpAddress: %S\n", pProperties->pszIpAddress);
270 DPRINT("SubnetMask: %S\n", pProperties->pszSubnetMask);
271 DPRINT("Parameters: %S\n", pProperties->pszParameters);
272
274 if (hr != S_OK)
275 {
276 DPRINT1("CoInitialize failed\n");
277 goto exit;
278 }
279
281 NULL,
282 CLSCTX_INPROC_SERVER,
284 (PVOID*)&pNetCfg);
285 if (hr != S_OK)
286 {
287 DPRINT1("CoCreateInstance failed\n");
288 goto exit;
289 }
290
291 /* Acquire the write-lock */
292 hr = INetCfg_QueryInterface(pNetCfg,
294 (PVOID*)&pNetCfgLock);
295 if (hr != S_OK)
296 {
297 DPRINT1("QueryInterface failed\n");
298 goto exit;
299 }
300
301 hr = INetCfgLock_AcquireWriteLock(pNetCfgLock, 5000,
302 L"NetSh",
303 NULL);
304 if (hr != S_OK)
305 {
306 DPRINT1("AcquireWriteLock failed\n");
307 goto exit;
308 }
309
310 fWriteLocked = TRUE;
311
312 /* Initialize the network configuration */
313 hr = INetCfg_Initialize(pNetCfg, NULL);
314 if (hr != S_OK)
315 {
316 DPRINT1("Initialize failed\n");
317 goto exit;
318 }
319
320 fInitialized = TRUE;
321
322 GUID ClassGuid = GUID_DEVCLASS_NETTRANS;
323 hr = INetCfg_QueryNetCfgClass(pNetCfg, &ClassGuid, &IID_INetCfgClass, (PVOID*)&pNetCfgClass);
324 if (hr != S_OK)
325 {
326 DPRINT1("INetCfg_QueryNetCfgClass failed!\n");
327 goto exit;
328 }
329
330 hr = INetCfgClass_FindComponent(pNetCfgClass, L"MS_TCPIP", &pTcpipComponent);
331 if (hr != S_OK)
332 {
333 DPRINT1("INetCfgClass_FindComponent failed\n");
334 goto exit;
335 }
336
337 hr = INetCfgComponent_QueryInterface(pTcpipComponent, &IID_INetCfgComponentPrivate, (PVOID*)&pTcpipComponentPrivate);
338 if (hr != S_OK)
339 {
340 DPRINT1("INetCfgComponent_QueryInterface failed\n");
341 goto exit;
342 }
343
344 hr = INetCfgComponentPrivate_Unknown1(pTcpipComponentPrivate, &IID_ITcpipProperties, (PVOID*)&pTcpipProperties);
345 if (hr != S_OK)
346 {
347 DPRINT1("INetCfgComponentPrivate_Unknown1 failed\n");
348 goto exit;
349 }
350
351 hr = ITcpipProperties_Unknown2(pTcpipProperties, InterfaceGuid, pProperties);
352 if (hr != S_OK)
353 {
354 DPRINT1("ITcpipProperties_Unknown2 failed\n");
355 goto exit;
356 }
357
358 hr = INetCfg_Apply(pNetCfg);
359 if (hr != S_OK)
360 {
361 DPRINT1("INetCfg_Apply failed\n");
362 }
363
364 DPRINT("Done!\n");
365exit:
366 if (pTcpipProperties)
367 ITcpipProperties_Release(pTcpipProperties);
368
369 if (pTcpipComponentPrivate)
370 INetCfgComponentPrivate_Release(pTcpipComponentPrivate);
371
372 if (pTcpipComponent != NULL)
373 INetCfgComponent_Release(pTcpipComponent);
374
375 if (pNetCfgClass != NULL)
376 INetCfgClass_Release(pNetCfgClass);
377
378 if (fInitialized)
379 INetCfg_Uninitialize(pNetCfg);
380
381 if (fWriteLocked)
382 INetCfgLock_ReleaseWriteLock(pNetCfgLock);
383
384 if (pNetCfgLock != NULL)
385 INetCfgLock_Release(pNetCfgLock);
386
387 if (pNetCfg != NULL)
388 INetCfg_Release(pNetCfg);
389
391
392 DPRINT("SetInterfaceProperties() done!\n");
393
394 return hr;
395}
396
397
398static
399PWSTR
401 PWSTR pszParameters,
402 PWSTR pszParameter)
403{
404 PWSTR pToken, pStart, pEnd, pBuffer;
406
407 pToken = wcsstr(pszParameters, pszParameter);
408 if (pToken == NULL)
409 return NULL;
410
411 pStart = wcschr(pToken, L'=');
412 if (pStart == NULL)
413 return NULL;
414
415 pStart++;
416 pEnd = wcschr(pStart, L';');
417 if (pEnd == NULL)
418 length = wcslen(pStart);
419 else
420 length = pEnd - pStart;
421
422 if (length == 0)
423 return NULL;
424
426 if (pBuffer)
427 {
428 CopyMemory(pBuffer, pStart, length * sizeof(WCHAR));
429 }
430
431 return pBuffer;
432}
433
434
435static
436BOOL
438 PWSTR pszParameters,
439 PWSTR pszParameter,
441{
442 PWSTR pToken, pStart, pEnd;
443
444 pToken = wcsstr(pszParameters, pszParameter);
445 if (pToken == NULL)
446 return FALSE;
447
448 pStart = wcschr(pToken, L';');
449 if (pStart == NULL)
450 return FALSE;
451
452 pEnd = pStart + wcslen(pszValue) + 1;
453 MoveMemory(pEnd, pStart, wcslen(pStart) * sizeof(WCHAR));
454
455 *pStart = L',';
456 pStart++;
457 CopyMemory(pStart, pszValue, wcslen(pszValue) * sizeof(WCHAR));
458
459 return TRUE;
460}
461
462static
463BOOL
465 PWSTR pszParameters,
466 PWSTR pszParameter,
468{
469 PWSTR pToken, pStart, pEnd, pValStart, pValEnd;
470
471 pToken = wcsstr(pszParameters, pszParameter);
472 if (pToken == NULL)
473 return FALSE;
474
475 pEnd = wcschr(pToken, L';');
476 if (pEnd == NULL)
477 return FALSE;
478
479 pStart = pToken + wcslen(pszParameter) + 1;
480 if (pStart == pEnd)
481 return TRUE;
482
483 if (pszValue == NULL)
484 {
485 MoveMemory(pStart, pEnd, (wcslen(pEnd) + 1) * sizeof(WCHAR));
486 }
487 else
488 {
489 pValStart = wcsstr(pStart, pszValue);
490 if ((pValStart >= pStart) & (pValStart < pEnd))
491 {
492 pValEnd = pValStart + wcslen(pszValue);
493 if (*pValEnd == L',')
494 pValEnd++;
495 else if ((*pValEnd == L';') && (*(pValStart - 1) == L','))
496 pValStart--;
497 MoveMemory(pValStart, pValEnd, (wcslen(pValEnd) + 1) * sizeof(WCHAR));
498 }
499 else
500 {
501 return FALSE;
502 }
503 }
504
505 return TRUE;
506}
507
508static
509DWORD
510WINAPI
512 LPCWSTR pwszMachine,
513 LPWSTR *argv,
518 BOOL *pbDone)
519{
520 TAG_TYPE pttTags[] = {{L"name", NS_REQ_ZERO, FALSE},
521 {L"addr", NS_REQ_ZERO, FALSE},
522 {L"mask", NS_REQ_ZERO, FALSE},
523 {L"gateway", NS_REQ_ZERO, FALSE},
524 {L"gwmetric", NS_REQ_ZERO, FALSE}};
525 GUID InterfaceGUID;
526 PDWORD pdwTagType = NULL;
527 DWORD i;
528 BOOL bHaveName = FALSE, bHaveAddress = FALSE, bHaveMask = FALSE,
529 bHaveGateway = FALSE, bHaveMetric = FALSE;
530 IN_ADDR Address, Mask, Gateway;
531 PWSTR pszName = NULL, pszAddress = NULL, pszMask = NULL, pszGateway = NULL, pszGwMetric = NULL;
532 PWSTR pszNewIpAddress = NULL, pszNewSubnetMask = NULL, pszNewParameters = NULL;
533 DWORD dwMetric, dwLength;
534 PCWSTR Term;
535 PTCPIP_PROPERTIES pProperties = NULL;
536 TCPIP_PROPERTIES NewProperties;
537 HRESULT hr;
539 DWORD dwError = ERROR_SUCCESS;
540
541 DPRINT("IpAddAddress()\n");
542
543 pdwTagType = HeapAlloc(GetProcessHeap(),
544 0,
545 (dwArgCount - dwCurrentIndex) * sizeof(DWORD));
546 if (pdwTagType == NULL)
547 {
549 }
550
552 argv,
555 pttTags,
556 ARRAYSIZE(pttTags),
557 pdwTagType);
558 if (dwError != ERROR_SUCCESS)
559 {
560 DPRINT1("MatchTagsInCmdLine() failed (Error %lu)\n", dwError);
561 HeapFree(GetProcessHeap(), 0, pdwTagType);
562 return dwError;
563 }
564
565 for (i = 0; i < (dwArgCount - dwCurrentIndex); i++)
566 {
567 DPRINT("Tag %lu: %lu\n", i, pdwTagType[i]);
568
569 switch (pdwTagType[i])
570 {
571 case 0: /* name */
572 DPRINT("Tag: name (%S)\n", argv[i + dwCurrentIndex]);
574 &InterfaceGUID,
575 0, 0);
576 if (dwError != ERROR_SUCCESS)
577 {
578 DPRINT1("NhGetGuidFromInterfaceName() failed (Error %lu)\n", dwError);
582 dwError = ERROR_SUPPRESS_OUTPUT;
583 break;
584 }
585 pszName = argv[i + dwCurrentIndex];
586 DPRINT("Interface: {%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
587 InterfaceGUID.Data1, InterfaceGUID.Data2, InterfaceGUID.Data3, InterfaceGUID.Data4[0], InterfaceGUID.Data4[1],
588 InterfaceGUID.Data4[2], InterfaceGUID.Data4[3], InterfaceGUID.Data4[4], InterfaceGUID.Data4[5], InterfaceGUID.Data4[6], InterfaceGUID.Data4[7]);
589 bHaveName = TRUE;
590 break;
591
592 case 1: /* addr */
593 DPRINT("Tag: addr (%S)\n", argv[i + dwCurrentIndex]);
595 TRUE,
596 &Term,
597 &Address);
598 if (Status != 0 /*STATUS_SUCCESS*/)
599 {
600 DPRINT("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
604 pttTags[pdwTagType[i]].pwszTag);
605 dwError = ERROR_SUPPRESS_OUTPUT;
606 break;
607 }
608 DPRINT("IP Address: %u.%u.%u.%u\n",
609 Address.S_un.S_un_b.s_b1, Address.S_un.S_un_b.s_b2, Address.S_un.S_un_b.s_b3, Address.S_un.S_un_b.s_b4);
610 pszAddress = argv[i + dwCurrentIndex];
611 DPRINT("IP Address: %S\n", pszAddress);
612 bHaveAddress = TRUE;
613 break;
614
615 case 2: /* mask */
616 DPRINT("Tag: mask (%S)\n", argv[i + dwCurrentIndex]);
618 TRUE,
619 &Term,
620 &Mask);
621 if (Status != 0 /*STATUS_SUCCESS*/)
622 {
623 DPRINT("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
627 pttTags[pdwTagType[i]].pwszTag);
628 dwError = ERROR_SUPPRESS_OUTPUT;
629 break;
630 }
631 DPRINT("Subnet Mask: %u.%u.%u.%u\n",
632 Mask.S_un.S_un_b.s_b1, Mask.S_un.S_un_b.s_b2, Mask.S_un.S_un_b.s_b3, Mask.S_un.S_un_b.s_b4);
633 pszMask = argv[i + dwCurrentIndex];
634 DPRINT("Subnat Mask: %S\n", pszMask);
635 bHaveMask = TRUE;
636 break;
637
638 case 3: /* gateway */
639 DPRINT("Tag: gateway (%S)\n", argv[i + dwCurrentIndex]);
641 TRUE,
642 &Term,
643 &Gateway);
644 if (Status != 0 /*STATUS_SUCCESS*/)
645 {
646 DPRINT("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
650 pttTags[pdwTagType[i]].pwszTag);
651 dwError = ERROR_SUPPRESS_OUTPUT;
652 break;
653 }
654 pszGateway = argv[i + dwCurrentIndex];
655 DPRINT("Gateway: %u.%u.%u.%u\n",
656 Gateway.S_un.S_un_b.s_b1, Gateway.S_un.S_un_b.s_b2, Gateway.S_un.S_un_b.s_b3, Gateway.S_un.S_un_b.s_b4);
657 bHaveGateway = TRUE;
658 break;
659
660 case 4: /* gwmetric */
661 DPRINT("Tag: gwmetric (%S)\n", argv[i + dwCurrentIndex]);
662 dwMetric = wcstoul(argv[i + dwCurrentIndex],
663 (wchar_t**)&Term,
664 10);
665 if (dwMetric > 9999)
666 {
667 dwError = ERROR_INVALID_PARAMETER;
668 break;
669 }
670 pszGwMetric = argv[i + dwCurrentIndex];
671 DPRINT("Metric: %lu\n", dwMetric);
672 bHaveMetric = TRUE;
673 break;
674
675 default:
676 DPRINT1("Unknown tag type %lu\n", pdwTagType[i]);
677 break;
678 }
679 }
680
681 if (pdwTagType)
682 HeapFree(GetProcessHeap(), 0, pdwTagType);
683
684 if (dwError != ERROR_SUCCESS)
685 return dwError;
686
687 /* Check parameters */
688
689 /* The interface name is mandatory */
690 if (bHaveName == FALSE)
692
693 /* We need address and mask, or none of them */
694 if ((bHaveAddress && !bHaveMask) ||
695 (!bHaveAddress && bHaveMask))
697
698 /* We need gateway and metric, or none of them */
699 if ((bHaveGateway && !bHaveMetric) ||
700 (!bHaveGateway && bHaveMetric))
702
703 hr = GetInterfaceProperties(&InterfaceGUID, &pProperties);
704 if (FAILED(hr))
705 {
708 pszName);
710 }
711
712 if (pszAddress && pszMask)
713 {
714 if (pProperties->dwDhcp)
715 {
718 dwError = ERROR_SUPPRESS_OUTPUT;
719 goto done;
720 }
721
722 dwLength = wcslen(pProperties->pszIpAddress) + wcslen(pszAddress) + 2;
723 pszNewIpAddress = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
724 if (pszNewIpAddress == NULL)
725 {
726 dwError = ERROR_NOT_ENOUGH_MEMORY;
727 goto done;
728 }
729
730 wcscpy(pszNewIpAddress, pProperties->pszIpAddress);
731 wcscat(pszNewIpAddress, L",");
732 wcscat(pszNewIpAddress, pszAddress);
733
734 dwLength = wcslen(pProperties->pszSubnetMask) + wcslen(pszAddress) + 2;
735 pszNewSubnetMask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
736 if (pszNewSubnetMask == NULL)
737 {
738 dwError = ERROR_NOT_ENOUGH_MEMORY;
739 goto done;
740 }
741
742 wcscpy(pszNewSubnetMask, pProperties->pszSubnetMask);
743 wcscat(pszNewSubnetMask, L",");
744 wcscat(pszNewSubnetMask, pszMask);
745 }
746
747 if (pszGateway && pszGwMetric)
748 {
749 dwLength = wcslen(pProperties->pszParameters) +
750 wcslen(pszGateway) + wcslen(pszGwMetric) + 3;
751
752 pszNewParameters = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
753 if (pszNewParameters == NULL)
754 {
755 dwError = ERROR_NOT_ENOUGH_MEMORY;
756 goto done;
757 }
758
759 wcscpy(pszNewParameters, pProperties->pszParameters);
760 AppendParameterValue(pszNewParameters, L"DefGw", pszGateway);
761 AppendParameterValue(pszNewParameters, L"GwMetric", pszGwMetric);
762 }
763
764 NewProperties.dwDhcp = 0;
765 NewProperties.pszIpAddress = pszNewIpAddress ? pszNewIpAddress : pProperties->pszIpAddress;
766 NewProperties.pszSubnetMask = pszNewSubnetMask ? pszNewSubnetMask : pProperties->pszSubnetMask;
767 NewProperties.pszParameters = pszNewParameters ? pszNewParameters : pProperties->pszParameters;
768
769 SetInterfaceProperties(&InterfaceGUID, &NewProperties);
770
771done:
772 if (pszNewIpAddress)
773 HeapFree(GetProcessHeap(), 0, pszNewIpAddress);
774
775 if (pszNewSubnetMask)
776 HeapFree(GetProcessHeap(), 0, pszNewSubnetMask);
777
778 if (pszNewParameters)
779 HeapFree(GetProcessHeap(), 0, pszNewParameters);
780
781 CoTaskMemFree(pProperties);
782 pProperties = NULL;
783
784 DPRINT("IpAddAddress() done (Error %lu)\n", dwError);
785 return dwError;
786}
787
788
789static
790DWORD
791WINAPI
793 LPCWSTR pwszMachine,
794 LPWSTR *argv,
799 BOOL *pbDone)
800{
801 TAG_TYPE pttTags[] = {{L"name", NS_REQ_ZERO, FALSE},
802 {L"addr", NS_REQ_ZERO, FALSE},
803 {L"index", NS_REQ_ZERO, FALSE}};
804 GUID InterfaceGUID;
805 PDWORD pdwTagType = NULL;
806 DWORD i;
807 BOOL bHaveName = FALSE, bHaveAddress = FALSE/*, bHaveIndex = FALSE*/;
809 PWSTR pszName = NULL, pszAddress = NULL;
810 PWSTR pszNewParameters = NULL;
811 DWORD dwIndex, dwLength;
812 PCWSTR Term;
813 PTCPIP_PROPERTIES pProperties = NULL;
814 TCPIP_PROPERTIES NewProperties;
815 HRESULT hr;
817 DWORD dwError = ERROR_SUCCESS;
818
819 DPRINT1("IpAddDns()\n");
820
821 pdwTagType = HeapAlloc(GetProcessHeap(),
822 0,
823 (dwArgCount - dwCurrentIndex) * sizeof(DWORD));
824 if (pdwTagType == NULL)
825 {
827 }
828
830 argv,
833 pttTags,
834 ARRAYSIZE(pttTags),
835 pdwTagType);
836 if (dwError != ERROR_SUCCESS)
837 {
838 DPRINT1("MatchTagsInCmdLine() failed (Error %lu)\n", dwError);
839 HeapFree(GetProcessHeap(), 0, pdwTagType);
840 return dwError;
841 }
842
843 for (i = 0; i < (dwArgCount - dwCurrentIndex); i++)
844 {
845 DPRINT1("Tag %lu: %lu\n", i, pdwTagType[i]);
846
847 switch (pdwTagType[i])
848 {
849 case 0: /* name */
850 DPRINT1("Tag: name (%S)\n", argv[i + dwCurrentIndex]);
852 &InterfaceGUID,
853 0, 0);
854 if (dwError != ERROR_SUCCESS)
855 {
856 DPRINT1("NhGetGuidFromInterfaceName() failed (Error %lu)\n", dwError);
860 dwError = ERROR_SUPPRESS_OUTPUT;
861 break;
862 }
863 pszName = argv[i + dwCurrentIndex];
864 DPRINT1("Interface: {%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
865 InterfaceGUID.Data1, InterfaceGUID.Data2, InterfaceGUID.Data3, InterfaceGUID.Data4[0], InterfaceGUID.Data4[1],
866 InterfaceGUID.Data4[2], InterfaceGUID.Data4[3], InterfaceGUID.Data4[4], InterfaceGUID.Data4[5], InterfaceGUID.Data4[6], InterfaceGUID.Data4[7]);
867 bHaveName = TRUE;
868 break;
869
870 case 1: /* addr */
871 DPRINT1("Tag: addr (%S)\n", argv[i + dwCurrentIndex]);
873 TRUE,
874 &Term,
875 &Address);
876 if (Status != 0 /*STATUS_SUCCESS*/)
877 {
878 DPRINT1("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
882 pttTags[pdwTagType[i]].pwszTag);
883 dwError = ERROR_SUPPRESS_OUTPUT;
884 break;
885 }
886 DPRINT1("IP Address: %u.%u.%u.%u\n",
887 Address.S_un.S_un_b.s_b1, Address.S_un.S_un_b.s_b2, Address.S_un.S_un_b.s_b3, Address.S_un.S_un_b.s_b4);
888 pszAddress = argv[i + dwCurrentIndex];
889 DPRINT1("IP Address: %S\n", pszAddress);
890 bHaveAddress = TRUE;
891 break;
892
893 case 2: /* index */
894 DPRINT1("Tag: index (%S)\n", argv[i + dwCurrentIndex]);
895 dwIndex = wcstoul(argv[i + dwCurrentIndex],
896 (wchar_t**)&Term,
897 10);
898 if ((dwIndex == 0) || (dwIndex > 999))
899 {
900 dwError = ERROR_INVALID_PARAMETER;
901 break;
902 }
903 DPRINT1("Index: %lu\n", dwIndex);
904// bHaveIndex = TRUE;
905 break;
906
907 default:
908 DPRINT1("Unknown tag type %lu\n", pdwTagType[i]);
909 break;
910 }
911 }
912
913 if (pdwTagType)
914 HeapFree(GetProcessHeap(), 0, pdwTagType);
915
916 if (dwError != ERROR_SUCCESS)
917 return dwError;
918
919 /* Check parameters */
920
921 /* The interface name is mandatory */
922 if (bHaveName == FALSE)
924
925 /* The address is mandatory */
926 if (!bHaveAddress)
928
929 hr = GetInterfaceProperties(&InterfaceGUID, &pProperties);
930 if (FAILED(hr))
931 {
934 pszName);
936 }
937
938 dwLength = wcslen(pProperties->pszParameters) + wcslen(pszAddress) + 2;
939
940 pszNewParameters = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
941 if (pszNewParameters == NULL)
942 {
943 dwError = ERROR_NOT_ENOUGH_MEMORY;
944 goto done;
945 }
946
947 wcscpy(pszNewParameters, pProperties->pszParameters);
948 AppendParameterValue(pszNewParameters, L"DNS", pszAddress);
949
950 NewProperties.dwDhcp = 0;
951 NewProperties.pszIpAddress = pProperties->pszIpAddress;
952 NewProperties.pszSubnetMask = pProperties->pszSubnetMask;
953 NewProperties.pszParameters = pszNewParameters;
954
955 SetInterfaceProperties(&InterfaceGUID, &NewProperties);
956
957done:
958 if (pszNewParameters)
959 HeapFree(GetProcessHeap(), 0, pszNewParameters);
960
961 CoTaskMemFree(pProperties);
962 pProperties = NULL;
963
964 DPRINT("IpAddDns() done (Error %lu)\n", dwError);
965 return dwError;
966}
967
968
969static
970DWORD
971WINAPI
973 LPCWSTR pwszMachine,
974 LPWSTR *argv,
979 BOOL *pbDone)
980{
981 TAG_TYPE pttTags[] = {{L"name", NS_REQ_ZERO, FALSE},
982 {L"addr", NS_REQ_ZERO, FALSE},
983 {L"gateway", NS_REQ_ZERO, FALSE}};
984 GUID InterfaceGUID;
985 PDWORD pdwTagType = NULL;
986 DWORD i;
987 BOOL bHaveName = FALSE, bHaveAddress = FALSE, bHaveGateway = FALSE;
988 IN_ADDR Address, Gateway;
989 PWSTR pszName = NULL, pszAddress = NULL, pszGateway = NULL;
990 PWSTR pszNewIpAddress = NULL, pszNewSubnetMask = NULL, pszNewParameters = NULL;
991// DWORD dwLength;
992 PCWSTR Term;
993 PTCPIP_PROPERTIES pProperties = NULL;
994 TCPIP_PROPERTIES NewProperties;
995 HRESULT hr;
997 DWORD dwError = ERROR_SUCCESS;
998
999 DPRINT("IpDeleteAddress()\n");
1000
1001 pdwTagType = HeapAlloc(GetProcessHeap(),
1002 0,
1003 (dwArgCount - dwCurrentIndex) * sizeof(DWORD));
1004 if (pdwTagType == NULL)
1005 {
1007 }
1008
1010 argv,
1012 dwArgCount,
1013 pttTags,
1014 ARRAYSIZE(pttTags),
1015 pdwTagType);
1016 if (dwError != ERROR_SUCCESS)
1017 {
1018 DPRINT1("MatchTagsInCmdLine() failed (Error %lu)\n", dwError);
1019 HeapFree(GetProcessHeap(), 0, pdwTagType);
1020 return dwError;
1021 }
1022
1023 for (i = 0; i < (dwArgCount - dwCurrentIndex); i++)
1024 {
1025 DPRINT("Tag %lu: %lu\n", i, pdwTagType[i]);
1026
1027 switch (pdwTagType[i])
1028 {
1029 case 0: /* name */
1030 DPRINT("Tag: name (%S)\n", argv[i + dwCurrentIndex]);
1032 &InterfaceGUID,
1033 0, 0);
1034 if (dwError != ERROR_SUCCESS)
1035 {
1036 DPRINT1("NhGetGuidFromInterfaceName() failed (Error %lu)\n", dwError);
1039 argv[i + dwCurrentIndex]);
1040 dwError = ERROR_SUPPRESS_OUTPUT;
1041 break;
1042 }
1043 pszName = argv[i + dwCurrentIndex];
1044 DPRINT("Interface: {%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
1045 InterfaceGUID.Data1, InterfaceGUID.Data2, InterfaceGUID.Data3, InterfaceGUID.Data4[0], InterfaceGUID.Data4[1],
1046 InterfaceGUID.Data4[2], InterfaceGUID.Data4[3], InterfaceGUID.Data4[4], InterfaceGUID.Data4[5], InterfaceGUID.Data4[6], InterfaceGUID.Data4[7]);
1047 bHaveName = TRUE;
1048 break;
1049
1050 case 1: /* addr */
1051 DPRINT("Tag: addr (%S)\n", argv[i + dwCurrentIndex]);
1053 TRUE,
1054 &Term,
1055 &Address);
1056 if (Status != 0 /*STATUS_SUCCESS*/)
1057 {
1058 DPRINT("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
1062 pttTags[pdwTagType[i]].pwszTag);
1063 dwError = ERROR_SUPPRESS_OUTPUT;
1064 break;
1065 }
1066 DPRINT("IP Address: %u.%u.%u.%u\n",
1067 Address.S_un.S_un_b.s_b1, Address.S_un.S_un_b.s_b2, Address.S_un.S_un_b.s_b3, Address.S_un.S_un_b.s_b4);
1068 pszAddress = argv[i + dwCurrentIndex];
1069 DPRINT("IP Address: %S\n", pszAddress);
1070 bHaveAddress = TRUE;
1071 break;
1072
1073 case 2: /* gateway */
1074 DPRINT("Tag: gateway (%S)\n", argv[i + dwCurrentIndex]);
1076 TRUE,
1077 &Term,
1078 &Gateway);
1079 if (Status != 0 /*STATUS_SUCCESS*/)
1080 {
1081 DPRINT("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
1085 pttTags[pdwTagType[i]].pwszTag);
1086 dwError = ERROR_SUPPRESS_OUTPUT;
1087 break;
1088 }
1089 pszGateway = argv[i + dwCurrentIndex];
1090 DPRINT("Gateway: %u.%u.%u.%u\n",
1091 Gateway.S_un.S_un_b.s_b1, Gateway.S_un.S_un_b.s_b2, Gateway.S_un.S_un_b.s_b3, Gateway.S_un.S_un_b.s_b4);
1092 bHaveGateway = TRUE;
1093 break;
1094
1095 default:
1096 DPRINT1("Unknown tag type %lu\n", pdwTagType[i]);
1097 break;
1098 }
1099 }
1100
1101 if (pdwTagType)
1102 HeapFree(GetProcessHeap(), 0, pdwTagType);
1103
1104 if (dwError != ERROR_SUCCESS)
1105 return dwError;
1106
1107 /* Check parameters */
1108
1109 /* The interface name is mandatory */
1110 if (bHaveName == FALSE)
1111 return ERROR_INVALID_SYNTAX;
1112
1113 hr = GetInterfaceProperties(&InterfaceGUID, &pProperties);
1114 if (FAILED(hr))
1115 {
1118 pszName);
1119 return ERROR_SUPPRESS_OUTPUT;
1120 }
1121
1122 if (bHaveAddress && pszAddress)
1123 {
1124 if (pProperties->dwDhcp)
1125 {
1128 return ERROR_SUPPRESS_OUTPUT;
1129 }
1130#if 0
1131 dwLength = wcslen(pProperties->pszIpAddress) + 1;
1132 pszNewIpAddress = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
1133 if (pszNewIpAddress == NULL)
1134 {
1135 dwError = ERROR_NOT_ENOUGH_MEMORY;
1136 goto done;
1137 }
1138
1139 wcscpy(pszNewIpAddress, pProperties->pszIpAddress);
1140 /* TODO */
1141
1142 dwLength = wcslen(pProperties->pszSubnetMask) + 1;
1143 pszNewSubnetMask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
1144 if (pszNewSubnetMask == NULL)
1145 {
1146 dwError = ERROR_NOT_ENOUGH_MEMORY;
1147 goto done;
1148 }
1149
1150 wcscpy(pszNewSubnetMask, pProperties->pszSubnetMask);
1151 /* TODO */
1152#endif
1153 }
1154
1155 if (bHaveGateway && pszGateway)
1156 {
1157#if 0
1158 dwLength = wcslen(pProperties->pszParameters) + 1;
1159
1160 pszNewParameters = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
1161 if (pszNewParameters == NULL)
1162 {
1163 dwError = ERROR_NOT_ENOUGH_MEMORY;
1164 goto done;
1165 }
1166
1167 wcscpy(pszNewParameters, pProperties->pszParameters);
1168 /* TODO */
1169#endif
1170 }
1171
1172 NewProperties.dwDhcp = 0;
1173 NewProperties.pszIpAddress = pszNewIpAddress ? pszNewIpAddress : pProperties->pszIpAddress;
1174 NewProperties.pszSubnetMask = pszNewSubnetMask ? pszNewSubnetMask : pProperties->pszSubnetMask;
1175 NewProperties.pszParameters = pszNewParameters ? pszNewParameters : pProperties->pszParameters;
1176
1177 SetInterfaceProperties(&InterfaceGUID, &NewProperties);
1178
1179//done:
1180 if (pszNewIpAddress)
1181 HeapFree(GetProcessHeap(), 0, pszNewIpAddress);
1182
1183 if (pszNewSubnetMask)
1184 HeapFree(GetProcessHeap(), 0, pszNewSubnetMask);
1185
1186 if (pszNewParameters)
1187 HeapFree(GetProcessHeap(), 0, pszNewParameters);
1188
1189 CoTaskMemFree(pProperties);
1190 pProperties = NULL;
1191
1192 DPRINT("IpDeleteAddress() done (Error %lu)\n", dwError);
1193 return dwError;
1194}
1195
1196
1197static
1198DWORD
1199WINAPI
1201 LPCWSTR pwszMachine,
1202 LPWSTR *argv,
1205 DWORD dwFlags,
1207 BOOL *pbDone)
1208{
1209 TAG_TYPE pttTags[] = {{L"name", NS_REQ_ZERO, FALSE}};
1210 GUID InterfaceGUID;
1211 PDWORD pdwTagType = NULL;
1212 DWORD dwCount = 0, i;
1213 PWSTR pszName = NULL;
1215 DWORD dwError = ERROR_SUCCESS;
1216
1217 DPRINT("IpDeleteArpCache()\n");
1218
1219 pdwTagType = HeapAlloc(GetProcessHeap(),
1220 0,
1221 (dwArgCount - dwCurrentIndex) * sizeof(DWORD));
1222 if (pdwTagType == NULL)
1223 {
1225 }
1226
1228 argv,
1230 dwArgCount,
1231 pttTags,
1232 ARRAYSIZE(pttTags),
1233 pdwTagType);
1234 if (dwError != ERROR_SUCCESS)
1235 {
1236 DPRINT1("MatchTagsInCmdLine() failed (Error %lu)\n", dwError);
1237 HeapFree(GetProcessHeap(), 0, pdwTagType);
1238 return dwError;
1239 }
1240
1241 for (i = 0; i < (dwArgCount - dwCurrentIndex); i++)
1242 {
1243 DPRINT("Tag %lu: %lu\n", i, pdwTagType[i]);
1244
1245 switch (pdwTagType[i])
1246 {
1247 case 0: /* name */
1248 DPRINT("Tag: name (%S)\n", argv[i + dwCurrentIndex]);
1250 &InterfaceGUID,
1251 0, 0);
1252 if (dwError != ERROR_SUCCESS)
1253 {
1254 DPRINT("NhGetGuidFromInterfaceName() failed (Error %lu)\n", dwError);
1257 argv[i + dwCurrentIndex]);
1258 dwError = ERROR_SUPPRESS_OUTPUT;
1259 break;
1260 }
1261 pszName = argv[i + dwCurrentIndex];
1262 DPRINT("Interface: {%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
1263 InterfaceGUID.Data1, InterfaceGUID.Data2, InterfaceGUID.Data3, InterfaceGUID.Data4[0], InterfaceGUID.Data4[1],
1264 InterfaceGUID.Data4[2], InterfaceGUID.Data4[3], InterfaceGUID.Data4[4], InterfaceGUID.Data4[5], InterfaceGUID.Data4[6], InterfaceGUID.Data4[7]);
1265 break;
1266
1267 default:
1268 DPRINT1("Unknown tag type %lu\n", pdwTagType[i]);
1269 break;
1270 }
1271 }
1272
1273 if (pdwTagType)
1274 HeapFree(GetProcessHeap(), 0, pdwTagType);
1275
1276 if (dwError != ERROR_SUCCESS)
1277 return dwError;
1278
1280 &dwCount,
1281 FALSE,
1283 0);
1284 if (dwError != ERROR_SUCCESS)
1285 {
1286 DPRINT1("NhpAllocateAndGetInterfaceInfoFromStack() failed (Error %lu)\n", dwError);
1287 return dwError;
1288 }
1289
1290 DPRINT("\nEntries: %lu\n", dwCount);
1291
1292 for (i = 0; i < dwCount; i++)
1293 {
1294 DPRINT("\nEntry %lu\n", i);
1295 DPRINT("Index: %lu\n", pTable[i].Index);
1296 DPRINT("MediaType: %lu\n", pTable[i].MediaType);
1297 DPRINT("ConnectionType: %u\n", pTable[i].ConnectionType);
1298 DPRINT("AccessType: %u\n", pTable[i].AccessType);
1299 DPRINT("DeviceGuid: %08lx\n", pTable[i].DeviceGuid.Data1);
1300 DPRINT("InterfaceGuid: %08lx\n", pTable[i].InterfaceGuid.Data1);
1301
1302 if ((pszName == NULL) || (memcmp(&pTable[i].DeviceGuid, &InterfaceGUID, sizeof(GUID)) == 0))
1303 {
1304 DPRINT("Delete ARP cache for %S (Index: %u)\n", pszName, pTable[i].Index);
1305 FlushIpNetTable(pTable[i].Index); /* Windows XP uses FlushIpNetTableFromStack() */
1306 }
1307 }
1308
1309 if (pTable)
1311
1312 DPRINT("IpDeleteArpCache() done (Error %lu)\n", dwError);
1313 return dwError;
1314}
1315
1316
1317static
1318DWORD
1319WINAPI
1321 LPCWSTR pwszMachine,
1322 LPWSTR *argv,
1325 DWORD dwFlags,
1327 BOOL *pbDone)
1328{
1329 TAG_TYPE pttTags[] = {{L"name", NS_REQ_ZERO, FALSE},
1330 {L"addr", NS_REQ_ZERO, FALSE}};
1331 TOKEN_VALUE ptvAddress[] = {{L"all", ADDRESS_ALL}};
1332 GUID InterfaceGUID;
1333 PDWORD pdwTagType = NULL;
1334 DWORD i;
1335 BOOL bHaveName = FALSE, bHaveAddress = FALSE;
1337 PWSTR pszName = NULL, pszAddress = NULL;
1338 PWSTR pszNewParameters = NULL;
1339 DWORD dwAddress, dwLength;
1340 PCWSTR Term;
1341 PTCPIP_PROPERTIES pProperties = NULL;
1342 TCPIP_PROPERTIES NewProperties;
1343 HRESULT hr;
1345 DWORD dwError = ERROR_SUCCESS;
1346
1347 DPRINT1("IpDeleteDns()\n");
1348
1349 pdwTagType = HeapAlloc(GetProcessHeap(),
1350 0,
1351 (dwArgCount - dwCurrentIndex) * sizeof(DWORD));
1352 if (pdwTagType == NULL)
1353 {
1355 }
1356
1358 argv,
1360 dwArgCount,
1361 pttTags,
1362 ARRAYSIZE(pttTags),
1363 pdwTagType);
1364 if (dwError != ERROR_SUCCESS)
1365 {
1366 DPRINT1("MatchTagsInCmdLine() failed (Error %lu)\n", dwError);
1367 HeapFree(GetProcessHeap(), 0, pdwTagType);
1368 return dwError;
1369 }
1370
1371 for (i = 0; i < (dwArgCount - dwCurrentIndex); i++)
1372 {
1373 DPRINT1("Tag %lu: %lu\n", i, pdwTagType[i]);
1374
1375 switch (pdwTagType[i])
1376 {
1377 case 0: /* name */
1378 DPRINT1("Tag: name (%S)\n", argv[i + dwCurrentIndex]);
1380 &InterfaceGUID,
1381 0, 0);
1382 if (dwError != ERROR_SUCCESS)
1383 {
1384 DPRINT1("NhGetGuidFromInterfaceName() failed (Error %lu)\n", dwError);
1387 argv[i + dwCurrentIndex]);
1388 dwError = ERROR_SUPPRESS_OUTPUT;
1389 break;
1390 }
1391 pszName = argv[i + dwCurrentIndex];
1392 DPRINT1("Interface: {%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
1393 InterfaceGUID.Data1, InterfaceGUID.Data2, InterfaceGUID.Data3, InterfaceGUID.Data4[0], InterfaceGUID.Data4[1],
1394 InterfaceGUID.Data4[2], InterfaceGUID.Data4[3], InterfaceGUID.Data4[4], InterfaceGUID.Data4[5], InterfaceGUID.Data4[6], InterfaceGUID.Data4[7]);
1395 bHaveName = TRUE;
1396 break;
1397
1398 case 1: /* addr */
1399 DPRINT1("Tag: addr (%S)\n", argv[i + dwCurrentIndex]);
1400 dwError = MatchEnumTag(hDllInstance,
1402 ARRAYSIZE(ptvAddress),
1403 ptvAddress,
1404 &dwAddress);
1405 if (dwError == ERROR_SUCCESS)
1406 {
1407 pszAddress = NULL;
1408 }
1409 else
1410 {
1411 dwError = ERROR_SUCCESS;
1413 TRUE,
1414 &Term,
1415 &Address);
1416 if (Status != 0 /*STATUS_SUCCESS*/)
1417 {
1418 DPRINT1("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
1422 pttTags[pdwTagType[i]].pwszTag);
1423 dwError = ERROR_SUPPRESS_OUTPUT;
1424 break;
1425 }
1426
1427 DPRINT1("IP Address: %u.%u.%u.%u\n",
1428 Address.S_un.S_un_b.s_b1, Address.S_un.S_un_b.s_b2, Address.S_un.S_un_b.s_b3, Address.S_un.S_un_b.s_b4);
1429 pszAddress = argv[i + dwCurrentIndex];
1430 DPRINT1("IP Address: %S\n", pszAddress);
1431 }
1432 bHaveAddress = TRUE;
1433 break;
1434
1435 default:
1436 DPRINT1("Unknown tag type %lu\n", pdwTagType[i]);
1437 break;
1438 }
1439 }
1440
1441 if (pdwTagType)
1442 HeapFree(GetProcessHeap(), 0, pdwTagType);
1443
1444 if (dwError != ERROR_SUCCESS)
1445 return dwError;
1446
1447 /* Check parameters */
1448
1449 /* The interface name is mandatory */
1450 if (bHaveName == FALSE)
1451 return ERROR_INVALID_SYNTAX;
1452
1453 /* The address is mandatory */
1454 if (!bHaveAddress)
1455 return ERROR_INVALID_SYNTAX;
1456
1457 hr = GetInterfaceProperties(&InterfaceGUID, &pProperties);
1458 if (FAILED(hr))
1459 {
1462 pszName);
1463 return ERROR_SUPPRESS_OUTPUT;
1464 }
1465
1466 dwLength = wcslen(pProperties->pszParameters) + 1;
1467
1468 pszNewParameters = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
1469 if (pszNewParameters == NULL)
1470 {
1471 dwError = ERROR_NOT_ENOUGH_MEMORY;
1472 goto done;
1473 }
1474
1475 wcscpy(pszNewParameters, pProperties->pszParameters);
1476 DeleteParameterValue(pszNewParameters, L"DNS", pszAddress);
1477
1478 NewProperties.dwDhcp = 0;
1479 NewProperties.pszIpAddress = pProperties->pszIpAddress;
1480 NewProperties.pszSubnetMask = pProperties->pszSubnetMask;
1481 NewProperties.pszParameters = pszNewParameters;
1482
1483 SetInterfaceProperties(&InterfaceGUID, &NewProperties);
1484
1485done:
1486 if (pszNewParameters)
1487 HeapFree(GetProcessHeap(), 0, pszNewParameters);
1488
1489 CoTaskMemFree(pProperties);
1490 pProperties = NULL;
1491
1492 DPRINT("IpDeleteDns() done (Error %lu)\n", dwError);
1493 return dwError;
1494}
1495
1496
1497static
1498DWORD
1499WINAPI
1501 LPCWSTR pwszMachine,
1502 LPWSTR *argv,
1505 DWORD dwFlags,
1507 BOOL *pbDone)
1508{
1509 TAG_TYPE pttTags[] = {{L"name", NS_REQ_ZERO, FALSE},
1510 {L"source", NS_REQ_ZERO, FALSE},
1511 {L"addr", NS_REQ_ZERO, FALSE},
1512 {L"mask", NS_REQ_ZERO, FALSE},
1513 {L"gateway", NS_REQ_ZERO, FALSE},
1514 {L"gwmetric", NS_REQ_ZERO, FALSE}};
1515 TOKEN_VALUE ptvSource[] = {{L"static", SOURCE_STATIC},
1516 {L"dhcp", SOURCE_DHCP}};
1517 TOKEN_VALUE ptvGateway[] = {{L"none", GATEWAY_NONE}};
1518 GUID InterfaceGUID;
1519 PDWORD pdwTagType = NULL;
1520 DWORD i, dwSource = SOURCE_UNCHANGED, dwGateway = 0;
1521 BOOL bHaveName = FALSE, bHaveSource = FALSE, bHaveAddress = FALSE,
1522 bHaveMask = FALSE, bHaveGateway = FALSE, bHaveMetric = FALSE;
1523 IN_ADDR Address, Mask, Gateway;
1524 PWSTR pszName = NULL, pszAddress = NULL, pszMask = NULL, pszGateway = NULL, pszGwMetric = NULL;
1525 PWSTR pszParameterBuffer = NULL;
1526 DWORD dwMetric;
1527 PCWSTR Term;
1528 PTCPIP_PROPERTIES pProperties = NULL;
1529 TCPIP_PROPERTIES NewProperties;
1530 HRESULT hr;
1532 DWORD dwError = ERROR_SUCCESS;
1533
1534 DPRINT("IpSetAddress()\n");
1535
1536 pdwTagType = HeapAlloc(GetProcessHeap(),
1537 0,
1538 (dwArgCount - dwCurrentIndex) * sizeof(DWORD));
1539 if (pdwTagType == NULL)
1540 {
1542 }
1543
1545 argv,
1547 dwArgCount,
1548 pttTags,
1549 ARRAYSIZE(pttTags),
1550 pdwTagType);
1551 if (dwError != ERROR_SUCCESS)
1552 {
1553 DPRINT1("MatchTagsInCmdLine() failed (Error %lu)\n", dwError);
1554 HeapFree(GetProcessHeap(), 0, pdwTagType);
1555 return dwError;
1556 }
1557
1558 for (i = 0; i < (dwArgCount - dwCurrentIndex); i++)
1559 {
1560 DPRINT("Tag %lu: %lu\n", i, pdwTagType[i]);
1561
1562 switch (pdwTagType[i])
1563 {
1564 case 0: /* name */
1565 DPRINT("Tag: name (%S)\n", argv[i + dwCurrentIndex]);
1567 &InterfaceGUID,
1568 0, 0);
1569 if (dwError != ERROR_SUCCESS)
1570 {
1571 DPRINT("NhGetGuidFromInterfaceName() failed (Error %lu)\n", dwError);
1574 argv[i + dwCurrentIndex]);
1575 dwError = ERROR_SUPPRESS_OUTPUT;
1576 break;
1577 }
1578 pszName = argv[i + dwCurrentIndex];
1579 DPRINT("Interface: {%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
1580 InterfaceGUID.Data1, InterfaceGUID.Data2, InterfaceGUID.Data3, InterfaceGUID.Data4[0], InterfaceGUID.Data4[1],
1581 InterfaceGUID.Data4[2], InterfaceGUID.Data4[3], InterfaceGUID.Data4[4], InterfaceGUID.Data4[5], InterfaceGUID.Data4[6], InterfaceGUID.Data4[7]);
1582 bHaveName = TRUE;
1583 break;
1584
1585 case 1: /* source */
1586 DPRINT("Tag: source (%S)\n", argv[i + dwCurrentIndex]);
1587 dwError = MatchEnumTag(hDllInstance,
1589 ARRAYSIZE(ptvSource),
1590 ptvSource,
1591 &dwSource);
1592 if (dwError != ERROR_SUCCESS)
1593 {
1594 DPRINT("MatchEnumTag() failed (Error %lu)\n", dwError);
1598 pttTags[pdwTagType[i]].pwszTag);
1599 dwError = ERROR_SUPPRESS_OUTPUT;
1600 break;
1601 }
1602 DPRINT("Source: %lu\n", dwSource);
1603 bHaveSource = TRUE;
1604 break;
1605
1606 case 2: /* addr */
1607 DPRINT("Tag: addr (%S)\n", argv[i + dwCurrentIndex]);
1609 TRUE,
1610 &Term,
1611 &Address);
1612 if (Status != 0 /*STATUS_SUCCESS*/)
1613 {
1614 DPRINT("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
1618 pttTags[pdwTagType[i]].pwszTag);
1619 dwError = ERROR_SUPPRESS_OUTPUT;
1620 break;
1621 }
1622 DPRINT("IP Address: %u.%u.%u.%u\n",
1623 Address.S_un.S_un_b.s_b1, Address.S_un.S_un_b.s_b2, Address.S_un.S_un_b.s_b3, Address.S_un.S_un_b.s_b4);
1624 pszAddress = argv[i + dwCurrentIndex];
1625 DPRINT("IP Address: %S\n", pszAddress);
1626 bHaveAddress = TRUE;
1627 break;
1628
1629 case 3: /* mask */
1630 DPRINT("Tag: mask (%S)\n", argv[i + dwCurrentIndex]);
1632 TRUE,
1633 &Term,
1634 &Mask);
1635 if (Status != 0 /*STATUS_SUCCESS*/)
1636 {
1637 DPRINT("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
1641 pttTags[pdwTagType[i]].pwszTag);
1642 dwError = ERROR_SUPPRESS_OUTPUT;
1643 break;
1644 }
1645 DPRINT("Subnet Mask: %u.%u.%u.%u\n",
1646 Mask.S_un.S_un_b.s_b1, Mask.S_un.S_un_b.s_b2, Mask.S_un.S_un_b.s_b3, Mask.S_un.S_un_b.s_b4);
1647 pszMask = argv[i + dwCurrentIndex];
1648 DPRINT("Subnat Mask: %S\n", pszMask);
1649 bHaveMask = TRUE;
1650 break;
1651
1652 case 4: /* gateway */
1653 DPRINT("Tag: gateway (%S)\n", argv[i + dwCurrentIndex]);
1654 dwError = MatchEnumTag(hDllInstance,
1656 ARRAYSIZE(ptvGateway),
1657 ptvGateway,
1658 &dwGateway);
1659 if (dwError == ERROR_SUCCESS)
1660 {
1661 pszGateway = NULL;
1662 pszGwMetric = NULL;
1663 }
1664 else
1665 {
1666 dwError = ERROR_SUCCESS;
1668 TRUE,
1669 &Term,
1670 &Gateway);
1671 if (Status != 0 /*STATUS_SUCCESS*/)
1672 {
1673 DPRINT("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
1677 pttTags[pdwTagType[i]].pwszTag);
1678 dwError = ERROR_SUPPRESS_OUTPUT;
1679 break;
1680 }
1681 pszGateway = argv[i + dwCurrentIndex];
1682 DPRINT("Gateway: %u.%u.%u.%u\n",
1683 Gateway.S_un.S_un_b.s_b1, Gateway.S_un.S_un_b.s_b2, Gateway.S_un.S_un_b.s_b3, Gateway.S_un.S_un_b.s_b4);
1684 }
1685 bHaveGateway = TRUE;
1686 break;
1687
1688 case 5: /* gwmetric */
1689 DPRINT("Tag: gwmetric (%S)\n", argv[i + dwCurrentIndex]);
1690 dwMetric = wcstoul(argv[i + dwCurrentIndex],
1691 (wchar_t**)&Term,
1692 10);
1693 if (dwMetric > 9999)
1694 {
1695 dwError = ERROR_INVALID_PARAMETER;
1696 break;
1697 }
1698 pszGwMetric = argv[i + dwCurrentIndex];
1699 DPRINT("Metric: %lu\n", dwMetric);
1700 bHaveMetric = TRUE;
1701 break;
1702
1703 default:
1704 DPRINT1("Unknown tag type %lu\n", pdwTagType[i]);
1705 break;
1706 }
1707 }
1708
1709 if (pdwTagType)
1710 HeapFree(GetProcessHeap(), 0, pdwTagType);
1711
1712 if (dwError != ERROR_SUCCESS)
1713 return dwError;
1714
1715 /* Check parameters */
1716
1717 /* The interface name is mandatory */
1718 if (bHaveName == FALSE)
1719 return ERROR_INVALID_SYNTAX;
1720
1721 /* We need address and mask, or none of them */
1722 if ((bHaveAddress && !bHaveMask) ||
1723 (!bHaveAddress && bHaveMask))
1724 return ERROR_INVALID_SYNTAX;
1725
1726 /* If we have an address, we need a source */
1727 if (bHaveAddress && !bHaveSource)
1728 return ERROR_INVALID_SYNTAX;
1729
1730 /* We need gateway and metric, or none of them */
1731 if ((bHaveGateway && !bHaveMetric) ||
1732 (!bHaveGateway && bHaveMetric))
1733 return ERROR_INVALID_SYNTAX;
1734
1735 /* If we have a static source, we need an address or a gateway */
1736 if ((dwSource == SOURCE_STATIC) && !bHaveAddress && !bHaveGateway)
1737 return ERROR_INVALID_SYNTAX;
1738
1739 hr = GetInterfaceProperties(&InterfaceGUID, &pProperties);
1740 if (FAILED(hr))
1741 {
1744 pszName);
1745 return ERROR_SUPPRESS_OUTPUT;
1746 }
1747
1748 pszParameterBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BUFFER_SIZE * sizeof(WCHAR));
1749 if (pszParameterBuffer == NULL)
1750 {
1751 dwError = ERROR_NOT_ENOUGH_MEMORY;
1752 goto done;
1753 }
1754
1755 if (dwSource == SOURCE_STATIC)
1756 {
1757 /* STATIC */
1758 NewProperties.dwDhcp = 0;
1759 NewProperties.pszIpAddress = pszAddress;
1760 NewProperties.pszSubnetMask = pszMask;
1761 NewProperties.pszParameters = pszParameterBuffer;
1762
1763 if (bHaveGateway)
1764 {
1765 StringCchPrintfW(pszParameterBuffer, BUFFER_SIZE,
1766 L"DefGw=%s;GwMetric=%s;",
1767 pszGateway, pszGwMetric);
1768 }
1769 else
1770 {
1771 StringCchPrintfW(pszParameterBuffer, BUFFER_SIZE,
1772 L"DefGw=%s;GwMetric=%s;",
1773 L"0.0.0.0", L"0");
1774 }
1775 }
1776 else if (dwSource == SOURCE_DHCP)
1777 {
1778 /* DHCP */
1779 if (pProperties->dwDhcp)
1780 {
1783 dwError = ERROR_SUPPRESS_OUTPUT;
1784 goto done;
1785 }
1786
1787 NewProperties.dwDhcp = 1;
1788 NewProperties.pszIpAddress = NULL;
1789 NewProperties.pszSubnetMask = NULL;
1790 NewProperties.pszParameters = pszParameterBuffer;
1791
1792 StringCchPrintfW(pszParameterBuffer, BUFFER_SIZE,
1793 L"DefGw=%s;GwMetric=%s;",
1794 L"", L"");
1795 }
1796
1797 SetInterfaceProperties(&InterfaceGUID, &NewProperties);
1798
1799done:
1800 if (pszParameterBuffer)
1801 HeapFree(GetProcessHeap(), 0, pszParameterBuffer);
1802
1803 CoTaskMemFree(pProperties);
1804 pProperties = NULL;
1805
1806 DPRINT("IpSetAddress() done (Error %lu)\n", dwError);
1807 return dwError;
1808}
1809
1810
1811static
1812DWORD
1813WINAPI
1815 LPCWSTR pwszMachine,
1816 LPWSTR *argv,
1819 DWORD dwFlags,
1821 BOOL *pbDone)
1822{
1823 TAG_TYPE pttTags[] = {{L"name", NS_REQ_ZERO, FALSE},
1824 {L"source", NS_REQ_ZERO, FALSE},
1825 {L"addr", NS_REQ_ZERO, FALSE},
1826 {L"register", NS_REQ_ZERO, FALSE}};
1827 TOKEN_VALUE ptvSource[] = {{L"static", SOURCE_STATIC},
1828 {L"dhcp", SOURCE_DHCP}};
1829 TOKEN_VALUE ptvRegister[] = {{L"none", REGISTER_NONE},
1830 {L"primary", REGISTER_PRIMARY},
1831 {L"both", REGISTER_BOTH}};
1832 GUID InterfaceGUID;
1833 PDWORD pdwTagType = NULL;
1834 DWORD i, dwSource = SOURCE_UNCHANGED;
1835 BOOL bHaveName = FALSE, bHaveSource = FALSE, bHaveAddress = FALSE /*,
1836 bHaveRegister = FALSE */;
1838 PWSTR pszName = NULL, pszAddress = NULL;
1839 PWSTR pszParameterBuffer = NULL;
1840 PCWSTR Term;
1841 DWORD dwRegister = REGISTER_NONE;
1842 PTCPIP_PROPERTIES pProperties = NULL;
1843 TCPIP_PROPERTIES NewProperties;
1844 HRESULT hr;
1846 DWORD dwError = ERROR_SUCCESS;
1847
1848 DPRINT("IpSetDns()\n");
1849
1850 pdwTagType = HeapAlloc(GetProcessHeap(),
1851 0,
1852 (dwArgCount - dwCurrentIndex) * sizeof(DWORD));
1853 if (pdwTagType == NULL)
1854 {
1856 }
1857
1859 argv,
1861 dwArgCount,
1862 pttTags,
1863 ARRAYSIZE(pttTags),
1864 pdwTagType);
1865 if (dwError != ERROR_SUCCESS)
1866 {
1867 DPRINT1("MatchTagsInCmdLine() failed (Error %lu)\n", dwError);
1868 HeapFree(GetProcessHeap(), 0, pdwTagType);
1869 return dwError;
1870 }
1871
1872 for (i = 0; i < (dwArgCount - dwCurrentIndex); i++)
1873 {
1874 DPRINT("Tag %lu: %lu\n", i, pdwTagType[i]);
1875
1876 switch (pdwTagType[i])
1877 {
1878 case 0: /* name */
1879 DPRINT("Tag: name (%S)\n", argv[i + dwCurrentIndex]);
1881 &InterfaceGUID,
1882 0, 0);
1883 if (dwError != ERROR_SUCCESS)
1884 {
1885 DPRINT("NhGetGuidFromInterfaceName() failed (Error %lu)\n", dwError);
1888 argv[i + dwCurrentIndex]);
1889 dwError = ERROR_SUPPRESS_OUTPUT;
1890 break;
1891 }
1892 pszName = argv[i + dwCurrentIndex];
1893 DPRINT("Interface: {%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
1894 InterfaceGUID.Data1, InterfaceGUID.Data2, InterfaceGUID.Data3, InterfaceGUID.Data4[0], InterfaceGUID.Data4[1],
1895 InterfaceGUID.Data4[2], InterfaceGUID.Data4[3], InterfaceGUID.Data4[4], InterfaceGUID.Data4[5], InterfaceGUID.Data4[6], InterfaceGUID.Data4[7]);
1896 bHaveName = TRUE;
1897 break;
1898
1899 case 1: /* source */
1900 DPRINT("Tag: source (%S)\n", argv[i + dwCurrentIndex]);
1901 dwError = MatchEnumTag(hDllInstance,
1903 ARRAYSIZE(ptvSource),
1904 ptvSource,
1905 &dwSource);
1906 if (dwError != ERROR_SUCCESS)
1907 {
1908 DPRINT("MatchEnumTag() failed (Error %lu)\n", dwError);
1912 pttTags[pdwTagType[i]].pwszTag);
1913 dwError = ERROR_SUPPRESS_OUTPUT;
1914 break;
1915 }
1916 DPRINT("Source: %lu\n", dwSource);
1917 bHaveSource = TRUE;
1918 break;
1919
1920 case 2: /* addr */
1921 DPRINT("Tag: addr (%S)\n", argv[i + dwCurrentIndex]);
1923 TRUE,
1924 &Term,
1925 &Address);
1926 if (Status != 0 /*STATUS_SUCCESS*/)
1927 {
1928 DPRINT("RtlIpv4StringToAddressW() failed (Status 0x%08lx)\n", Status);
1932 pttTags[pdwTagType[i]].pwszTag);
1933 dwError = ERROR_SUPPRESS_OUTPUT;
1934 break;
1935 }
1936 DPRINT("IP Address: %u.%u.%u.%u\n",
1937 Address.S_un.S_un_b.s_b1, Address.S_un.S_un_b.s_b2, Address.S_un.S_un_b.s_b3, Address.S_un.S_un_b.s_b4);
1938 pszAddress = argv[i + dwCurrentIndex];
1939 DPRINT("IP Address: %S\n", pszAddress);
1940 bHaveAddress = TRUE;
1941 break;
1942
1943 case 3: /* register */
1944 DPRINT("Tag: register (%S)\n", argv[i + dwCurrentIndex]);
1945 dwError = MatchEnumTag(hDllInstance,
1947 ARRAYSIZE(ptvRegister),
1948 ptvRegister,
1949 &dwRegister);
1950 if (dwError != ERROR_SUCCESS)
1951 {
1952 DPRINT("MatchEnumTag() failed (Error %lu)\n", dwError);
1956 pttTags[pdwTagType[i]].pwszTag);
1957 dwError = ERROR_SUPPRESS_OUTPUT;
1958 break;
1959 }
1960 DPRINT("Register: %lu\n", dwRegister);
1961// bHaveRegister = TRUE;
1962 break;
1963
1964 default:
1965 DPRINT1("Unknown tag type %lu\n", pdwTagType[i]);
1966 break;
1967 }
1968 }
1969
1970 if (pdwTagType)
1971 HeapFree(GetProcessHeap(), 0, pdwTagType);
1972
1973 if (dwError != ERROR_SUCCESS)
1974 return dwError;
1975
1976 /* Check parameters */
1977
1978 /* The name and source arguments are mandatory */
1979 if (!bHaveName || !bHaveSource)
1980 return ERROR_INVALID_SYNTAX;
1981
1982 /* If we have a static source, we need to have an address */
1983 if ((dwSource == SOURCE_STATIC) && (!bHaveAddress))
1984 return ERROR_INVALID_SYNTAX;
1985
1986 /* If we have a dhcp source, we must not have an address */
1987 if ((dwSource == SOURCE_DHCP) && (bHaveAddress))
1988 return ERROR_INVALID_SYNTAX;
1989
1990 hr = GetInterfaceProperties(&InterfaceGUID, &pProperties);
1991 if (FAILED(hr))
1992 {
1995 pszName);
1996 return ERROR_SUPPRESS_OUTPUT;
1997 }
1998
1999 pszParameterBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BUFFER_SIZE * sizeof(WCHAR));
2000 if (pszParameterBuffer == NULL)
2001 {
2002 dwError = ERROR_NOT_ENOUGH_MEMORY;
2003 goto done;
2004 }
2005
2006 StringCchPrintfW(pszParameterBuffer, BUFFER_SIZE,
2007 L"DNS=%s;DynamicUpdate=%s;NameRegistration=%s;",
2008 (pszAddress) ? pszAddress : L"",
2009 ((dwRegister == REGISTER_BOTH) || (dwRegister == REGISTER_PRIMARY)) ? L"1" : L"0",
2010 (dwRegister == REGISTER_BOTH) ? L"1" : L"0");
2011
2012 NewProperties.dwDhcp = pProperties->dwDhcp;
2013 NewProperties.pszIpAddress = pProperties->pszIpAddress;
2014 NewProperties.pszSubnetMask = pProperties->pszSubnetMask;
2015 NewProperties.pszParameters = pszParameterBuffer;
2016
2017 SetInterfaceProperties(&InterfaceGUID, &NewProperties);
2018
2019done:
2020 if (pszParameterBuffer)
2021 HeapFree(GetProcessHeap(), 0, pszParameterBuffer);
2022
2023 CoTaskMemFree(pProperties);
2024 pProperties = NULL;
2025
2026 return dwError;
2027}
2028
2029
2030static
2031DWORD
2033 _In_ DWORD DisplayFlags,
2034 _In_ PWSTR InterfaceName)
2035{
2037 DWORD dwCount = 0, i;
2038 DWORD dwError;
2039 WCHAR szFriendlyName[80];
2040 DWORD dwFriendlyNameSize;
2041 PTCPIP_PROPERTIES pProperties = NULL;
2042 PWSTR pBuffer, pStart, pEnd;
2043
2045 &dwCount,
2046 FALSE,
2048 0);
2049 if (dwError != ERROR_SUCCESS)
2050 {
2051 DPRINT1("NhpAllocateAndGetInterfaceInfoFromStack() failed (Error %lu)\n", dwError);
2052 return dwError;
2053 }
2054
2055 DPRINT("\nEntries: %lu\n", dwCount);
2056
2057 for (i = 0; i < dwCount; i++)
2058 {
2059 DPRINT("\nEntry %lu\n", i);
2060 DPRINT("Index: %lu\n", pTable[i].Index);
2061 DPRINT("MediaType: %lu\n", pTable[i].MediaType);
2062 DPRINT("ConnectionType: %u\n", pTable[i].ConnectionType);
2063 DPRINT("AccessType: %u\n", pTable[i].AccessType);
2064 DPRINT("DeviceGuid: %08lx\n", pTable[i].DeviceGuid.Data1);
2065 DPRINT("InterfaceGuid: %08lx\n", pTable[i].InterfaceGuid.Data1);
2066
2067 dwFriendlyNameSize = sizeof(szFriendlyName);
2068 NhGetInterfaceNameFromGuid(&pTable[i].DeviceGuid,
2069 szFriendlyName,
2070 &dwFriendlyNameSize,
2071 0,
2072 0);
2073
2074 if ((InterfaceName == NULL) || MatchToken(InterfaceName, szFriendlyName))
2075 {
2077
2078 GetInterfaceProperties(&pTable[i].DeviceGuid, &pProperties);
2079
2080 if (pProperties)
2081 {
2082 DPRINT("Dhcp %lu\n", pProperties->dwDhcp);
2083 DPRINT("IpAddress %S\n", pProperties->pszIpAddress);
2084 DPRINT("SubnetMask %S\n", pProperties->pszSubnetMask);
2085 DPRINT("Parameters %S\n", pProperties->pszParameters);
2086
2087 if (DisplayFlags & DISPLAY_ADRESSES)
2088 {
2090
2091 if (pProperties->dwDhcp == 0)
2092 {
2093 if (*pProperties->pszIpAddress == UNICODE_NULL)
2094 {
2096 }
2097 else
2098 {
2100 }
2101
2102 if (*pProperties->pszSubnetMask == UNICODE_NULL)
2103 {
2105 }
2106 else
2107 {
2109 }
2110
2111 pBuffer = ExtractParameterValue(pProperties->pszParameters, L"DefGw");
2112 if (pBuffer)
2113 {
2116 }
2117
2118 pBuffer = ExtractParameterValue(pProperties->pszParameters, L"GwMetric");
2119 if (pBuffer)
2120 {
2123 }
2124 }
2125
2126 pBuffer = ExtractParameterValue(pProperties->pszParameters, L"IfMetric");
2127 if (pBuffer)
2128 {
2131 }
2132 }
2133
2134 if (DisplayFlags & DISPLAY_DNS)
2135 {
2136 if (pProperties->dwDhcp == 0)
2137 {
2138 pBuffer = ExtractParameterValue(pProperties->pszParameters, L"DNS");
2139 if (pBuffer)
2140 {
2141 pEnd = wcschr(pBuffer, L',');
2142 if (pEnd == NULL)
2143 {
2145 }
2146 else
2147 {
2148 pStart = pBuffer;
2149 *pEnd = UNICODE_NULL;
2151 for (;;)
2152 {
2153 pStart = pEnd + 1;
2154 pEnd = wcschr(pStart, L',');
2155 if (pEnd == NULL)
2156 break;
2157 *pEnd = UNICODE_NULL;
2159 }
2160 }
2162 }
2163 }
2164 }
2165
2166 CoTaskMemFree(pProperties);
2167 pProperties = NULL;
2168 }
2169 }
2170 }
2171
2172 if (pTable)
2174
2175 return ERROR_SUCCESS;
2176}
2177
2178
2179static
2180DWORD
2181WINAPI
2183 LPCWSTR pwszMachine,
2184 LPWSTR *argv,
2187 DWORD dwFlags,
2189 BOOL *pbDone)
2190{
2191 PWSTR pszInterfaceName = NULL;
2192
2193 if (dwArgCount - dwCurrentIndex > 1)
2195
2196 if (dwArgCount - dwCurrentIndex == 1)
2197 pszInterfaceName = argv[dwCurrentIndex];
2198
2199 return IpShowAdapters(DISPLAY_ADRESSES, pszInterfaceName);
2200}
2201
2202
2203static
2204DWORD
2205WINAPI
2207 LPCWSTR pwszMachine,
2208 LPWSTR *argv,
2211 DWORD dwFlags,
2213 BOOL *pbDone)
2214{
2215 PWSTR pszInterfaceName = NULL;
2216
2217 if (dwArgCount - dwCurrentIndex > 1)
2219
2220 if (dwArgCount - dwCurrentIndex == 1)
2221 pszInterfaceName = argv[dwCurrentIndex];
2222
2223 return IpShowAdapters(DISPLAY_ADRESSES | DISPLAY_DNS, pszInterfaceName);
2224}
2225
2226
2227static
2228DWORD
2229WINAPI
2231 LPCWSTR pwszMachine,
2232 LPWSTR *argv,
2235 DWORD dwFlags,
2237 BOOL *pbDone)
2238{
2239 PWSTR pszInterfaceName = NULL;
2240
2241 if (dwArgCount - dwCurrentIndex > 1)
2243
2244 if (dwArgCount - dwCurrentIndex == 1)
2245 pszInterfaceName = argv[dwCurrentIndex];
2246
2247 return IpShowAdapters(DISPLAY_DNS, pszInterfaceName);
2248}
2249
2250
2251static
2252DWORD
2253WINAPI
2255 LPCWSTR pwszMachine,
2256 LPWSTR *argv,
2259 DWORD dwFlags,
2261 BOOL *pbDone)
2262{
2263 DPRINT1("IpReset()\n");
2264 return ERROR_SUCCESS;
2265}
2266
2267
2268static
2269DWORD
2270WINAPI
2272 _In_ LPCWSTR pwszRouter,
2276{
2278 DWORD dwCount = 0, i;
2279 DWORD dwError;
2280 WCHAR szFriendlyName[80];
2281 DWORD dwFriendlyNameSize;
2282 PTCPIP_PROPERTIES pProperties = NULL;
2283 PWSTR pBuffer;
2284
2285 DPRINT("IpDumpFn(%S %p %lu %p)\n", pwszRouter, ppwcArguments, dwArgCount, pvData);
2286
2288 &dwCount,
2289 FALSE,
2291 0);
2292 if (dwError != ERROR_SUCCESS)
2293 {
2294 DPRINT1("NhpAllocateAndGetInterfaceInfoFromStack() failed (Error %lu)\n", dwError);
2295 return dwError;
2296 }
2297
2301 PrintMessage(L"pushd interface ip\n");
2303
2304 DPRINT("\nEntries: %lu\n", dwCount);
2305
2306 for (i = 0; i < dwCount; i++)
2307 {
2308 DPRINT("\nEntry %lu\n", i);
2309 DPRINT("Index: %lu\n", pTable[i].Index);
2310 DPRINT("MediaType: %lu\n", pTable[i].MediaType);
2311 DPRINT("ConnectionType: %u\n", pTable[i].ConnectionType);
2312 DPRINT("AccessType: %u\n", pTable[i].AccessType);
2313 DPRINT("DeviceGuid: %08lx\n", pTable[i].DeviceGuid.Data1);
2314 DPRINT("InterfaceGuid: %08lx\n", pTable[i].InterfaceGuid.Data1);
2315
2316 dwFriendlyNameSize = sizeof(szFriendlyName);
2317 NhGetInterfaceNameFromGuid(&pTable[i].DeviceGuid,
2318 szFriendlyName,
2319 &dwFriendlyNameSize,
2320 0,
2321 0);
2322
2326
2327 GetInterfaceProperties(&pTable[i].DeviceGuid, &pProperties);
2328
2329 if (pProperties)
2330 {
2331 DPRINT("Dhcp %lu\n", pProperties->dwDhcp);
2332 DPRINT("IpAddress %S\n", pProperties->pszIpAddress);
2333 DPRINT("SubnetMask %S\n", pProperties->pszSubnetMask);
2334 DPRINT("Parameters %S\n", pProperties->pszParameters);
2335
2336 if (pProperties->dwDhcp)
2337 {
2338 PrintMessage(L"set address name=\"%s\" source=dhcp\n",
2339 szFriendlyName);
2340 }
2341 else
2342 {
2343 PrintMessage(L"set address name=\"%s\" source=static addr=%s mask=%s\n",
2344 szFriendlyName, pProperties->pszIpAddress, pProperties->pszSubnetMask);
2345 }
2346
2347 if (pProperties->dwDhcp)
2348 {
2349 PrintMessage(L"set dns name=\"%s\" source=dhcp\n",
2350 szFriendlyName);
2351 }
2352 else
2353 {
2354 pBuffer = ExtractParameterValue(pProperties->pszParameters, L"DNS");
2355 if (pBuffer)
2356 {
2357 PrintMessage(L"set dns name=\"%s\" source=static addr=%s\n",
2358 szFriendlyName, pBuffer);
2360 }
2361 }
2362
2363 CoTaskMemFree(pProperties);
2364 pProperties = NULL;
2365 }
2366 }
2367
2369 PrintMessage(L"popd\n");
2372
2373 if (pTable)
2375
2376
2377 return ERROR_SUCCESS;
2378}
2379
2380
2381static
2382DWORD
2383WINAPI
2385 _In_ const GUID *pguidParent,
2387{
2388 NS_CONTEXT_ATTRIBUTES ContextAttributes;
2389
2390 DPRINT1("IpStart()\n");
2391
2392 ZeroMemory(&ContextAttributes, sizeof(ContextAttributes));
2393 ContextAttributes.dwVersion = 1;
2394 ContextAttributes.pwszContext = L"ip";
2395 ContextAttributes.guidHelper = GUID_IFMON_IP;
2396
2397 ContextAttributes.ulNumTopCmds = sizeof(IpTopCommands) / sizeof(CMD_ENTRY);
2398 ContextAttributes.pTopCmds = IpTopCommands;
2399
2400 ContextAttributes.ulNumGroups = sizeof(IpGroups) / sizeof(CMD_GROUP_ENTRY);
2401 ContextAttributes.pCmdGroups = IpGroups;
2402
2403 ContextAttributes.pfnDumpFn = IpDumpFn;
2404
2405 RegisterContext(&ContextAttributes);
2406
2407 return ERROR_SUCCESS;
2408}
2409
2410
2411DWORD
2412WINAPI
2414{
2415 NS_HELPER_ATTRIBUTES HelperAttributes;
2416 GUID guidParent = GUID_IFMON_INTERFACE;
2417
2418 DPRINT1("RegisterIpHelper()\n");
2419
2420 ZeroMemory(&HelperAttributes, sizeof(HelperAttributes));
2421 HelperAttributes.dwVersion = 1;
2422 HelperAttributes.guidHelper = GUID_IFMON_IP;
2423 HelperAttributes.pfnStart = IpStart;
2424 HelperAttributes.pfnStop = NULL;
2425 RegisterHelper(&guidParent, &HelperAttributes);
2426
2427 return ERROR_SUCCESS;
2428}
LONG NTSTATUS
Definition: precomp.h:26
VOID PrintMessage(DWORD dwMessage)
Definition: arp.c:95
#define IDS_DEFAULTGATEWAY
Definition: resource.h:28
#define IDS_IPADDRESS
Definition: resource.h:26
#define IDS_SUBNETMASK
Definition: resource.h:27
#define IDS_EMPTYLINE
Definition: resource.h:16
DWORD WINAPI RegisterContext(_In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
Definition: context.c:909
#define DPRINT1
Definition: precomp.h:8
static HINSTANCE hDllInstance
Definition: clb.c:9
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
HRESULT hr
Definition: delayimp.cpp:582
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static DWORD DWORD * dwLength
Definition: fusion.c:86
static DWORD WINAPI IpStart(_In_ const GUID *pguidParent, _In_ DWORD dwVersion)
Definition: ip.c:2384
static CMD_GROUP_ENTRY IpGroups[]
Definition: ip.c:84
static HRESULT SetInterfaceProperties(GUID *InterfaceGuid, PTCPIP_PROPERTIES pProperties)
Definition: ip.c:252
#define SOURCE_STATIC
Definition: ip.c:25
static FN_HANDLE_CMD IpSetAddress
Definition: ip.c:41
#define REGISTER_BOTH
Definition: ip.c:32
static FN_HANDLE_CMD IpShowAddresses
Definition: ip.c:43
static HRESULT GetInterfaceProperties(GUID *InterfaceGuid, PTCPIP_PROPERTIES *ppProperties)
Definition: ip.c:102
static FN_HANDLE_CMD IpDeleteAddress
Definition: ip.c:38
#define SOURCE_UNCHANGED
Definition: ip.c:24
static FN_HANDLE_CMD IpSetDns
Definition: ip.c:42
DWORD WINAPI RegisterIpHelper(VOID)
Definition: ip.c:2413
static BOOL DeleteParameterValue(PWSTR pszParameters, PWSTR pszParameter, PWSTR pszValue)
Definition: ip.c:464
#define ADDRESS_ALL
Definition: ip.c:34
#define GATEWAY_NONE
Definition: ip.c:28
static DWORD IpShowAdapters(_In_ DWORD DisplayFlags, _In_ PWSTR InterfaceName)
Definition: ip.c:2032
static CMD_ENTRY IpShowCommands[]
Definition: ip.c:75
static DWORD WINAPI IpDumpFn(_In_ LPCWSTR pwszRouter, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwArgCount, _In_ LPCVOID pvData)
Definition: ip.c:2271
static FN_HANDLE_CMD IpShowConfig
Definition: ip.c:44
#define BUFFER_SIZE
Definition: ip.c:19
static FN_HANDLE_CMD IpAddAddress
Definition: ip.c:36
#define REGISTER_PRIMARY
Definition: ip.c:31
static FN_HANDLE_CMD IpDeleteArpCache
Definition: ip.c:39
static FN_HANDLE_CMD IpReset
Definition: ip.c:46
#define SOURCE_DHCP
Definition: ip.c:26
static PWSTR ExtractParameterValue(PWSTR pszParameters, PWSTR pszParameter)
Definition: ip.c:400
#define DISPLAY_DNS
Definition: ip.c:22
static FN_HANDLE_CMD IpAddDns
Definition: ip.c:37
static CMD_ENTRY IpSetCommands[]
Definition: ip.c:67
static CMD_ENTRY IpDeleteCommands[]
Definition: ip.c:58
static FN_HANDLE_CMD IpDeleteDns
Definition: ip.c:40
static CMD_ENTRY IpTopCommands[]
Definition: ip.c:94
static CMD_ENTRY IpAddCommands[]
Definition: ip.c:50
#define REGISTER_NONE
Definition: ip.c:30
#define DISPLAY_ADRESSES
Definition: ip.c:21
static FN_HANDLE_CMD IpShowDns
Definition: ip.c:45
static BOOL AppendParameterValue(PWSTR pszParameters, PWSTR pszParameter, PWSTR pszValue)
Definition: ip.c:437
#define IDS_HLP_IP_DELETE_ADDRESS
Definition: resource.h:13
#define IDS_GATEWAYMETRIC
Definition: resource.h:53
#define IDS_HLP_IP_DELETE_ARPCACHE_EX
Definition: resource.h:16
#define IDS_ERROR_ALREADY_DHCP
Definition: resource.h:68
#define IDS_HLP_IP_ADD
Definition: resource.h:6
#define IDS_NOIPADDRESS
Definition: resource.h:46
#define IDS_IP_HEADER
Definition: resource.h:43
#define IDS_NOSUBNETMASK
Definition: resource.h:49
#define IDS_ERROR_GET_PROPERTIES
Definition: resource.h:69
#define IDS_ERROR_BAD_VALUE
Definition: resource.h:67
#define IDS_DUMP_NEWLINE
Definition: resource.h:60
#define IDS_HLP_IP_SHOW_DNS
Definition: resource.h:31
#define IDS_HLP_IP_DELETE_ARPCACHE
Definition: resource.h:15
#define IDS_DHCP_ON
Definition: resource.h:44
#define IDS_DUMP_IP_HEADER
Definition: resource.h:62
#define IDS_HLP_IP_DELETE_DNS
Definition: resource.h:17
#define IDS_HLP_IP_SET_ADDRESS
Definition: resource.h:21
#define IDS_HLP_IP_DELETE_ADDRESS_EX
Definition: resource.h:14
#define IDS_HLP_IP_RESET_EX
Definition: resource.h:35
#define IDS_HLP_IP_ADD_ADDRESS
Definition: resource.h:7
#define IDS_HLP_IP_DELETE_DNS_EX
Definition: resource.h:18
#define IDS_HLP_IP_SHOW_DNS_EX
Definition: resource.h:32
#define IDS_HLP_IP_RESET
Definition: resource.h:34
#define IDS_HLP_IP_SET_DNS
Definition: resource.h:23
#define IDS_ERROR_ADD_DHCP_ADDRESS
Definition: resource.h:70
#define IDS_DUMP_HEADERLINE
Definition: resource.h:61
#define IDS_HLP_IP_SHOW
Definition: resource.h:26
#define IDS_ERROR_INVALID_INTERFACE
Definition: resource.h:66
#define IDS_HLP_IP_ADD_DNS_EX
Definition: resource.h:10
#define IDS_HLP_IP_SET_ADDRESS_EX
Definition: resource.h:22
#define IDS_HLP_IP_ADD_ADDRESS_EX
Definition: resource.h:8
#define IDS_HLP_IP_SET
Definition: resource.h:20
#define IDS_STATICNAMESERVER
Definition: resource.h:55
#define IDS_ERROR_DELETE_DHCP_ADDRESS
Definition: resource.h:71
#define IDS_HLP_IP_SET_DNS_EX
Definition: resource.h:24
#define IDS_DUMP_IP_INTERFACE
Definition: resource.h:63
#define IDS_HLP_IP_SHOW_CONFIG
Definition: resource.h:29
#define IDS_HLP_IP_DELETE
Definition: resource.h:12
#define IDS_DUMP_IP_FOOTER
Definition: resource.h:64
#define IDS_HLP_IP_SHOW_ADDRESSES
Definition: resource.h:27
#define IDS_INTERFACEMETRIC
Definition: resource.h:54
#define IDS_DHCP_OFF
Definition: resource.h:45
#define IDS_HLP_IP_SHOW_ADDRESSES_EX
Definition: resource.h:28
#define IDS_HLP_IP_SHOW_CONFIG_EX
Definition: resource.h:30
#define IDS_HLP_IP_ADD_DNS
Definition: resource.h:9
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2917
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
Definition: wcs.c:2998
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int Mask
Definition: fpcontrol.c:82
Status
Definition: gdiplustypes.h:24
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD WINAPI RegisterHelper(_In_ const GUID *pguidParentHelper, _In_ const NS_HELPER_ATTRIBUTES *pHelperAttributes)
Definition: helper.c:385
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
DWORD WINAPI NhGetGuidFromInterfaceName(_In_ PWCHAR pInterfaceName, _Out_ GUID *pInterfaceGUID, DWORD dwUnknown3, DWORD dwUnknown4)
DWORD WINAPI FlushIpNetTable(DWORD dwIfIndex)
DWORD WINAPI NhGetInterfaceNameFromGuid(_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen, DWORD dwUnknown4, DWORD dwUnknown5)
DWORD WINAPI NhpAllocateAndGetInterfaceInfoFromStack(_Inout_ IP_INTERFACE_NAME_INFO **ppTable, _Inout_ PDWORD pdwCount, _In_ BOOL bOrder, _In_ HANDLE hHeap, _In_ DWORD dwFlags)
#define ZeroMemory
Definition: minwinbase.h:31
#define CopyMemory
Definition: minwinbase.h:29
#define MoveMemory
Definition: minwinbase.h:28
CONST void * LPCVOID
Definition: minwindef.h:164
#define argv
Definition: mplay32.c:18
NTSYSAPI NTSTATUS NTAPI RtlIpv4StringToAddressW(_In_ PCWSTR String, _In_ BOOLEAN Strict, _Out_ PCWSTR *Terminator, _Out_ struct in_addr *Addr)
Definition: network.c:385
#define ITcpipProperties_Unknown1(p, a, b)
Definition: netcfgn_undoc.h:32
#define ITcpipProperties_Unknown2(p, a, b)
Definition: netcfgn_undoc.h:33
EXTERN_C const IID IID_ITcpipProperties
Definition: netcfgn_undoc.h:25
#define ITcpipProperties_Release(p)
Definition: netcfgn_undoc.h:31
#define INetCfgComponent_QueryInterface(p, a, b)
Definition: netcfgx.h:60
#define INetCfg_Release(p)
Definition: netcfgx.h:289
#define INetCfgComponent_Release(p)
Definition: netcfgx.h:62
#define INetCfg_Apply(p)
Definition: netcfgx.h:292
#define INetCfg_QueryInterface(p, a, b)
Definition: netcfgx.h:287
#define INetCfg_QueryNetCfgClass(p, a, b, c)
Definition: netcfgx.h:296
EXTERN_C const IID IID_INetCfgLock
Definition: netcfgx.h:17
EXTERN_C const IID IID_INetCfgClass
Definition: netcfgx.h:317
EXTERN_C const GUID CLSID_CNetCfg
Definition: netcfgx.h:299
#define INetCfgLock_AcquireWriteLock(p, a, b, c)
Definition: netcfgx.h:24
#define INetCfgLock_ReleaseWriteLock(p)
Definition: netcfgx.h:25
#define INetCfgClass_Release(p)
Definition: netcfgx.h:335
#define INetCfg_Uninitialize(p)
Definition: netcfgx.h:291
#define INetCfgLock_Release(p)
Definition: netcfgx.h:23
EXTERN_C const IID IID_INetCfg
Definition: netcfgx.h:300
#define INetCfgClass_FindComponent(p, a, b)
Definition: netcfgx.h:336
#define INetCfg_Initialize(p, a)
Definition: netcfgx.h:290
#define INetCfgComponentPrivate_Unknown1(p, a, b)
Definition: netcfgx_undoc.h:23
#define INetCfgComponentPrivate_Release(p)
Definition: netcfgx_undoc.h:22
EXTERN_C const IID IID_INetCfgComponentPrivate
Definition: netcfgx_undoc.h:16
DWORD WINAPI MatchEnumTag(_In_ HANDLE hModule, _In_ LPCWSTR pwcArg, _In_ DWORD dwNumArg, _In_ const TOKEN_VALUE *pEnumTable, _Out_ PDWORD pdwValue)
Definition: netsh.c:346
DWORD WINAPI MatchTagsInCmdLine(_In_ HANDLE hModule, _Inout_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _Inout_ TAG_TYPE *pttTags, _In_ DWORD dwTagCount, _Out_ DWORD *pdwTagType)
Definition: netsh.c:375
BOOL WINAPI MatchToken(_In_ LPCWSTR pwszUserToken, _In_ LPCWSTR pwszCmdToken)
Definition: netsh.c:448
DWORD CDECL PrintMessageFromModule(_In_ HANDLE hModule, _In_ DWORD dwMsgId,...)
Definition: netsh.c:635
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
@ NS_REQ_ZERO
Definition: netsh.h:34
#define ERROR_SUPPRESS_OUTPUT
Definition: netsh.h:26
#define ERROR_INVALID_SYNTAX
Definition: netsh.h:10
_In_ LPWSTR _In_ DWORD _In_ LPCVOID pvData
Definition: netsh.h:116
_In_ LPWSTR * ppwcArguments
Definition: netsh.h:114
_In_ DWORD dwVersion
Definition: netsh.h:85
_In_ LPWSTR _In_ DWORD dwArgCount
Definition: netsh.h:115
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD _In_ LPCVOID _Out_ BOOL * pbDone
Definition: netsh.h:143
_In_ LPWSTR _In_ DWORD dwCurrentIndex
Definition: netsh.h:139
#define _In_
Definition: no_sal2.h:158
#define UNICODE_NULL
short WCHAR
Definition: pedump.c:58
DWORD * PDWORD
Definition: pedump.c:68
static WCHAR Address[46]
Definition: ping.c:68
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
Definition: shlwapi.h:783
PVOID pBuffer
wcscat
wcscpy
#define exit(n)
Definition: config.h:202
#define DPRINT
Definition: sndvol32.h:73
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
Definition: netsh.h:148
Definition: netsh.h:158
CMD_ENTRY * pTopCmds
Definition: netsh.h:199
CMD_GROUP_ENTRY * pCmdGroups
Definition: netsh.h:201
PNS_CONTEXT_DUMP_FN pfnDumpFn
Definition: netsh.h:203
PNS_HELPER_STOP_FN pfnStop
Definition: netsh.h:180
PNS_HELPER_START_FN pfnStart
Definition: netsh.h:179
Definition: tcpip.h:126
struct in_addr::@1123::@1124 S_un_b
union in_addr::@1123 S_un
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
static const EHCI_PERIOD pTable[]
Definition: usbehci.c:29
_In_ WDFCOLLECTION _In_ ULONG Index
#define WINAPI
Definition: msvc.h:6
static const GUID InterfaceGuid
Definition: wlanapi.c:25