-revert janderwalds change until because it breaks the gcc 4.x build
[reactos.git] / reactos / base / applications / network / ipconfig / ipconfig.c
1 /*
2 * PROJECT: ReactOS ipconfig utility
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: apps/utils/net/ipconfig/ipconfig.c
5 * PURPOSE: Display IP info for net adapters
6 * PROGRAMMERS: Copyright 2005 - 2006 Ged Murphy (gedmurphy@gmail.com)
7 */
8 /*
9 * TODO:
10 * fix renew / release
11 * implement flushdns, registerdns, displaydns, showclassid, setclassid
12 * allow globbing on adapter names
13 */
14
15 #define WIN32_LEAN_AND_MEAN
16 #include <windows.h>
17 #include <stdio.h>
18 #include <tchar.h>
19 #include <time.h>
20 #include <iphlpapi.h>
21 #include "resource.h"
22
23 #define GUID_LEN 40
24
25 HINSTANCE hInstance;
26 HANDLE ProcessHeap;
27
28
29 LPTSTR GetNodeTypeName(UINT NodeType)
30 {
31 static TCHAR szNode[14];
32
33 switch (NodeType)
34 {
35 case 1:
36 if (!LoadString(hInstance, IDS_BCAST, szNode, sizeof(szNode)))
37 return NULL;
38 break;
39
40 case 2:
41 if (!LoadString(hInstance, IDS_P2P, szNode, sizeof(szNode)))
42 return NULL;
43 break;
44
45 case 4:
46 if (!LoadString(hInstance, IDS_MIXED, szNode, sizeof(szNode)))
47 return NULL;
48 break;
49
50 case 8:
51 if (!LoadString(hInstance, IDS_HYBRID, szNode, sizeof(szNode)))
52 return NULL;
53 break;
54
55 default :
56 if (!LoadString(hInstance, IDS_UNKNOWN, szNode, sizeof(szNode)))
57 return NULL;
58 break;
59 }
60
61 return szNode;
62 }
63
64
65 LPTSTR GetInterfaceTypeName(UINT InterfaceType)
66 {
67 static TCHAR szIntType[25];
68
69 switch (InterfaceType)
70 {
71 case MIB_IF_TYPE_OTHER:
72 if (!LoadString(hInstance, IDS_OTHER, szIntType, sizeof(szIntType)))
73 return NULL;
74 break;
75
76 case MIB_IF_TYPE_ETHERNET:
77 if (!LoadString(hInstance, IDS_ETH, szIntType, sizeof(szIntType)))
78 return NULL;
79 break;
80
81 case MIB_IF_TYPE_TOKENRING:
82 if (!LoadString(hInstance, IDS_TOKEN, szIntType, sizeof(szIntType)))
83 return NULL;
84 break;
85
86 case MIB_IF_TYPE_FDDI:
87 if (!LoadString(hInstance, IDS_FDDI, szIntType, sizeof(szIntType)))
88 return NULL;
89 break;
90
91 case MIB_IF_TYPE_PPP:
92 if (!LoadString(hInstance, IDS_PPP, szIntType, sizeof(szIntType)))
93 return NULL;
94 break;
95
96 case MIB_IF_TYPE_LOOPBACK:
97 if (!LoadString(hInstance, IDS_LOOP, szIntType, sizeof(szIntType)))
98 return NULL;
99 break;
100
101 case MIB_IF_TYPE_SLIP:
102 if (!LoadString(hInstance, IDS_SLIP, szIntType, sizeof(szIntType)))
103 return NULL;
104 break;
105
106 default:
107 if (!LoadString(hInstance, IDS_UNKNOWN, szIntType, sizeof(szIntType)))
108 return NULL;
109 break;
110 }
111
112 return szIntType;
113 }
114
115
116 /* print MAC address */
117 PTCHAR PrintMacAddr(PBYTE Mac)
118 {
119 static TCHAR MacAddr[20];
120
121 _stprintf(MacAddr, _T("%02x-%02x-%02x-%02x-%02x-%02x"),
122 Mac[0], Mac[1], Mac[2], Mac[3], Mac[4], Mac[5]);
123
124 return MacAddr;
125 }
126
127
128 VOID DoFormatMessage(LONG ErrorCode)
129 {
130 LPVOID lpMsgBuf;
131 //DWORD ErrorCode;
132
133 if (ErrorCode == 0)
134 ErrorCode = GetLastError();
135
136 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
137 FORMAT_MESSAGE_FROM_SYSTEM |
138 FORMAT_MESSAGE_IGNORE_INSERTS,
139 NULL,
140 ErrorCode,
141 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
142 (LPTSTR) &lpMsgBuf,
143 0,
144 NULL))
145 {
146 _tprintf(_T("%s"), (LPTSTR)lpMsgBuf);
147 LocalFree(lpMsgBuf);
148 }
149 }
150
151
152 LPTSTR GetConnectionType(LPTSTR lpClass)
153 {
154 HKEY hKey = NULL;
155 LPTSTR ConType = NULL;
156 TCHAR Path[256];
157 LPTSTR PrePath = _T("SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\");
158 LPTSTR PostPath = _T("\\Connection");
159 DWORD PathSize;
160 DWORD dwType;
161 DWORD dwDataSize;
162
163 /* don't overflow the buffer */
164 PathSize = lstrlen(PrePath) + lstrlen(lpClass) + lstrlen(PostPath) + 1;
165 if (PathSize >= 255)
166 return NULL;
167
168 wsprintf(Path, _T("%s%s%s"), PrePath, lpClass, PostPath);
169
170 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
171 Path,
172 0,
173 KEY_READ,
174 &hKey) == ERROR_SUCCESS)
175 {
176 if(RegQueryValueEx(hKey,
177 _T("Name"),
178 NULL,
179 &dwType,
180 NULL,
181 &dwDataSize) == ERROR_SUCCESS)
182 {
183 ConType = (LPTSTR)HeapAlloc(ProcessHeap,
184 0,
185 dwDataSize);
186 if (ConType == NULL)
187 return NULL;
188
189 if(RegQueryValueEx(hKey,
190 _T("Name"),
191 NULL,
192 &dwType,
193 (PBYTE)ConType,
194 &dwDataSize) != ERROR_SUCCESS)
195 {
196 ConType = NULL;
197 }
198 }
199 }
200
201 if (hKey != NULL)
202 RegCloseKey(hKey);
203
204 return ConType;
205 }
206
207
208 LPTSTR GetConnectionDescription(LPTSTR lpClass)
209 {
210 HKEY hBaseKey = NULL;
211 HKEY hClassKey = NULL;
212 LPTSTR lpKeyClass = NULL;
213 LPTSTR lpConDesc = NULL;
214 LPTSTR lpPath = NULL;
215 TCHAR szPrePath[] = _T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\");
216 DWORD dwType;
217 DWORD dwDataSize;
218 INT i;
219
220 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
221 szPrePath,
222 0,
223 KEY_READ,
224 &hBaseKey) != ERROR_SUCCESS)
225 {
226 return NULL;
227 }
228
229 for (i=0; ; i++)
230 {
231 DWORD PathSize;
232 LONG Status;
233 TCHAR szName[10];
234 DWORD NameLen = 9;
235
236 if ((Status = RegEnumKeyEx(hBaseKey,
237 i,
238 szName,
239 &NameLen,
240 NULL,
241 NULL,
242 NULL,
243 NULL)) != ERROR_SUCCESS)
244 {
245 if (Status == ERROR_NO_MORE_ITEMS)
246 {
247 DoFormatMessage(Status);
248 lpConDesc = NULL;
249 goto CLEANUP;
250 }
251 else
252 continue;
253 }
254
255 PathSize = lstrlen(szPrePath) + lstrlen(szName) + 1;
256 lpPath = (LPTSTR)HeapAlloc(ProcessHeap,
257 0,
258 PathSize * sizeof(TCHAR));
259 if (lpPath == NULL)
260 goto CLEANUP;
261
262 wsprintf(lpPath, _T("%s%s"), szPrePath, szName);
263
264 //MessageBox(NULL, lpPath, NULL, 0);
265
266 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
267 lpPath,
268 0,
269 KEY_READ,
270 &hClassKey) != ERROR_SUCCESS)
271 {
272 goto CLEANUP;
273 }
274
275 HeapFree(ProcessHeap, 0, lpPath);
276 lpPath = NULL;
277
278 if(RegQueryValueEx(hClassKey,
279 _T("NetCfgInstanceId"),
280 NULL,
281 &dwType,
282 NULL,
283 &dwDataSize) == ERROR_SUCCESS)
284 {
285 lpKeyClass = (LPTSTR)HeapAlloc(ProcessHeap,
286 0,
287 dwDataSize);
288 if (lpKeyClass == NULL)
289 goto CLEANUP;
290
291 if(RegQueryValueEx(hClassKey,
292 _T("NetCfgInstanceId"),
293 NULL,
294 &dwType,
295 (PBYTE)lpKeyClass,
296 &dwDataSize) != ERROR_SUCCESS)
297 {
298 lpKeyClass = NULL;
299 HeapFree(ProcessHeap, 0, lpKeyClass);
300 continue;
301 }
302 }
303 else
304 continue;
305
306 if (!lstrcmp(lpClass, lpKeyClass))
307 {
308 HeapFree(ProcessHeap, 0, lpKeyClass);
309 lpKeyClass = NULL;
310
311 if(RegQueryValueEx(hClassKey,
312 _T("DriverDesc"),
313 NULL,
314 &dwType,
315 NULL,
316 &dwDataSize) == ERROR_SUCCESS)
317 {
318 lpConDesc = (LPTSTR)HeapAlloc(ProcessHeap,
319 0,
320 dwDataSize);
321 if (lpConDesc == NULL)
322 goto CLEANUP;
323
324 if(RegQueryValueEx(hClassKey,
325 _T("DriverDesc"),
326 NULL,
327 &dwType,
328 (PBYTE)lpConDesc,
329 &dwDataSize) != ERROR_SUCCESS)
330 {
331 lpConDesc = NULL;
332 goto CLEANUP;
333 }
334 }
335 else
336 lpConDesc = NULL;
337
338 break;
339 }
340 }
341
342 CLEANUP:
343 if (hBaseKey != NULL)
344 RegCloseKey(hBaseKey);
345 if (hClassKey != NULL)
346 RegCloseKey(hClassKey);
347 if (lpConDesc != NULL)
348 HeapFree(ProcessHeap, 0, lpPath);
349 if (lpConDesc != NULL)
350 HeapFree(ProcessHeap, 0, lpKeyClass);
351
352 return lpConDesc;
353 }
354
355
356 VOID ShowInfo(BOOL bAll)
357 {
358 PIP_ADAPTER_INFO pAdapterInfo = NULL;
359 PIP_ADAPTER_INFO pAdapter = NULL;
360 ULONG adaptOutBufLen = 0;
361 PFIXED_INFO pFixedInfo = NULL;
362 ULONG netOutBufLen = 0;
363
364 /* call GetAdaptersInfo to obtain the adapter info */
365 if (GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen) == ERROR_BUFFER_OVERFLOW)
366 {
367 pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
368 if (pAdapterInfo == NULL)
369 return;
370
371 if (GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen) != NO_ERROR)
372 {
373 DoFormatMessage(0);
374 HeapFree(ProcessHeap, 0, pAdapterInfo);
375 return;
376 }
377 }
378 else
379 {
380 DoFormatMessage(0);
381 return;
382 }
383
384 /* call GetNetworkParams to obtain the network info */
385 if(GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW)
386 {
387 pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
388 if (pFixedInfo == NULL)
389 return;
390
391 if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR)
392 {
393 DoFormatMessage(0);
394 HeapFree(ProcessHeap, 0, pFixedInfo);
395 return;
396 }
397 }
398 else
399 {
400 DoFormatMessage(0);
401 return;
402 }
403
404 pAdapter = pAdapterInfo;
405
406 _tprintf(_T("\nReactOS IP Configuration\n\n"));
407 if (bAll)
408 {
409 _tprintf(_T("\tHost Name . . . . . . . . . . . . : %s\n"), pFixedInfo->HostName);
410 _tprintf(_T("\tPrimary DNS Suffix. . . . . . . . : \n"));
411 _tprintf(_T("\tNode Type . . . . . . . . . . . . : %s\n"), GetNodeTypeName(pFixedInfo->NodeType));
412 if (pFixedInfo->EnableRouting)
413 _tprintf(_T("\tIP Routing Enabled. . . . . . . . : Yes\n"));
414 else
415 _tprintf(_T("\tIP Routing Enabled. . . . . . . . : No\n"));
416 if (pAdapter->HaveWins)
417 _tprintf(_T("\tWINS Proxy enabled. . . . . . . . : Yes\n"));
418 else
419 _tprintf(_T("\tWINS Proxy enabled. . . . . . . . : No\n"));
420 _tprintf(_T("\tDNS Suffix Search List. . . . . . : %s\n"), pFixedInfo->DomainName);
421 }
422
423 while (pAdapter)
424 {
425 LPTSTR IntType, myConType;
426
427 IntType = GetInterfaceTypeName(pAdapter->Type);
428 myConType = GetConnectionType(pAdapter->AdapterName);
429
430 _tprintf(_T("\n%s %s: \n\n"), IntType , myConType);
431
432 if (myConType != NULL) HeapFree(ProcessHeap, 0, myConType);
433
434 /* check if the adapter is connected to the media */
435 if (_tcscmp(pAdapter->IpAddressList.IpAddress.String, "0.0.0.0") == 0)
436 {
437 _tprintf(_T("\tMedia State . . . . . . . . . . . : Media disconnected\n"));
438 pAdapter = pAdapter->Next;
439 continue;
440 }
441
442 _tprintf(_T("\tConnection-specific DNS Suffix. . : %s\n"), pFixedInfo->DomainName);
443
444 if (bAll)
445 {
446 _tprintf(_T("\tDescription . . . . . . . . . . . : %s\n"), GetConnectionDescription(pAdapter->AdapterName));
447 _tprintf(_T("\tPhysical Address. . . . . . . . . : %s\n"), PrintMacAddr(pAdapter->Address));
448 if (pAdapter->DhcpEnabled)
449 _tprintf(_T("\tDHCP Enabled. . . . . . . . . . . : Yes\n"));
450 else
451 _tprintf(_T("\tDHCP Enabled. . . . . . . . . . . : No\n"));
452 _tprintf(_T("\tAutoconfiguration Enabled . . . . : \n"));
453 }
454
455 _tprintf(_T("\tIP Address. . . . . . . . . . . . : %s\n"), pAdapter->IpAddressList.IpAddress.String);
456 _tprintf(_T("\tSubnet Mask . . . . . . . . . . . : %s\n"), pAdapter->IpAddressList.IpMask.String);
457 _tprintf(_T("\tDefault Gateway . . . . . . . . . : %s\n"), pAdapter->GatewayList.IpAddress.String);
458
459 if (bAll)
460 {
461 PIP_ADDR_STRING pIPAddr;
462
463 if (pAdapter->DhcpEnabled)
464 _tprintf(_T("\tDHCP Server . . . . . . . . . . . : %s\n"), pAdapter->DhcpServer.IpAddress.String);
465
466 _tprintf(_T("\tDNS Servers . . . . . . . . . . . : "));
467 _tprintf(_T("%s\n"), pFixedInfo->DnsServerList.IpAddress.String);
468 pIPAddr = pFixedInfo->DnsServerList.Next;
469 while (pIPAddr)
470 {
471 _tprintf(_T("\t\t\t\t\t %s\n"), pIPAddr ->IpAddress.String );
472 pIPAddr = pIPAddr->Next;
473 }
474
475 if (pAdapter->HaveWins)
476 {
477 _tprintf(_T("\tPrimary WINS Server . . . . . . . : %s\n"), pAdapter->PrimaryWinsServer.IpAddress.String);
478 _tprintf(_T("\tSecondard WINS Server . . . . . . : %s\n"), pAdapter->SecondaryWinsServer.IpAddress.String);
479 }
480
481 if (pAdapter->DhcpEnabled)
482 {
483 _tprintf(_T("\tLease Obtained. . . . . . . . . . : %s"), _tasctime(localtime(&pAdapter->LeaseObtained)));
484 _tprintf(_T("\tLease Expires . . . . . . . . . . : %s"), _tasctime(localtime(&pAdapter->LeaseExpires)));
485 }
486 }
487 _tprintf(_T("\n"));
488
489 pAdapter = pAdapter->Next;
490
491 }
492
493 HeapFree(ProcessHeap, 0, pFixedInfo);
494 HeapFree(ProcessHeap, 0, pAdapterInfo);
495 }
496
497 VOID Release(LPTSTR Index)
498 {
499 IP_ADAPTER_INDEX_MAP AdapterInfo;
500 DWORD ret;
501
502 /* if interface is not given, query GetInterfaceInfo */
503 if (Index == NULL)
504 {
505 PIP_INTERFACE_INFO pInfo = NULL;
506 ULONG ulOutBufLen = 0;
507
508 if (GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER)
509 {
510 pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, ulOutBufLen);
511 if (pInfo == NULL)
512 return;
513
514 if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR )
515 {
516 CopyMemory(&AdapterInfo, &pInfo->Adapter[0], sizeof(IP_ADAPTER_INDEX_MAP));
517 _tprintf(_T("name - %S\n"), pInfo->Adapter[0].Name);
518 HeapFree(ProcessHeap, 0, pInfo);
519 }
520 else
521 {
522 DoFormatMessage(0);
523 HeapFree(ProcessHeap, 0, pInfo);
524 return;
525 }
526 }
527 else
528 {
529 DoFormatMessage(0);
530 return;
531 }
532 }
533 else
534 {
535 ;
536 /* FIXME:
537 * we need to be able to release connections by name with support for globbing
538 * i.e. ipconfig /release Eth* will release all cards starting with Eth...
539 * ipconfig /release *con* will release all cards with 'con' in their name
540 */
541 }
542
543
544 /* Call IpReleaseAddress to release the IP address on the specified adapter. */
545 if ((ret = IpReleaseAddress(&AdapterInfo)) != NO_ERROR)
546 {
547 _tprintf(_T("\nAn error occured while releasing interface %S : \n"), AdapterInfo.Name);
548 DoFormatMessage(ret);
549 }
550
551 }
552
553
554
555
556 VOID Renew(LPTSTR Index)
557 {
558 IP_ADAPTER_INDEX_MAP AdapterInfo;
559
560 /* if interface is not given, query GetInterfaceInfo */
561 if (Index == NULL)
562 {
563 PIP_INTERFACE_INFO pInfo;
564 ULONG ulOutBufLen = 0;
565
566 pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, sizeof(IP_INTERFACE_INFO));
567 if (pInfo == NULL)
568 {
569 _tprintf(_T("memory allocation error"));
570 return;
571 }
572
573 /* Make an initial call to GetInterfaceInfo to get
574 * the necessary size into the ulOutBufLen variable */
575 if ( GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER)
576 {
577 HeapFree(ProcessHeap, 0, pInfo);
578 pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, ulOutBufLen);
579 if (pInfo == NULL)
580 {
581 _tprintf(_T("memory allocation error"));
582 return;
583 }
584 }
585
586 /* Make a second call to GetInterfaceInfo to get the actual data we want */
587 if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR )
588 {
589 CopyMemory(&AdapterInfo, &pInfo->Adapter[0], sizeof(IP_ADAPTER_INDEX_MAP));
590 _tprintf(_T("name - %S\n"), pInfo->Adapter[0].Name);
591 }
592 else
593 {
594 _tprintf(_T("\nGetInterfaceInfo failed : "));
595 DoFormatMessage(0);
596 }
597
598 HeapFree(ProcessHeap, 0, pInfo);
599 }
600 else
601 {
602 ;
603 /* FIXME:
604 * we need to be able to renew connections by name with support for globbing
605 * i.e. ipconfig /renew Eth* will renew all cards starting with Eth...
606 * ipconfig /renew *con* will renew all cards with 'con' in their name
607 */
608 }
609
610
611 /* Call IpRenewAddress to renew the IP address on the specified adapter. */
612 if (IpRenewAddress(&AdapterInfo) != NO_ERROR)
613 {
614 _tprintf(_T("\nAn error occured while renew interface %s : "), _T("*name*"));
615 DoFormatMessage(0);
616 }
617 }
618
619
620
621 VOID Usage(VOID)
622 {
623 HRSRC hRes;
624 LPTSTR lpUsage;
625 DWORD Size;
626
627 LPTSTR lpName = (LPTSTR)MAKEINTRESOURCE((IDS_USAGE >> 4) + 1);
628
629 hRes = FindResource(hInstance,
630 lpName,
631 RT_STRING);
632 if (hRes != NULL)
633 {
634 if ((Size = SizeofResource(hInstance,
635 hRes)))
636 {
637 lpUsage = (LPTSTR)HeapAlloc(ProcessHeap,
638 0,
639 Size);
640 if (lpUsage == NULL)
641 return;
642
643 if (LoadString(hInstance,
644 IDS_USAGE,
645 lpUsage,
646 Size))
647 {
648 _tprintf(_T("%s"), lpUsage);
649 }
650 }
651 }
652
653
654 }
655
656 int main(int argc, char *argv[])
657 {
658 BOOL DoUsage=FALSE;
659 BOOL DoAll=FALSE;
660 BOOL DoRelease=FALSE;
661 BOOL DoRenew=FALSE;
662 BOOL DoFlushdns=FALSE;
663 BOOL DoRegisterdns=FALSE;
664 BOOL DoDisplaydns=FALSE;
665 BOOL DoShowclassid=FALSE;
666 BOOL DoSetclassid=FALSE;
667
668 hInstance = GetModuleHandle(NULL);
669 ProcessHeap = GetProcessHeap();
670
671 /* Parse command line for options we have been given. */
672 if ( (argc > 1)&&(argv[1][0]=='/') )
673 {
674 if( !_tcsicmp( &argv[1][1], _T("?") ))
675 {
676 DoUsage = TRUE;
677 }
678 else if( !_tcsnicmp( &argv[1][1], _T("ALL"), _tcslen(&argv[1][1]) ))
679 {
680 DoAll = TRUE;
681 }
682 else if( !_tcsnicmp( &argv[1][1], _T("RELEASE"), _tcslen(&argv[1][1]) ))
683 {
684 DoRelease = TRUE;
685 }
686 else if( ! _tcsnicmp( &argv[1][1], _T("RENEW"), _tcslen(&argv[1][1]) ))
687 {
688 DoRenew = TRUE;
689 }
690 else if( ! _tcsnicmp( &argv[1][1], _T("FLUSHDNS"), _tcslen(&argv[1][1]) ))
691 {
692 DoFlushdns = TRUE;
693 }
694 else if( ! _tcsnicmp( &argv[1][1], _T("FLUSHREGISTERDNS"), _tcslen(&argv[1][1]) ))
695 {
696 DoRegisterdns = TRUE;
697 }
698 else if( ! _tcsnicmp( &argv[1][1], _T("DISPLAYDNS"), _tcslen(&argv[1][1]) ))
699 {
700 DoDisplaydns = TRUE;
701 }
702 else if( ! _tcsnicmp( &argv[1][1], _T("SHOWCLASSID"), _tcslen(&argv[1][1]) ))
703 {
704 DoShowclassid = TRUE;
705 }
706 else if( ! _tcsnicmp( &argv[1][1], _T("SETCLASSID"), _tcslen(&argv[1][1]) ))
707 {
708 DoSetclassid = TRUE;
709 }
710 }
711
712 switch (argc)
713 {
714 case 1: /* Default behaviour if no options are given*/
715 ShowInfo(FALSE);
716 break;
717 case 2: /* Process all the options that take no parameters */
718 if (DoUsage)
719 Usage();
720 else if (DoAll)
721 ShowInfo(TRUE);
722 else if (DoRelease)
723 Release(NULL);
724 else if (DoRenew)
725 Renew(NULL);
726 else if (DoFlushdns)
727 _tprintf(_T("\nSorry /flushdns is not implemented yet\n"));
728 else if (DoRegisterdns)
729 _tprintf(_T("\nSorry /registerdns is not implemented yet\n"));
730 else if (DoDisplaydns)
731 _tprintf(_T("\nSorry /displaydns is not implemented yet\n"));
732 else
733 Usage();
734 break;
735 case 3: /* Process all the options that can have 1 parameter */
736 if (DoRelease)
737 _tprintf(_T("\nSorry /release [adapter] is not implemented yet\n"));
738 //Release(argv[2]);
739 else if (DoRenew)
740 _tprintf(_T("\nSorry /renew [adapter] is not implemented yet\n"));
741 else if (DoShowclassid)
742 _tprintf(_T("\nSorry /showclassid adapter is not implemented yet\n"));
743 else if (DoSetclassid)
744 _tprintf(_T("\nSorry /setclassid adapter is not implemented yet\n"));
745 else
746 Usage();
747 break;
748 case 4: /* Process all the options that can have 2 parameters */
749 if (DoSetclassid)
750 _tprintf(_T("\nSorry /setclassid adapter [classid]is not implemented yet\n"));
751 else
752 Usage();
753 break;
754 default:
755 Usage();
756 }
757
758 return 0;
759 }
760