ReactOS  0.4.14-dev-815-ge410a12
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)
 
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 950 of file ipconfig.c.

951 {
952  PDNS_CACHE_ENTRY DnsEntry = NULL, pThisEntry, pNextEntry;
953 
954  _tprintf(_T("\nReactOS IP Configuration\n\n"));
955 
956  if (!DnsGetCacheDataTable(&DnsEntry))
957  {
959  return;
960  }
961 
962  if (DnsEntry == NULL)
963  return;
964 
965  pThisEntry = DnsEntry;
966  while (pThisEntry != NULL)
967  {
968  pNextEntry = pThisEntry->pNext;
969 
970  if (pThisEntry->wType1 != 0)
971  DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType1);
972 
973  if (pThisEntry->wType2 != 0)
974  DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType2);
975 
976  if (pThisEntry->pszName)
977  LocalFree(pThisEntry->pszName);
978  LocalFree(pThisEntry);
979 
980  pThisEntry = pNextEntry;
981  }
982 }
#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:953
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static VOID DisplayDnsRecord(PWSTR pszName, WORD wType)
Definition: ipconfig.c:832
VOID DoFormatMessage(LONG ErrorCode)
Definition: ipconfig.c:241

Referenced by main().

◆ DisplayDnsRecord()

static VOID DisplayDnsRecord ( PWSTR  pszName,
WORD  wType 
)
static

Definition at line 832 of file ipconfig.c.

835 {
836  PDNS_RECORDW pQueryResults = NULL, pThisRecord, pNextRecord;
837  WCHAR szBuffer[48];
838  IN_ADDR Addr4;
839  IN6_ADDR Addr6;
840  DNS_STATUS Status;
841 
842  pQueryResults = NULL;
843  Status = DnsQuery_W(pszName,
844  wType,
846  NULL,
847  (PDNS_RECORD *)&pQueryResults,
848  NULL);
849  if (Status != ERROR_SUCCESS)
850  {
852  {
853  _tprintf(_T("\t%S\n"), pszName);
854  _tprintf(_T("\t----------------------------------------\n"));
855  _tprintf(_T("\tName does not exist\n\n"));
856  }
857  else if (Status == DNS_INFO_NO_RECORDS)
858  {
859  _tprintf(_T("\t%S\n"), pszName);
860  _tprintf(_T("\t----------------------------------------\n"));
861  _tprintf(_T("\tNo records of type %s\n\n"), GetRecordTypeName(wType));
862  }
863  return;
864  }
865 
866  _tprintf(_T("\t%S\n"), pszName);
867  _tprintf(_T("\t----------------------------------------\n"));
868 
869  pThisRecord = pQueryResults;
870  while (pThisRecord != NULL)
871  {
872  pNextRecord = pThisRecord->pNext;
873 
874  _tprintf(_T("\tRecord Name . . . . . : %S\n"), pThisRecord->pName);
875  _tprintf(_T("\tRecord Type . . . . . : %hu\n"), pThisRecord->wType);
876  _tprintf(_T("\tTime To Live. . . . . : %lu\n"), pThisRecord->dwTtl);
877  _tprintf(_T("\tData Length . . . . . : %hu\n"), pThisRecord->wDataLength);
878 
879  switch (pThisRecord->Flags.S.Section)
880  {
881  case DnsSectionQuestion:
882  _tprintf(_T("\tSection . . . . . . . : Question\n"));
883  break;
884 
885  case DnsSectionAnswer:
886  _tprintf(_T("\tSection . . . . . . . : Answer\n"));
887  break;
888 
889  case DnsSectionAuthority:
890  _tprintf(_T("\tSection . . . . . . . : Authority\n"));
891  break;
892 
894  _tprintf(_T("\tSection . . . . . . . : Additional\n"));
895  break;
896  }
897 
898  switch (pThisRecord->wType)
899  {
900  case DNS_TYPE_A:
901  Addr4.S_un.S_addr = pThisRecord->Data.A.IpAddress;
902  RtlIpv4AddressToStringW(&Addr4, szBuffer);
903  _tprintf(_T("\tA (Host) Record . . . : %S\n"), szBuffer);
904  break;
905 
906  case DNS_TYPE_NS:
907  _tprintf(_T("\tNS Record . . . . . . : %S\n"), pThisRecord->Data.NS.pNameHost);
908  break;
909 
910  case DNS_TYPE_CNAME:
911  _tprintf(_T("\tCNAME Record. . . . . : %S\n"), pThisRecord->Data.CNAME.pNameHost);
912  break;
913 
914  case DNS_TYPE_SOA:
915  _tprintf(_T("\tSOA Record. . . . . . : \n"));
916  break;
917 
918  case DNS_TYPE_PTR:
919  _tprintf(_T("\tPTR Record. . . . . . : %S\n"), pThisRecord->Data.PTR.pNameHost);
920  break;
921 
922  case DNS_TYPE_MX:
923  _tprintf(_T("\tMX Record . . . . . . : \n"));
924  break;
925 
926  case DNS_TYPE_AAAA:
927  RtlCopyMemory(&Addr6, &pThisRecord->Data.AAAA.Ip6Address, sizeof(IN6_ADDR));
928  RtlIpv6AddressToStringW(&Addr6, szBuffer);
929  _tprintf(_T("\tAAAA Record . . . . . : %S\n"), szBuffer);
930  break;
931 
932  case DNS_TYPE_ATMA:
933  _tprintf(_T("\tATMA Record . . . . . : \n"));
934  break;
935 
936  case DNS_TYPE_SRV:
937  _tprintf(_T("\tSRV Record. . . . . . : \n"));
938  break;
939  }
940  _tprintf(_T("\n\n"));
941 
942  pThisRecord = pNextRecord;
943  }
944 
946 }
#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
union in_addr::@1007 S_un
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
#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:3629
#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 819 of file ipconfig.c.

820 {
821  _tprintf(_T("\nReactOS IP Configuration\n\n"));
822 
823  if (DnsFlushResolverCache())
824  _tprintf(_T("The DNS Resolver Cache has been deleted.\n"));
825  else
827 }
#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:930
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:56
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:3706
Status
Definition: gdiplustypes.h:24
#define RegOpenKeyEx
Definition: winreg.h:520
#define lstrlen
Definition: winbase.h:3710
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:402
#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:3710
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:402
#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:56
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:402
#define LoadString
Definition: winuser.h:5794

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

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 1019 of file ipconfig.c.

1020 {
1021  BOOL DoUsage=FALSE;
1022  BOOL DoAll=FALSE;
1023  BOOL DoRelease=FALSE;
1024  BOOL DoRenew=FALSE;
1025  BOOL DoFlushdns=FALSE;
1026  BOOL DoRegisterdns=FALSE;
1027  BOOL DoDisplaydns=FALSE;
1028  BOOL DoShowclassid=FALSE;
1029  BOOL DoSetclassid=FALSE;
1030 
1033 
1034  /* Parse command line for options we have been given. */
1035  if ((argc > 1) && (argv[1][0]=='/' || argv[1][0]=='-'))
1036  {
1037  if (!_tcsicmp(&argv[1][1], _T("?")))
1038  {
1039  DoUsage = TRUE;
1040  }
1041  else if (!_tcsnicmp(&argv[1][1], _T("ALL"), _tcslen(&argv[1][1])))
1042  {
1043  DoAll = TRUE;
1044  }
1045  else if (!_tcsnicmp(&argv[1][1], _T("RELEASE"), _tcslen(&argv[1][1])))
1046  {
1047  DoRelease = TRUE;
1048  }
1049  else if (!_tcsnicmp(&argv[1][1], _T("RENEW"), _tcslen(&argv[1][1])))
1050  {
1051  DoRenew = TRUE;
1052  }
1053  else if (!_tcsnicmp(&argv[1][1], _T("FLUSHDNS"), _tcslen(&argv[1][1])))
1054  {
1055  DoFlushdns = TRUE;
1056  }
1057  else if (!_tcsnicmp(&argv[1][1], _T("FLUSHREGISTERDNS"), _tcslen(&argv[1][1])))
1058  {
1059  DoRegisterdns = TRUE;
1060  }
1061  else if (!_tcsnicmp(&argv[1][1], _T("DISPLAYDNS"), _tcslen(&argv[1][1])))
1062  {
1063  DoDisplaydns = TRUE;
1064  }
1065  else if (!_tcsnicmp(&argv[1][1], _T("SHOWCLASSID"), _tcslen(&argv[1][1])))
1066  {
1067  DoShowclassid = TRUE;
1068  }
1069  else if (!_tcsnicmp(&argv[1][1], _T("SETCLASSID"), _tcslen(&argv[1][1])))
1070  {
1071  DoSetclassid = TRUE;
1072  }
1073  }
1074 
1075  switch (argc)
1076  {
1077  case 1: /* Default behaviour if no options are given*/
1078  ShowInfo(FALSE);
1079  break;
1080  case 2: /* Process all the options that take no parameters */
1081  if (DoUsage)
1082  Usage();
1083  else if (DoAll)
1084  ShowInfo(TRUE);
1085  else if (DoRelease)
1086  Release(NULL);
1087  else if (DoRenew)
1088  Renew(NULL);
1089  else if (DoFlushdns)
1090  FlushDns();
1091  else if (DoRegisterdns)
1092  _tprintf(_T("\nSorry /registerdns is not implemented yet\n"));
1093  else if (DoDisplaydns)
1094  DisplayDns();
1095  else
1096  Usage();
1097  break;
1098  case 3: /* Process all the options that can have 1 parameter */
1099  if (DoRelease)
1100  _tprintf(_T("\nSorry /release [adapter] is not implemented yet\n"));
1101  //Release(argv[2]);
1102  else if (DoRenew)
1103  _tprintf(_T("\nSorry /renew [adapter] is not implemented yet\n"));
1104  else if (DoShowclassid)
1105  _tprintf(_T("\nSorry /showclassid adapter is not implemented yet\n"));
1106  else if (DoSetclassid)
1107  _tprintf(_T("\nSorry /setclassid adapter is not implemented yet\n"));
1108  else
1109  Usage();
1110  break;
1111  case 4: /* Process all the options that can have 2 parameters */
1112  if (DoSetclassid)
1113  _tprintf(_T("\nSorry /setclassid adapter [classid]is not implemented yet\n"));
1114  else
1115  Usage();
1116  break;
1117  default:
1118  Usage();
1119  }
1120 
1121  return 0;
1122 }
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:984
#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:819
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
VOID Release(LPTSTR Index)
Definition: ipconfig.c:690
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:403
HANDLE ProcessHeap
Definition: ipconfig.c:41
VOID DisplayDns(VOID)
Definition: ipconfig.c:950
#define GetModuleHandle
Definition: winbase.h:3661
HINSTANCE hInstance
Definition: ipconfig.c:40
VOID ShowInfo(BOOL bAll)
Definition: ipconfig.c:492
VOID Renew(LPTSTR Index)
Definition: ipconfig.c:752

◆ 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().

◆ Release()

VOID Release ( LPTSTR  Index)

Definition at line 690 of file ipconfig.c.

691 {
692  IP_ADAPTER_INDEX_MAP AdapterInfo;
693  DWORD ret;
694  DWORD i;
695 
696  /* if interface is not given, query GetInterfaceInfo */
697  if (Index == NULL)
698  {
699  PIP_INTERFACE_INFO pInfo = NULL;
700  ULONG ulOutBufLen = 0;
701 
702  if (GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER)
703  {
704  pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, ulOutBufLen);
705  if (pInfo == NULL)
706  return;
707 
708  if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR )
709  {
710  for (i = 0; i < pInfo->NumAdapters; i++)
711  {
712  CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP));
713  _tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name);
714 
715  /* Call IpReleaseAddress to release the IP address on the specified adapter. */
716  if ((ret = IpReleaseAddress(&AdapterInfo)) != NO_ERROR)
717  {
718  _tprintf(_T("\nAn error occured while releasing interface %ls : \n"), AdapterInfo.Name);
720  }
721  }
722 
723  HeapFree(ProcessHeap, 0, pInfo);
724  }
725  else
726  {
727  DoFormatMessage(0);
728  HeapFree(ProcessHeap, 0, pInfo);
729  return;
730  }
731  }
732  else
733  {
734  DoFormatMessage(0);
735  return;
736  }
737  }
738  else
739  {
740  ;
741  /* FIXME:
742  * we need to be able to release connections by name with support for globbing
743  * i.e. ipconfig /release Eth* will release all cards starting with Eth...
744  * ipconfig /release *con* will release all cards with 'con' in their name
745  */
746  }
747 }
DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
#define _tprintf
Definition: tchar.h:506
IP_ADAPTER_INDEX_MAP Adapter[1]
Definition: ipexport.h:141
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:136
#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:1640
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:402
#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 752 of file ipconfig.c.

753 {
754  IP_ADAPTER_INDEX_MAP AdapterInfo;
755  DWORD i;
756 
757  /* if interface is not given, query GetInterfaceInfo */
758  if (Index == NULL)
759  {
760  PIP_INTERFACE_INFO pInfo;
761  ULONG ulOutBufLen = 0;
762 
764  if (pInfo == NULL)
765  {
766  _tprintf(_T("memory allocation error"));
767  return;
768  }
769 
770  /* Make an initial call to GetInterfaceInfo to get
771  * the necessary size into the ulOutBufLen variable */
772  if (GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER)
773  {
774  HeapFree(ProcessHeap, 0, pInfo);
775  pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, ulOutBufLen);
776  if (pInfo == NULL)
777  {
778  _tprintf(_T("memory allocation error"));
779  return;
780  }
781  }
782 
783  /* Make a second call to GetInterfaceInfo to get the actual data we want */
784  if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR)
785  {
786  for (i = 0; i < pInfo->NumAdapters; i++)
787  {
788  CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP));
789  _tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name);
790 
791  /* Call IpRenewAddress to renew the IP address on the specified adapter. */
792  if (IpRenewAddress(&AdapterInfo) != NO_ERROR)
793  {
794  _tprintf(_T("\nAn error occured while renew interface %s : "), _T("*name*"));
795  DoFormatMessage(0);
796  }
797  }
798  }
799  else
800  {
801  _tprintf(_T("\nGetInterfaceInfo failed : "));
802  DoFormatMessage(0);
803  }
804 
805  HeapFree(ProcessHeap, 0, pInfo);
806  }
807  else
808  {
809  ;
810  /* FIXME:
811  * we need to be able to renew connections by name with support for globbing
812  * i.e. ipconfig /renew Eth* will renew all cards starting with Eth...
813  * ipconfig /renew *con* will renew all cards with 'con' in their name
814  */
815  }
816 }
#define _tprintf
Definition: tchar.h:506
IP_ADAPTER_INDEX_MAP Adapter[1]
Definition: ipexport.h:141
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:136
#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:1640
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:402
#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  ULONG ret = 0;
503 
504  /* call GetAdaptersInfo to obtain the adapter info */
505  ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
506  if (ret == ERROR_BUFFER_OVERFLOW)
507  {
508  pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
509  if (pAdapterInfo == NULL)
510  return;
511 
512  ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
513  if (ret != NO_ERROR)
514  {
515  DoFormatMessage(0);
516  HeapFree(ProcessHeap, 0, pAdapterInfo);
517  return;
518  }
519  }
520  else
521  {
522  if (ret != ERROR_NO_DATA)
523  {
524  DoFormatMessage(0);
525  return;
526  }
527  }
528 
529  /* call GetNetworkParams to obtain the network info */
530  if (GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW)
531  {
532  pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
533  if (pFixedInfo == NULL)
534  {
535  if (pAdapterInfo)
536  HeapFree(ProcessHeap, 0, pAdapterInfo);
537  return;
538  }
539  if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR)
540  {
541  DoFormatMessage(0);
542  if (pAdapterInfo)
543  HeapFree(ProcessHeap, 0, pAdapterInfo);
544  HeapFree(ProcessHeap, 0, pFixedInfo);
545  return;
546  }
547  }
548  else
549  {
550  if (pAdapterInfo)
551  HeapFree(ProcessHeap, 0, pAdapterInfo);
552  DoFormatMessage(0);
553  return;
554  }
555 
556  pAdapter = pAdapterInfo;
557 
558  _tprintf(_T("\nReactOS IP Configuration\n\n"));
559  if (bAll)
560  {
561  _tprintf(_T("\tHost Name . . . . . . . . . . . . : %s\n"), pFixedInfo->HostName);
562  _tprintf(_T("\tPrimary DNS Suffix. . . . . . . . : \n"));
563  _tprintf(_T("\tNode Type . . . . . . . . . . . . : %s\n"), GetNodeTypeName(pFixedInfo->NodeType));
564  if (pFixedInfo->EnableRouting)
565  _tprintf(_T("\tIP Routing Enabled. . . . . . . . : Yes\n"));
566  else
567  _tprintf(_T("\tIP Routing Enabled. . . . . . . . : No\n"));
568  if (pAdapter && pAdapter->HaveWins)
569  _tprintf(_T("\tWINS Proxy enabled. . . . . . . . : Yes\n"));
570  else
571  _tprintf(_T("\tWINS Proxy enabled. . . . . . . . : No\n"));
572  _tprintf(_T("\tDNS Suffix Search List. . . . . . : %s\n"), pFixedInfo->DomainName);
573  }
574 
575  while (pAdapter)
576  {
577  LPTSTR IntType, myConType;
579 
580  mibEntry.dwIndex = pAdapter->Index;
581  GetIfEntry(&mibEntry);
582 
583  IntType = GetInterfaceTypeName(pAdapter->Type);
584  myConType = GetConnectionType(pAdapter->AdapterName);
585 
586  _tprintf(_T("\n%s %s: \n\n"), IntType , myConType);
587 
588  if (myConType != NULL) HeapFree(ProcessHeap, 0, myConType);
589 
590  if (GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength) == ERROR_BUFFER_OVERFLOW)
591  {
592  pPerAdapterInfo = (PIP_PER_ADAPTER_INFO)HeapAlloc(ProcessHeap, 0, ulPerAdapterInfoLength);
593  if (pPerAdapterInfo != NULL)
594  {
595  GetPerAdapterInfo(pAdapter->Index, pPerAdapterInfo, &ulPerAdapterInfoLength);
596  }
597  }
598 
599  /* check if the adapter is connected to the media */
601  {
602  bConnected = FALSE;
603  _tprintf(_T("\tMedia State . . . . . . . . . . . : Media disconnected\n"));
604  }
605  else
606  {
607  _tprintf(_T("\tConnection-specific DNS Suffix. . : %s\n"), pFixedInfo->DomainName);
608  }
609 
610  if (bAll)
611  {
612  LPTSTR lpDesc = GetConnectionDescription(pAdapter->AdapterName);
613  _tprintf(_T("\tDescription . . . . . . . . . . . : %s\n"), lpDesc);
614  HeapFree(ProcessHeap, 0, lpDesc);
615  _tprintf(_T("\tPhysical Address. . . . . . . . . : %s\n"), PrintMacAddr(pAdapter->Address));
616  if (bConnected)
617  {
618  if (pAdapter->DhcpEnabled)
619  {
620  _tprintf(_T("\tDHCP Enabled. . . . . . . . . . . : Yes\n"));
621  if (pPerAdapterInfo != NULL)
622  {
623  if (pPerAdapterInfo->AutoconfigEnabled)
624  _tprintf(_T("\tAutoconfiguration Enabled . . . . : Yes\n"));
625  else
626  _tprintf(_T("\tAutoconfiguration Enabled . . . . : No\n"));
627  }
628  }
629  else
630  {
631  _tprintf(_T("\tDHCP Enabled. . . . . . . . . . . : No\n"));
632  }
633  }
634  }
635 
636  if (!bConnected)
637  {
638  pAdapter = pAdapter->Next;
639  continue;
640  }
641 
642  _tprintf(_T("\tIP Address. . . . . . . . . . . . : %s\n"), pAdapter->IpAddressList.IpAddress.String);
643  _tprintf(_T("\tSubnet Mask . . . . . . . . . . . : %s\n"), pAdapter->IpAddressList.IpMask.String);
644  if (pAdapter->GatewayList.IpAddress.String[0] != '0')
645  _tprintf(_T("\tDefault Gateway . . . . . . . . . : %s\n"), pAdapter->GatewayList.IpAddress.String);
646  else
647  _tprintf(_T("\tDefault Gateway . . . . . . . . . :\n"));
648 
649  if (bAll)
650  {
651  PIP_ADDR_STRING pIPAddr;
652 
653  if (pAdapter->DhcpEnabled)
654  _tprintf(_T("\tDHCP Server . . . . . . . . . . . : %s\n"), pAdapter->DhcpServer.IpAddress.String);
655 
656  _tprintf(_T("\tDNS Servers . . . . . . . . . . . : "));
657  _tprintf(_T("%s\n"), pFixedInfo->DnsServerList.IpAddress.String);
658  pIPAddr = pFixedInfo->DnsServerList.Next;
659  while (pIPAddr)
660  {
661  _tprintf(_T("\t\t\t\t\t %s\n"), pIPAddr ->IpAddress.String );
662  pIPAddr = pIPAddr->Next;
663  }
664 
665  if (pAdapter->HaveWins)
666  {
667  _tprintf(_T("\tPrimary WINS Server . . . . . . . : %s\n"), pAdapter->PrimaryWinsServer.IpAddress.String);
668  _tprintf(_T("\tSecondary WINS Server . . . . . . : %s\n"), pAdapter->SecondaryWinsServer.IpAddress.String);
669  }
670 
671  if (pAdapter->DhcpEnabled && _tcscmp(pAdapter->DhcpServer.IpAddress.String, _T("255.255.255.255")))
672  {
673  _tprintf(_T("\tLease Obtained. . . . . . . . . . : %s"), _tasctime(localtime(&pAdapter->LeaseObtained)));
674  _tprintf(_T("\tLease Expires . . . . . . . . . . : %s"), _tasctime(localtime(&pAdapter->LeaseExpires)));
675  }
676  }
677  _tprintf(_T("\n"));
678 
679  HeapFree(ProcessHeap, 0, pPerAdapterInfo);
680  pPerAdapterInfo = NULL;
681 
682  pAdapter = pAdapter->Next;
683  }
684 
685  HeapFree(ProcessHeap, 0, pFixedInfo);
686  if (pAdapterInfo)
687  HeapFree(ProcessHeap, 0, pAdapterInfo);
688 }
#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
#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
#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
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
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:402
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 984 of file ipconfig.c.

985 {
986  HRSRC hRes;
987  LPTSTR lpUsage;
988  DWORD Size;
989 
991 
992  hRes = FindResource(hInstance,
993  lpName,
994  RT_STRING);
995  if (hRes != NULL)
996  {
998  hRes)))
999  {
1000  lpUsage = (LPTSTR)HeapAlloc(ProcessHeap,
1001  0,
1002  Size);
1003  if (lpUsage == NULL)
1004  return;
1005 
1007  IDS_USAGE,
1008  lpUsage,
1009  Size))
1010  {
1011  _tprintf(_T("%s"), lpUsage);
1012  }
1013 
1014  HeapFree(ProcessHeap, 0, lpUsage);
1015  }
1016  }
1017 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define _tprintf
Definition: tchar.h:506
#define FindResource
Definition: winbase.h:3627
_In_ LPCSTR lpName
Definition: winbase.h:2746
#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:359
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:402
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().