ReactOS 0.4.16-dev-2613-g9533ad7
ipconfig.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS ipconfig utility
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Display IP info for net adapters
5 * COPYRIGHT: Copyright 2005-2006 Ged Murphy <gedmurphy@gmail.com>
6 */
7/*
8 * TODO:
9 * implement registerdns, showclassid, setclassid
10 */
11
12#include <stdarg.h>
13#include <stdio.h>
14#include <stdlib.h>
15
16#define WIN32_NO_STATUS
17#include <windef.h>
18#include <winbase.h>
19#include <winnls.h>
20#include <winreg.h>
21#include <iphlpapi.h>
22#include <ndk/rtlfuncs.h>
23#include <inaddr.h>
24#include <windns.h>
25#include <windns_undoc.h>
26#include <dhcpcsdk.h>
27#include <dhcpcapi.h>
28#include <strsafe.h>
29#include <conutils.h>
30
31#include "resource.h"
32
33typedef struct _RECORDTYPE
34{
38
39#define GUID_LEN 40
40
43
45{
46 {DNS_TYPE_ZERO, L"ZERO"},
47 {DNS_TYPE_A, L"A"},
48 {DNS_TYPE_NS, L"NS"},
49 {DNS_TYPE_MD, L"MD"},
50 {DNS_TYPE_MF, L"MF"},
51 {DNS_TYPE_CNAME, L"CNAME"},
52 {DNS_TYPE_SOA, L"SOA"},
53 {DNS_TYPE_MB, L"MB"},
54 {DNS_TYPE_MG, L"MG"},
55 {DNS_TYPE_MR, L"MR"},
56 {DNS_TYPE_NULL, L"NULL"},
57 {DNS_TYPE_WKS, L"WKS"},
58 {DNS_TYPE_PTR, L"PTR"},
59 {DNS_TYPE_HINFO, L"HINFO"},
60 {DNS_TYPE_MINFO, L"MINFO"},
61 {DNS_TYPE_MX, L"MX"},
62 {DNS_TYPE_TEXT, L"TXT"},
63 {DNS_TYPE_RP, L"RP"},
64 {DNS_TYPE_AFSDB, L"AFSDB"},
65 {DNS_TYPE_X25, L"X25"},
66 {DNS_TYPE_ISDN, L"ISDN"},
67 {DNS_TYPE_RT, L"RT"},
68 {DNS_TYPE_NSAP, L"NSAP"},
69 {DNS_TYPE_NSAPPTR, L"NSAPPTR"},
70 {DNS_TYPE_SIG, L"SIG"},
71 {DNS_TYPE_KEY, L"KEY"},
72 {DNS_TYPE_PX, L"PX"},
73 {DNS_TYPE_GPOS, L"GPOS"},
74 {DNS_TYPE_AAAA, L"AAAA"},
75 {DNS_TYPE_LOC, L"LOC"},
76 {DNS_TYPE_NXT, L"NXT"},
77 {DNS_TYPE_EID, L"EID"},
78 {DNS_TYPE_NIMLOC, L"NIMLOC"},
79 {DNS_TYPE_SRV, L"SRV"},
80 {DNS_TYPE_ATMA, L"ATMA"},
81 {DNS_TYPE_NAPTR, L"NAPTR"},
82 {DNS_TYPE_KX, L"KX"},
83 {DNS_TYPE_CERT, L"CERT"},
84 {DNS_TYPE_A6, L"A6"},
85 {DNS_TYPE_DNAME, L"DNAME"},
86 {DNS_TYPE_SINK, L"SINK"},
87 {DNS_TYPE_OPT, L"OPT"},
88 {DNS_TYPE_UINFO, L"UINFO"},
89 {DNS_TYPE_UID, L"UID"},
90 {DNS_TYPE_GID, L"GID"},
91 {DNS_TYPE_UNSPEC, L"UNSPEC"},
92 {DNS_TYPE_ADDRS, L"ADDRS"},
93 {DNS_TYPE_TKEY, L"TKEY"},
94 {DNS_TYPE_TSIG, L"TSIG"},
95 {DNS_TYPE_IXFR, L"IXFR"},
96 {DNS_TYPE_AXFR, L"AXFR"},
97 {DNS_TYPE_MAILB, L"MAILB"},
98 {DNS_TYPE_MAILA, L"MAILA"},
99 {DNS_TYPE_ALL, L"ALL"},
100 {0, NULL}
101};
102
103PCWSTR
105{
106 static WCHAR szType[8];
107 INT i;
108
109 for (i = 0; ; i++)
110 {
111 if (TypeArray[i].pszRecordName == NULL)
112 break;
113
114 if (TypeArray[i].wRecordType == wType)
115 return TypeArray[i].pszRecordName;
116 }
117
118 swprintf(szType, L"%hu", wType);
119
120 return szType;
121}
122
123/* print MAC address */
125{
126 static CHAR MacAddr[20];
127
128 sprintf(MacAddr, "%02X-%02X-%02X-%02X-%02X-%02X",
129 Mac[0], Mac[1], Mac[2], Mac[3], Mac[4], Mac[5]);
130
131 return MacAddr;
132}
133
134/* convert time_t to localized string */
136{
137 struct tm* ptm;
138 SYSTEMTIME SystemTime;
139 INT DateCchSize, TimeCchSize, TotalCchSize, i;
140 PWSTR DateTimeString, psz;
141
142 /* Convert Unix time to SYSTEMTIME */
143 /* localtime_s may be preferred if available */
144 ptm = localtime(&TimeStamp);
145 if (!ptm)
146 {
147 return NULL;
148 }
149 SystemTime.wYear = ptm->tm_year + 1900;
150 SystemTime.wMonth = ptm->tm_mon + 1;
151 SystemTime.wDay = ptm->tm_mday;
152 SystemTime.wHour = ptm->tm_hour;
153 SystemTime.wMinute = ptm->tm_min;
154 SystemTime.wSecond = ptm->tm_sec;
155
156 /* Get total size in characters required of buffer */
157 DateCchSize = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &SystemTime, NULL, NULL, 0);
158 if (!DateCchSize)
159 {
160 return NULL;
161 }
162 TimeCchSize = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &SystemTime, NULL, NULL, 0);
163 if (!TimeCchSize)
164 {
165 return NULL;
166 }
167 /* Two terminating null are included, the first one will be replaced by space */
168 TotalCchSize = DateCchSize + TimeCchSize;
169
170 /* Allocate buffer and format datetime string */
171 DateTimeString = (PWSTR)HeapAlloc(ProcessHeap, 0, TotalCchSize * sizeof(WCHAR));
172 if (!DateTimeString)
173 {
174 return NULL;
175 }
176
177 /* Get date string */
178 i = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &SystemTime, NULL, DateTimeString, TotalCchSize);
179 if (i)
180 {
181 /* Append space and move pointer */
182 DateTimeString[i - 1] = L' ';
183 psz = DateTimeString + i;
184 TotalCchSize -= i;
185
186 /* Get time string */
187 if (GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &SystemTime, NULL, psz, TotalCchSize))
188 {
189 return DateTimeString;
190 }
191 }
192
193 HeapFree(ProcessHeap, 0, DateTimeString);
194 return NULL;
195}
196
197VOID
200{
201 if (ErrorCode == 0)
203
206 NULL,
207 ErrorCode,
209}
210
211PWSTR
213 _In_ PSTR pszAnsiName)
214{
215 PWSTR pszUnicodeName;
216 size_t i, len;
217
218 len = strlen(pszAnsiName);
219 pszUnicodeName = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
220 if (pszUnicodeName == NULL)
221 return NULL;
222
223 for (i = 0; i < len; i++)
224 pszUnicodeName[i] = (WCHAR)pszAnsiName[i];
225 pszUnicodeName[i] = UNICODE_NULL;
226
227 return pszUnicodeName;
228}
229
230VOID
232 _In_ PSTR lpClass,
233 _In_ DWORD cchFriendlyNameLength,
234 _Out_ PWSTR pszFriendlyName)
235{
236 HKEY hKey = NULL;
237 CHAR Path[256];
238 PCSTR PrePath = "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
239 PCSTR PostPath = "\\Connection";
240 size_t PathSize;
241 DWORD dwType;
242 DWORD dwDataSize;
243
244 /* don't overflow the buffer */
245 PathSize = strlen(PrePath) + strlen(lpClass) + strlen(PostPath) + 1;
246 if (PathSize > _countof(Path))
247 return;
248
249 sprintf(Path, "%s%s%s", PrePath, lpClass, PostPath);
250
252 Path,
253 0,
254 KEY_READ,
255 &hKey) == ERROR_SUCCESS)
256 {
257 dwDataSize = cchFriendlyNameLength * sizeof(WCHAR);
259 L"Name",
260 NULL,
261 &dwType,
262 (PBYTE)pszFriendlyName,
263 &dwDataSize);
264 }
265
266 if (hKey != NULL)
268}
269
270VOID
272 _In_ PCWSTR lpDeviceName,
273 _In_ DWORD cchFriendlyNameLength,
274 _Out_ PWSTR pszFriendlyName)
275{
276 HKEY hKey = NULL;
277 WCHAR Path[256];
278 PCWSTR PrePath = L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
279 PCWSTR PostPath = L"\\Connection";
280 PCWSTR DevicePrefix = L"\\DEVICE\\TCPIP_";
281 size_t PathSize;
282 DWORD dwType;
283 DWORD dwDataSize;
284
285 size_t dwPrefixLength = wcslen(DevicePrefix);
286
287 /* don't overflow the buffer */
288 PathSize = wcslen(PrePath) + wcslen(lpDeviceName) - dwPrefixLength + wcslen(PostPath) + 1;
289 if (PathSize > _countof(Path))
290 return;
291
292 swprintf(Path, L"%s%s%s", PrePath, &lpDeviceName[dwPrefixLength], PostPath);
293
295 Path,
296 0,
297 KEY_READ,
298 &hKey) == ERROR_SUCCESS)
299 {
300 dwDataSize = cchFriendlyNameLength * sizeof(WCHAR);
302 L"Name",
303 NULL,
304 &dwType,
305 (PBYTE)pszFriendlyName,
306 &dwDataSize);
307 }
308
309 if (hKey != NULL)
311}
312
313static
314VOID
316{
317 HKEY hBaseKey = NULL;
319 PSTR lpKeyClass = NULL;
320 PSTR lpConDesc = NULL;
321 PWSTR lpPath = NULL;
322 WCHAR szPrePath[] = L"SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\";
323 DWORD dwType;
324 DWORD dwDataSize;
325 INT i;
326
328 szPrePath,
329 0,
330 KEY_READ,
331 &hBaseKey) != ERROR_SUCCESS)
332 {
333 return;
334 }
335
336 for (i = 0; ; i++)
337 {
338 size_t PathSize;
339 LONG Status;
340 WCHAR szName[10];
341 DWORD NameLen = 9;
342
343 if ((Status = RegEnumKeyExW(hBaseKey,
344 i,
345 szName,
346 &NameLen,
347 NULL,
348 NULL,
349 NULL,
350 NULL)) != ERROR_SUCCESS)
351 {
353 {
355 lpConDesc = NULL;
356 goto CLEANUP;
357 }
358 else
359 continue;
360 }
361
362 PathSize = wcslen(szPrePath) + wcslen(szName) + 1;
363 lpPath = (PWSTR)HeapAlloc(ProcessHeap,
364 0,
365 PathSize * sizeof(WCHAR));
366 if (lpPath == NULL)
367 goto CLEANUP;
368
369 swprintf(lpPath, L"%s%s", szPrePath, szName);
370
371 //MessageBox(NULL, lpPath, NULL, 0);
372
374 lpPath,
375 0,
376 KEY_READ,
378 {
379 goto CLEANUP;
380 }
381
382 HeapFree(ProcessHeap, 0, lpPath);
383 lpPath = NULL;
384
386 "NetCfgInstanceId",
387 NULL,
388 &dwType,
389 NULL,
390 &dwDataSize) == ERROR_SUCCESS)
391 {
392 lpKeyClass = (PSTR)HeapAlloc(ProcessHeap,
393 0,
394 dwDataSize);
395 if (lpKeyClass == NULL)
396 goto CLEANUP;
397
399 "NetCfgInstanceId",
400 NULL,
401 &dwType,
402 (PBYTE)lpKeyClass,
403 &dwDataSize) != ERROR_SUCCESS)
404 {
405 HeapFree(ProcessHeap, 0, lpKeyClass);
406 lpKeyClass = NULL;
407 continue;
408 }
409 }
410 else
411 continue;
412
413 if (!strcmp(lpClass, lpKeyClass))
414 {
415 HeapFree(ProcessHeap, 0, lpKeyClass);
416 lpKeyClass = NULL;
417
419 "DriverDesc",
420 NULL,
421 &dwType,
422 NULL,
423 &dwDataSize) == ERROR_SUCCESS)
424 {
425 lpConDesc = (PSTR)HeapAlloc(ProcessHeap,
426 0,
427 dwDataSize);
428 if (lpConDesc != NULL)
429 {
431 "DriverDesc",
432 NULL,
433 &dwType,
434 (PBYTE)lpConDesc,
435 &dwDataSize) == ERROR_SUCCESS)
436 {
437 printf("%s", lpConDesc);
438 }
439
440 HeapFree(ProcessHeap, 0, lpConDesc);
441 lpConDesc = NULL;
442 }
443 }
444
445 break;
446 }
447 }
448
449CLEANUP:
450 if (hBaseKey != NULL)
451 RegCloseKey(hBaseKey);
452 if (hClassKey != NULL)
454 if (lpPath != NULL)
455 HeapFree(ProcessHeap, 0, lpPath);
456 if (lpKeyClass != NULL)
457 HeapFree(ProcessHeap, 0, lpKeyClass);
458}
459
460static
461VOID
464{
465 switch (NodeType)
466 {
469 break;
470
473 break;
474
475 case MIXED_NODETYPE:
477 break;
478
479 case HYBRID_NODETYPE:
481 break;
482
483 default :
485 break;
486 }
487}
488
489static
490VOID
492 PIP_ADAPTER_INFO pAdapterInfo)
493{
494 WCHAR szFriendlyName[MAX_PATH];
495
496 GetAdapterFriendlyName(pAdapterInfo->AdapterName, MAX_PATH, szFriendlyName);
497
498 switch (pAdapterInfo->Type)
499 {
501 ConResPrintf(StdOut, IDS_OTHER, szFriendlyName);
502 break;
503
505 ConResPrintf(StdOut, IDS_ETH, szFriendlyName);
506 break;
507
509 ConResPrintf(StdOut, IDS_TOKEN, szFriendlyName);
510 break;
511
512 case MIB_IF_TYPE_FDDI:
513 ConResPrintf(StdOut, IDS_FDDI, szFriendlyName);
514 break;
515
516 case MIB_IF_TYPE_PPP:
517 ConResPrintf(StdOut, IDS_PPP, szFriendlyName);
518 break;
519
521 ConResPrintf(StdOut, IDS_LOOP, szFriendlyName);
522 break;
523
524 case MIB_IF_TYPE_SLIP:
525 ConResPrintf(StdOut, IDS_SLIP, szFriendlyName);
526 break;
527
529 ConResPrintf(StdOut, IDS_WIFI, szFriendlyName);
530 break;
531
532 default:
533 ConResPrintf(StdOut, IDS_UNKNOWNADAPTER, szFriendlyName);
534 break;
535 }
536}
537
538VOID
540 BOOL bShowHeader,
541 BOOL bAll)
542{
543 MIB_IFROW mibEntry;
544 PIP_ADAPTER_INFO pAdapterInfo = NULL;
545 PIP_ADAPTER_INFO pAdapter = NULL;
546 ULONG adaptOutBufLen = 0;
547 PFIXED_INFO pFixedInfo = NULL;
548 ULONG netOutBufLen = 0;
549 PIP_PER_ADAPTER_INFO pPerAdapterInfo = NULL;
550 ULONG ulPerAdapterInfoLength = 0;
551 PSTR pszDomainName = NULL;
552 DWORD dwDomainNameSize = 0;
553 ULONG ret = 0;
554
555 GetComputerNameExA(ComputerNameDnsDomain,
556 NULL,
557 &dwDomainNameSize);
558 if (dwDomainNameSize > 0)
559 {
560 pszDomainName = HeapAlloc(ProcessHeap,
561 0,
562 dwDomainNameSize * sizeof(CHAR));
563 if (pszDomainName != NULL)
564 GetComputerNameExA(ComputerNameDnsDomain,
565 pszDomainName,
566 &dwDomainNameSize);
567 }
568
569 /* call GetAdaptersInfo to obtain the adapter info */
570 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
572 {
573 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
574 if (pAdapterInfo == NULL)
575 goto done;
576
577 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
578 if (ret != NO_ERROR)
579 {
581 goto done;
582 }
583 }
584 else
585 {
586 if (ret != ERROR_NO_DATA)
587 {
589 goto done;
590 }
591 }
592
593 /* call GetNetworkParams to obtain the network info */
594 if (GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW)
595 {
596 pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
597 if (pFixedInfo == NULL)
598 {
599 goto done;
600 }
601 if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR)
602 {
604 goto done;
605 }
606 }
607 else
608 {
610 goto done;
611 }
612
613 pAdapter = pAdapterInfo;
614
615 if (bShowHeader)
617
618 if (bAll)
619 {
621 ConResPrintf(StdOut, IDS_PRIMARYDNSSUFFIX, (pszDomainName != NULL) ? pszDomainName : "");
622
623 PrintNodeType(pFixedInfo->NodeType);
624
625 if (pFixedInfo->EnableRouting)
627 else
629
630 if (pAdapter && pAdapter->HaveWins)
632 else
634
635 if (pszDomainName != NULL && pszDomainName[0] != 0)
636 {
637 ConResPrintf(StdOut, IDS_DNSSUFFIXLIST, pszDomainName);
639 }
640 else
641 {
643 }
644 }
645
646 while (pAdapter)
647 {
649
650 mibEntry.dwIndex = pAdapter->Index;
651 GetIfEntry(&mibEntry);
652
653 PrintAdapterTypeAndName(pAdapter);
654
655 if (GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength) == ERROR_BUFFER_OVERFLOW)
656 {
657 pPerAdapterInfo = (PIP_PER_ADAPTER_INFO)HeapAlloc(ProcessHeap, 0, ulPerAdapterInfoLength);
658 if (pPerAdapterInfo != NULL)
659 {
660 GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength);
661 }
662 }
663
664 /* check if the adapter is connected to the media */
666 {
669 }
670 else
671 {
673 }
674
675 if (bAll)
676 {
679 printf("\n");
680
682
683 if (bConnected)
684 {
685 if (pAdapter->DhcpEnabled)
686 {
688
689 if (pPerAdapterInfo != NULL)
690 {
691 if (pPerAdapterInfo->AutoconfigEnabled)
693 else
695 }
696 }
697 else
698 {
700 }
701 }
702 }
703
704 if (!bConnected)
705 {
706 pAdapter = pAdapter->Next;
707 continue;
708 }
709
712
713 if (strcmp(pAdapter->GatewayList.IpAddress.String, "0.0.0.0"))
715 else
717
718 if (bAll)
719 {
720 PIP_ADDR_STRING pIPAddr;
721
722 if (pAdapter->DhcpEnabled)
724
726 pIPAddr = pFixedInfo->DnsServerList.Next;
727 while (pIPAddr)
728 {
730 pIPAddr = pIPAddr->Next;
731 }
732
733 if (pAdapter->HaveWins)
734 {
737 }
738
739 if (pAdapter->DhcpEnabled && strcmp(pAdapter->DhcpServer.IpAddress.String, "255.255.255.255"))
740 {
741 PWSTR DateTimeString;
742 DateTimeString = timeToStr(pAdapter->LeaseObtained);
743 ConResPrintf(StdOut, IDS_LEASEOBTAINED, DateTimeString ? DateTimeString : L"N/A");
744 if (DateTimeString)
745 {
746 HeapFree(ProcessHeap, 0, DateTimeString);
747 }
748 DateTimeString = timeToStr(pAdapter->LeaseExpires);
749 ConResPrintf(StdOut, IDS_LEASEEXPIRES, DateTimeString ? DateTimeString : L"N/A");
750 if (DateTimeString)
751 {
752 HeapFree(ProcessHeap, 0, DateTimeString);
753 }
754 }
755 }
756
757 HeapFree(ProcessHeap, 0, pPerAdapterInfo);
758 pPerAdapterInfo = NULL;
759
760 pAdapter = pAdapter->Next;
761 }
762
763done:
764 if (pszDomainName)
765 HeapFree(ProcessHeap, 0, pszDomainName);
766 if (pFixedInfo)
767 HeapFree(ProcessHeap, 0, pFixedInfo);
768 if (pAdapterInfo)
769 HeapFree(ProcessHeap, 0, pAdapterInfo);
770}
771
772static
773BOOL
775 _In_ PWSTR pszExpression,
776 _In_ PWSTR pszName)
777{
778 WCHAR *pCharE, *pCharN, charE, charN;
779
780 if (pszExpression == NULL)
781 return TRUE;
782
783 if (pszName == NULL)
784 return FALSE;
785
786 pCharE = pszExpression;
787 pCharN = pszName;
788 while (*pCharE != UNICODE_NULL)
789 {
790 charE = towlower(*pCharE);
791 charN = towlower(*pCharN);
792
793 if (charE == L'*')
794 {
795 if (*(pCharE + 1) != charN)
796 pCharN++;
797 else
798 pCharE++;
799 }
800 else if (charE == L'?')
801 {
802 pCharE++;
803 pCharN++;
804 }
805 else if (charE == charN)
806 {
807 pCharE++;
808 pCharN++;
809 }
810 else
811 {
812 return FALSE;
813 }
814 }
815
816 return TRUE;
817}
818
819VOID
821 PWSTR pszAdapterName)
822{
823 PIP_ADAPTER_INFO pAdapterInfo = NULL;
824 PIP_ADAPTER_INFO pAdapter = NULL;
825 ULONG adaptOutBufLen = 0;
826 ULONG ret = 0;
827 WCHAR szFriendlyName[MAX_PATH];
828 WCHAR szUnicodeAdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
829 MIB_IFROW mibEntry;
832
834
835 /* call GetAdaptersInfo to obtain the adapter info */
836 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
838 {
840 return;
841 }
842
843 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
844 if (pAdapterInfo == NULL)
845 {
847 return;
848 }
849
850 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
851 if (ret != NO_ERROR)
852 {
854 goto done;
855 }
856
858
859 pAdapter = pAdapterInfo;
860
861 while (pAdapter)
862 {
863 GetAdapterFriendlyName(pAdapter->AdapterName, MAX_PATH, szFriendlyName);
864
865 if ((pszAdapterName == NULL) || MatchWildcard(pszAdapterName, szFriendlyName))
866 {
868
869 mibEntry.dwIndex = pAdapter->Index;
870 GetIfEntry(&mibEntry);
871
874 {
875 if (pAdapter->DhcpEnabled)
876 {
877 if (strcmp(pAdapter->IpAddressList.IpAddress.String, "0.0.0.0"))
878 {
879 mbstowcs(szUnicodeAdapterName, pAdapter->AdapterName, strlen(pAdapter->AdapterName) + 1);
880
881 /* Call DhcpReleaseParameters to release the IP address on the specified adapter. */
882 ret = DhcpReleaseParameters(szUnicodeAdapterName);
883 if (ret != NO_ERROR)
884 {
885 ConResPrintf(StdOut, IDS_DHCPRELEASEERROR, szFriendlyName);
887 }
888 }
889 else
890 {
892 }
893 }
894 else
895 {
896 ConResPrintf(StdOut, IDS_DHCPNOTENABLED, szFriendlyName);
897 }
898 }
899 else
900 {
901 ConResPrintf(StdOut, IDS_DHCPNOTCONNECTED, szFriendlyName);
902 }
903 }
904
905 pAdapter = pAdapter->Next;
906 }
907
909
910 if (bFoundAdapter == FALSE)
911 {
913 }
914 else
915 {
917 }
918
919done:
920 if (pAdapterInfo)
921 HeapFree(ProcessHeap, 0, pAdapterInfo);
922}
923
924VOID
926 PWSTR pszAdapterName)
927{
928 PIP_ADAPTER_INFO pAdapterInfo = NULL;
929 PIP_ADAPTER_INFO pAdapter = NULL;
930 ULONG adaptOutBufLen = 0;
931 ULONG ret = 0;
932 WCHAR szFriendlyName[MAX_PATH];
933 WCHAR szUnicodeAdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
934 MIB_IFROW mibEntry;
937
939
940 /* call GetAdaptersInfo to obtain the adapter info */
941 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
943 {
945 return;
946 }
947
948 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
949 if (pAdapterInfo == NULL)
950 {
952 return;
953 }
954
955 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
956 if (ret != NO_ERROR)
957 {
959 goto done;
960 }
961
963
964 pAdapter = pAdapterInfo;
965
966 while (pAdapter)
967 {
968 GetAdapterFriendlyName(pAdapter->AdapterName, MAX_PATH, szFriendlyName);
969
970 if ((pszAdapterName == NULL) || MatchWildcard(pszAdapterName, szFriendlyName))
971 {
973
974 mibEntry.dwIndex = pAdapter->Index;
975 GetIfEntry(&mibEntry);
976
979 {
980 if (pAdapter->DhcpEnabled)
981 {
982 mbstowcs(szUnicodeAdapterName, pAdapter->AdapterName, strlen(pAdapter->AdapterName) + 1);
983
984 /* Call DhcpAcquireParameters to renew the IP address on the specified adapter. */
985 ret = DhcpAcquireParameters(szUnicodeAdapterName);
986 if (ret != NO_ERROR)
987 {
988 ConResPrintf(StdOut, IDS_DHCPRENEWERROR, szFriendlyName);
990 }
991 }
992 else
993 {
994 ConResPrintf(StdOut, IDS_DHCPNOTENABLED, szFriendlyName);
995 }
996 }
997 else
998 {
999 ConResPrintf(StdOut, IDS_DHCPNOTCONNECTED, szFriendlyName);
1000 }
1001 }
1002
1003 pAdapter = pAdapter->Next;
1004 }
1005
1007
1008 if (bFoundAdapter == FALSE)
1009 {
1011 }
1012 else
1013 {
1015 }
1016
1017done:
1018 if (pAdapterInfo)
1019 HeapFree(ProcessHeap, 0, pAdapterInfo);
1020}
1021
1022VOID
1024{
1026
1028 {
1030 }
1031 else
1032 {
1035 }
1036}
1037
1038VOID
1040{
1041 /* FIXME */
1042 printf("\nSorry /registerdns is not implemented yet\n");
1043}
1044
1045static
1046VOID
1048 PWSTR pszName,
1049 WORD wType)
1050{
1051 PDNS_RECORDW pQueryResults = NULL, pThisRecord, pNextRecord;
1052 WCHAR szBuffer[48];
1053 IN_ADDR Addr4;
1054 IN6_ADDR Addr6;
1056
1057 ConResPrintf(StdOut, IDS_DNSNAME, pszName);
1059
1060 pQueryResults = NULL;
1061 Status = DnsQuery_W(pszName,
1062 wType,
1064 NULL,
1065 (PDNS_RECORD *)&pQueryResults,
1066 NULL);
1067 if (Status != ERROR_SUCCESS)
1068 {
1070 {
1072 }
1073 else if (Status == DNS_INFO_NO_RECORDS)
1074 {
1076 }
1077 return;
1078 }
1079
1080 pThisRecord = pQueryResults;
1081 while (pThisRecord != NULL)
1082 {
1083 pNextRecord = pThisRecord->pNext;
1084
1085 ConResPrintf(StdOut, IDS_DNSRECORDNAME, pThisRecord->pName);
1086 ConResPrintf(StdOut, IDS_DNSRECORDTYPE, pThisRecord->wType);
1087 ConResPrintf(StdOut, IDS_DNSRECORDTTL, pThisRecord->dwTtl);
1088 ConResPrintf(StdOut, IDS_DNSRECORDLENGTH, pThisRecord->wDataLength);
1089
1090 switch (pThisRecord->Flags.S.Section)
1091 {
1092 case DnsSectionQuestion:
1094 break;
1095
1096 case DnsSectionAnswer:
1098 break;
1099
1102 break;
1103
1106 break;
1107 }
1108
1109 switch (pThisRecord->wType)
1110 {
1111 case DNS_TYPE_A:
1112 Addr4.S_un.S_addr = pThisRecord->Data.A.IpAddress;
1113 RtlIpv4AddressToStringW(&Addr4, szBuffer);
1114 ConResPrintf(StdOut, IDS_DNSTYPEA, szBuffer);
1115 break;
1116
1117 case DNS_TYPE_NS:
1118 ConResPrintf(StdOut, IDS_DNSTYPENS, pThisRecord->Data.NS.pNameHost);
1119 break;
1120
1121 case DNS_TYPE_CNAME:
1122 ConResPrintf(StdOut, IDS_DNSTYPECNAME, pThisRecord->Data.CNAME.pNameHost);
1123 break;
1124
1125 case DNS_TYPE_SOA:
1127 pThisRecord->Data.SOA.pNamePrimaryServer,
1128 pThisRecord->Data.SOA.pNameAdministrator,
1129 pThisRecord->Data.SOA.dwSerialNo);
1131 pThisRecord->Data.SOA.dwRefresh,
1132 pThisRecord->Data.SOA.dwRetry,
1133 pThisRecord->Data.SOA.dwExpire,
1134 pThisRecord->Data.SOA.dwDefaultTtl);
1135 break;
1136
1137 case DNS_TYPE_PTR:
1138 ConResPrintf(StdOut, IDS_DNSTYPEPTR, pThisRecord->Data.PTR.pNameHost);
1139 break;
1140
1141 case DNS_TYPE_MX:
1143 pThisRecord->Data.MX.pNameExchange,
1144 pThisRecord->Data.MX.wPreference,
1145 pThisRecord->Data.MX.Pad);
1146 break;
1147
1148 case DNS_TYPE_AAAA:
1149 RtlCopyMemory(&Addr6, &pThisRecord->Data.AAAA.Ip6Address, sizeof(Addr6));
1150 RtlIpv6AddressToStringW(&Addr6, szBuffer);
1152 break;
1153
1154 case DNS_TYPE_ATMA:
1156 break;
1157
1158 case DNS_TYPE_SRV:
1160 pThisRecord->Data.SRV.pNameTarget,
1161 pThisRecord->Data.SRV.wPriority,
1162 pThisRecord->Data.SRV.wWeight,
1163 pThisRecord->Data.SRV.wPort);
1164 break;
1165 }
1166 ConPuts(StdOut, L"\n\n");
1167
1168 pThisRecord = pNextRecord;
1169 }
1170
1172}
1173
1174VOID
1176{
1177 PDNS_CACHE_ENTRY DnsEntry = NULL, pThisEntry, pNextEntry;
1178
1180
1181 if (!DnsGetCacheDataTable(&DnsEntry))
1182 {
1184 return;
1185 }
1186
1187 if (DnsEntry == NULL)
1188 return;
1189
1190 pThisEntry = DnsEntry;
1191 while (pThisEntry != NULL)
1192 {
1193 pNextEntry = pThisEntry->pNext;
1194
1195 if (pThisEntry->wType1 != DNS_TYPE_ZERO)
1196 DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType1);
1197
1198 if (pThisEntry->wType2 != DNS_TYPE_ZERO)
1199 DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType2);
1200
1201 if (pThisEntry->pszName)
1202 LocalFree(pThisEntry->pszName);
1203 LocalFree(pThisEntry);
1204
1205 pThisEntry = pNextEntry;
1206 }
1207}
1208
1209VOID
1211 PWSTR pszAdapterName)
1212{
1213 printf("\nSorry /showclassid adapter is not implemented yet\n");
1214}
1215
1216VOID
1218 PWSTR pszAdapterName,
1219 PWSTR pszClassId)
1220{
1221 PIP_ADAPTER_INFO pAdapterInfo = NULL;
1222 PIP_ADAPTER_INFO pAdapter = NULL, pFoundAdapter = NULL;
1223 ULONG adaptOutBufLen = 0;
1224 ULONG ret = 0;
1225 WCHAR szFriendlyName[MAX_PATH];
1226 WCHAR szKeyName[256];
1227 WCHAR szUnicodeAdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
1228 MIB_IFROW mibEntry;
1229 HKEY hKey;
1230 DHCP_PNP_EVENT PnpEvent;
1231
1233
1234 /* call GetAdaptersInfo to obtain the adapter info */
1235 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
1237 {
1239 return;
1240 }
1241
1242 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
1243 if (pAdapterInfo == NULL)
1244 {
1246 return;
1247 }
1248
1249 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
1250 if (ret != NO_ERROR)
1251 {
1252 DoFormatMessage(0);
1253 goto done;
1254 }
1255
1256 pAdapter = pAdapterInfo;
1257 while (pAdapter)
1258 {
1259 GetAdapterFriendlyName(pAdapter->AdapterName, MAX_PATH, szFriendlyName);
1260
1261 if (MatchWildcard(pszAdapterName, szFriendlyName))
1262 {
1263 mibEntry.dwIndex = pAdapter->Index;
1264 GetIfEntry(&mibEntry);
1265
1268 {
1269 pFoundAdapter = pAdapter;
1270 break;
1271 }
1272 }
1273
1274 pAdapter = pAdapter->Next;
1275 }
1276
1277 if (pFoundAdapter)
1278 {
1279 swprintf(szKeyName,
1280 L"System\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%S",
1281 pFoundAdapter->AdapterName);
1282
1284 szKeyName,
1285 0,
1286 KEY_WRITE,
1287 &hKey);
1288 if (ret != ERROR_SUCCESS)
1289 {
1290 ConResPrintf(StdOut, IDS_DHCPSETIDERROR, szFriendlyName);
1292 goto done;
1293 }
1294
1295 if (pszClassId == NULL)
1296 pszClassId = L"";
1297
1299 L"DhcpClassId",
1300 0, REG_SZ,
1301 (PBYTE)pszClassId,
1302 (DWORD)((wcslen(pszClassId) + 1) * sizeof(WCHAR)));
1304 if (ret != ERROR_SUCCESS)
1305 {
1306 ConResPrintf(StdOut, IDS_DHCPSETIDERROR, szFriendlyName);
1308 goto done;
1309 }
1310
1311 mbstowcs(szUnicodeAdapterName, pFoundAdapter->AdapterName, strlen(pFoundAdapter->AdapterName) + 1);
1312
1313 ZeroMemory(&PnpEvent, sizeof(PnpEvent));
1314 PnpEvent.Unknown5 = 1;
1315
1317 1,
1318 szUnicodeAdapterName,
1319 &PnpEvent,
1320 0);
1321 if (ret != ERROR_SUCCESS)
1322 {
1323 ConResPrintf(StdOut, IDS_DHCPSETIDERROR, szFriendlyName);
1325 goto done;
1326 }
1327
1328 ConResPrintf(StdOut, IDS_DHCPSETIDSUCCESS, szFriendlyName);
1329 }
1330 else
1331 {
1333 }
1334
1335done:
1336 if (pAdapterInfo)
1337 HeapFree(ProcessHeap, 0, pAdapterInfo);
1338}
1339
1340VOID
1342 _In_ BOOL Error)
1343{
1344 if (Error)
1347}
1348
1349int wmain(int argc, wchar_t *argv[])
1350{
1351 BOOL DoUsage=FALSE;
1352 BOOL DoAll=FALSE;
1353 BOOL DoRelease=FALSE;
1354 BOOL DoRenew=FALSE;
1355 BOOL DoFlushdns=FALSE;
1356 BOOL DoRegisterdns=FALSE;
1357 BOOL DoDisplaydns=FALSE;
1358 BOOL DoShowclassid=FALSE;
1359 BOOL DoSetclassid=FALSE;
1360
1361 /* Initialize the Console Standard Streams */
1363
1366
1367 /* Parse command line for options we have been given. */
1368 if ((argc > 1) && (argv[1][0] == L'/' || argv[1][0] == L'-'))
1369 {
1370 if (!_wcsicmp(&argv[1][1], L"?"))
1371 {
1372 DoUsage = TRUE;
1373 }
1374 else if (!_wcsnicmp(&argv[1][1], L"ALL", wcslen(&argv[1][1])))
1375 {
1376 DoAll = TRUE;
1377 }
1378 else if (!_wcsnicmp(&argv[1][1], L"RELEASE", wcslen(&argv[1][1])))
1379 {
1380 DoRelease = TRUE;
1381 }
1382 else if (!_wcsnicmp(&argv[1][1], L"RENEW", wcslen(&argv[1][1])))
1383 {
1384 DoRenew = TRUE;
1385 }
1386 else if (!_wcsnicmp(&argv[1][1], L"FLUSHDNS", wcslen(&argv[1][1])))
1387 {
1388 DoFlushdns = TRUE;
1389 }
1390 else if (!_wcsnicmp(&argv[1][1], L"FLUSHREGISTERDNS", wcslen(&argv[1][1])))
1391 {
1392 DoRegisterdns = TRUE;
1393 }
1394 else if (!_wcsnicmp(&argv[1][1], L"DISPLAYDNS", wcslen(&argv[1][1])))
1395 {
1396 DoDisplaydns = TRUE;
1397 }
1398 else if (!_wcsnicmp(&argv[1][1], L"SHOWCLASSID", wcslen(&argv[1][1])))
1399 {
1400 DoShowclassid = TRUE;
1401 }
1402 else if (!_wcsnicmp(&argv[1][1], L"SETCLASSID", wcslen(&argv[1][1])))
1403 {
1404 DoSetclassid = TRUE;
1405 }
1406 }
1407
1408 switch (argc)
1409 {
1410 case 1: /* Default behaviour if no options are given*/
1412 break;
1413 case 2: /* Process all the options that take no parameters */
1414 if (DoUsage)
1415 Usage(FALSE);
1416 else if (DoAll)
1417 ShowInfo(TRUE, TRUE);
1418 else if (DoRelease)
1419 Release(NULL);
1420 else if (DoRenew)
1421 Renew(NULL);
1422 else if (DoFlushdns)
1423 FlushDns();
1424 else if (DoRegisterdns)
1425 RegisterDns();
1426 else if (DoDisplaydns)
1427 DisplayDns();
1428 else
1429 Usage(TRUE);
1430 break;
1431 case 3: /* Process all the options that can have 1 parameter */
1432 if (DoRelease)
1433 Release(argv[2]);
1434 else if (DoRenew)
1435 Renew(argv[2]);
1436 else if (DoShowclassid)
1437 ShowClassId(argv[2]);
1438 else if (DoSetclassid)
1439 SetClassId(argv[2], NULL);
1440 else
1441 Usage(TRUE);
1442 break;
1443 case 4: /* Process all the options that can have 2 parameters */
1444 if (DoSetclassid)
1445 SetClassId(argv[2], argv[3]);
1446 else
1447 Usage(TRUE);
1448 break;
1449 default:
1450 Usage(TRUE);
1451 }
1452
1453 return 0;
1454}
NodeType
Definition: Node.h:6
PRTL_UNICODE_STRING_BUFFER Path
unsigned char BOOLEAN
Definition: actypes.h:127
#define IDS_USAGE
Definition: resource.h:3
#define IDS_DESCRIPTION
Definition: resource.h:4
#define IDS_DNSSECTIONAUTHORITY
Definition: resource.h:55
#define IDS_DHCPRELEASED
Definition: resource.h:78
#define IDS_IPROUTINGNO
Definition: resource.h:11
#define IDS_CMDLINEERROR
Definition: resource.h:69
#define IDS_DEFAULTGATEWAY
Definition: resource.h:28
#define IDS_DNSRECORDTYPE
Definition: resource.h:50
#define IDS_CONNECTIONDNSSUFFIX
Definition: resource.h:19
#define IDS_UNKNOWNADAPTER
Definition: resource.h:17
#define IDS_DNSSECTIONANSWER
Definition: resource.h:54
#define IDS_WINSPROXYYES
Definition: resource.h:14
#define IDS_DHCPSETIDSUCCESS
Definition: resource.h:82
#define IDS_IPADDRESS
Definition: resource.h:26
#define IDS_DNSTYPESOA2
Definition: resource.h:61
#define IDS_DNSTYPESRV
Definition: resource.h:66
#define IDS_DNSSERVERS
Definition: resource.h:30
#define IDS_LOOP
Definition: resource.h:43
#define IDS_DNSTYPEAAAA
Definition: resource.h:64
#define IDS_DNSRECORDTTL
Definition: resource.h:51
#define IDS_FDDI
Definition: resource.h:41
#define IDS_HOSTNAME
Definition: resource.h:4
#define IDS_SUBNETMASK
Definition: resource.h:27
#define IDS_DHCPNOTENABLED
Definition: resource.h:76
#define IDS_WINSPROXYNO
Definition: resource.h:13
#define IDS_DNSTYPECNAME
Definition: resource.h:59
#define IDS_NODETYPEP2P
Definition: resource.h:7
#define IDS_LEASEEXPIRES
Definition: resource.h:34
#define IDS_DNSNORECORD
Definition: resource.h:71
#define IDS_PRIMARYWINSSERVER
Definition: resource.h:31
#define IDS_NODETYPEBCAST
Definition: resource.h:6
#define IDS_DHCPSETIDERROR
Definition: resource.h:81
#define IDS_DNSSUFFIXLIST
Definition: resource.h:15
#define IDS_OTHER
Definition: resource.h:38
#define IDS_DNSRECORDLENGTH
Definition: resource.h:52
#define IDS_DHCPNO
Definition: resource.h:22
#define IDS_DNSSECTIONADDITIONAL
Definition: resource.h:56
#define IDS_DNSSECTIONQUESTION
Definition: resource.h:53
#define IDS_LEASEOBTAINED
Definition: resource.h:33
#define IDS_DNSNAME
Definition: resource.h:47
#define IDS_WIFI
Definition: resource.h:45
#define IDS_SECONDARYWINSSERVER
Definition: resource.h:32
#define IDS_DNSRECORDNAME
Definition: resource.h:49
#define IDS_DNSLINE
Definition: resource.h:48
#define IDS_TOKEN
Definition: resource.h:40
#define IDS_ETH
Definition: resource.h:39
#define IDS_DHCPNOADAPTER
Definition: resource.h:77
#define IDS_DNSTYPEA
Definition: resource.h:57
#define IDS_AUTOCONFIGNO
Definition: resource.h:24
#define IDS_DNSTYPENS
Definition: resource.h:58
#define IDS_PHYSICALADDRESS
Definition: resource.h:21
#define IDS_AUTOCONFIGYES
Definition: resource.h:25
#define IDS_DHCPRENEWERROR
Definition: resource.h:80
#define IDS_DNSFLUSHERROR
Definition: resource.h:73
#define IDS_MEDIADISCONNECTED
Definition: resource.h:18
#define IDS_DNSTYPEPTR
Definition: resource.h:62
#define IDS_NODETYPEUNKNOWN
Definition: resource.h:10
#define IDS_DNSTYPEATMA
Definition: resource.h:65
#define IDS_DHCPSERVER
Definition: resource.h:29
#define IDS_DHCPYES
Definition: resource.h:23
#define IDS_PPP
Definition: resource.h:42
#define IDS_IPROUTINGYES
Definition: resource.h:12
#define IDS_PRIMARYDNSSUFFIX
Definition: resource.h:5
#define IDS_SLIP
Definition: resource.h:44
#define IDS_HEADER
Definition: resource.h:3
#define IDS_NODETYPEMIXED
Definition: resource.h:8
#define IDS_DNSFLUSHSUCCESS
Definition: resource.h:74
#define IDS_DNSTYPEMX
Definition: resource.h:63
#define IDS_DHCPNOTCONNECTED
Definition: resource.h:75
#define IDS_DNSNONAME
Definition: resource.h:72
#define IDS_EMPTYLINE
Definition: resource.h:16
#define IDS_DNSTYPESOA1
Definition: resource.h:60
#define IDS_DHCPRELEASEERROR
Definition: resource.h:79
#define IDS_NODETYPEHYBRID
Definition: resource.h:9
HKEY hClassKey
Definition: umpnpmgr.c:45
BOOL Error
Definition: chkdsk.c:66
#define RegCloseKey(hKey)
Definition: registry.h:49
_In_ BOOLEAN Release
Definition: cdrom.h:920
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: conutils_noros.h:8
#define ConInitStdStreams()
Definition: conutils_noros.h:5
#define StdOut
Definition: conutils_noros.h:6
void ConResPrintf(FILE *fp, UINT nID,...)
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_SUCCESS
Definition: deptool.c:10
static BOOL bFoundAdapter
Definition: deskmon.c:13
DWORD APIENTRY DhcpCApiInitialize(_Out_ LPDWORD Version)
Definition: dhcpcsvc.c:213
DWORD APIENTRY DhcpHandlePnPEvent(_In_ DWORD Unknown1, _In_ DWORD Unknown2, _In_ PWSTR AdapterName, _In_ PDHCP_PNP_EVENT PnpEvent, _In_ DWORD Unknown5)
Definition: dhcpcsvc.c:383
DWORD APIENTRY DhcpReleaseParameters(_In_ PWSTR AdapterName)
Definition: dhcpcsvc.c:578
DWORD APIENTRY DhcpAcquireParameters(_In_ PWSTR AdapterName)
Definition: dhcpcsvc.c:243
VOID APIENTRY DhcpCApiCleanup(VOID)
Definition: dhcpcsvc.c:227
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI DnsFlushResolverCache(VOID)
Definition: query.c:933
DNS_STATUS WINAPI DnsQuery_W(LPCWSTR Name, WORD Type, DWORD Options, PVOID Extra, PDNS_RECORD *QueryResultSet, PVOID *Reserved)
Definition: query.c:469
BOOL WINAPI DnsGetCacheDataTable(_Out_ PDNS_CACHE_ENTRY *DnsCache)
Definition: query.c:1055
VOID WINAPI DnsRecordListFree(PDNS_RECORD list, DNS_FREE_TYPE type)
Definition: record.c:526
MonoAssembly int argc
Definition: metahost.c:107
__time32_t time_t
Definition: corecrt.h:228
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:195
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
static struct tm * localtime(const time_t *t)
Definition: time.h:121
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
BOOL bConnected
Definition: fdebug.c:27
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:103
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
GLenum GLsizei len
Definition: glext.h:6722
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
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
VOID RegisterDns(VOID)
Definition: ipconfig.c:1039
PCSTR PrintMacAddr(PBYTE Mac)
Definition: ipconfig.c:124
VOID ShowInfo(BOOL bShowHeader, BOOL bAll)
Definition: ipconfig.c:539
VOID FlushDns(VOID)
Definition: ipconfig.c:1023
VOID GetInterfaceFriendlyName(_In_ PCWSTR lpDeviceName, _In_ DWORD cchFriendlyNameLength, _Out_ PWSTR pszFriendlyName)
Definition: ipconfig.c:271
RECORDTYPE TypeArray[]
Definition: ipconfig.c:44
_Ret_opt_z_ PWSTR timeToStr(_In_ time_t TimeStamp)
Definition: ipconfig.c:135
VOID Renew(PWSTR pszAdapterName)
Definition: ipconfig.c:925
VOID DoFormatMessage(_In_ LONG ErrorCode)
Definition: ipconfig.c:198
HANDLE ProcessHeap
Definition: ipconfig.c:42
VOID ShowClassId(PWSTR pszAdapterName)
Definition: ipconfig.c:1210
struct _RECORDTYPE * PRECORDTYPE
PWSTR GetUnicodeAdapterName(_In_ PSTR pszAnsiName)
Definition: ipconfig.c:212
struct _RECORDTYPE RECORDTYPE
HINSTANCE hInstance
Definition: ipconfig.c:41
static VOID PrintAdapterDescription(PSTR lpClass)
Definition: ipconfig.c:315
VOID SetClassId(PWSTR pszAdapterName, PWSTR pszClassId)
Definition: ipconfig.c:1217
static VOID PrintNodeType(_In_ UINT NodeType)
Definition: ipconfig.c:462
VOID GetAdapterFriendlyName(_In_ PSTR lpClass, _In_ DWORD cchFriendlyNameLength, _Out_ PWSTR pszFriendlyName)
Definition: ipconfig.c:231
VOID DisplayDns(VOID)
Definition: ipconfig.c:1175
static VOID PrintAdapterTypeAndName(PIP_ADAPTER_INFO pAdapterInfo)
Definition: ipconfig.c:491
PCWSTR GetRecordTypeName(WORD wType)
Definition: ipconfig.c:104
static BOOL MatchWildcard(_In_ PWSTR pszExpression, _In_ PWSTR pszName)
Definition: ipconfig.c:774
static VOID DisplayDnsRecord(PWSTR pszName, WORD wType)
Definition: ipconfig.c:1047
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD)
Definition: compname.c:376
#define MIB_IF_TYPE_ETHERNET
Definition: ipifcons.h:223
#define MIB_IF_TYPE_LOOPBACK
Definition: ipifcons.h:227
#define MIB_IF_TYPE_SLIP
Definition: ipifcons.h:228
#define MIB_IF_TYPE_OTHER
Definition: ipifcons.h:222
#define IF_TYPE_IEEE80211
Definition: ipifcons.h:91
#define MIB_IF_OPER_STATUS_CONNECTED
Definition: ipifcons.h:250
#define MIB_IF_TYPE_TOKENRING
Definition: ipifcons.h:224
#define MIB_IF_TYPE_FDDI
Definition: ipifcons.h:225
#define MIB_IF_OPER_STATUS_OPERATIONAL
Definition: ipifcons.h:251
#define MIB_IF_TYPE_PPP
Definition: ipifcons.h:226
#define REG_SZ
Definition: layer.c:22
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1101
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:1001
#define ZeroMemory
Definition: minwinbase.h:31
#define sprintf
Definition: sprintf.c:45
#define argv
Definition: mplay32.c:18
#define _Ret_opt_z_
Definition: ms_sal.h:1220
unsigned int UINT
Definition: ndis.h:50
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
NTSYSAPI PWSTR NTAPI RtlIpv4AddressToStringW(_In_ const struct in_addr *Addr, _Out_writes_(16) PWCHAR S)
NTSYSAPI PWSTR NTAPI RtlIpv6AddressToStringW(_In_ const struct in6_addr *Addr, _Out_writes_(46) PWSTR S)
_In_ DWORD dwVersion
Definition: netsh.h:85
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define KEY_READ
Definition: nt_native.h:1026
#define KEY_WRITE
Definition: nt_native.h:1034
#define LOCALE_USER_DEFAULT
#define UNICODE_NULL
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:835
BYTE * PBYTE
Definition: pedump.c:66
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
char CHAR
Definition: pedump.c:57
static const WCHAR szName[]
Definition: powrprof.c:45
#define MAX_ADAPTER_NAME_LENGTH
Definition: iptypes.h:16
IP_PER_ADAPTER_INFO_W2KSP1 * PIP_PER_ADAPTER_INFO
Definition: iptypes.h:70
#define MIXED_NODETYPE
Definition: iptypes.h:27
#define HYBRID_NODETYPE
Definition: iptypes.h:28
#define PEER_TO_PEER_NODETYPE
Definition: iptypes.h:26
#define BROADCAST_NODETYPE
Definition: iptypes.h:25
#define DNS_TYPE_TKEY
Definition: windns.h:87
#define DNS_TYPE_NSAPPTR
Definition: windns.h:63
#define DNS_TYPE_NSAP
Definition: windns.h:62
#define DNS_TYPE_MINFO
Definition: windns.h:54
#define DNS_TYPE_UNSPEC
Definition: windns.h:85
#define DNS_TYPE_MAILA
Definition: windns.h:92
#define DNS_TYPE_HINFO
Definition: windns.h:53
#define DNS_TYPE_EID
Definition: windns.h:71
#define DNS_TYPE_RT
Definition: windns.h:61
#define DNS_TYPE_GID
Definition: windns.h:84
#define DNS_TYPE_MX
Definition: windns.h:55
#define DNS_TYPE_ATMA
Definition: windns.h:74
#define DNS_TYPE_LOC
Definition: windns.h:69
#define DNS_TYPE_WKS
Definition: windns.h:51
@ DnsSectionAdditional
Definition: windns.h:156
@ DnsSectionAnswer
Definition: windns.h:154
@ DnsSectionQuestion
Definition: windns.h:153
@ DnsSectionAuthority
Definition: windns.h:155
#define DNS_TYPE_SIG
Definition: windns.h:64
#define DNS_TYPE_ALL
Definition: windns.h:93
@ DnsFreeRecordList
Definition: windns.h:139
#define DNS_TYPE_ISDN
Definition: windns.h:60
#define DNS_TYPE_TEXT
Definition: windns.h:56
#define DNS_TYPE_PTR
Definition: windns.h:52
#define DNS_TYPE_MB
Definition: windns.h:47
#define DNS_TYPE_X25
Definition: windns.h:59
#define DNS_TYPE_MG
Definition: windns.h:48
#define DNS_TYPE_KEY
Definition: windns.h:65
#define DNS_TYPE_SINK
Definition: windns.h:80
#define DNS_TYPE_CNAME
Definition: windns.h:45
#define DNS_TYPE_OPT
Definition: windns.h:81
#define DNS_TYPE_UINFO
Definition: windns.h:82
#define DNS_TYPE_NS
Definition: windns.h:42
#define DNS_TYPE_SOA
Definition: windns.h:46
#define DNS_TYPE_PX
Definition: windns.h:66
#define DNS_TYPE_ZERO
Definition: windns.h:40
#define DNS_TYPE_MD
Definition: windns.h:43
#define DNS_TYPE_KX
Definition: windns.h:76
#define DNS_TYPE_MF
Definition: windns.h:44
#define DNS_TYPE_AFSDB
Definition: windns.h:58
#define DNS_TYPE_CERT
Definition: windns.h:77
#define DNS_TYPE_MAILB
Definition: windns.h:91
#define DNS_TYPE_DNAME
Definition: windns.h:79
#define DNS_TYPE_UID
Definition: windns.h:83
#define DNS_TYPE_ADDRS
Definition: windns.h:86
#define DNS_QUERY_NO_WIRE_QUERY
Definition: windns.h:13
#define DNS_TYPE_SRV
Definition: windns.h:73
#define DNS_TYPE_NAPTR
Definition: windns.h:75
#define DNS_TYPE_AAAA
Definition: windns.h:68
#define DNS_TYPE_NULL
Definition: windns.h:50
#define DNS_TYPE_TSIG
Definition: windns.h:88
#define DNS_TYPE_RP
Definition: windns.h:57
#define DNS_TYPE_A6
Definition: windns.h:78
#define DNS_TYPE_IXFR
Definition: windns.h:89
#define DNS_TYPE_MR
Definition: windns.h:49
#define DNS_TYPE_NXT
Definition: windns.h:70
#define DNS_TYPE_NIMLOC
Definition: windns.h:72
#define DNS_TYPE_GPOS
Definition: windns.h:67
#define DNS_TYPE_AXFR
Definition: windns.h:90
#define DNS_TYPE_A
Definition: windns.h:41
int wmain()
mbstowcs
Definition: stdlib.h:925
#define towlower(c)
Definition: wctype.h:97
#define _countof(array)
Definition: sndvol32.h:70
char DomainName[MAX_DOMAIN_NAME_LEN+4]
Definition: iptypes.h:75
char HostName[MAX_HOSTNAME_LEN+4]
Definition: iptypes.h:74
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:77
UINT EnableRouting
Definition: iptypes.h:80
char String[4 *4]
Definition: iptypes.h:31
DWORD Unknown5
Definition: dhcpcapi.h:14
Definition: windns_undoc.h:9
struct _DNS_CACHE_ENTRY * pNext
Definition: windns_undoc.h:10
struct _DnsRecordW * pNext
Definition: windns.h:598
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]
Definition: iptypes.h:47
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:42
IP_ADDR_STRING SecondaryWinsServer
Definition: iptypes.h:57
IP_ADDR_STRING IpAddressList
Definition: iptypes.h:52
char AdapterName[MAX_ADAPTER_NAME_LENGTH+4]
Definition: iptypes.h:44
IP_ADDR_STRING DhcpServer
Definition: iptypes.h:54
time_t LeaseObtained
Definition: iptypes.h:58
IP_ADDR_STRING GatewayList
Definition: iptypes.h:53
time_t LeaseExpires
Definition: iptypes.h:59
IP_ADDR_STRING PrimaryWinsServer
Definition: iptypes.h:56
UINT DhcpEnabled
Definition: iptypes.h:50
struct _IP_ADDR_STRING * Next
Definition: iptypes.h:35
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:36
IP_MASK_STRING IpMask
Definition: iptypes.h:37
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
DWORD dwIndex
Definition: ifmib.h:38
WORD wRecordType
Definition: ipconfig.c:35
PCWSTR pszRecordName
Definition: ipconfig.c:36
WORD wSecond
Definition: minwinbase.h:262
WORD wMinute
Definition: minwinbase.h:261
Definition: inet.h:67
Definition: tcpip.h:126
u_long S_addr
Definition: tcpip.h:131
union in_addr::@1116 S_un
int tm_mon
Definition: corecrt_wtime.h:16
int tm_year
Definition: corecrt_wtime.h:17
int tm_hour
Definition: corecrt_wtime.h:14
int tm_sec
Definition: corecrt_wtime.h:12
int tm_mday
Definition: corecrt_wtime.h:15
int tm_min
Definition: corecrt_wtime.h:13
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
uint16_t * PWSTR
Definition: typedefs.h:56
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetModuleHandle
Definition: winbase.h:3576
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400
LONG DNS_STATUS
Definition: windns.h:183
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:307
#define ERROR_NO_DATA
Definition: winerror.h:406
#define DNS_INFO_NO_RECORDS
Definition: winerror.h:2671
#define DNS_ERROR_RCODE_NAME_ERROR
Definition: winerror.h:2628
#define DATE_LONGDATE
Definition: winnls.h:210
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12