ReactOS 0.4.16-dev-399-g1faa571
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 * fix renew / release
10 * implement registerdns, showclassid, setclassid
11 */
12
13#define WIN32_NO_STATUS
14#include <stdarg.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 <tchar.h>
23#include <time.h>
24#include <iphlpapi.h>
25#include <ndk/rtlfuncs.h>
26#include <inaddr.h>
27#include <windns.h>
28#include <windns_undoc.h>
29#include <strsafe.h>
30#include <conutils.h>
31
32#include "resource.h"
33
34typedef struct _RECORDTYPE
35{
39
40#define GUID_LEN 40
41
44
46{
47 {DNS_TYPE_ZERO, _T("ZERO")},
48 {DNS_TYPE_A, _T("A")},
49 {DNS_TYPE_NS, _T("NS")},
50 {DNS_TYPE_MD, _T("MD")},
51 {DNS_TYPE_MF, _T("MF")},
52 {DNS_TYPE_CNAME, _T("CNAME")},
53 {DNS_TYPE_SOA, _T("SOA")},
54 {DNS_TYPE_MB, _T("MB")},
55 {DNS_TYPE_MG, _T("MG")},
56 {DNS_TYPE_MR, _T("MR")},
57 {DNS_TYPE_NULL, _T("NULL")},
58 {DNS_TYPE_WKS, _T("WKS")},
59 {DNS_TYPE_PTR, _T("PTR")},
60 {DNS_TYPE_HINFO, _T("HINFO")},
61 {DNS_TYPE_MINFO, _T("MINFO")},
62 {DNS_TYPE_MX, _T("MX")},
63 {DNS_TYPE_TEXT, _T("TXT")},
64 {DNS_TYPE_RP, _T("RP")},
65 {DNS_TYPE_AFSDB, _T("AFSDB")},
66 {DNS_TYPE_X25, _T("X25")},
67 {DNS_TYPE_ISDN, _T("ISDN")},
68 {DNS_TYPE_RT, _T("RT")},
69 {DNS_TYPE_NSAP, _T("NSAP")},
70 {DNS_TYPE_NSAPPTR, _T("NSAPPTR")},
71 {DNS_TYPE_SIG, _T("SIG")},
72 {DNS_TYPE_KEY, _T("KEY")},
73 {DNS_TYPE_PX, _T("PX")},
74 {DNS_TYPE_GPOS, _T("GPOS")},
75 {DNS_TYPE_AAAA, _T("AAAA")},
76 {DNS_TYPE_LOC, _T("LOC")},
77 {DNS_TYPE_NXT, _T("NXT")},
78 {DNS_TYPE_EID, _T("EID")},
79 {DNS_TYPE_NIMLOC, _T("NIMLOC")},
80 {DNS_TYPE_SRV, _T("SRV")},
81 {DNS_TYPE_ATMA, _T("ATMA")},
82 {DNS_TYPE_NAPTR, _T("NAPTR")},
83 {DNS_TYPE_KX, _T("KX")},
84 {DNS_TYPE_CERT, _T("CERT")},
85 {DNS_TYPE_A6, _T("A6")},
86 {DNS_TYPE_DNAME, _T("DNAME")},
87 {DNS_TYPE_SINK, _T("SINK")},
88 {DNS_TYPE_OPT, _T("OPT")},
89 {DNS_TYPE_UINFO, _T("UINFO")},
90 {DNS_TYPE_UID, _T("UID")},
91 {DNS_TYPE_GID, _T("GID")},
92 {DNS_TYPE_UNSPEC, _T("UNSPEC")},
93 {DNS_TYPE_ADDRS, _T("ADDRS")},
94 {DNS_TYPE_TKEY, _T("TKEY")},
95 {DNS_TYPE_TSIG, _T("TSIG")},
96 {DNS_TYPE_IXFR, _T("IXFR")},
97 {DNS_TYPE_AXFR, _T("AXFR")},
98 {DNS_TYPE_MAILB, _T("MAILB")},
99 {DNS_TYPE_MAILA, _T("MAILA")},
100 {DNS_TYPE_ALL, _T("ALL")},
101 {0, NULL}
102};
103
104LPTSTR
106{
107 static TCHAR szType[8];
108 INT i;
109
110 for (i = 0; ; i++)
111 {
112 if (TypeArray[i].pszRecordName == NULL)
113 break;
114
115 if (TypeArray[i].wRecordType == wType)
116 return TypeArray[i].pszRecordName;
117 }
118
119 _stprintf(szType, _T("%hu"), wType);
120
121 return szType;
122}
123
124/* print MAC address */
126{
127 static CHAR MacAddr[20];
128
129 sprintf(MacAddr, "%02X-%02X-%02X-%02X-%02X-%02X",
130 Mac[0], Mac[1], Mac[2], Mac[3], Mac[4], Mac[5]);
131
132 return MacAddr;
133}
134
135
136/* convert time_t to localized string */
138{
139 struct tm* ptm;
140 SYSTEMTIME SystemTime;
141 INT DateCchSize, TimeCchSize, TotalCchSize, i;
142 PTSTR DateTimeString, psz;
143
144 /* Convert Unix time to SYSTEMTIME */
145 /* localtime_s may be preferred if available */
146 ptm = localtime(&TimeStamp);
147 if (!ptm)
148 {
149 return NULL;
150 }
151 SystemTime.wYear = ptm->tm_year + 1900;
152 SystemTime.wMonth = ptm->tm_mon + 1;
153 SystemTime.wDay = ptm->tm_mday;
154 SystemTime.wHour = ptm->tm_hour;
155 SystemTime.wMinute = ptm->tm_min;
156 SystemTime.wSecond = ptm->tm_sec;
157
158 /* Get total size in characters required of buffer */
159 DateCchSize = GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &SystemTime, NULL, NULL, 0);
160 if (!DateCchSize)
161 {
162 return NULL;
163 }
164 TimeCchSize = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &SystemTime, NULL, NULL, 0);
165 if (!TimeCchSize)
166 {
167 return NULL;
168 }
169 /* Two terminating null are included, the first one will be replaced by space */
170 TotalCchSize = DateCchSize + TimeCchSize;
171
172 /* Allocate buffer and format datetime string */
173 DateTimeString = (PTSTR)HeapAlloc(ProcessHeap, 0, TotalCchSize * sizeof(TCHAR));
174 if (!DateTimeString)
175 {
176 return NULL;
177 }
178
179 /* Get date string */
180 i = GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &SystemTime, NULL, DateTimeString, TotalCchSize);
181 if (i)
182 {
183 /* Append space and move pointer */
184 DateTimeString[i - 1] = _T(' ');
185 psz = DateTimeString + i;
186 TotalCchSize -= i;
187
188 /* Get time string */
189 if (GetTimeFormat(LOCALE_USER_DEFAULT, 0, &SystemTime, NULL, psz, TotalCchSize))
190 {
191 return DateTimeString;
192 }
193 }
194
195 HeapFree(ProcessHeap, 0, DateTimeString);
196 return NULL;
197}
198
199
201{
202 LPVOID lpMsgBuf;
203 //DWORD ErrorCode;
204
205 if (ErrorCode == 0)
207
211 NULL,
212 ErrorCode,
213 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
214 (LPTSTR) &lpMsgBuf,
215 0,
216 NULL))
217 {
218 _tprintf(_T("%s"), (LPTSTR)lpMsgBuf);
219 LocalFree(lpMsgBuf);
220 }
221}
222
223VOID
225 _In_ LPSTR lpClass,
226 _In_ DWORD cchFriendlyNameLength,
227 _Out_ LPWSTR pszFriendlyName)
228{
229 HKEY hKey = NULL;
230 CHAR Path[256];
231 LPSTR PrePath = "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
232 LPSTR PostPath = "\\Connection";
233 DWORD PathSize;
234 DWORD dwType;
235 DWORD dwDataSize;
236
237 /* don't overflow the buffer */
238 PathSize = strlen(PrePath) + strlen(lpClass) + strlen(PostPath) + 1;
239 if (PathSize >= 255)
240 return;
241
242 sprintf(Path, "%s%s%s", PrePath, lpClass, PostPath);
243
245 Path,
246 0,
247 KEY_READ,
248 &hKey) == ERROR_SUCCESS)
249 {
250 dwDataSize = cchFriendlyNameLength * sizeof(WCHAR);
252 L"Name",
253 NULL,
254 &dwType,
255 (PBYTE)pszFriendlyName,
256 &dwDataSize);
257 }
258
259 if (hKey != NULL)
261}
262
263VOID
265 _In_ LPWSTR lpDeviceName,
266 _In_ DWORD cchFriendlyNameLength,
267 _Out_ LPWSTR pszFriendlyName)
268{
269 HKEY hKey = NULL;
270 WCHAR Path[256];
271 LPWSTR PrePath = L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
272 LPWSTR PostPath = L"\\Connection";
273 LPWSTR DevicePrefix = L"\\DEVICE\\TCPIP_";
274 DWORD PathSize;
275 DWORD dwType;
276 DWORD dwDataSize;
277
278 DWORD dwPrefixLength = wcslen(DevicePrefix);
279
280 /* don't overflow the buffer */
281 PathSize = wcslen(PrePath) + wcslen(lpDeviceName) - dwPrefixLength + wcslen(PostPath) + 1;
282 if (PathSize >= 255)
283 return;
284
285 swprintf(Path, L"%s%s%s", PrePath, &lpDeviceName[dwPrefixLength], PostPath);
286
288 Path,
289 0,
290 KEY_READ,
291 &hKey) == ERROR_SUCCESS)
292 {
293 dwDataSize = cchFriendlyNameLength * sizeof(WCHAR);
295 L"Name",
296 NULL,
297 &dwType,
298 (PBYTE)pszFriendlyName,
299 &dwDataSize);
300 }
301
302 if (hKey != NULL)
304}
305
306static
307VOID
309{
310 HKEY hBaseKey = NULL;
312 LPSTR lpKeyClass = NULL;
313 LPSTR lpConDesc = NULL;
314 LPTSTR lpPath = NULL;
315 TCHAR szPrePath[] = _T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\");
316 DWORD dwType;
317 DWORD dwDataSize;
318 INT i;
319
321 szPrePath,
322 0,
323 KEY_READ,
324 &hBaseKey) != ERROR_SUCCESS)
325 {
326 return;
327 }
328
329 for (i = 0; ; i++)
330 {
331 DWORD PathSize;
332 LONG Status;
333 TCHAR szName[10];
334 DWORD NameLen = 9;
335
336 if ((Status = RegEnumKeyEx(hBaseKey,
337 i,
338 szName,
339 &NameLen,
340 NULL,
341 NULL,
342 NULL,
343 NULL)) != ERROR_SUCCESS)
344 {
346 {
348 lpConDesc = NULL;
349 goto CLEANUP;
350 }
351 else
352 continue;
353 }
354
355 PathSize = lstrlen(szPrePath) + lstrlen(szName) + 1;
356 lpPath = (LPTSTR)HeapAlloc(ProcessHeap,
357 0,
358 PathSize * sizeof(TCHAR));
359 if (lpPath == NULL)
360 goto CLEANUP;
361
362 wsprintf(lpPath, _T("%s%s"), szPrePath, szName);
363
364 //MessageBox(NULL, lpPath, NULL, 0);
365
367 lpPath,
368 0,
369 KEY_READ,
371 {
372 goto CLEANUP;
373 }
374
375 HeapFree(ProcessHeap, 0, lpPath);
376 lpPath = NULL;
377
379 "NetCfgInstanceId",
380 NULL,
381 &dwType,
382 NULL,
383 &dwDataSize) == ERROR_SUCCESS)
384 {
385 lpKeyClass = (LPSTR)HeapAlloc(ProcessHeap,
386 0,
387 dwDataSize);
388 if (lpKeyClass == NULL)
389 goto CLEANUP;
390
392 "NetCfgInstanceId",
393 NULL,
394 &dwType,
395 (PBYTE)lpKeyClass,
396 &dwDataSize) != ERROR_SUCCESS)
397 {
398 HeapFree(ProcessHeap, 0, lpKeyClass);
399 lpKeyClass = NULL;
400 continue;
401 }
402 }
403 else
404 continue;
405
406 if (!strcmp(lpClass, lpKeyClass))
407 {
408 HeapFree(ProcessHeap, 0, lpKeyClass);
409 lpKeyClass = NULL;
410
412 "DriverDesc",
413 NULL,
414 &dwType,
415 NULL,
416 &dwDataSize) == ERROR_SUCCESS)
417 {
418 lpConDesc = (LPSTR)HeapAlloc(ProcessHeap,
419 0,
420 dwDataSize);
421 if (lpConDesc != NULL)
422 {
424 "DriverDesc",
425 NULL,
426 &dwType,
427 (PBYTE)lpConDesc,
428 &dwDataSize) == ERROR_SUCCESS)
429 {
430 printf("%s", lpConDesc);
431 }
432
433 HeapFree(ProcessHeap, 0, lpConDesc);
434 lpConDesc = NULL;
435 }
436 }
437
438 break;
439 }
440 }
441
442CLEANUP:
443 if (hBaseKey != NULL)
444 RegCloseKey(hBaseKey);
445 if (hClassKey != NULL)
447 if (lpPath != NULL)
448 HeapFree(ProcessHeap, 0, lpPath);
449 if (lpKeyClass != NULL)
450 HeapFree(ProcessHeap, 0, lpKeyClass);
451}
452
453static
454VOID
457{
458 switch (NodeType)
459 {
462 break;
463
466 break;
467
468 case MIXED_NODETYPE:
470 break;
471
472 case HYBRID_NODETYPE:
474 break;
475
476 default :
478 break;
479 }
480}
481
482static
483VOID
485 PIP_ADAPTER_INFO pAdapterInfo)
486{
487 WCHAR szFriendlyName[MAX_PATH];
488
489 GetAdapterFriendlyName(pAdapterInfo->AdapterName, MAX_PATH, szFriendlyName);
490
491 switch (pAdapterInfo->Type)
492 {
494 ConResPrintf(StdOut, IDS_OTHER, szFriendlyName);
495 break;
496
498 ConResPrintf(StdOut, IDS_ETH, szFriendlyName);
499 break;
500
502 ConResPrintf(StdOut, IDS_TOKEN, szFriendlyName);
503 break;
504
505 case MIB_IF_TYPE_FDDI:
506 ConResPrintf(StdOut, IDS_FDDI, szFriendlyName);
507 break;
508
509 case MIB_IF_TYPE_PPP:
510 ConResPrintf(StdOut, IDS_PPP, szFriendlyName);
511 break;
512
514 ConResPrintf(StdOut, IDS_LOOP, szFriendlyName);
515 break;
516
517 case MIB_IF_TYPE_SLIP:
518 ConResPrintf(StdOut, IDS_SLIP, szFriendlyName);
519 break;
520
522 ConResPrintf(StdOut, IDS_WIFI, szFriendlyName);
523 break;
524
525 default:
526 ConResPrintf(StdOut, IDS_UNKNOWNADAPTER, szFriendlyName);
527 break;
528 }
529}
530
531VOID
533 BOOL bShowHeader,
534 BOOL bAll)
535{
536 MIB_IFROW mibEntry;
537 PIP_ADAPTER_INFO pAdapterInfo = NULL;
538 PIP_ADAPTER_INFO pAdapter = NULL;
539 ULONG adaptOutBufLen = 0;
540 PFIXED_INFO pFixedInfo = NULL;
541 ULONG netOutBufLen = 0;
542 PIP_PER_ADAPTER_INFO pPerAdapterInfo = NULL;
543 ULONG ulPerAdapterInfoLength = 0;
544 PSTR pszDomainName = NULL;
545 DWORD dwDomainNameSize = 0;
546 ULONG ret = 0;
547
548 GetComputerNameExA(ComputerNameDnsDomain,
549 NULL,
550 &dwDomainNameSize);
551 if (dwDomainNameSize > 0)
552 {
553 pszDomainName = HeapAlloc(ProcessHeap,
554 0,
555 dwDomainNameSize * sizeof(TCHAR));
556 if (pszDomainName != NULL)
557 GetComputerNameExA(ComputerNameDnsDomain,
558 pszDomainName,
559 &dwDomainNameSize);
560 }
561
562 /* call GetAdaptersInfo to obtain the adapter info */
563 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
565 {
566 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
567 if (pAdapterInfo == NULL)
568 goto done;
569
570 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
571 if (ret != NO_ERROR)
572 {
574 goto done;
575 }
576 }
577 else
578 {
579 if (ret != ERROR_NO_DATA)
580 {
582 goto done;
583 }
584 }
585
586 /* call GetNetworkParams to obtain the network info */
587 if (GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW)
588 {
589 pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
590 if (pFixedInfo == NULL)
591 {
592 goto done;
593 }
594 if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR)
595 {
597 goto done;
598 }
599 }
600 else
601 {
603 goto done;
604 }
605
606 pAdapter = pAdapterInfo;
607
608 if (bShowHeader)
610
611 if (bAll)
612 {
614 ConResPrintf(StdOut, IDS_PRIMARYDNSSUFFIX, (pszDomainName != NULL) ? pszDomainName : "");
615
616 PrintNodeType(pFixedInfo->NodeType);
617
618 if (pFixedInfo->EnableRouting)
620 else
622
623 if (pAdapter && pAdapter->HaveWins)
625 else
627
628 if (pszDomainName != NULL && pszDomainName[0] != 0)
629 {
630 ConResPrintf(StdOut, IDS_DNSSUFFIXLIST, pszDomainName);
632 }
633 else
634 {
636 }
637 }
638
639 while (pAdapter)
640 {
642
643 mibEntry.dwIndex = pAdapter->Index;
644 GetIfEntry(&mibEntry);
645
646 PrintAdapterTypeAndName(pAdapter);
647
648 if (GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength) == ERROR_BUFFER_OVERFLOW)
649 {
650 pPerAdapterInfo = (PIP_PER_ADAPTER_INFO)HeapAlloc(ProcessHeap, 0, ulPerAdapterInfoLength);
651 if (pPerAdapterInfo != NULL)
652 {
653 GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength);
654 }
655 }
656
657 /* check if the adapter is connected to the media */
659 {
662 }
663 else
664 {
666 }
667
668 if (bAll)
669 {
672 printf("\n");
673
675
676 if (bConnected)
677 {
678 if (pAdapter->DhcpEnabled)
679 {
681
682 if (pPerAdapterInfo != NULL)
683 {
684 if (pPerAdapterInfo->AutoconfigEnabled)
686 else
688 }
689 }
690 else
691 {
693 }
694 }
695 }
696
697 if (!bConnected)
698 {
699 pAdapter = pAdapter->Next;
700 continue;
701 }
702
705
706 if (strcmp(pAdapter->GatewayList.IpAddress.String, "0.0.0.0"))
708 else
710
711 if (bAll)
712 {
713 PIP_ADDR_STRING pIPAddr;
714
715 if (pAdapter->DhcpEnabled)
717
719 pIPAddr = pFixedInfo->DnsServerList.Next;
720 while (pIPAddr)
721 {
722 ConResPrintf(StdOut, IDS_EMPTYLINE, pIPAddr ->IpAddress.String);
723 pIPAddr = pIPAddr->Next;
724 }
725
726 if (pAdapter->HaveWins)
727 {
730 }
731
732 if (pAdapter->DhcpEnabled && strcmp(pAdapter->DhcpServer.IpAddress.String, "255.255.255.255"))
733 {
734 PTSTR DateTimeString;
735 DateTimeString = timeToStr(pAdapter->LeaseObtained);
736 ConResPrintf(StdOut, IDS_LEASEOBTAINED, DateTimeString ? DateTimeString : _T("N/A"));
737 if (DateTimeString)
738 {
739 HeapFree(ProcessHeap, 0, DateTimeString);
740 }
741 DateTimeString = timeToStr(pAdapter->LeaseExpires);
742 ConResPrintf(StdOut, IDS_LEASEEXPIRES, DateTimeString ? DateTimeString : _T("N/A"));
743 if (DateTimeString)
744 {
745 HeapFree(ProcessHeap, 0, DateTimeString);
746 }
747 }
748 }
749
750 HeapFree(ProcessHeap, 0, pPerAdapterInfo);
751 pPerAdapterInfo = NULL;
752
753 pAdapter = pAdapter->Next;
754 }
755
756done:
757 if (pszDomainName)
758 HeapFree(ProcessHeap, 0, pszDomainName);
759 if (pFixedInfo)
760 HeapFree(ProcessHeap, 0, pFixedInfo);
761 if (pAdapterInfo)
762 HeapFree(ProcessHeap, 0, pAdapterInfo);
763}
764
765static
766BOOL
768 _In_ PWSTR pszExpression,
769 _In_ PWSTR pszName)
770{
771 WCHAR *pCharE, *pCharN, charE, charN;
772
773 if (pszExpression == NULL)
774 return TRUE;
775
776 if (pszName == NULL)
777 return FALSE;
778
779 pCharE = pszExpression;
780 pCharN = pszName;
781 while (*pCharE != UNICODE_NULL)
782 {
783 charE = towlower(*pCharE);
784 charN = towlower(*pCharN);
785
786 if (charE == L'*')
787 {
788 if (*(pCharE + 1) != charN)
789 pCharN++;
790 else
791 pCharE++;
792 }
793 else if (charE == L'?')
794 {
795 pCharE++;
796 pCharN++;
797 }
798 else if (charE == charN)
799 {
800 pCharE++;
801 pCharN++;
802 }
803 else
804 {
805 return FALSE;
806 }
807 }
808
809 return TRUE;
810}
811
812static
813VOID
815 PIP_ADAPTER_INDEX_MAP pAdapterMap,
816 PIP_ADAPTER_INFO pAdapterInfo)
817{
818 int i, l1, l2;
819
820 pAdapterMap->Index = pAdapterInfo->Index;
821
822 wcscpy(pAdapterMap->Name, L"\\DEVICE\\TCPIP_");
823 l1 = wcslen(pAdapterMap->Name);
824 l2 = strlen(pAdapterInfo->AdapterName);
825 for (i = 0; i < l2; i++)
826 pAdapterMap->Name[i + l1] = (WCHAR)pAdapterInfo->AdapterName[i];
827 pAdapterMap->Name[i + l1] = UNICODE_NULL;
828}
829
830VOID
832 LPWSTR pszAdapterName)
833{
834 PIP_ADAPTER_INFO pAdapterInfo = NULL;
835 PIP_ADAPTER_INFO pAdapter = NULL;
836 ULONG adaptOutBufLen = 0;
837 ULONG ret = 0;
838 WCHAR szFriendlyName[MAX_PATH];
839 MIB_IFROW mibEntry;
840 IP_ADAPTER_INDEX_MAP AdapterMap;
842
844
845 /* call GetAdaptersInfo to obtain the adapter info */
846 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
848 {
850 return;
851 }
852
853 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
854 if (pAdapterInfo == NULL)
855 {
856 _tprintf(_T("memory allocation error"));
857 return;
858 }
859
860 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
861 if (ret != NO_ERROR)
862 {
864 goto done;
865 }
866
867 pAdapter = pAdapterInfo;
868
869 while (pAdapter)
870 {
871 GetAdapterFriendlyName(pAdapter->AdapterName, MAX_PATH, szFriendlyName);
872
873 if ((pszAdapterName == NULL) || MatchWildcard(pszAdapterName, szFriendlyName))
874 {
876
877 mibEntry.dwIndex = pAdapter->Index;
878 GetIfEntry(&mibEntry);
879
882 {
883 if (pAdapter->DhcpEnabled)
884 {
885 if (strcmp(pAdapter->IpAddressList.IpAddress.String, "0.0.0.0"))
886 {
887 BuildAdapterMap(&AdapterMap, pAdapter);
888
889 /* Call IpReleaseAddress to release the IP address on the specified adapter. */
890 ret = IpReleaseAddress(&AdapterMap);
891 if (ret != NO_ERROR)
892 {
893 ConResPrintf(StdOut, IDS_DHCPRELEASEERROR, szFriendlyName);
895 }
896 }
897 else
898 {
900 }
901 }
902 else
903 {
904 ConResPrintf(StdOut, IDS_DHCPNOTENABLED, szFriendlyName);
905 }
906 }
907 else
908 {
909 ConResPrintf(StdOut, IDS_DHCPNOTCONNECTED, szFriendlyName);
910 }
911 }
912
913 pAdapter = pAdapter->Next;
914 }
915
916 if (bFoundAdapter == FALSE)
917 {
919 }
920 else
921 {
923 }
924
925done:
926 if (pAdapterInfo)
927 HeapFree(ProcessHeap, 0, pAdapterInfo);
928}
929
930VOID
932 LPWSTR pszAdapterName)
933{
934 PIP_ADAPTER_INFO pAdapterInfo = NULL;
935 PIP_ADAPTER_INFO pAdapter = NULL;
936 ULONG adaptOutBufLen = 0;
937 ULONG ret = 0;
938 WCHAR szFriendlyName[MAX_PATH];
939 MIB_IFROW mibEntry;
940 IP_ADAPTER_INDEX_MAP AdapterMap;
942
944
945 /* call GetAdaptersInfo to obtain the adapter info */
946 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
948 {
950 return;
951 }
952
953 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
954 if (pAdapterInfo == NULL)
955 {
956 _tprintf(_T("memory allocation error"));
957 return;
958 }
959
960 ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
961 if (ret != NO_ERROR)
962 {
964 goto done;
965 }
966
967 pAdapter = pAdapterInfo;
968
969 while (pAdapter)
970 {
971 GetAdapterFriendlyName(pAdapter->AdapterName, MAX_PATH, szFriendlyName);
972
973 if ((pszAdapterName == NULL) || MatchWildcard(pszAdapterName, szFriendlyName))
974 {
976
977 mibEntry.dwIndex = pAdapter->Index;
978 GetIfEntry(&mibEntry);
979
982 {
983 if (pAdapter->DhcpEnabled)
984 {
985 BuildAdapterMap(&AdapterMap, pAdapter);
986
987 /* Call IpRenewAddress to renew the IP address on the specified adapter. */
988 ret = IpRenewAddress(&AdapterMap);
989 if (ret != NO_ERROR)
990 {
991 ConResPrintf(StdOut, IDS_DHCPRENEWERROR, szFriendlyName);
993 }
994 }
995 else
996 {
997 ConResPrintf(StdOut, IDS_DHCPNOTENABLED, szFriendlyName);
998 }
999 }
1000 else
1001 {
1002 ConResPrintf(StdOut, IDS_DHCPNOTCONNECTED, szFriendlyName);
1003 }
1004 }
1005
1006 pAdapter = pAdapter->Next;
1007 }
1008
1009 if (bFoundAdapter == FALSE)
1010 {
1012 }
1013 else
1014 {
1016 }
1017
1018done:
1019 if (pAdapterInfo)
1020 HeapFree(ProcessHeap, 0, pAdapterInfo);
1021}
1022
1023VOID
1025{
1027
1029 {
1031 }
1032 else
1033 {
1036 }
1037}
1038
1039VOID
1041{
1042 /* FIXME */
1043 _tprintf(_T("\nSorry /registerdns is not implemented yet\n"));
1044}
1045
1046static
1047VOID
1049 PWSTR pszName,
1050 WORD wType)
1051{
1052 PDNS_RECORDW pQueryResults = NULL, pThisRecord, pNextRecord;
1053 WCHAR szBuffer[48];
1054 IN_ADDR Addr4;
1055 IN6_ADDR Addr6;
1056 DNS_STATUS Status;
1057
1058 ConResPrintf(StdOut, IDS_DNSNAME, pszName);
1060
1061 pQueryResults = NULL;
1062 Status = DnsQuery_W(pszName,
1063 wType,
1065 NULL,
1066 (PDNS_RECORD *)&pQueryResults,
1067 NULL);
1068 if (Status != ERROR_SUCCESS)
1069 {
1071 {
1073 }
1074 else if (Status == DNS_INFO_NO_RECORDS)
1075 {
1077 }
1078 return;
1079 }
1080
1081 pThisRecord = pQueryResults;
1082 while (pThisRecord != NULL)
1083 {
1084 pNextRecord = pThisRecord->pNext;
1085
1086 ConResPrintf(StdOut, IDS_DNSRECORDNAME, pThisRecord->pName);
1087 ConResPrintf(StdOut, IDS_DNSRECORDTYPE, pThisRecord->wType);
1088 ConResPrintf(StdOut, IDS_DNSRECORDTTL, pThisRecord->dwTtl);
1089 ConResPrintf(StdOut, IDS_DNSRECORDLENGTH, pThisRecord->wDataLength);
1090
1091 switch (pThisRecord->Flags.S.Section)
1092 {
1093 case DnsSectionQuestion:
1095 break;
1096
1097 case DnsSectionAnswer:
1099 break;
1100
1103 break;
1104
1107 break;
1108 }
1109
1110 switch (pThisRecord->wType)
1111 {
1112 case DNS_TYPE_A:
1113 Addr4.S_un.S_addr = pThisRecord->Data.A.IpAddress;
1114 RtlIpv4AddressToStringW(&Addr4, szBuffer);
1115 ConResPrintf(StdOut, IDS_DNSTYPEA, szBuffer);
1116 break;
1117
1118 case DNS_TYPE_NS:
1119 ConResPrintf(StdOut, IDS_DNSTYPENS, pThisRecord->Data.NS.pNameHost);
1120 break;
1121
1122 case DNS_TYPE_CNAME:
1123 ConResPrintf(StdOut, IDS_DNSTYPECNAME, pThisRecord->Data.CNAME.pNameHost);
1124 break;
1125
1126 case DNS_TYPE_SOA:
1128 pThisRecord->Data.SOA.pNamePrimaryServer,
1129 pThisRecord->Data.SOA.pNameAdministrator,
1130 pThisRecord->Data.SOA.dwSerialNo);
1132 pThisRecord->Data.SOA.dwRefresh,
1133 pThisRecord->Data.SOA.dwRetry,
1134 pThisRecord->Data.SOA.dwExpire,
1135 pThisRecord->Data.SOA.dwDefaultTtl);
1136 break;
1137
1138 case DNS_TYPE_PTR:
1139 ConResPrintf(StdOut, IDS_DNSTYPEPTR, pThisRecord->Data.PTR.pNameHost);
1140 break;
1141
1142 case DNS_TYPE_MX:
1144 pThisRecord->Data.MX.pNameExchange,
1145 pThisRecord->Data.MX.wPreference,
1146 pThisRecord->Data.MX.Pad);
1147 break;
1148
1149 case DNS_TYPE_AAAA:
1150 RtlCopyMemory(&Addr6, &pThisRecord->Data.AAAA.Ip6Address, sizeof(IN6_ADDR));
1151 RtlIpv6AddressToStringW(&Addr6, szBuffer);
1153 break;
1154
1155 case DNS_TYPE_ATMA:
1157 break;
1158
1159 case DNS_TYPE_SRV:
1161 pThisRecord->Data.SRV.pNameTarget,
1162 pThisRecord->Data.SRV.wPriority,
1163 pThisRecord->Data.SRV.wWeight,
1164 pThisRecord->Data.SRV.wPort);
1165 break;
1166 }
1167 ConPuts(StdOut, L"\n\n");
1168
1169 pThisRecord = pNextRecord;
1170 }
1171
1173}
1174
1175VOID
1177{
1178 PDNS_CACHE_ENTRY DnsEntry = NULL, pThisEntry, pNextEntry;
1179
1181
1182 if (!DnsGetCacheDataTable(&DnsEntry))
1183 {
1185 return;
1186 }
1187
1188 if (DnsEntry == NULL)
1189 return;
1190
1191 pThisEntry = DnsEntry;
1192 while (pThisEntry != NULL)
1193 {
1194 pNextEntry = pThisEntry->pNext;
1195
1196 if (pThisEntry->wType1 != DNS_TYPE_ZERO)
1197 DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType1);
1198
1199 if (pThisEntry->wType2 != DNS_TYPE_ZERO)
1200 DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType2);
1201
1202 if (pThisEntry->pszName)
1203 LocalFree(pThisEntry->pszName);
1204 LocalFree(pThisEntry);
1205
1206 pThisEntry = pNextEntry;
1207 }
1208}
1209
1211{
1213}
1214
1215int wmain(int argc, wchar_t *argv[])
1216{
1217 BOOL DoUsage=FALSE;
1218 BOOL DoAll=FALSE;
1219 BOOL DoRelease=FALSE;
1220 BOOL DoRenew=FALSE;
1221 BOOL DoFlushdns=FALSE;
1222 BOOL DoRegisterdns=FALSE;
1223 BOOL DoDisplaydns=FALSE;
1224 BOOL DoShowclassid=FALSE;
1225 BOOL DoSetclassid=FALSE;
1226
1227 /* Initialize the Console Standard Streams */
1229
1232
1233 /* Parse command line for options we have been given. */
1234 if ((argc > 1) && (argv[1][0]=='/' || argv[1][0]=='-'))
1235 {
1236 if (!_tcsicmp(&argv[1][1], _T("?")))
1237 {
1238 DoUsage = TRUE;
1239 }
1240 else if (!_tcsnicmp(&argv[1][1], _T("ALL"), _tcslen(&argv[1][1])))
1241 {
1242 DoAll = TRUE;
1243 }
1244 else if (!_tcsnicmp(&argv[1][1], _T("RELEASE"), _tcslen(&argv[1][1])))
1245 {
1246 DoRelease = TRUE;
1247 }
1248 else if (!_tcsnicmp(&argv[1][1], _T("RENEW"), _tcslen(&argv[1][1])))
1249 {
1250 DoRenew = TRUE;
1251 }
1252 else if (!_tcsnicmp(&argv[1][1], _T("FLUSHDNS"), _tcslen(&argv[1][1])))
1253 {
1254 DoFlushdns = TRUE;
1255 }
1256 else if (!_tcsnicmp(&argv[1][1], _T("FLUSHREGISTERDNS"), _tcslen(&argv[1][1])))
1257 {
1258 DoRegisterdns = TRUE;
1259 }
1260 else if (!_tcsnicmp(&argv[1][1], _T("DISPLAYDNS"), _tcslen(&argv[1][1])))
1261 {
1262 DoDisplaydns = TRUE;
1263 }
1264 else if (!_tcsnicmp(&argv[1][1], _T("SHOWCLASSID"), _tcslen(&argv[1][1])))
1265 {
1266 DoShowclassid = TRUE;
1267 }
1268 else if (!_tcsnicmp(&argv[1][1], _T("SETCLASSID"), _tcslen(&argv[1][1])))
1269 {
1270 DoSetclassid = TRUE;
1271 }
1272 }
1273
1274 switch (argc)
1275 {
1276 case 1: /* Default behaviour if no options are given*/
1278 break;
1279 case 2: /* Process all the options that take no parameters */
1280 if (DoUsage)
1281 Usage();
1282 else if (DoAll)
1283 ShowInfo(TRUE, TRUE);
1284 else if (DoRelease)
1285 Release(NULL);
1286 else if (DoRenew)
1287 Renew(NULL);
1288 else if (DoFlushdns)
1289 FlushDns();
1290 else if (DoRegisterdns)
1291 RegisterDns();
1292 else if (DoDisplaydns)
1293 DisplayDns();
1294 else
1295 Usage();
1296 break;
1297 case 3: /* Process all the options that can have 1 parameter */
1298 if (DoRelease)
1299 Release(argv[2]);
1300 else if (DoRenew)
1301 Renew(argv[2]);
1302 else if (DoShowclassid)
1303 _tprintf(_T("\nSorry /showclassid adapter is not implemented yet\n"));
1304 else if (DoSetclassid)
1305 _tprintf(_T("\nSorry /setclassid adapter is not implemented yet\n"));
1306 else
1307 Usage();
1308 break;
1309 case 4: /* Process all the options that can have 2 parameters */
1310 if (DoSetclassid)
1311 _tprintf(_T("\nSorry /setclassid adapter [classid]is not implemented yet\n"));
1312 else
1313 Usage();
1314 break;
1315 default:
1316 Usage();
1317 }
1318
1319 return 0;
1320}
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:77
#define IDS_IPROUTINGNO
Definition: resource.h:11
#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_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:75
#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:70
#define IDS_PRIMARYWINSSERVER
Definition: resource.h:31
#define IDS_NODETYPEBCAST
Definition: resource.h:6
#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:76
#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:79
#define IDS_DNSFLUSHERROR
Definition: resource.h:72
#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:73
#define IDS_DNSTYPEMX
Definition: resource.h:63
#define IDS_DHCPNOTCONNECTED
Definition: resource.h:74
#define IDS_DNSNONAME
Definition: resource.h:71
#define IDS_EMPTYLINE
Definition: resource.h:16
#define IDS_DNSTYPESOA1
Definition: resource.h:60
#define IDS_DHCPRELEASEERROR
Definition: resource.h:78
#define IDS_NODETYPEHYBRID
Definition: resource.h:9
HKEY hClassKey
Definition: umpnpmgr.c:45
#define RegCloseKey(hKey)
Definition: registry.h:49
_In_ BOOLEAN Release
Definition: cdrom.h:920
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_SUCCESS
Definition: deptool.c:10
static BOOL bFoundAdapter
Definition: deskmon.c:13
#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 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
#define swprintf
Definition: precomp.h:40
__kernel_time_t time_t
Definition: linux.h:252
BOOL bConnected
Definition: fdebug.c:27
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
#define printf
Definition: freeldr.h:97
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
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
#define _tprintf
Definition: tchar.h:506
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
VOID Renew(LPWSTR pszAdapterName)
Definition: ipconfig.c:931
VOID GetInterfaceFriendlyName(_In_ LPWSTR lpDeviceName, _In_ DWORD cchFriendlyNameLength, _Out_ LPWSTR pszFriendlyName)
Definition: ipconfig.c:264
_Ret_opt_z_ PTSTR timeToStr(_In_ time_t TimeStamp)
Definition: ipconfig.c:137
VOID RegisterDns(VOID)
Definition: ipconfig.c:1040
VOID ShowInfo(BOOL bShowHeader, BOOL bAll)
Definition: ipconfig.c:532
VOID FlushDns(VOID)
Definition: ipconfig.c:1024
RECORDTYPE TypeArray[]
Definition: ipconfig.c:45
VOID DoFormatMessage(LONG ErrorCode)
Definition: ipconfig.c:200
HANDLE ProcessHeap
Definition: ipconfig.c:43
LPTSTR GetRecordTypeName(WORD wType)
Definition: ipconfig.c:105
struct _RECORDTYPE * PRECORDTYPE
static VOID PrintAdapterDescription(LPSTR lpClass)
Definition: ipconfig.c:308
struct _RECORDTYPE RECORDTYPE
HINSTANCE hInstance
Definition: ipconfig.c:42
static VOID BuildAdapterMap(PIP_ADAPTER_INDEX_MAP pAdapterMap, PIP_ADAPTER_INFO pAdapterInfo)
Definition: ipconfig.c:814
PCHAR PrintMacAddr(PBYTE Mac)
Definition: ipconfig.c:125
static VOID PrintNodeType(_In_ UINT NodeType)
Definition: ipconfig.c:455
VOID DisplayDns(VOID)
Definition: ipconfig.c:1176
static VOID PrintAdapterTypeAndName(PIP_ADAPTER_INFO pAdapterInfo)
Definition: ipconfig.c:484
static BOOL MatchWildcard(_In_ PWSTR pszExpression, _In_ PWSTR pszName)
Definition: ipconfig.c:767
VOID GetAdapterFriendlyName(_In_ LPSTR lpClass, _In_ DWORD cchFriendlyNameLength, _Out_ LPWSTR pszFriendlyName)
Definition: ipconfig.c:224
static VOID DisplayDnsRecord(PWSTR pszName, WORD wType)
Definition: ipconfig.c:1048
DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
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)
DWORD WINAPI IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
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 MIXED_NODETYPE
Definition: iptypes.h:38
#define HYBRID_NODETYPE
Definition: iptypes.h:39
struct _IP_PER_ADAPTER_INFO * PIP_PER_ADAPTER_INFO
#define PEER_TO_PEER_NODETYPE
Definition: iptypes.h:37
#define BROADCAST_NODETYPE
Definition: iptypes.h:36
#define _stprintf
Definition: utility.h:124
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#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)
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define KEY_READ
Definition: nt_native.h:1023
#define LOCALE_USER_DEFAULT
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
static const WCHAR szName[]
Definition: powrprof.c:45
int wmain()
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_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
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:84
UINT EnableRouting
Definition: iptypes.h:87
char HostName[MAX_HOSTNAME_LEN+4]
Definition: iptypes.h:81
UINT NodeType
Definition: iptypes.h:85
char DomainName[MAX_DOMAIN_NAME_LEN+4]
Definition: iptypes.h:82
char String[4 *4]
Definition: iptypes.h:42
Definition: windns_undoc.h:9
struct _DNS_CACHE_ENTRY * pNext
Definition: windns_undoc.h:10
struct _DnsRecordW * pNext
Definition: windns.h:598
WCHAR Name[MAX_ADAPTER_NAME]
Definition: ipexport.h:147
IP_ADDR_STRING SecondaryWinsServer
Definition: iptypes.h:68
IP_ADDR_STRING IpAddressList
Definition: iptypes.h:63
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]
Definition: iptypes.h:58
IP_ADDR_STRING DhcpServer
Definition: iptypes.h:65
char AdapterName[MAX_ADAPTER_NAME_LENGTH+4]
Definition: iptypes.h:55
time_t LeaseObtained
Definition: iptypes.h:69
IP_ADDR_STRING GatewayList
Definition: iptypes.h:64
time_t LeaseExpires
Definition: iptypes.h:70
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:53
IP_ADDR_STRING PrimaryWinsServer
Definition: iptypes.h:67
UINT DhcpEnabled
Definition: iptypes.h:61
struct _IP_ADDR_STRING * Next
Definition: iptypes.h:46
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
IP_MASK_STRING IpMask
Definition: iptypes.h:48
UINT AutoconfigEnabled
Definition: iptypes.h:74
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
DWORD dwIndex
Definition: ifmib.h:38
WORD wRecordType
Definition: ipconfig.c:36
LPTSTR pszRecordName
Definition: ipconfig.c:37
WORD wYear
Definition: winbase.h:930
WORD wMonth
Definition: winbase.h:931
WORD wHour
Definition: winbase.h:934
WORD wSecond
Definition: winbase.h:936
WORD wMinute
Definition: winbase.h:935
WORD wDay
Definition: winbase.h:933
Definition: inet.h:67
Definition: tcpip.h:126
u_long S_addr
Definition: tcpip.h:131
union in_addr::@1034 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
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
#define _T(x)
Definition: vfdio.h:22
int ret
#define FormatMessage
Definition: winbase.h:3820
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:446
#define GetModuleHandle
Definition: winbase.h:3852
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:449
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:445
#define lstrlen
Definition: winbase.h:3901
#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 PDNS_RECORD
Definition: windns.h:636
#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
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define ERROR_NO_DATA
Definition: winerror.h:284
#define DNS_INFO_NO_RECORDS
Definition: winerror.h:1861
#define DNS_ERROR_RCODE_NAME_ERROR
Definition: winerror.h:1850
#define GetTimeFormat
Definition: winnls.h:1245
#define DATE_LONGDATE
Definition: winnls.h:199
#define GetDateFormat
Definition: winnls.h:1240
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegEnumKeyEx
Definition: winreg.h:510
#define wsprintf
Definition: winuser.h:5877
char TCHAR
Definition: xmlstorage.h:189
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
CHAR * PTSTR
Definition: xmlstorage.h:191
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define _tcsnicmp
Definition: xmlstorage.h:207
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define _tcslen
Definition: xmlstorage.h:198
#define _tcsicmp
Definition: xmlstorage.h:205
char CHAR
Definition: xmlstorage.h:175