ReactOS  0.4.15-dev-499-g1f31905
ipconfig.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <winreg.h>
#include <stdio.h>
#include <tchar.h>
#include <time.h>
#include <iphlpapi.h>
#include <ndk/rtlfuncs.h>
#include <inaddr.h>
#include <windns.h>
#include <windns_undoc.h>
#include "resource.h"
Include dependency graph for ipconfig.c:

Go to the source code of this file.

Classes

struct  _RECORDTYPE
 

Macros

#define WIN32_NO_STATUS
 
#define GUID_LEN   40
 

Typedefs

typedef struct _RECORDTYPE RECORDTYPE
 
typedef struct _RECORDTYPEPRECORDTYPE
 

Functions

LPTSTR GetRecordTypeName (WORD wType)
 
int LoadStringAndOem (HINSTANCE hInst, UINT uID, LPTSTR szNode, int byteSize)
 
LPTSTR GetNodeTypeName (UINT NodeType)
 
LPTSTR GetInterfaceTypeName (UINT InterfaceType)
 
PTCHAR PrintMacAddr (PBYTE Mac)
 
VOID DoFormatMessage (LONG ErrorCode)
 
LPTSTR GetConnectionType (LPTSTR lpClass)
 
LPTSTR GetConnectionDescription (LPTSTR lpClass)
 
VOID ShowInfo (BOOL bAll)
 
VOID Release (LPTSTR Index)
 
VOID Renew (LPTSTR Index)
 
VOID FlushDns (VOID)
 
VOID RegisterDns (VOID)
 
static VOID DisplayDnsRecord (PWSTR pszName, WORD wType)
 
VOID DisplayDns (VOID)
 
VOID Usage (VOID)
 
int main (int argc, char *argv[])
 

Variables

HINSTANCE hInstance
 
HANDLE ProcessHeap
 
RECORDTYPE TypeArray []
 

Macro Definition Documentation

◆ GUID_LEN

#define GUID_LEN   40

Definition at line 38 of file ipconfig.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 15 of file ipconfig.c.

Typedef Documentation

◆ PRECORDTYPE

◆ RECORDTYPE

Function Documentation

◆ DisplayDns()

VOID DisplayDns ( VOID  )

Definition at line 976 of file ipconfig.c.

977 {
978  PDNS_CACHE_ENTRY DnsEntry = NULL, pThisEntry, pNextEntry;
979 
980  _tprintf(_T("\nReactOS IP Configuration\n\n"));
981 
982  if (!DnsGetCacheDataTable(&DnsEntry))
983  {
985  return;
986  }
987 
988  if (DnsEntry == NULL)
989  return;
990 
991  pThisEntry = DnsEntry;
992  while (pThisEntry != NULL)
993  {
994  pNextEntry = pThisEntry->pNext;
995 
996  if (pThisEntry->wType1 != 0)
997  DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType1);
998 
999  if (pThisEntry->wType2 != 0)
1000  DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType2);
1001 
1002  if (pThisEntry->pszName)
1003  LocalFree(pThisEntry->pszName);
1004  LocalFree(pThisEntry);
1005 
1006  pThisEntry = pNextEntry;
1007  }
1008 }
#define _tprintf
Definition: tchar.h:506
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _DNS_CACHE_ENTRY * pNext
Definition: windns_undoc.h:10
Definition: windns_undoc.h:8
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
BOOL WINAPI DnsGetCacheDataTable(_Out_ PDNS_CACHE_ENTRY *DnsCache)
Definition: query.c:956
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static VOID DisplayDnsRecord(PWSTR pszName, WORD wType)
Definition: ipconfig.c:858
VOID DoFormatMessage(LONG ErrorCode)
Definition: ipconfig.c:241

Referenced by main().

◆ DisplayDnsRecord()

static VOID DisplayDnsRecord ( PWSTR  pszName,
WORD  wType 
)
static

Definition at line 858 of file ipconfig.c.

861 {
862  PDNS_RECORDW pQueryResults = NULL, pThisRecord, pNextRecord;
863  WCHAR szBuffer[48];
864  IN_ADDR Addr4;
865  IN6_ADDR Addr6;
866  DNS_STATUS Status;
867 
868  pQueryResults = NULL;
869  Status = DnsQuery_W(pszName,
870  wType,
872  NULL,
873  (PDNS_RECORD *)&pQueryResults,
874  NULL);
875  if (Status != ERROR_SUCCESS)
876  {
878  {
879  _tprintf(_T("\t%S\n"), pszName);
880  _tprintf(_T("\t----------------------------------------\n"));
881  _tprintf(_T("\tName does not exist\n\n"));
882  }
883  else if (Status == DNS_INFO_NO_RECORDS)
884  {
885  _tprintf(_T("\t%S\n"), pszName);
886  _tprintf(_T("\t----------------------------------------\n"));
887  _tprintf(_T("\tNo records of type %s\n\n"), GetRecordTypeName(wType));
888  }
889  return;
890  }
891 
892  _tprintf(_T("\t%S\n"), pszName);
893  _tprintf(_T("\t----------------------------------------\n"));
894 
895  pThisRecord = pQueryResults;
896  while (pThisRecord != NULL)
897  {
898  pNextRecord = pThisRecord->pNext;
899 
900  _tprintf(_T("\tRecord Name . . . . . : %S\n"), pThisRecord->pName);
901  _tprintf(_T("\tRecord Type . . . . . : %hu\n"), pThisRecord->wType);
902  _tprintf(_T("\tTime To Live. . . . . : %lu\n"), pThisRecord->dwTtl);
903  _tprintf(_T("\tData Length . . . . . : %hu\n"), pThisRecord->wDataLength);
904 
905  switch (pThisRecord->Flags.S.Section)
906  {
907  case DnsSectionQuestion:
908  _tprintf(_T("\tSection . . . . . . . : Question\n"));
909  break;
910 
911  case DnsSectionAnswer:
912  _tprintf(_T("\tSection . . . . . . . : Answer\n"));
913  break;
914 
915  case DnsSectionAuthority:
916  _tprintf(_T("\tSection . . . . . . . : Authority\n"));
917  break;
918 
920  _tprintf(_T("\tSection . . . . . . . : Additional\n"));
921  break;
922  }
923 
924  switch (pThisRecord->wType)
925  {
926  case DNS_TYPE_A:
927  Addr4.S_un.S_addr = pThisRecord->Data.A.IpAddress;
928  RtlIpv4AddressToStringW(&Addr4, szBuffer);
929  _tprintf(_T("\tA (Host) Record . . . : %S\n"), szBuffer);
930  break;
931 
932  case DNS_TYPE_NS:
933  _tprintf(_T("\tNS Record . . . . . . : %S\n"), pThisRecord->Data.NS.pNameHost);
934  break;
935 
936  case DNS_TYPE_CNAME:
937  _tprintf(_T("\tCNAME Record. . . . . : %S\n"), pThisRecord->Data.CNAME.pNameHost);
938  break;
939 
940  case DNS_TYPE_SOA:
941  _tprintf(_T("\tSOA Record. . . . . . : \n"));
942  break;
943 
944  case DNS_TYPE_PTR:
945  _tprintf(_T("\tPTR Record. . . . . . : %S\n"), pThisRecord->Data.PTR.pNameHost);
946  break;
947 
948  case DNS_TYPE_MX:
949  _tprintf(_T("\tMX Record . . . . . . : \n"));
950  break;
951 
952  case DNS_TYPE_AAAA:
953  RtlCopyMemory(&Addr6, &pThisRecord->Data.AAAA.Ip6Address, sizeof(IN6_ADDR));
954  RtlIpv6AddressToStringW(&Addr6, szBuffer);
955  _tprintf(_T("\tAAAA Record . . . . . : %S\n"), szBuffer);
956  break;
957 
958  case DNS_TYPE_ATMA:
959  _tprintf(_T("\tATMA Record . . . . . : \n"));
960  break;
961 
962  case DNS_TYPE_SRV:
963  _tprintf(_T("\tSRV Record. . . . . . : \n"));
964  break;
965  }
966  _tprintf(_T("\n\n"));
967 
968  pThisRecord = pNextRecord;
969  }
970 
972 }
#define DNS_TYPE_ATMA
Definition: windns.h:74
#define _tprintf
Definition: tchar.h:506
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define ERROR_SUCCESS
Definition: deptool.c:10
NTSYSAPI PWSTR NTAPI RtlIpv4AddressToStringW(_In_ const struct in_addr *Addr, _Out_writes_(16) PWCHAR S)
#define DNS_TYPE_AAAA
Definition: windns.h:68
#define DNS_TYPE_A
Definition: windns.h:41
#define DNS_INFO_NO_RECORDS
Definition: winerror.h:1861
VOID WINAPI DnsRecordListFree(PDNS_RECORD list, DNS_FREE_TYPE type)
Definition: record.c:526
#define DNS_TYPE_CNAME
Definition: windns.h:45
#define DNS_TYPE_SOA
Definition: windns.h:46
#define DNS_ERROR_RCODE_NAME_ERROR
Definition: winerror.h:1850
DNS_STATUS WINAPI DnsQuery_W(LPCWSTR Name, WORD Type, DWORD Options, PVOID Extra, PDNS_RECORD *QueryResultSet, PVOID *Reserved)
Definition: query.c:469
smooth NULL
Definition: ftsmooth.c:416
LPTSTR GetRecordTypeName(WORD wType)
Definition: ipconfig.c:103
#define _T(x)
Definition: vfdio.h:22
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DNS_TYPE_PTR
Definition: windns.h:52
Definition: tcpip.h:125
#define DNS_TYPE_MX
Definition: windns.h:55
Status
Definition: gdiplustypes.h:24
u_long S_addr
Definition: tcpip.h:131
#define DNS_TYPE_SRV
Definition: windns.h:73
#define DNS_QUERY_NO_WIRE_QUERY
Definition: windns.h:13
#define DNS_TYPE_NS
Definition: windns.h:42
struct _DnsRecordW * pNext
Definition: windns.h:598
union in_addr::@1019 S_un
#define PDNS_RECORD
Definition: windns.h:636
NTSYSAPI PWSTR NTAPI RtlIpv6AddressToStringW(_In_ const struct in6_addr *Addr, _Out_writes_(46) PWSTR S)

Referenced by DisplayDns().

◆ DoFormatMessage()

VOID DoFormatMessage ( LONG  ErrorCode)

Definition at line 241 of file ipconfig.c.

242 {
243  LPVOID lpMsgBuf;
244  //DWORD ErrorCode;
245 
246  if (ErrorCode == 0)
248 
252  NULL,
253  ErrorCode,
254  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
255  (LPTSTR) &lpMsgBuf,
256  0,
257  NULL))
258  {
259  _tprintf(_T("%s"), (LPTSTR)lpMsgBuf);
260  LocalFree(lpMsgBuf);
261  }
262 }
#define _tprintf
Definition: tchar.h:506
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
#define _T(x)
Definition: vfdio.h:22
#define FormatMessage
Definition: winbase.h:3635
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:401
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define MAKELANGID(p, s)
Definition: nls.h:15

Referenced by DisplayDns(), FlushDns(), GetConnectionDescription(), Release(), Renew(), and ShowInfo().

◆ FlushDns()

VOID FlushDns ( VOID  )

Definition at line 839 of file ipconfig.c.

840 {
841  _tprintf(_T("\nReactOS IP Configuration\n\n"));
842 
843  if (DnsFlushResolverCache())
844  _tprintf(_T("The DNS Resolver Cache has been deleted.\n"));
845  else
847 }
#define _tprintf
Definition: tchar.h:506
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define _T(x)
Definition: vfdio.h:22
BOOL WINAPI DnsFlushResolverCache(VOID)
Definition: query.c:933
VOID DoFormatMessage(LONG ErrorCode)
Definition: ipconfig.c:241

Referenced by main().

◆ GetConnectionDescription()

LPTSTR GetConnectionDescription ( LPTSTR  lpClass)

Definition at line 341 of file ipconfig.c.

342 {
343  HKEY hBaseKey = NULL;
344  HKEY hClassKey = NULL;
345  LPTSTR lpKeyClass = NULL;
346  LPTSTR lpConDesc = NULL;
347  LPTSTR lpPath = NULL;
348  TCHAR szPrePath[] = _T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\");
349  DWORD dwType;
350  DWORD dwDataSize;
351  INT i;
352 
354  szPrePath,
355  0,
356  KEY_READ,
357  &hBaseKey) != ERROR_SUCCESS)
358  {
359  return NULL;
360  }
361 
362  for (i = 0; ; i++)
363  {
364  DWORD PathSize;
365  LONG Status;
366  TCHAR szName[10];
367  DWORD NameLen = 9;
368 
369  if ((Status = RegEnumKeyEx(hBaseKey,
370  i,
371  szName,
372  &NameLen,
373  NULL,
374  NULL,
375  NULL,
376  NULL)) != ERROR_SUCCESS)
377  {
379  {
381  lpConDesc = NULL;
382  goto CLEANUP;
383  }
384  else
385  continue;
386  }
387 
388  PathSize = lstrlen(szPrePath) + lstrlen(szName) + 1;
389  lpPath = (LPTSTR)HeapAlloc(ProcessHeap,
390  0,
391  PathSize * sizeof(TCHAR));
392  if (lpPath == NULL)
393  goto CLEANUP;
394 
395  wsprintf(lpPath, _T("%s%s"), szPrePath, szName);
396 
397  //MessageBox(NULL, lpPath, NULL, 0);
398 
400  lpPath,
401  0,
402  KEY_READ,
404  {
405  goto CLEANUP;
406  }
407 
408  HeapFree(ProcessHeap, 0, lpPath);
409  lpPath = NULL;
410 
412  _T("NetCfgInstanceId"),
413  NULL,
414  &dwType,
415  NULL,
416  &dwDataSize) == ERROR_SUCCESS)
417  {
418  lpKeyClass = (LPTSTR)HeapAlloc(ProcessHeap,
419  0,
420  dwDataSize);
421  if (lpKeyClass == NULL)
422  goto CLEANUP;
423 
425  _T("NetCfgInstanceId"),
426  NULL,
427  &dwType,
428  (PBYTE)lpKeyClass,
429  &dwDataSize) != ERROR_SUCCESS)
430  {
431  HeapFree(ProcessHeap, 0, lpKeyClass);
432  lpKeyClass = NULL;
433  continue;
434  }
435  }
436  else
437  continue;
438 
439  if (!lstrcmp(lpClass, lpKeyClass))
440  {
441  HeapFree(ProcessHeap, 0, lpKeyClass);
442  lpKeyClass = NULL;
443 
445  _T("DriverDesc"),
446  NULL,
447  &dwType,
448  NULL,
449  &dwDataSize) == ERROR_SUCCESS)
450  {
451  lpConDesc = (LPTSTR)HeapAlloc(ProcessHeap,
452  0,
453  dwDataSize);
454  if (lpConDesc == NULL)
455  goto CLEANUP;
456 
458  _T("DriverDesc"),
459  NULL,
460  &dwType,
461  (PBYTE)lpConDesc,
462  &dwDataSize) != ERROR_SUCCESS)
463  {
464  HeapFree(ProcessHeap, 0, lpConDesc);
465  lpConDesc = NULL;
466  goto CLEANUP;
467  }
468  }
469  else
470  {
471  lpConDesc = NULL;
472  }
473 
474  break;
475  }
476  }
477 
478 CLEANUP:
479  if (hBaseKey != NULL)
480  RegCloseKey(hBaseKey);
481  if (hClassKey != NULL)
483  if (lpPath != NULL)
484  HeapFree(ProcessHeap, 0, lpPath);
485  if (lpKeyClass != NULL)
486  HeapFree(ProcessHeap, 0, lpKeyClass);
487 
488  return lpConDesc;
489 }
#define RegQueryValueEx
Definition: winreg.h:524
#define CLEANUP
Definition: ntuser.h:5
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
#define KEY_READ
Definition: nt_native.h:1023
int32_t INT
Definition: typedefs.h:57
CHAR * LPTSTR
Definition: xmlstorage.h:192
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
HKEY hClassKey
Definition: umpnpmgr.c:45
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HANDLE ProcessHeap
Definition: ipconfig.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegEnumKeyEx
Definition: winreg.h:510
#define lstrcmp
Definition: winbase.h:3712
Status
Definition: gdiplustypes.h:24
#define RegOpenKeyEx
Definition: winreg.h:520
#define lstrlen
Definition: winbase.h:3716
static const WCHAR szName[]
Definition: msipriv.h:1194
#define wsprintf
Definition: winuser.h:5840
BYTE * PBYTE
Definition: pedump.c:66
#define HeapFree(x, y, z)
Definition: compat.h:403
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
VOID DoFormatMessage(LONG ErrorCode)
Definition: ipconfig.c:241

Referenced by ShowInfo().

◆ GetConnectionType()

LPTSTR GetConnectionType ( LPTSTR  lpClass)

Definition at line 265 of file ipconfig.c.

266 {
267  HKEY hKey = NULL;
268  LPTSTR ConType = NULL;
269  LPTSTR ConTypeTmp = NULL;
270  TCHAR Path[256];
271  LPTSTR PrePath = _T("SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\");
272  LPTSTR PostPath = _T("\\Connection");
273  DWORD PathSize;
274  DWORD dwType;
275  DWORD dwDataSize;
276 
277  /* don't overflow the buffer */
278  PathSize = lstrlen(PrePath) + lstrlen(lpClass) + lstrlen(PostPath) + 1;
279  if (PathSize >= 255)
280  return NULL;
281 
282  wsprintf(Path, _T("%s%s%s"), PrePath, lpClass, PostPath);
283 
285  Path,
286  0,
287  KEY_READ,
288  &hKey) == ERROR_SUCCESS)
289  {
290  if (RegQueryValueEx(hKey,
291  _T("Name"),
292  NULL,
293  &dwType,
294  NULL,
295  &dwDataSize) == ERROR_SUCCESS)
296  {
297  ConTypeTmp = (LPTSTR)HeapAlloc(ProcessHeap,
298  0,
299  dwDataSize);
300 
301  if (ConTypeTmp == NULL)
302  return NULL;
303 
304  ConType = (LPTSTR)HeapAlloc(ProcessHeap,
305  0,
306  dwDataSize);
307 
308  if (ConType == NULL)
309  {
310  HeapFree(ProcessHeap, 0, ConTypeTmp);
311  return NULL;
312  }
313 
314  if (RegQueryValueEx(hKey,
315  _T("Name"),
316  NULL,
317  &dwType,
318  (PBYTE)ConTypeTmp,
319  &dwDataSize) != ERROR_SUCCESS)
320  {
322  0,
323  ConType);
324 
325  ConType = NULL;
326  }
327 
328  if (ConType)
329  CharToOem(ConTypeTmp, ConType);
330  HeapFree(ProcessHeap, 0, ConTypeTmp);
331  }
332  }
333 
334  if (hKey != NULL)
335  RegCloseKey(hKey);
336 
337  return ConType;
338 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
CHAR * LPTSTR
Definition: xmlstorage.h:192
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HANDLE ProcessHeap
Definition: ipconfig.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegOpenKeyEx
Definition: winreg.h:520
#define lstrlen
Definition: winbase.h:3716
PRTL_UNICODE_STRING_BUFFER Path
#define CharToOem
Definition: winuser.h:5718
#define wsprintf
Definition: winuser.h:5840
BYTE * PBYTE
Definition: pedump.c:66
#define HeapFree(x, y, z)
Definition: compat.h:403
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShowInfo().

◆ GetInterfaceTypeName()

LPTSTR GetInterfaceTypeName ( UINT  InterfaceType)

Definition at line 178 of file ipconfig.c.

179 {
180  static TCHAR szIntType[25];
181 
182  switch (InterfaceType)
183  {
184  case MIB_IF_TYPE_OTHER:
185  if (!LoadStringAndOem(hInstance, IDS_OTHER, szIntType, sizeof(szIntType)))
186  return NULL;
187  break;
188 
190  if (!LoadStringAndOem(hInstance, IDS_ETH, szIntType, sizeof(szIntType)))
191  return NULL;
192  break;
193 
195  if (!LoadStringAndOem(hInstance, IDS_TOKEN, szIntType, sizeof(szIntType)))
196  return NULL;
197  break;
198 
199  case MIB_IF_TYPE_FDDI:
200  if (!LoadStringAndOem(hInstance, IDS_FDDI, szIntType, sizeof(szIntType)))
201  return NULL;
202  break;
203 
204  case MIB_IF_TYPE_PPP:
205  if (!LoadStringAndOem(hInstance, IDS_PPP, szIntType, sizeof(szIntType)))
206  return NULL;
207  break;
208 
210  if (!LoadStringAndOem(hInstance, IDS_LOOP, szIntType, sizeof(szIntType)))
211  return NULL;
212  break;
213 
214  case MIB_IF_TYPE_SLIP:
215  if (!LoadStringAndOem(hInstance, IDS_SLIP, szIntType, sizeof(szIntType)))
216  return NULL;
217  break;
218 
219  default:
220  if (!LoadStringAndOem(hInstance, IDS_UNKNOWN, szIntType, sizeof(szIntType)))
221  return NULL;
222  break;
223  }
224 
225  return szIntType;
226 }
#define IDS_PPP
Definition: resource.h:17
#define MIB_IF_TYPE_OTHER
Definition: ipifcons.h:222
#define IDS_FDDI
Definition: resource.h:16
#define IDS_TOKEN
Definition: resource.h:15
#define MIB_IF_TYPE_SLIP
Definition: ipifcons.h:228
#define MIB_IF_TYPE_LOOPBACK
Definition: ipifcons.h:227
#define MIB_IF_TYPE_FDDI
Definition: ipifcons.h:225
smooth NULL
Definition: ftsmooth.c:416
#define IDS_UNKNOWN
Definition: resource.h:7
#define IDS_OTHER
Definition: resource.h:13
char TCHAR
Definition: xmlstorage.h:189
#define MIB_IF_TYPE_PPP
Definition: ipifcons.h:226
#define MIB_IF_TYPE_ETHERNET
Definition: ipifcons.h:223
#define MIB_IF_TYPE_TOKENRING
Definition: ipifcons.h:224
HINSTANCE hInstance
Definition: ipconfig.c:40
#define IDS_SLIP
Definition: resource.h:19
#define IDS_LOOP
Definition: resource.h:18
int LoadStringAndOem(HINSTANCE hInst, UINT uID, LPTSTR szNode, int byteSize)
Definition: ipconfig.c:122
#define IDS_ETH
Definition: resource.h:14

Referenced by ShowInfo().

◆ GetNodeTypeName()

LPTSTR GetNodeTypeName ( UINT  NodeType)

Definition at line 142 of file ipconfig.c.

143 {
144  static TCHAR szNode[14];
145 
146  switch (NodeType)
147  {
148  case 1:
149  if (!LoadStringAndOem(hInstance, IDS_BCAST, szNode, sizeof(szNode)))
150  return NULL;
151  break;
152 
153  case 2:
154  if (!LoadStringAndOem(hInstance, IDS_P2P, szNode, sizeof(szNode)))
155  return NULL;
156  break;
157 
158  case 4:
159  if (!LoadStringAndOem(hInstance, IDS_MIXED, szNode, sizeof(szNode)))
160  return NULL;
161  break;
162 
163  case 8:
164  if (!LoadStringAndOem(hInstance, IDS_HYBRID, szNode, sizeof(szNode)))
165  return NULL;
166  break;
167 
168  default :
169  if (!LoadStringAndOem(hInstance, IDS_UNKNOWN, szNode, sizeof(szNode)))
170  return NULL;
171  break;
172  }
173 
174  return szNode;
175 }
#define IDS_P2P
Definition: resource.h:8
#define IDS_HYBRID
Definition: resource.h:10
#define IDS_BCAST
Definition: resource.h:7
smooth NULL
Definition: ftsmooth.c:416
NodeType
Definition: Node.h:5
#define IDS_UNKNOWN
Definition: resource.h:7
char TCHAR
Definition: xmlstorage.h:189
HINSTANCE hInstance
Definition: ipconfig.c:40
#define IDS_MIXED
Definition: resource.h:9
int LoadStringAndOem(HINSTANCE hInst, UINT uID, LPTSTR szNode, int byteSize)
Definition: ipconfig.c:122

Referenced by ShowInfo().

◆ GetRecordTypeName()

LPTSTR GetRecordTypeName ( WORD  wType)

Definition at line 103 of file ipconfig.c.

104 {
105  static TCHAR szType[8];
106  INT i;
107 
108  for (i = 0; ; i++)
109  {
110  if (TypeArray[i].pszRecordName == NULL)
111  break;
112 
113  if (TypeArray[i].wRecordType == wType)
114  return TypeArray[i].pszRecordName;
115  }
116 
117  _stprintf(szType, _T("%hu"), wType);
118 
119  return szType;
120 }
LPTSTR pszRecordName
Definition: ipconfig.c:35
int32_t INT
Definition: typedefs.h:57
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
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define _stprintf
Definition: utility.h:124
static const WCHAR szType[]
Definition: table.c:81
RECORDTYPE TypeArray[]
Definition: ipconfig.c:43

Referenced by DisplayDnsRecord().

◆ LoadStringAndOem()

int LoadStringAndOem ( HINSTANCE  hInst,
UINT  uID,
LPTSTR  szNode,
int  byteSize 
)

Definition at line 122 of file ipconfig.c.

126 {
127  TCHAR *szTmp;
128  int res;
129 
130  szTmp = (LPTSTR)HeapAlloc(ProcessHeap, 0, byteSize);
131  if (szTmp == NULL)
132  {
133  return 0;
134  }
135 
136  res = LoadString(hInst, uID, szTmp, byteSize);
137  CharToOem(szTmp, szNode);
139  return res;
140 }
char szTmp[518]
CHAR * LPTSTR
Definition: xmlstorage.h:192
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HANDLE ProcessHeap
Definition: ipconfig.c:41
HINSTANCE hInst
Definition: dxdiag.c:13
#define CharToOem
Definition: winuser.h:5718
GLuint res
Definition: glext.h:9613
#define HeapFree(x, y, z)
Definition: compat.h:403
#define LoadString
Definition: winuser.h:5794

Referenced by GetInterfaceTypeName(), GetNodeTypeName(), and Usage().

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 1045 of file ipconfig.c.

1046 {
1047  BOOL DoUsage=FALSE;
1048  BOOL DoAll=FALSE;
1049  BOOL DoRelease=FALSE;
1050  BOOL DoRenew=FALSE;
1051  BOOL DoFlushdns=FALSE;
1052  BOOL DoRegisterdns=FALSE;
1053  BOOL DoDisplaydns=FALSE;
1054  BOOL DoShowclassid=FALSE;
1055  BOOL DoSetclassid=FALSE;
1056 
1059 
1060  /* Parse command line for options we have been given. */
1061  if ((argc > 1) && (argv[1][0]=='/' || argv[1][0]=='-'))
1062  {
1063  if (!_tcsicmp(&argv[1][1], _T("?")))
1064  {
1065  DoUsage = TRUE;
1066  }
1067  else if (!_tcsnicmp(&argv[1][1], _T("ALL"), _tcslen(&argv[1][1])))
1068  {
1069  DoAll = TRUE;
1070  }
1071  else if (!_tcsnicmp(&argv[1][1], _T("RELEASE"), _tcslen(&argv[1][1])))
1072  {
1073  DoRelease = TRUE;
1074  }
1075  else if (!_tcsnicmp(&argv[1][1], _T("RENEW"), _tcslen(&argv[1][1])))
1076  {
1077  DoRenew = TRUE;
1078  }
1079  else if (!_tcsnicmp(&argv[1][1], _T("FLUSHDNS"), _tcslen(&argv[1][1])))
1080  {
1081  DoFlushdns = TRUE;
1082  }
1083  else if (!_tcsnicmp(&argv[1][1], _T("FLUSHREGISTERDNS"), _tcslen(&argv[1][1])))
1084  {
1085  DoRegisterdns = TRUE;
1086  }
1087  else if (!_tcsnicmp(&argv[1][1], _T("DISPLAYDNS"), _tcslen(&argv[1][1])))
1088  {
1089  DoDisplaydns = TRUE;
1090  }
1091  else if (!_tcsnicmp(&argv[1][1], _T("SHOWCLASSID"), _tcslen(&argv[1][1])))
1092  {
1093  DoShowclassid = TRUE;
1094  }
1095  else if (!_tcsnicmp(&argv[1][1], _T("SETCLASSID"), _tcslen(&argv[1][1])))
1096  {
1097  DoSetclassid = TRUE;
1098  }
1099  }
1100 
1101  switch (argc)
1102  {
1103  case 1: /* Default behaviour if no options are given*/
1104  ShowInfo(FALSE);
1105  break;
1106  case 2: /* Process all the options that take no parameters */
1107  if (DoUsage)
1108  Usage();
1109  else if (DoAll)
1110  ShowInfo(TRUE);
1111  else if (DoRelease)
1112  Release(NULL);
1113  else if (DoRenew)
1114  Renew(NULL);
1115  else if (DoFlushdns)
1116  FlushDns();
1117  else if (DoRegisterdns)
1118  RegisterDns();
1119  else if (DoDisplaydns)
1120  DisplayDns();
1121  else
1122  Usage();
1123  break;
1124  case 3: /* Process all the options that can have 1 parameter */
1125  if (DoRelease)
1126  _tprintf(_T("\nSorry /release [adapter] is not implemented yet\n"));
1127  //Release(argv[2]);
1128  else if (DoRenew)
1129  _tprintf(_T("\nSorry /renew [adapter] is not implemented yet\n"));
1130  else if (DoShowclassid)
1131  _tprintf(_T("\nSorry /showclassid adapter is not implemented yet\n"));
1132  else if (DoSetclassid)
1133  _tprintf(_T("\nSorry /setclassid adapter is not implemented yet\n"));
1134  else
1135  Usage();
1136  break;
1137  case 4: /* Process all the options that can have 2 parameters */
1138  if (DoSetclassid)
1139  _tprintf(_T("\nSorry /setclassid adapter [classid]is not implemented yet\n"));
1140  else
1141  Usage();
1142  break;
1143  default:
1144  Usage();
1145  }
1146 
1147  return 0;
1148 }
static int argc
Definition: ServiceArgs.c:12
#define _tprintf
Definition: tchar.h:506
#define TRUE
Definition: types.h:120
VOID Usage(VOID)
Definition: ipconfig.c:1010
#define _tcsicmp
Definition: xmlstorage.h:205
#define argv
Definition: mplay32.c:18
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _tcsnicmp
Definition: xmlstorage.h:207
VOID FlushDns(VOID)
Definition: ipconfig.c:839
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
VOID Release(LPTSTR Index)
Definition: ipconfig.c:710
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:404
HANDLE ProcessHeap
Definition: ipconfig.c:41
VOID DisplayDns(VOID)
Definition: ipconfig.c:976
#define GetModuleHandle
Definition: winbase.h:3667
HINSTANCE hInstance
Definition: ipconfig.c:40
VOID ShowInfo(BOOL bAll)
Definition: ipconfig.c:492
VOID RegisterDns(VOID)
Definition: ipconfig.c:850
VOID Renew(LPTSTR Index)
Definition: ipconfig.c:772

◆ PrintMacAddr()

PTCHAR PrintMacAddr ( PBYTE  Mac)

Definition at line 230 of file ipconfig.c.

231 {
232  static TCHAR MacAddr[20];
233 
234  _stprintf(MacAddr, _T("%02x-%02x-%02x-%02x-%02x-%02x"),
235  Mac[0], Mac[1], Mac[2], Mac[3], Mac[4], Mac[5]);
236 
237  return MacAddr;
238 }
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define _stprintf
Definition: utility.h:124

Referenced by ShowInfo().

◆ RegisterDns()

VOID RegisterDns ( VOID  )

Definition at line 850 of file ipconfig.c.

851 {
852  /* FIXME */
853  _tprintf(_T("\nSorry /registerdns is not implemented yet\n"));
854 }
#define _tprintf
Definition: tchar.h:506
#define _T(x)
Definition: vfdio.h:22

Referenced by main().

◆ Release()

VOID Release ( LPTSTR  Index)

Definition at line 710 of file ipconfig.c.

711 {
712  IP_ADAPTER_INDEX_MAP AdapterInfo;
713  DWORD ret;
714  DWORD i;
715 
716  /* if interface is not given, query GetInterfaceInfo */
717  if (Index == NULL)
718  {
719  PIP_INTERFACE_INFO pInfo = NULL;
720  ULONG ulOutBufLen = 0;
721 
722  if (GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER)
723  {
724  pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, ulOutBufLen);
725  if (pInfo == NULL)
726  return;
727 
728  if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR )
729  {
730  for (i = 0; i < pInfo->NumAdapters; i++)
731  {
732  CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP));
733  _tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name);
734 
735  /* Call IpReleaseAddress to release the IP address on the specified adapter. */
736  if ((ret = IpReleaseAddress(&AdapterInfo)) != NO_ERROR)
737  {
738  _tprintf(_T("\nAn error occured while releasing interface %ls : \n"), AdapterInfo.Name);
740  }
741  }
742 
743  HeapFree(ProcessHeap, 0, pInfo);
744  }
745  else
746  {
747  DoFormatMessage(0);
748  HeapFree(ProcessHeap, 0, pInfo);
749  return;
750  }
751  }
752  else
753  {
754  DoFormatMessage(0);
755  return;
756  }
757  }
758  else
759  {
760  ;
761  /* FIXME:
762  * we need to be able to release connections by name with support for globbing
763  * i.e. ipconfig /release Eth* will release all cards starting with Eth...
764  * ipconfig /release *con* will release all cards with 'con' in their name
765  */
766  }
767 }
DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
#define _tprintf
Definition: tchar.h:506
IP_ADAPTER_INDEX_MAP Adapter[1]
Definition: ipexport.h:152
DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
#define NO_ERROR
Definition: dderror.h:5
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
smooth NULL
Definition: ftsmooth.c:416
WCHAR Name[MAX_ADAPTER_NAME]
Definition: ipexport.h:147
#define _T(x)
Definition: vfdio.h:22
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HANDLE ProcessHeap
Definition: ipconfig.c:41
#define CopyMemory
Definition: winbase.h:1646
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:403
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
VOID DoFormatMessage(LONG ErrorCode)
Definition: ipconfig.c:241

Referenced by main().

◆ Renew()

VOID Renew ( LPTSTR  Index)

Definition at line 772 of file ipconfig.c.

773 {
774  IP_ADAPTER_INDEX_MAP AdapterInfo;
775  DWORD i;
776 
777  /* if interface is not given, query GetInterfaceInfo */
778  if (Index == NULL)
779  {
780  PIP_INTERFACE_INFO pInfo;
781  ULONG ulOutBufLen = 0;
782 
784  if (pInfo == NULL)
785  {
786  _tprintf(_T("memory allocation error"));
787  return;
788  }
789 
790  /* Make an initial call to GetInterfaceInfo to get
791  * the necessary size into the ulOutBufLen variable */
792  if (GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER)
793  {
794  HeapFree(ProcessHeap, 0, pInfo);
795  pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, ulOutBufLen);
796  if (pInfo == NULL)
797  {
798  _tprintf(_T("memory allocation error"));
799  return;
800  }
801  }
802 
803  /* Make a second call to GetInterfaceInfo to get the actual data we want */
804  if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR)
805  {
806  for (i = 0; i < pInfo->NumAdapters; i++)
807  {
808  CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP));
809  _tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name);
810 
811  /* Call IpRenewAddress to renew the IP address on the specified adapter. */
812  if (IpRenewAddress(&AdapterInfo) != NO_ERROR)
813  {
814  _tprintf(_T("\nAn error occured while renew interface %s : "), _T("*name*"));
815  DoFormatMessage(0);
816  }
817  }
818  }
819  else
820  {
821  _tprintf(_T("\nGetInterfaceInfo failed : "));
822  DoFormatMessage(0);
823  }
824 
825  HeapFree(ProcessHeap, 0, pInfo);
826  }
827  else
828  {
829  ;
830  /* FIXME:
831  * we need to be able to renew connections by name with support for globbing
832  * i.e. ipconfig /renew Eth* will renew all cards starting with Eth...
833  * ipconfig /renew *con* will renew all cards with 'con' in their name
834  */
835  }
836 }
#define _tprintf
Definition: tchar.h:506
IP_ADAPTER_INDEX_MAP Adapter[1]
Definition: ipexport.h:152
DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
#define NO_ERROR
Definition: dderror.h:5
DWORD WINAPI IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
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
smooth NULL
Definition: ftsmooth.c:416
WCHAR Name[MAX_ADAPTER_NAME]
Definition: ipexport.h:147
#define _T(x)
Definition: vfdio.h:22
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HANDLE ProcessHeap
Definition: ipconfig.c:41
#define CopyMemory
Definition: winbase.h:1646
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:403
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
VOID DoFormatMessage(LONG ErrorCode)
Definition: ipconfig.c:241

Referenced by main().

◆ ShowInfo()

VOID ShowInfo ( BOOL  bAll)

Definition at line 492 of file ipconfig.c.

493 {
494  MIB_IFROW mibEntry;
495  PIP_ADAPTER_INFO pAdapterInfo = NULL;
496  PIP_ADAPTER_INFO pAdapter = NULL;
497  ULONG adaptOutBufLen = 0;
498  PFIXED_INFO pFixedInfo = NULL;
499  ULONG netOutBufLen = 0;
500  PIP_PER_ADAPTER_INFO pPerAdapterInfo = NULL;
501  ULONG ulPerAdapterInfoLength = 0;
502  PSTR pszDomainName = NULL;
503  DWORD dwDomainNameSize = 0;
504  ULONG ret = 0;
505 
506  GetComputerNameExA(ComputerNameDnsDomain,
507  NULL,
508  &dwDomainNameSize);
509  if (dwDomainNameSize > 0)
510  {
511  pszDomainName = HeapAlloc(ProcessHeap,
512  0,
513  dwDomainNameSize * sizeof(TCHAR));
514  if (pszDomainName != NULL)
515  GetComputerNameExA(ComputerNameDnsDomain,
516  pszDomainName,
517  &dwDomainNameSize);
518  }
519 
520  /* call GetAdaptersInfo to obtain the adapter info */
521  ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
522  if (ret == ERROR_BUFFER_OVERFLOW)
523  {
524  pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
525  if (pAdapterInfo == NULL)
526  goto done;
527 
528  ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
529  if (ret != NO_ERROR)
530  {
531  DoFormatMessage(0);
532  goto done;
533  }
534  }
535  else
536  {
537  if (ret != ERROR_NO_DATA)
538  {
539  DoFormatMessage(0);
540  goto done;
541  }
542  }
543 
544  /* call GetNetworkParams to obtain the network info */
545  if (GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW)
546  {
547  pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
548  if (pFixedInfo == NULL)
549  {
550  goto done;
551  }
552  if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR)
553  {
554  DoFormatMessage(0);
555  goto done;
556  }
557  }
558  else
559  {
560  DoFormatMessage(0);
561  goto done;
562  }
563 
564  pAdapter = pAdapterInfo;
565 
566  _tprintf(_T("\nReactOS IP Configuration\n\n"));
567  if (bAll)
568  {
569  _tprintf(_T("\tHost Name . . . . . . . . . . . . : %s\n"), pFixedInfo->HostName);
570  _tprintf(_T("\tPrimary DNS Suffix. . . . . . . . : %s\n"), (pszDomainName != NULL) ? pszDomainName : "");
571  _tprintf(_T("\tNode Type . . . . . . . . . . . . : %s\n"), GetNodeTypeName(pFixedInfo->NodeType));
572  if (pFixedInfo->EnableRouting)
573  _tprintf(_T("\tIP Routing Enabled. . . . . . . . : Yes\n"));
574  else
575  _tprintf(_T("\tIP Routing Enabled. . . . . . . . : No\n"));
576  if (pAdapter && pAdapter->HaveWins)
577  _tprintf(_T("\tWINS Proxy enabled. . . . . . . . : Yes\n"));
578  else
579  _tprintf(_T("\tWINS Proxy enabled. . . . . . . . : No\n"));
580  if (pszDomainName != NULL && pszDomainName[0] != 0)
581  {
582  _tprintf(_T("\tDNS Suffix Search List. . . . . . : %s\n"), pszDomainName);
583  _tprintf(_T("\t %s\n"), pFixedInfo->DomainName);
584  }
585  else
586  {
587  _tprintf(_T("\tDNS Suffix Search List. . . . . . : %s\n"), pFixedInfo->DomainName);
588  }
589  }
590 
591  while (pAdapter)
592  {
593  LPTSTR IntType, myConType;
595 
596  mibEntry.dwIndex = pAdapter->Index;
597  GetIfEntry(&mibEntry);
598 
599  IntType = GetInterfaceTypeName(pAdapter->Type);
600  myConType = GetConnectionType(pAdapter->AdapterName);
601 
602  _tprintf(_T("\n%s %s: \n\n"), IntType , myConType);
603 
604  if (myConType != NULL) HeapFree(ProcessHeap, 0, myConType);
605 
606  if (GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength) == ERROR_BUFFER_OVERFLOW)
607  {
608  pPerAdapterInfo = (PIP_PER_ADAPTER_INFO)HeapAlloc(ProcessHeap, 0, ulPerAdapterInfoLength);
609  if (pPerAdapterInfo != NULL)
610  {
611  GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength);
612  }
613  }
614 
615  /* check if the adapter is connected to the media */
617  {
618  bConnected = FALSE;
619  _tprintf(_T("\tMedia State . . . . . . . . . . . : Media disconnected\n"));
620  }
621  else
622  {
623  _tprintf(_T("\tConnection-specific DNS Suffix. . : %s\n"), pFixedInfo->DomainName);
624  }
625 
626  if (bAll)
627  {
628  LPTSTR lpDesc = GetConnectionDescription(pAdapter->AdapterName);
629  _tprintf(_T("\tDescription . . . . . . . . . . . : %s\n"), lpDesc);
630  HeapFree(ProcessHeap, 0, lpDesc);
631  _tprintf(_T("\tPhysical Address. . . . . . . . . : %s\n"), PrintMacAddr(pAdapter->Address));
632  if (bConnected)
633  {
634  if (pAdapter->DhcpEnabled)
635  {
636  _tprintf(_T("\tDHCP Enabled. . . . . . . . . . . : Yes\n"));
637  if (pPerAdapterInfo != NULL)
638  {
639  if (pPerAdapterInfo->AutoconfigEnabled)
640  _tprintf(_T("\tAutoconfiguration Enabled . . . . : Yes\n"));
641  else
642  _tprintf(_T("\tAutoconfiguration Enabled . . . . : No\n"));
643  }
644  }
645  else
646  {
647  _tprintf(_T("\tDHCP Enabled. . . . . . . . . . . : No\n"));
648  }
649  }
650  }
651 
652  if (!bConnected)
653  {
654  pAdapter = pAdapter->Next;
655  continue;
656  }
657 
658  _tprintf(_T("\tIP Address. . . . . . . . . . . . : %s\n"), pAdapter->IpAddressList.IpAddress.String);
659  _tprintf(_T("\tSubnet Mask . . . . . . . . . . . : %s\n"), pAdapter->IpAddressList.IpMask.String);
660  if (pAdapter->GatewayList.IpAddress.String[0] != '0')
661  _tprintf(_T("\tDefault Gateway . . . . . . . . . : %s\n"), pAdapter->GatewayList.IpAddress.String);
662  else
663  _tprintf(_T("\tDefault Gateway . . . . . . . . . :\n"));
664 
665  if (bAll)
666  {
667  PIP_ADDR_STRING pIPAddr;
668 
669  if (pAdapter->DhcpEnabled)
670  _tprintf(_T("\tDHCP Server . . . . . . . . . . . : %s\n"), pAdapter->DhcpServer.IpAddress.String);
671 
672  _tprintf(_T("\tDNS Servers . . . . . . . . . . . : "));
673  _tprintf(_T("%s\n"), pFixedInfo->DnsServerList.IpAddress.String);
674  pIPAddr = pFixedInfo->DnsServerList.Next;
675  while (pIPAddr)
676  {
677  _tprintf(_T("\t\t\t\t\t %s\n"), pIPAddr ->IpAddress.String );
678  pIPAddr = pIPAddr->Next;
679  }
680 
681  if (pAdapter->HaveWins)
682  {
683  _tprintf(_T("\tPrimary WINS Server . . . . . . . : %s\n"), pAdapter->PrimaryWinsServer.IpAddress.String);
684  _tprintf(_T("\tSecondary WINS Server . . . . . . : %s\n"), pAdapter->SecondaryWinsServer.IpAddress.String);
685  }
686 
687  if (pAdapter->DhcpEnabled && _tcscmp(pAdapter->DhcpServer.IpAddress.String, _T("255.255.255.255")))
688  {
689  _tprintf(_T("\tLease Obtained. . . . . . . . . . : %s"), _tasctime(localtime(&pAdapter->LeaseObtained)));
690  _tprintf(_T("\tLease Expires . . . . . . . . . . : %s"), _tasctime(localtime(&pAdapter->LeaseExpires)));
691  }
692  }
693  _tprintf(_T("\n"));
694 
695  HeapFree(ProcessHeap, 0, pPerAdapterInfo);
696  pPerAdapterInfo = NULL;
697 
698  pAdapter = pAdapter->Next;
699  }
700 
701 done:
702  if (pszDomainName)
703  HeapFree(ProcessHeap, 0, pszDomainName);
704  if (pFixedInfo)
705  HeapFree(ProcessHeap, 0, pFixedInfo);
706  if (pAdapterInfo)
707  HeapFree(ProcessHeap, 0, pAdapterInfo);
708 }
#define _tprintf
Definition: tchar.h:506
#define TRUE
Definition: types.h:120
UINT AutoconfigEnabled
Definition: iptypes.h:74
IP_ADDR_STRING DhcpServer
Definition: iptypes.h:65
UINT EnableRouting
Definition: iptypes.h:87
LPTSTR GetConnectionType(LPTSTR lpClass)
Definition: ipconfig.c:265
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
UINT DhcpEnabled
Definition: iptypes.h:61
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
struct _IP_ADDR_STRING * Next
Definition: iptypes.h:46
IP_ADDR_STRING SecondaryWinsServer
Definition: iptypes.h:68
LPTSTR GetInterfaceTypeName(UINT InterfaceType)
Definition: ipconfig.c:178
char String[4 *4]
Definition: iptypes.h:42
_TCHAR * _tasctime(const struct tm *ptm)
Definition: asctime.c:150
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD)
Definition: compname.c:373
#define NO_ERROR
Definition: dderror.h:5
CHAR * LPTSTR
Definition: xmlstorage.h:192
char AdapterName[MAX_ADAPTER_NAME_LENGTH+4]
Definition: iptypes.h:55
LPTSTR GetConnectionDescription(LPTSTR lpClass)
Definition: ipconfig.c:341
DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
char DomainName[MAX_DOMAIN_NAME_LEN+4]
Definition: iptypes.h:82
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]
Definition: iptypes.h:58
time_t LeaseObtained
Definition: iptypes.h:69
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HANDLE ProcessHeap
Definition: ipconfig.c:41
#define ERROR_NO_DATA
Definition: winerror.h:284
DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
UINT NodeType
Definition: iptypes.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL bConnected
Definition: fdebug.c:27
struct _IP_PER_ADAPTER_INFO * PIP_PER_ADAPTER_INFO
PTCHAR PrintMacAddr(PBYTE Mac)
Definition: ipconfig.c:230
int ret
char HostName[MAX_HOSTNAME_LEN+4]
Definition: iptypes.h:81
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:424
LPTSTR GetNodeTypeName(UINT NodeType)
Definition: ipconfig.c:142
IP_MASK_STRING IpMask
Definition: iptypes.h:48
IP_ADDR_STRING GatewayList
Definition: iptypes.h:64
signed char * PSTR
Definition: retypes.h:7
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
#define MIB_IF_OPER_STATUS_CONNECTED
Definition: ipifcons.h:250
IP_ADDR_STRING PrimaryWinsServer
Definition: iptypes.h:67
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
unsigned int ULONG
Definition: retypes.h:1
DWORD dwIndex
Definition: ifmib.h:38
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:84
#define MIB_IF_OPER_STATUS_OPERATIONAL
Definition: ipifcons.h:251
#define HeapFree(x, y, z)
Definition: compat.h:403
time_t LeaseExpires
Definition: iptypes.h:70
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:53
IP_ADDR_STRING IpAddressList
Definition: iptypes.h:63
VOID DoFormatMessage(LONG ErrorCode)
Definition: ipconfig.c:241

Referenced by main().

◆ Usage()

VOID Usage ( VOID  )

Definition at line 1010 of file ipconfig.c.

1011 {
1012  HRSRC hRes;
1013  LPTSTR lpUsage;
1014  DWORD Size;
1015 
1016  LPTSTR lpName = (LPTSTR)MAKEINTRESOURCE((IDS_USAGE >> 4) + 1);
1017 
1018  hRes = FindResource(hInstance,
1019  lpName,
1020  RT_STRING);
1021  if (hRes != NULL)
1022  {
1023  if ((Size = SizeofResource(hInstance,
1024  hRes)))
1025  {
1026  lpUsage = (LPTSTR)HeapAlloc(ProcessHeap,
1027  0,
1028  Size);
1029  if (lpUsage == NULL)
1030  return;
1031 
1033  IDS_USAGE,
1034  lpUsage,
1035  Size))
1036  {
1037  _tprintf(_T("%s"), lpUsage);
1038  }
1039 
1040  HeapFree(ProcessHeap, 0, lpUsage);
1041  }
1042  }
1043 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define _tprintf
Definition: tchar.h:506
#define FindResource
Definition: winbase.h:3633
_In_ LPCSTR lpName
Definition: winbase.h:2752
#define IDS_USAGE
Definition: resource.h:3
CHAR * LPTSTR
Definition: xmlstorage.h:192
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HANDLE ProcessHeap
Definition: ipconfig.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RT_STRING
Definition: pedump.c:368
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
HINSTANCE hInstance
Definition: ipconfig.c:40
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
#define HeapFree(x, y, z)
Definition: compat.h:403
int LoadStringAndOem(HINSTANCE hInst, UINT uID, LPTSTR szNode, int byteSize)
Definition: ipconfig.c:122

Referenced by main().

Variable Documentation

◆ hInstance

HINSTANCE hInstance

Definition at line 40 of file ipconfig.c.

Referenced by GetInterfaceTypeName(), GetNodeTypeName(), main(), and Usage().

◆ ProcessHeap

HANDLE ProcessHeap
  • Internal Headers */

Definition at line 41 of file ipconfig.c.

Referenced by GetConnectionDescription(), GetConnectionType(), LoadStringAndOem(), main(), Release(), Renew(), ShowInfo(), and Usage().

◆ TypeArray

RECORDTYPE TypeArray[]

Definition at line 43 of file ipconfig.c.

Referenced by GetRecordTypeName().