ReactOS 0.4.16-dev-1946-g52006dd
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#define WIN32_NO_STATUS
13#include <stdarg.h>
14#include <stdlib.h>
15#include <windef.h>
16#include <winbase.h>
17#include <winnls.h>
18#include <winuser.h>
19#include <winreg.h>
20#include <winnls.h>
21#include <stdio.h>
22#include <time.h>
23#include <iphlpapi.h>
24#include <ndk/rtlfuncs.h>
25#include <inaddr.h>
26#include <windns.h>
27#include <windns_undoc.h>
28#include <dhcpcsdk.h>
29#include <dhcpcapi.h>
30#include <strsafe.h>
31#include <conutils.h>
32
33#include "resource.h"
34
35#define NDEBUG
36#include <debug.h>
37
38typedef struct _RECORDTYPE
39{
43
44#define GUID_LEN 40
45
48
50{
51 {DNS_TYPE_ZERO, L"ZERO"},
52 {DNS_TYPE_A, L"A"},
53 {DNS_TYPE_NS, L"NS"},
54 {DNS_TYPE_MD, L"MD"},
55 {DNS_TYPE_MF, L"MF"},
56 {DNS_TYPE_CNAME, L"CNAME"},
57 {DNS_TYPE_SOA, L"SOA"},
58 {DNS_TYPE_MB, L"MB"},
59 {DNS_TYPE_MG, L"MG"},
60 {DNS_TYPE_MR, L"MR"},
61 {DNS_TYPE_NULL, L"NULL"},
62 {DNS_TYPE_WKS, L"WKS"},
63 {DNS_TYPE_PTR, L"PTR"},
64 {DNS_TYPE_HINFO, L"HINFO"},
65 {DNS_TYPE_MINFO, L"MINFO"},
66 {DNS_TYPE_MX, L"MX"},
67 {DNS_TYPE_TEXT, L"TXT"},
68 {DNS_TYPE_RP, L"RP"},
69 {DNS_TYPE_AFSDB, L"AFSDB"},
70 {DNS_TYPE_X25, L"X25"},
71 {DNS_TYPE_ISDN, L"ISDN"},
72 {DNS_TYPE_RT, L"RT"},
73 {DNS_TYPE_NSAP, L"NSAP"},
74 {DNS_TYPE_NSAPPTR, L"NSAPPTR"},
75 {DNS_TYPE_SIG, L"SIG"},
76 {DNS_TYPE_KEY, L"KEY"},
77 {DNS_TYPE_PX, L"PX"},
78 {DNS_TYPE_GPOS, L"GPOS"},
79 {DNS_TYPE_AAAA, L"AAAA"},
80 {DNS_TYPE_LOC, L"LOC"},
81 {DNS_TYPE_NXT, L"NXT"},
82 {DNS_TYPE_EID, L"EID"},
83 {DNS_TYPE_NIMLOC, L"NIMLOC"},
84 {DNS_TYPE_SRV, L"SRV"},
85 {DNS_TYPE_ATMA, L"ATMA"},
86 {DNS_TYPE_NAPTR, L"NAPTR"},
87 {DNS_TYPE_KX, L"KX"},
88 {DNS_TYPE_CERT, L"CERT"},
89 {DNS_TYPE_A6, L"A6"},
90 {DNS_TYPE_DNAME, L"DNAME"},
91 {DNS_TYPE_SINK, L"SINK"},
92 {DNS_TYPE_OPT, L"OPT"},
93 {DNS_TYPE_UINFO, L"UINFO"},
94 {DNS_TYPE_UID, L"UID"},
95 {DNS_TYPE_GID, L"GID"},
96 {DNS_TYPE_UNSPEC, L"UNSPEC"},
97 {DNS_TYPE_ADDRS, L"ADDRS"},
98 {DNS_TYPE_TKEY, L"TKEY"},
99 {DNS_TYPE_TSIG, L"TSIG"},
100 {DNS_TYPE_IXFR, L"IXFR"},
101 {DNS_TYPE_AXFR, L"AXFR"},
102 {DNS_TYPE_MAILB, L"MAILB"},
103 {DNS_TYPE_MAILA, L"MAILA"},
104 {DNS_TYPE_ALL, L"ALL"},
105 {0, NULL}
106};
107
108LPWSTR
110{
111 static WCHAR szType[8];
112 INT i;
113
114 for (i = 0; ; i++)
115 {
116 if (TypeArray[i].pszRecordName == NULL)
117 break;
118
119 if (TypeArray[i].wRecordType == wType)
120 return TypeArray[i].pszRecordName;
121 }
122
123 swprintf(szType, L"%hu", wType);
124
125 return szType;
126}
127
128/* print MAC address */
130{
131 static CHAR MacAddr[20];
132
133 sprintf(MacAddr, "%02X-%02X-%02X-%02X-%02X-%02X",
134 Mac[0], Mac[1], Mac[2], Mac[3], Mac[4], Mac[5]);
135
136 return MacAddr;
137}
138
139
140/* convert time_t to localized string */
142{
143 struct tm* ptm;
144 SYSTEMTIME SystemTime;
145 INT DateCchSize, TimeCchSize, TotalCchSize, i;
146 PWSTR DateTimeString, psz;
147
148 /* Convert Unix time to SYSTEMTIME */
149 /* localtime_s may be preferred if available */
150 ptm = localtime(&TimeStamp);
151 if (!ptm)
152 {
153 return NULL;
154 }
155 SystemTime.wYear = ptm->tm_year + 1900;
156 SystemTime.wMonth = ptm->tm_mon + 1;
157 SystemTime.wDay = ptm->tm_mday;
158 SystemTime.wHour = ptm->tm_hour;
159 SystemTime.wMinute = ptm->tm_min;
160 SystemTime.wSecond = ptm->tm_sec;
161
162 /* Get total size in characters required of buffer */
163 DateCchSize = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &SystemTime, NULL, NULL, 0);
164 if (!DateCchSize)
165 {
166 return NULL;
167 }
168 TimeCchSize = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &SystemTime, NULL, NULL, 0);
169 if (!TimeCchSize)
170 {
171 return NULL;
172 }
173 /* Two terminating null are included, the first one will be replaced by space */
174 TotalCchSize = DateCchSize + TimeCchSize;
175
176 /* Allocate buffer and format datetime string */
177 DateTimeString = (PWSTR)HeapAlloc(ProcessHeap, 0, TotalCchSize * sizeof(WCHAR));
178 if (!DateTimeString)
179 {
180 return NULL;
181 }
182
183 /* Get date string */
184 i = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &SystemTime, NULL, DateTimeString, TotalCchSize);
185 if (i)
186 {
187 /* Append space and move pointer */
188 DateTimeString[i - 1] = L' ';
189 psz = DateTimeString + i;
190 TotalCchSize -= i;
191
192 /* Get time string */
193 if (GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &SystemTime, NULL, psz, TotalCchSize))
194 {
195 return DateTimeString;
196 }
197 }
198
199 HeapFree(ProcessHeap, 0, DateTimeString);
200 return NULL;
201}
202
203
204VOID
207{
208 LPVOID lpMsgBuf;
209 //DWORD ErrorCode;
210
211 if (ErrorCode == 0)
213
217 NULL,
218 ErrorCode,
219 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
220 (LPWSTR)&lpMsgBuf,
221 0,
222 NULL))
223 {
224 ConPuts(StdOut, (LPWSTR)lpMsgBuf);
225 LocalFree(lpMsgBuf);
226 }
227}
228
229LPWSTR
231 _In_ LPSTR pszAnsiName)
232{
233 LPWSTR pszUnicodeName;
234 int i, len;
235
236 len = strlen(pszAnsiName);
237 pszUnicodeName = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
238 if (pszUnicodeName == NULL)
239 return NULL;
240
241 for (i = 0; i < len; i++)
242 pszUnicodeName[i] = (WCHAR)pszAnsiName[i];
243 pszUnicodeName[i] = UNICODE_NULL;
244
245 return pszUnicodeName;
246}
247
248VOID
250 _In_ LPSTR lpClass,
251 _In_ DWORD cchFriendlyNameLength,
252 _Out_ LPWSTR pszFriendlyName)
253{
254 HKEY hKey = NULL;
255 CHAR Path[256];
256 LPSTR PrePath = "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
257 LPSTR PostPath = "\\Connection";
258 DWORD PathSize;
259 DWORD dwType;
260 DWORD dwDataSize;
261
262 /* don't overflow the buffer */
263 PathSize = strlen(PrePath) + strlen(lpClass) + strlen(PostPath) + 1;
264 if (PathSize >= 255)
265 return;
266
267 sprintf(Path, "%s%s%s", PrePath, lpClass, PostPath);
268
270 Path,
271 0,
272 KEY_READ,
273 &hKey) == ERROR_SUCCESS)
274 {
275 dwDataSize = cchFriendlyNameLength * sizeof(WCHAR);
277 L"Name",
278 NULL,
279 &dwType,
280 (PBYTE)pszFriendlyName,
281 &dwDataSize);
282 }
283
284 if (hKey != NULL)
286}
287
288VOID
290 _In_ LPWSTR lpDeviceName,
291 _In_ DWORD cchFriendlyNameLength,
292 _Out_ LPWSTR pszFriendlyName)
293{
294 HKEY hKey = NULL;
295 WCHAR Path[256];
296 LPWSTR PrePath = L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
297 LPWSTR PostPath = L"\\Connection";
298 LPWSTR DevicePrefix = L"\\DEVICE\\TCPIP_";
299 DWORD PathSize;
300 DWORD dwType;
301 DWORD dwDataSize;
302
303 DWORD dwPrefixLength = wcslen(DevicePrefix);
304
305 /* don't overflow the buffer */
306 PathSize = wcslen(PrePath) + wcslen(lpDeviceName) - dwPrefixLength + wcslen(PostPath) + 1;
307 if (PathSize >= 255)
308 return;
309
310 swprintf(Path, L"%s%s%s", PrePath, &lpDeviceName[dwPrefixLength], PostPath);
311
313 Path,
314 0,
315 KEY_READ,
316 &hKey) == ERROR_SUCCESS)
317 {
318 dwDataSize = cchFriendlyNameLength * sizeof(WCHAR);
320 L"Name",
321 NULL,
322 &dwType,
323 (PBYTE)pszFriendlyName,
324 &dwDataSize);
325 }
326
327 if (hKey != NULL)
329}
330
331static
332VOID
334{
335 HKEY hBaseKey = NULL;
337 LPSTR lpKeyClass = NULL;
338 LPSTR lpConDesc = NULL;
339 LPWSTR lpPath = NULL;
340 WCHAR szPrePath[] = L"SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\";
341 DWORD dwType;
342 DWORD dwDataSize;
343 INT i;
344
346 szPrePath,
347 0,
348 KEY_READ,
349 &hBaseKey) != ERROR_SUCCESS)
350 {
351 return;
352 }
353
354 for (i = 0; ; i++)
355 {
356 DWORD PathSize;
357 LONG Status;
358 WCHAR szName[10];
359 DWORD NameLen = 9;
360
361 if ((Status = RegEnumKeyExW(hBaseKey,
362 i,
363 szName,
364 &NameLen,
365 NULL,
366 NULL,
367 NULL,
368 NULL)) != ERROR_SUCCESS)
369 {
371 {
373 lpConDesc = NULL;
374 goto CLEANUP;
375 }
376 else
377 continue;
378 }
379
380 PathSize = wcslen(szPrePath) + wcslen(szName) + 1;
381 lpPath = (LPWSTR)HeapAlloc(ProcessHeap,
382 0,
383 PathSize * sizeof(WCHAR));
384 if (lpPath == NULL)
385 goto CLEANUP;
386
387 wsprintf(lpPath, L"%s%s", szPrePath, szName);
388
389 //MessageBox(NULL, lpPath, NULL, 0);
390
392 lpPath,
393 0,
394 KEY_READ,
396 {
397 goto CLEANUP;
398 }
399
400 HeapFree(ProcessHeap, 0, lpPath);
401 lpPath = NULL;
402
404 "NetCfgInstanceId",
405 NULL,
406 &dwType,
407 NULL,
408 &dwDataSize) == ERROR_SUCCESS)
409 {
410 lpKeyClass = (LPSTR)HeapAlloc(ProcessHeap,
411 0,
412 dwDataSize);
413 if (lpKeyClass == NULL)
414 goto CLEANUP;
415
417 "NetCfgInstanceId",
418 NULL,
419 &dwType,
420 (PBYTE)lpKeyClass,
421 &dwDataSize) != ERROR_SUCCESS)
422 {
423 HeapFree(ProcessHeap, 0, lpKeyClass);
424 lpKeyClass = NULL;
425 continue;
426 }
427 }
428 else
429 continue;
430
431 if (!strcmp(lpClass, lpKeyClass))
432 {
433 HeapFree(ProcessHeap, 0, lpKeyClass);
434 lpKeyClass = NULL;
435
437 "DriverDesc",
438 NULL,
439 &dwType,
440 NULL,
441 &dwDataSize) == ERROR_SUCCESS)
442 {
443 lpConDesc = (LPSTR)HeapAlloc(ProcessHeap,
444 0,
445 dwDataSize);
446 if (lpConDesc != NULL)
447 {
449 "DriverDesc",
450 NULL,
451 &dwType,
452 (PBYTE)lpConDesc,
453 &dwDataSize) == ERROR_SUCCESS)
454 {
455 printf("%s", lpConDesc);
456 }
457
458 HeapFree(ProcessHeap, 0, lpConDesc);
459 lpConDesc = NULL;
460 }
461 }
462
463 break;
464 }
465 }
466
467CLEANUP:
468 if (hBaseKey != NULL)
469 RegCloseKey(hBaseKey);
470 if (hClassKey != NULL)
472 if (lpPath != NULL)
473 HeapFree(ProcessHeap, 0, lpPath);
474 if (lpKeyClass != NULL)
475 HeapFree(ProcessHeap, 0, lpKeyClass);
476}
477
478static
479VOID
482{
483 switch (NodeType)
484 {
487 break;
488
491 break;
492
493 case MIXED_NODETYPE:
495 break;
496
497 case HYBRID_NODETYPE:
499 break;
500
501 default :
503 break;
504 }
505}
506
507static
508VOID
510 PIP_ADAPTER_INFO pAdapterInfo)
511{
512 WCHAR szFriendlyName[MAX_PATH];
513
514 GetAdapterFriendlyName(pAdapterInfo->AdapterName, MAX_PATH, szFriendlyName);
515
516 switch (pAdapterInfo->Type)
517 {
519 ConResPrintf(StdOut, IDS_OTHER, szFriendlyName);
520 break;
521
523 ConResPrintf(StdOut, IDS_ETH, szFriendlyName);
524 break;
525
527 ConResPrintf(StdOut, IDS_TOKEN, szFriendlyName);
528 break;
529
530 case MIB_IF_TYPE_FDDI:
531 ConResPrintf(StdOut, IDS_FDDI, szFriendlyName);
532 break;
533
534 case MIB_IF_TYPE_PPP:
535 ConResPrintf(StdOut, IDS_PPP, szFriendlyName);
536 break;
537
539 ConResPrintf(StdOut, IDS_LOOP, szFriendlyName);
540 break;
541
542 case MIB_IF_TYPE_SLIP:
543 ConResPrintf(StdOut, IDS_SLIP, szFriendlyName);
544 break;
545
547 ConResPrintf(StdOut, IDS_WIFI, szFriendlyName);
548 break;
549
550 default:
551 ConResPrintf(StdOut, IDS_UNKNOWNADAPTER, szFriendlyName);
552 break;
553 }
554}
555
556VOID
558 BOOL bShowHeader,
559 BOOL bAll)
560{
561 MIB_IFROW mibEntry;
562 PIP_ADAPTER_INFO pAdapterInfo = NULL;
563 PIP_ADAPTER_INFO pAdapter = NULL;
564 ULONG adaptOutBufLen = 0;
565 PFIXED_INFO pFixedInfo = NULL;
566 ULONG netOutBufLen = 0;
567 PIP_PER_ADAPTER_INFO pPerAdapterInfo = NULL;
568 ULONG ulPerAdapterInfoLength = 0;
569 PSTR pszDomainName = NULL;
570 DWORD dwDomainNameSize = 0;
571 ULONG ret = 0;
572
573 GetComputerNameExA(ComputerNameDnsDomain,
574 NULL,
575 &dwDomainNameSize);
576 if (dwDomainNameSize > 0)
577 {
578 pszDomainName = HeapAlloc(ProcessHeap,
579 0,
580 dwDomainNameSize * sizeof(CHAR));
581 if (pszDomainName != NULL)
582 GetComputerNameExA(ComputerNameDnsDomain,
583 pszDomainName,
584 &dwDomainNameSize);
585 }
586
587 /* call GetAdaptersInfo to obtain the adapter info */
588 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
590 {
591 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
592 if (pAdapterInfo == NULL)
593 goto done;
594
595 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
596 if (ret != NO_ERROR)
597 {
599 goto done;
600 }
601 }
602 else
603 {
604 if (ret != ERROR_NO_DATA)
605 {
607 goto done;
608 }
609 }
610
611 /* call GetNetworkParams to obtain the network info */
612 if (GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW)
613 {
614 pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
615 if (pFixedInfo == NULL)
616 {
617 goto done;
618 }
619 if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR)
620 {
622 goto done;
623 }
624 }
625 else
626 {
628 goto done;
629 }
630
631 pAdapter = pAdapterInfo;
632
633 if (bShowHeader)
635
636 if (bAll)
637 {
639 ConResPrintf(StdOut, IDS_PRIMARYDNSSUFFIX, (pszDomainName != NULL) ? pszDomainName : "");
640
641 PrintNodeType(pFixedInfo->NodeType);
642
643 if (pFixedInfo->EnableRouting)
645 else
647
648 if (pAdapter && pAdapter->HaveWins)
650 else
652
653 if (pszDomainName != NULL && pszDomainName[0] != 0)
654 {
655 ConResPrintf(StdOut, IDS_DNSSUFFIXLIST, pszDomainName);
657 }
658 else
659 {
661 }
662 }
663
664 while (pAdapter)
665 {
667
668 mibEntry.dwIndex = pAdapter->Index;
669 GetIfEntry(&mibEntry);
670
671 PrintAdapterTypeAndName(pAdapter);
672
673 if (GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength) == ERROR_BUFFER_OVERFLOW)
674 {
675 pPerAdapterInfo = (PIP_PER_ADAPTER_INFO)HeapAlloc(ProcessHeap, 0, ulPerAdapterInfoLength);
676 if (pPerAdapterInfo != NULL)
677 {
678 GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength);
679 }
680 }
681
682 /* check if the adapter is connected to the media */
684 {
687 }
688 else
689 {
691 }
692
693 if (bAll)
694 {
697 printf("\n");
698
700
701 if (bConnected)
702 {
703 if (pAdapter->DhcpEnabled)
704 {
706
707 if (pPerAdapterInfo != NULL)
708 {
709 if (pPerAdapterInfo->AutoconfigEnabled)
711 else
713 }
714 }
715 else
716 {
718 }
719 }
720 }
721
722 if (!bConnected)
723 {
724 pAdapter = pAdapter->Next;
725 continue;
726 }
727
730
731 if (strcmp(pAdapter->GatewayList.IpAddress.String, "0.0.0.0"))
733 else
735
736 if (bAll)
737 {
738 PIP_ADDR_STRING pIPAddr;
739
740 if (pAdapter->DhcpEnabled)
742
744 pIPAddr = pFixedInfo->DnsServerList.Next;
745 while (pIPAddr)
746 {
748 pIPAddr = pIPAddr->Next;
749 }
750
751 if (pAdapter->HaveWins)
752 {
755 }
756
757 if (pAdapter->DhcpEnabled && strcmp(pAdapter->DhcpServer.IpAddress.String, "255.255.255.255"))
758 {
759 PWSTR DateTimeString;
760 DateTimeString = timeToStr(pAdapter->LeaseObtained);
761 ConResPrintf(StdOut, IDS_LEASEOBTAINED, DateTimeString ? DateTimeString : L"N/A");
762 if (DateTimeString)
763 {
764 HeapFree(ProcessHeap, 0, DateTimeString);
765 }
766 DateTimeString = timeToStr(pAdapter->LeaseExpires);
767 ConResPrintf(StdOut, IDS_LEASEEXPIRES, DateTimeString ? DateTimeString : L"N/A");
768 if (DateTimeString)
769 {
770 HeapFree(ProcessHeap, 0, DateTimeString);
771 }
772 }
773 }
774
775 HeapFree(ProcessHeap, 0, pPerAdapterInfo);
776 pPerAdapterInfo = NULL;
777
778 pAdapter = pAdapter->Next;
779 }
780
781done:
782 if (pszDomainName)
783 HeapFree(ProcessHeap, 0, pszDomainName);
784 if (pFixedInfo)
785 HeapFree(ProcessHeap, 0, pFixedInfo);
786 if (pAdapterInfo)
787 HeapFree(ProcessHeap, 0, pAdapterInfo);
788}
789
790static
791BOOL
793 _In_ PWSTR pszExpression,
794 _In_ PWSTR pszName)
795{
796 WCHAR *pCharE, *pCharN, charE, charN;
797
798 if (pszExpression == NULL)
799 return TRUE;
800
801 if (pszName == NULL)
802 return FALSE;
803
804 pCharE = pszExpression;
805 pCharN = pszName;
806 while (*pCharE != UNICODE_NULL)
807 {
808 charE = towlower(*pCharE);
809 charN = towlower(*pCharN);
810
811 if (charE == L'*')
812 {
813 if (*(pCharE + 1) != charN)
814 pCharN++;
815 else
816 pCharE++;
817 }
818 else if (charE == L'?')
819 {
820 pCharE++;
821 pCharN++;
822 }
823 else if (charE == charN)
824 {
825 pCharE++;
826 pCharN++;
827 }
828 else
829 {
830 return FALSE;
831 }
832 }
833
834 return TRUE;
835}
836
837VOID
839 LPWSTR pszAdapterName)
840{
841 PIP_ADAPTER_INFO pAdapterInfo = NULL;
842 PIP_ADAPTER_INFO pAdapter = NULL;
843 ULONG adaptOutBufLen = 0;
844 ULONG ret = 0;
845 WCHAR szFriendlyName[MAX_PATH];
846 WCHAR szUnicodeAdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
847 MIB_IFROW mibEntry;
850
852
853 /* call GetAdaptersInfo to obtain the adapter info */
854 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
856 {
858 return;
859 }
860
861 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
862 if (pAdapterInfo == NULL)
863 {
865 return;
866 }
867
868 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
869 if (ret != NO_ERROR)
870 {
872 goto done;
873 }
874
876
877 pAdapter = pAdapterInfo;
878
879 while (pAdapter)
880 {
881 GetAdapterFriendlyName(pAdapter->AdapterName, MAX_PATH, szFriendlyName);
882
883 if ((pszAdapterName == NULL) || MatchWildcard(pszAdapterName, szFriendlyName))
884 {
886
887 mibEntry.dwIndex = pAdapter->Index;
888 GetIfEntry(&mibEntry);
889
892 {
893 if (pAdapter->DhcpEnabled)
894 {
895 if (strcmp(pAdapter->IpAddressList.IpAddress.String, "0.0.0.0"))
896 {
897 mbstowcs(szUnicodeAdapterName, pAdapter->AdapterName, strlen(pAdapter->AdapterName) + 1);
898 DPRINT1("AdapterName: %S\n", szUnicodeAdapterName);
899
900 /* Call DhcpReleaseParameters to release the IP address on the specified adapter. */
901 ret = DhcpReleaseParameters(szUnicodeAdapterName);
902 if (ret != NO_ERROR)
903 {
904 ConResPrintf(StdOut, IDS_DHCPRELEASEERROR, szFriendlyName);
906 }
907 }
908 else
909 {
911 }
912 }
913 else
914 {
915 ConResPrintf(StdOut, IDS_DHCPNOTENABLED, szFriendlyName);
916 }
917 }
918 else
919 {
920 ConResPrintf(StdOut, IDS_DHCPNOTCONNECTED, szFriendlyName);
921 }
922 }
923
924 pAdapter = pAdapter->Next;
925 }
926
928
929 if (bFoundAdapter == FALSE)
930 {
932 }
933 else
934 {
936 }
937
938done:
939 if (pAdapterInfo)
940 HeapFree(ProcessHeap, 0, pAdapterInfo);
941}
942
943VOID
945 LPWSTR pszAdapterName)
946{
947 PIP_ADAPTER_INFO pAdapterInfo = NULL;
948 PIP_ADAPTER_INFO pAdapter = NULL;
949 ULONG adaptOutBufLen = 0;
950 ULONG ret = 0;
951 WCHAR szFriendlyName[MAX_PATH];
952 WCHAR szUnicodeAdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
953 MIB_IFROW mibEntry;
956
958
959 /* call GetAdaptersInfo to obtain the adapter info */
960 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
962 {
964 return;
965 }
966
967 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
968 if (pAdapterInfo == NULL)
969 {
971 return;
972 }
973
974 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
975 if (ret != NO_ERROR)
976 {
978 goto done;
979 }
980
982
983 pAdapter = pAdapterInfo;
984
985 while (pAdapter)
986 {
987 GetAdapterFriendlyName(pAdapter->AdapterName, MAX_PATH, szFriendlyName);
988
989 if ((pszAdapterName == NULL) || MatchWildcard(pszAdapterName, szFriendlyName))
990 {
992
993 mibEntry.dwIndex = pAdapter->Index;
994 GetIfEntry(&mibEntry);
995
998 {
999 if (pAdapter->DhcpEnabled)
1000 {
1001 mbstowcs(szUnicodeAdapterName, pAdapter->AdapterName, strlen(pAdapter->AdapterName) + 1);
1002 DPRINT1("AdapterName: %S\n", szUnicodeAdapterName);
1003
1004 /* Call DhcpAcquireParameters to renew the IP address on the specified adapter. */
1005 ret = DhcpAcquireParameters(szUnicodeAdapterName);
1006 if (ret != NO_ERROR)
1007 {
1008 ConResPrintf(StdOut, IDS_DHCPRENEWERROR, szFriendlyName);
1010 }
1011 }
1012 else
1013 {
1014 ConResPrintf(StdOut, IDS_DHCPNOTENABLED, szFriendlyName);
1015 }
1016 }
1017 else
1018 {
1019 ConResPrintf(StdOut, IDS_DHCPNOTCONNECTED, szFriendlyName);
1020 }
1021 }
1022
1023 pAdapter = pAdapter->Next;
1024 }
1025
1027
1028 if (bFoundAdapter == FALSE)
1029 {
1031 }
1032 else
1033 {
1035 }
1036
1037done:
1038 if (pAdapterInfo)
1039 HeapFree(ProcessHeap, 0, pAdapterInfo);
1040}
1041
1042VOID
1044{
1046
1048 {
1050 }
1051 else
1052 {
1055 }
1056}
1057
1058VOID
1060{
1061 /* FIXME */
1062 printf("\nSorry /registerdns is not implemented yet\n");
1063}
1064
1065static
1066VOID
1068 PWSTR pszName,
1069 WORD wType)
1070{
1071 PDNS_RECORDW pQueryResults = NULL, pThisRecord, pNextRecord;
1072 WCHAR szBuffer[48];
1073 IN_ADDR Addr4;
1074 IN6_ADDR Addr6;
1076
1077 ConResPrintf(StdOut, IDS_DNSNAME, pszName);
1079
1080 pQueryResults = NULL;
1081 Status = DnsQuery_W(pszName,
1082 wType,
1084 NULL,
1085 (PDNS_RECORD *)&pQueryResults,
1086 NULL);
1087 if (Status != ERROR_SUCCESS)
1088 {
1090 {
1092 }
1093 else if (Status == DNS_INFO_NO_RECORDS)
1094 {
1096 }
1097 return;
1098 }
1099
1100 pThisRecord = pQueryResults;
1101 while (pThisRecord != NULL)
1102 {
1103 pNextRecord = pThisRecord->pNext;
1104
1105 ConResPrintf(StdOut, IDS_DNSRECORDNAME, pThisRecord->pName);
1106 ConResPrintf(StdOut, IDS_DNSRECORDTYPE, pThisRecord->wType);
1107 ConResPrintf(StdOut, IDS_DNSRECORDTTL, pThisRecord->dwTtl);
1108 ConResPrintf(StdOut, IDS_DNSRECORDLENGTH, pThisRecord->wDataLength);
1109
1110 switch (pThisRecord->Flags.S.Section)
1111 {
1112 case DnsSectionQuestion:
1114 break;
1115
1116 case DnsSectionAnswer:
1118 break;
1119
1122 break;
1123
1126 break;
1127 }
1128
1129 switch (pThisRecord->wType)
1130 {
1131 case DNS_TYPE_A:
1132 Addr4.S_un.S_addr = pThisRecord->Data.A.IpAddress;
1133 RtlIpv4AddressToStringW(&Addr4, szBuffer);
1134 ConResPrintf(StdOut, IDS_DNSTYPEA, szBuffer);
1135 break;
1136
1137 case DNS_TYPE_NS:
1138 ConResPrintf(StdOut, IDS_DNSTYPENS, pThisRecord->Data.NS.pNameHost);
1139 break;
1140
1141 case DNS_TYPE_CNAME:
1142 ConResPrintf(StdOut, IDS_DNSTYPECNAME, pThisRecord->Data.CNAME.pNameHost);
1143 break;
1144
1145 case DNS_TYPE_SOA:
1147 pThisRecord->Data.SOA.pNamePrimaryServer,
1148 pThisRecord->Data.SOA.pNameAdministrator,
1149 pThisRecord->Data.SOA.dwSerialNo);
1151 pThisRecord->Data.SOA.dwRefresh,
1152 pThisRecord->Data.SOA.dwRetry,
1153 pThisRecord->Data.SOA.dwExpire,
1154 pThisRecord->Data.SOA.dwDefaultTtl);
1155 break;
1156
1157 case DNS_TYPE_PTR:
1158 ConResPrintf(StdOut, IDS_DNSTYPEPTR, pThisRecord->Data.PTR.pNameHost);
1159 break;
1160
1161 case DNS_TYPE_MX:
1163 pThisRecord->Data.MX.pNameExchange,
1164 pThisRecord->Data.MX.wPreference,
1165 pThisRecord->Data.MX.Pad);
1166 break;
1167
1168 case DNS_TYPE_AAAA:
1169 RtlCopyMemory(&Addr6, &pThisRecord->Data.AAAA.Ip6Address, sizeof(IN6_ADDR));
1170 RtlIpv6AddressToStringW(&Addr6, szBuffer);
1172 break;
1173
1174 case DNS_TYPE_ATMA:
1176 break;
1177
1178 case DNS_TYPE_SRV:
1180 pThisRecord->Data.SRV.pNameTarget,
1181 pThisRecord->Data.SRV.wPriority,
1182 pThisRecord->Data.SRV.wWeight,
1183 pThisRecord->Data.SRV.wPort);
1184 break;
1185 }
1186 ConPuts(StdOut, L"\n\n");
1187
1188 pThisRecord = pNextRecord;
1189 }
1190
1192}
1193
1194VOID
1196{
1197 PDNS_CACHE_ENTRY DnsEntry = NULL, pThisEntry, pNextEntry;
1198
1200
1201 if (!DnsGetCacheDataTable(&DnsEntry))
1202 {
1204 return;
1205 }
1206
1207 if (DnsEntry == NULL)
1208 return;
1209
1210 pThisEntry = DnsEntry;
1211 while (pThisEntry != NULL)
1212 {
1213 pNextEntry = pThisEntry->pNext;
1214
1215 if (pThisEntry->wType1 != DNS_TYPE_ZERO)
1216 DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType1);
1217
1218 if (pThisEntry->wType2 != DNS_TYPE_ZERO)
1219 DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType2);
1220
1221 if (pThisEntry->pszName)
1222 LocalFree(pThisEntry->pszName);
1223 LocalFree(pThisEntry);
1224
1225 pThisEntry = pNextEntry;
1226 }
1227}
1228
1229VOID
1231 LPWSTR pszAdapterName)
1232{
1233 printf("\nSorry /showclassid adapter is not implemented yet\n");
1234}
1235
1236VOID
1238 LPWSTR pszAdapterName,
1239 LPWSTR pszClassId)
1240{
1241 PIP_ADAPTER_INFO pAdapterInfo = NULL;
1242 PIP_ADAPTER_INFO pAdapter = NULL, pFoundAdapter = NULL;
1243 ULONG adaptOutBufLen = 0;
1244 ULONG ret = 0;
1245 WCHAR szFriendlyName[MAX_PATH];
1246 WCHAR szKeyName[256];
1247 MIB_IFROW mibEntry;
1248 HKEY hKey;
1249
1251
1252 /* call GetAdaptersInfo to obtain the adapter info */
1253 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
1255 {
1257 return;
1258 }
1259
1260 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
1261 if (pAdapterInfo == NULL)
1262 {
1264 return;
1265 }
1266
1267 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
1268 if (ret != NO_ERROR)
1269 {
1270 DoFormatMessage(0);
1271 goto done;
1272 }
1273
1274 pAdapter = pAdapterInfo;
1275 while (pAdapter)
1276 {
1277 GetAdapterFriendlyName(pAdapter->AdapterName, MAX_PATH, szFriendlyName);
1278
1279 if (MatchWildcard(pszAdapterName, szFriendlyName))
1280 {
1281 mibEntry.dwIndex = pAdapter->Index;
1282 GetIfEntry(&mibEntry);
1283
1286 {
1287 pFoundAdapter = pAdapter;
1288 break;
1289 }
1290 }
1291
1292 pAdapter = pAdapter->Next;
1293 }
1294
1295 if (pFoundAdapter)
1296 {
1297 swprintf(szKeyName,
1298 L"System\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%S",
1299 pFoundAdapter->AdapterName);
1300
1302 szKeyName,
1303 0,
1304 KEY_WRITE,
1305 &hKey);
1306 if (ret != ERROR_SUCCESS)
1307 {
1308 ConResPrintf(StdOut, IDS_DHCPSETIDERROR, szFriendlyName);
1310 goto done;
1311 }
1312
1313 if (pszClassId == NULL)
1314 pszClassId = L"";
1315
1316 RegSetValueExW(hKey, L"DhcpClassId", 0, REG_SZ, (LPBYTE)pszClassId, (wcslen(pszClassId) + 1) * sizeof(WCHAR));
1318
1319 ConResPrintf(StdOut, IDS_DHCPSETIDSUCCESS, szFriendlyName);
1320 }
1321 else
1322 {
1324 }
1325
1326done:
1327 if (pAdapterInfo)
1328 HeapFree(ProcessHeap, 0, pAdapterInfo);
1329}
1330
1331VOID
1333 _In_ BOOL Error)
1334{
1335 if (Error)
1338}
1339
1340int wmain(int argc, wchar_t *argv[])
1341{
1342 BOOL DoUsage=FALSE;
1343 BOOL DoAll=FALSE;
1344 BOOL DoRelease=FALSE;
1345 BOOL DoRenew=FALSE;
1346 BOOL DoFlushdns=FALSE;
1347 BOOL DoRegisterdns=FALSE;
1348 BOOL DoDisplaydns=FALSE;
1349 BOOL DoShowclassid=FALSE;
1350 BOOL DoSetclassid=FALSE;
1351
1352 /* Initialize the Console Standard Streams */
1354
1357
1358 /* Parse command line for options we have been given. */
1359 if ((argc > 1) && (argv[1][0] == L'/' || argv[1][0] == L'-'))
1360 {
1361 if (!_wcsicmp(&argv[1][1], L"?"))
1362 {
1363 DoUsage = TRUE;
1364 }
1365 else if (!_wcsnicmp(&argv[1][1], L"ALL", wcslen(&argv[1][1])))
1366 {
1367 DoAll = TRUE;
1368 }
1369 else if (!_wcsnicmp(&argv[1][1], L"RELEASE", wcslen(&argv[1][1])))
1370 {
1371 DoRelease = TRUE;
1372 }
1373 else if (!_wcsnicmp(&argv[1][1], L"RENEW", wcslen(&argv[1][1])))
1374 {
1375 DoRenew = TRUE;
1376 }
1377 else if (!_wcsnicmp(&argv[1][1], L"FLUSHDNS", wcslen(&argv[1][1])))
1378 {
1379 DoFlushdns = TRUE;
1380 }
1381 else if (!_wcsnicmp(&argv[1][1], L"FLUSHREGISTERDNS", wcslen(&argv[1][1])))
1382 {
1383 DoRegisterdns = TRUE;
1384 }
1385 else if (!_wcsnicmp(&argv[1][1], L"DISPLAYDNS", wcslen(&argv[1][1])))
1386 {
1387 DoDisplaydns = TRUE;
1388 }
1389 else if (!_wcsnicmp(&argv[1][1], L"SHOWCLASSID", wcslen(&argv[1][1])))
1390 {
1391 DoShowclassid = TRUE;
1392 }
1393 else if (!_wcsnicmp(&argv[1][1], L"SETCLASSID", wcslen(&argv[1][1])))
1394 {
1395 DoSetclassid = TRUE;
1396 }
1397 }
1398
1399 switch (argc)
1400 {
1401 case 1: /* Default behaviour if no options are given*/
1403 break;
1404 case 2: /* Process all the options that take no parameters */
1405 if (DoUsage)
1406 Usage(FALSE);
1407 else if (DoAll)
1408 ShowInfo(TRUE, TRUE);
1409 else if (DoRelease)
1410 Release(NULL);
1411 else if (DoRenew)
1412 Renew(NULL);
1413 else if (DoFlushdns)
1414 FlushDns();
1415 else if (DoRegisterdns)
1416 RegisterDns();
1417 else if (DoDisplaydns)
1418 DisplayDns();
1419 else
1420 Usage(TRUE);
1421 break;
1422 case 3: /* Process all the options that can have 1 parameter */
1423 if (DoRelease)
1424 Release(argv[2]);
1425 else if (DoRenew)
1426 Renew(argv[2]);
1427 else if (DoShowclassid)
1428 ShowClassId(argv[2]);
1429 else if (DoSetclassid)
1430 SetClassId(argv[2], NULL);
1431 else
1432 Usage(TRUE);
1433 break;
1434 case 4: /* Process all the options that can have 2 parameters */
1435 if (DoSetclassid)
1436 SetClassId(argv[2], argv[3]);
1437 else
1438 Usage(TRUE);
1439 break;
1440 default:
1441 Usage(TRUE);
1442 }
1443
1444 return 0;
1445}
NodeType
Definition: Node.h:6
unsigned char BOOLEAN
PRTL_UNICODE_STRING_BUFFER Path
static int argc
Definition: ServiceArgs.c:12
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define IDS_USAGE
Definition: resource.h:3
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define ConInitStdStreams()
Definition: fc.c:13
#define StdOut
Definition: fc.c:14
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#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
#define DPRINT1
Definition: precomp.h:8
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
#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:102
DWORD APIENTRY DhcpReleaseParameters(_In_ PWSTR AdapterName)
Definition: dhcpcsvc.c:266
DWORD APIENTRY DhcpAcquireParameters(_In_ PWSTR AdapterName)
Definition: dhcpcsvc.c:132
VOID APIENTRY DhcpCApiCleanup(VOID)
Definition: dhcpcsvc.c:116
#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
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
__kernel_time_t time_t
Definition: linux.h:252
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:97
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
VOID Renew(LPWSTR pszAdapterName)
Definition: ipconfig.c:944
VOID GetInterfaceFriendlyName(_In_ LPWSTR lpDeviceName, _In_ DWORD cchFriendlyNameLength, _Out_ LPWSTR pszFriendlyName)
Definition: ipconfig.c:289
VOID RegisterDns(VOID)
Definition: ipconfig.c:1059
VOID ShowInfo(BOOL bShowHeader, BOOL bAll)
Definition: ipconfig.c:557
VOID FlushDns(VOID)
Definition: ipconfig.c:1043
RECORDTYPE TypeArray[]
Definition: ipconfig.c:49
_Ret_opt_z_ PWSTR timeToStr(_In_ time_t TimeStamp)
Definition: ipconfig.c:141
VOID DoFormatMessage(_In_ LONG ErrorCode)
Definition: ipconfig.c:205
HANDLE ProcessHeap
Definition: ipconfig.c:47
VOID SetClassId(LPWSTR pszAdapterName, LPWSTR pszClassId)
Definition: ipconfig.c:1237
struct _RECORDTYPE * PRECORDTYPE
static VOID PrintAdapterDescription(LPSTR lpClass)
Definition: ipconfig.c:333
struct _RECORDTYPE RECORDTYPE
HINSTANCE hInstance
Definition: ipconfig.c:46
VOID ShowClassId(LPWSTR pszAdapterName)
Definition: ipconfig.c:1230
PCHAR PrintMacAddr(PBYTE Mac)
Definition: ipconfig.c:129
LPWSTR GetUnicodeAdapterName(_In_ LPSTR pszAnsiName)
Definition: ipconfig.c:230
static VOID PrintNodeType(_In_ UINT NodeType)
Definition: ipconfig.c:480
VOID DisplayDns(VOID)
Definition: ipconfig.c:1195
LPWSTR GetRecordTypeName(WORD wType)
Definition: ipconfig.c:109
static VOID PrintAdapterTypeAndName(PIP_ADAPTER_INFO pAdapterInfo)
Definition: ipconfig.c:509
static BOOL MatchWildcard(_In_ PWSTR pszExpression, _In_ PWSTR pszName)
Definition: ipconfig.c:792
VOID GetAdapterFriendlyName(_In_ LPSTR lpClass, _In_ DWORD cchFriendlyNameLength, _Out_ LPWSTR pszFriendlyName)
Definition: ipconfig.c:249
static VOID DisplayDnsRecord(PWSTR pszName, WORD wType)
Definition: ipconfig.c:1067
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:1089
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:989
#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
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
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()
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
mbstowcs
Definition: stdlib.h:925
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
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:40
LPWSTR pszRecordName
Definition: ipconfig.c:41
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::@1141 S_un
Definition: time.h:68
int tm_mon
Definition: time.h:73
int tm_year
Definition: time.h:74
int tm_hour
Definition: time.h:71
int tm_sec
Definition: time.h:69
int tm_mday
Definition: time.h:72
int tm_min
Definition: time.h:70
#define towlower(c)
Definition: wctype.h:97
uint16_t * PWSTR
Definition: typedefs.h:56
char * PSTR
Definition: typedefs.h:51
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:397
#define GetModuleHandle
Definition: winbase.h:3576
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:396
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
#define wsprintf
Definition: winuser.h:5976
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175