Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

903 lines
20 KiB

  1. /*++
  2. Copyright (c) 1997 FORE Systems, Inc.
  3. Copyright (c) 1997 Microsoft Corporation
  4. Module Name:
  5. aas.c
  6. Abstract:
  7. ATM ARP Admin Utility.
  8. Usage:
  9. atmarp
  10. Revision History:
  11. Who When What
  12. -------- -------- ---------------------------------------------
  13. josephj 06-10-1998 Created (adapted from atmlane admin utility).
  14. Notes:
  15. Modelled after atmlane utility.
  16. --*/
  17. #include "common.h"
  18. #include "..\atmarps\arp.h"
  19. #include "..\atmarps\ioctl.h"
  20. #include "atmmsg.h"
  21. //
  22. // Globals
  23. //
  24. static CHAR DefaultDeviceName[] = "\\\\.\\AtmArpServer";
  25. static CHAR *pDeviceName = DefaultDeviceName;
  26. //
  27. // LoadMessages - courtesy IPCONFIG
  28. //
  29. // Loads all internationalizable messages into the various tables
  30. //
  31. VOID
  32. LoadMessages(
  33. )
  34. {
  35. }
  36. BOOL
  37. CheckVersion(
  38. HANDLE DeviceHandle
  39. )
  40. {
  41. return TRUE;
  42. }
  43. BOOL
  44. AasGetInterfaces(
  45. HANDLE DeviceHandle,
  46. PINTERFACES pInterfaces,
  47. ULONG cbInterfaces
  48. )
  49. {
  50. ULONG BytesReturned;
  51. BOOL Result = FALSE;
  52. if (DeviceIoControl(
  53. DeviceHandle,
  54. ARPS_IOCTL_QUERY_INTERFACES,
  55. (PVOID)pInterfaces,
  56. cbInterfaces,
  57. (PVOID)pInterfaces,
  58. cbInterfaces,
  59. &BytesReturned,
  60. 0))
  61. {
  62. UINT u = pInterfaces->NumberOfInterfaces;
  63. //
  64. // Fixup pointers
  65. //
  66. for (u=0;u<pInterfaces->NumberOfInterfaces;u++)
  67. {
  68. INTERFACE_NAME *pInterface = (pInterfaces->Interfaces)+u;
  69. pInterface->Buffer = (PWSTR)( (ULONG_PTR)pInterface->Buffer
  70. + (PUCHAR)pInterface);
  71. //
  72. // check that all this is valid...
  73. //
  74. if ( ((PUCHAR)pInterface->Buffer < (PUCHAR) pInterface)
  75. || ( ((PUCHAR)pInterface->Buffer + pInterface->Length)
  76. > ((PUCHAR)pInterfaces + cbInterfaces)))
  77. {
  78. printf("WHOA THERE!\n");
  79. DebugBreak();
  80. }
  81. else
  82. {
  83. #if 0
  84. printf("INTERFACE: Len=%lu, Name=\"%c%c%c%c...\n",
  85. pInterface->Length,
  86. pInterface->Buffer[0],
  87. pInterface->Buffer[1],
  88. pInterface->Buffer[2],
  89. pInterface->Buffer[3]
  90. );
  91. #endif // 0
  92. }
  93. }
  94. Result = TRUE;
  95. }
  96. else
  97. {
  98. DisplayMessage(FALSE, MSG_ERROR_GETTING_INTERFACE_LIST);
  99. }
  100. return Result;
  101. }
  102. BOOL
  103. AasGetArpCache(
  104. HANDLE DeviceHandle,
  105. INTERFACE_NAME *pInterface,
  106. PIOCTL_QUERY_CACHE
  107. pArpCache,
  108. ULONG cbArpCache
  109. )
  110. {
  111. ULONG BytesReturned;
  112. BOOL Result = FALSE;
  113. UINT BufferOffset;
  114. BufferOffset = FIELD_OFFSET(struct QUERY_ARP_CACHE_INPUT_PARAMS, Name) +
  115. sizeof(pArpCache->Name);
  116. pArpCache->Name.Buffer = (PWSTR)sizeof(pArpCache->Name);
  117. pArpCache->Name.Length = pInterface->Length;
  118. pArpCache->Name.MaximumLength = pInterface->MaximumLength;
  119. memcpy((PUCHAR)pArpCache + BufferOffset,
  120. pInterface->Buffer,
  121. pInterface->MaximumLength);
  122. Result = DeviceIoControl(
  123. DeviceHandle,
  124. ARPS_IOCTL_QUERY_ARPCACHE,
  125. (PVOID)pArpCache,
  126. BufferOffset + pInterface->Length,
  127. (PVOID)pArpCache,
  128. cbArpCache,
  129. &BytesReturned,
  130. NULL);
  131. if (Result)
  132. {
  133. #if 0
  134. printf(
  135. "DeviceIoCtl: cbRet = %lu, cArps=%lu, cArpsInBuf=%lu\n",
  136. BytesReturned,
  137. pArpCache->Entries.TotalNumberOfEntries,
  138. pArpCache->Entries.NumberOfEntriesInBuffer
  139. );
  140. #endif // 0
  141. }
  142. else
  143. {
  144. DisplayMessage(FALSE, MSG_ERROR_GETTING_ARP_CACHE);
  145. }
  146. return Result;
  147. }
  148. BOOL
  149. AasGetMarsCache(
  150. HANDLE DeviceHandle,
  151. INTERFACE_NAME *pInterface,
  152. PIOCTL_QUERY_MARS_CACHE
  153. pMarsCache,
  154. ULONG cbMarsCache
  155. )
  156. {
  157. ULONG BytesReturned;
  158. BOOL Result = FALSE;
  159. UINT BufferOffset;
  160. BufferOffset = FIELD_OFFSET(struct QUERY_MARS_CACHE_INPUT_PARAMS, Name) +
  161. sizeof(pMarsCache->Name);
  162. pMarsCache->Name.Buffer = (PWSTR)sizeof(pMarsCache->Name);
  163. pMarsCache->Name.Length = pInterface->Length;
  164. pMarsCache->Name.MaximumLength = pInterface->MaximumLength;
  165. memcpy((PUCHAR)pMarsCache + BufferOffset,
  166. pInterface->Buffer,
  167. pInterface->MaximumLength);
  168. Result = DeviceIoControl(
  169. DeviceHandle,
  170. ARPS_IOCTL_QUERY_MARSCACHE,
  171. (PVOID)pMarsCache,
  172. BufferOffset + pInterface->Length,
  173. (PVOID)pMarsCache,
  174. cbMarsCache,
  175. &BytesReturned,
  176. NULL);
  177. if (Result)
  178. {
  179. #if 0
  180. printf(
  181. "DeviceIoCtl: cbRet = %lu, Sig=0x%lx, cMars=%lu, cMarsInBuf=%lu\n",
  182. BytesReturned,
  183. pMarsCache->MarsCache.Sig,
  184. pMarsCache->MarsCache.TotalNumberOfEntries,
  185. pMarsCache->MarsCache.NumberOfEntriesInBuffer
  186. );
  187. #endif // 0
  188. }
  189. else
  190. {
  191. DisplayMessage(FALSE, MSG_ERROR_GETTING_MARS_CACHE);
  192. }
  193. return Result;
  194. }
  195. BOOL
  196. AasGetArpStats(
  197. HANDLE DeviceHandle,
  198. INTERFACE_NAME *pInterface,
  199. PARP_SERVER_STATISTICS
  200. pArpStats
  201. )
  202. {
  203. ULONG BytesReturned;
  204. BOOL Result = FALSE;
  205. // printf ( " In AasGetArpStats\n");
  206. //
  207. // Temporarily fixup buffer pointer
  208. //
  209. pInterface->Buffer = (PWSTR)( (PUCHAR)pInterface->Buffer
  210. - (PUCHAR)pInterface);
  211. Result = DeviceIoControl(
  212. DeviceHandle,
  213. ARPS_IOCTL_QUERY_ARP_STATISTICS,
  214. (PVOID)pInterface,
  215. (UINT) (((ULONG_PTR)pInterface->Buffer)+pInterface->Length),
  216. (PVOID)pArpStats,
  217. sizeof(*pArpStats),
  218. &BytesReturned,
  219. NULL);
  220. //
  221. // Restore buffer pointer
  222. //
  223. pInterface->Buffer = (PWSTR)( (ULONG_PTR)pInterface->Buffer
  224. + (PUCHAR)pInterface);
  225. if (Result)
  226. {
  227. #if 0
  228. printf(
  229. "DeviceIoCtl: cbRet = %lu, TotRcvPkts=%lu\n",
  230. BytesReturned,
  231. pArpStats->TotalRecvPkts
  232. );
  233. #endif // 0
  234. }
  235. else
  236. {
  237. DisplayMessage(FALSE, MSG_ERROR_GETTING_ARP_STATS);
  238. }
  239. return Result;
  240. }
  241. BOOL
  242. AasGetMarsStats(
  243. HANDLE DeviceHandle,
  244. INTERFACE_NAME *pInterface,
  245. PMARS_SERVER_STATISTICS
  246. pMarsStats
  247. )
  248. {
  249. ULONG BytesReturned;
  250. BOOL Result = FALSE;
  251. // printf ( " In AasGetMarsStats\n");
  252. //
  253. // Temporarily fixup buffer pointer
  254. //
  255. pInterface->Buffer = (PWSTR)( (PUCHAR)pInterface->Buffer
  256. - (PUCHAR)pInterface);
  257. Result = DeviceIoControl(
  258. DeviceHandle,
  259. ARPS_IOCTL_QUERY_MARS_STATISTICS,
  260. (PVOID)pInterface,
  261. (UINT) (((ULONG_PTR)pInterface->Buffer)+pInterface->Length),
  262. (PVOID)pMarsStats,
  263. sizeof(*pMarsStats),
  264. &BytesReturned,
  265. NULL);
  266. //
  267. // Restore buffer pointer
  268. //
  269. pInterface->Buffer = (PWSTR)( (ULONG_PTR)pInterface->Buffer
  270. + (PUCHAR)pInterface);
  271. if (Result)
  272. {
  273. #if 0
  274. printf(
  275. "DeviceIoCtl: cbRet = %lu, TotRcvPkts=%lu\n",
  276. BytesReturned,
  277. pMarsStats->TotalRecvPkts
  278. );
  279. #endif // 0
  280. }
  281. else
  282. {
  283. DisplayMessage(FALSE, MSG_ERROR_GETTING_MARS_STATS);
  284. }
  285. return Result;
  286. }
  287. BOOL
  288. AasResetStatistics(
  289. HANDLE DeviceHandle,
  290. INTERFACE_NAME *pInterface
  291. )
  292. {
  293. ULONG BytesReturned;
  294. BOOL Result = FALSE;
  295. //
  296. // Temporarily fixup buffer pointer
  297. //
  298. pInterface->Buffer = (PWSTR)( (PUCHAR)pInterface->Buffer
  299. - (PUCHAR)pInterface);
  300. Result = DeviceIoControl(
  301. DeviceHandle,
  302. ARPS_IOCTL_RESET_STATISTICS,
  303. (PVOID)pInterface,
  304. (UINT) (((ULONG_PTR)pInterface->Buffer)+pInterface->Length),
  305. NULL,
  306. 0,
  307. &BytesReturned,
  308. NULL);
  309. //
  310. // Restore buffer pointer
  311. //
  312. pInterface->Buffer = (PWSTR)( (ULONG_PTR)pInterface->Buffer
  313. + (PUCHAR)pInterface);
  314. if (Result)
  315. {
  316. DisplayMessage(FALSE, MSG_STATS_RESET_STATS);
  317. #if 0
  318. printf(
  319. "DeviceIoCtl: cbRet = %lu, TotRcvPkts=%lu\n",
  320. BytesReturned,
  321. pMarsStats->TotalRecvPkts
  322. );
  323. #endif // 0
  324. }
  325. else
  326. {
  327. DisplayMessage(FALSE, MSG_ERROR_RESETTING_STATS);
  328. }
  329. return Result;
  330. }
  331. #if 0
  332. LPSTR
  333. ElanStateToString(ULONG In)
  334. {
  335. switch(In)
  336. {
  337. case 1:
  338. case 2:
  339. case 3:
  340. case 4:
  341. case 5:
  342. case 6:
  343. case 7:
  344. case 8:
  345. case 9:
  346. case 10:
  347. case 11:
  348. return (ElanState[In].String);
  349. default:
  350. return (ElanState[0].String);
  351. }
  352. }
  353. LPSTR
  354. ElanLanTypeToString(ULONG In)
  355. {
  356. switch(In)
  357. {
  358. case 0:
  359. return LanType[1].String;
  360. case 1:
  361. return LanType[2].String;
  362. case 2:
  363. return LanType[3].String;
  364. default:
  365. return LanType[0].String;
  366. }
  367. }
  368. LPSTR
  369. ElanMaxFrameSizeToString(ULONG In)
  370. {
  371. switch(In)
  372. {
  373. case 0:
  374. return Misc[3].String;
  375. case 1:
  376. return "1516";
  377. case 2:
  378. return "4544";
  379. case 3:
  380. return "9234";
  381. case 4:
  382. return "18190";
  383. default:
  384. return " ? ";
  385. }
  386. }
  387. LPSTR
  388. McastVcTypeToString(ULONG In)
  389. {
  390. switch(In)
  391. {
  392. case 0:
  393. return McastSendVcType[1].String;
  394. case 1:
  395. return McastSendVcType[2].String;
  396. case 2:
  397. return McastSendVcType[3].String;
  398. default:
  399. return McastSendVcType[0].String;
  400. }
  401. }
  402. PUCHAR
  403. MacAddrToString(PVOID In)
  404. {
  405. static UCHAR String[20];
  406. static PUCHAR HexChars = "0123456789abcdef";
  407. PUCHAR EthAddr = (PUCHAR) In;
  408. UINT i;
  409. PUCHAR s;
  410. for (i = 0, s = String; i < 6; i++, EthAddr++)
  411. {
  412. *s++ = HexChars[(*EthAddr)>>4];
  413. *s++ = HexChars[(*EthAddr)&0xf];
  414. *s++ = '.';
  415. }
  416. *(--s) = '\0';
  417. return String;
  418. }
  419. #endif // 0
  420. PUCHAR
  421. IpAddrToString(IPADDR *pIpAddr)
  422. {
  423. PUCHAR puc = (PUCHAR) pIpAddr;
  424. static UCHAR String[80];
  425. wsprintf(String, "%u.%u.%u.%u", puc[0], puc[1], puc[2], puc[3]);
  426. return String;
  427. }
  428. PUCHAR
  429. AtmAddrToString(ATM_ADDRESS *pAtmAddress)
  430. {
  431. static UCHAR String[80];
  432. static PUCHAR HexChars = "0123456789abcdef";
  433. PUCHAR AtmAddr = (PUCHAR) &(pAtmAddress->Address);
  434. PUCHAR s = String;
  435. *s++ = HexChars[(*AtmAddr)>>4];
  436. *s++ = HexChars[(*AtmAddr++)&0xf]; // 1
  437. *s++ = '.';
  438. *s++ = HexChars[(*AtmAddr)>>4];
  439. *s++ = HexChars[(*AtmAddr++)&0xf]; // 2
  440. *s++ = HexChars[(*AtmAddr)>>4];
  441. *s++ = HexChars[(*AtmAddr++)&0xf]; // 3
  442. *s++ = '.';
  443. *s++ = HexChars[(*AtmAddr)>>4];
  444. *s++ = HexChars[(*AtmAddr++)&0xf]; // 4
  445. *s++ = '.';
  446. *s++ = HexChars[(*AtmAddr)>>4];
  447. *s++ = HexChars[(*AtmAddr++)&0xf]; // 5
  448. *s++ = HexChars[(*AtmAddr)>>4];
  449. *s++ = HexChars[(*AtmAddr++)&0xf]; // 6
  450. *s++ = HexChars[(*AtmAddr)>>4];
  451. *s++ = HexChars[(*AtmAddr++)&0xf]; // 7
  452. *s++ = '.';
  453. *s++ = HexChars[(*AtmAddr)>>4];
  454. *s++ = HexChars[(*AtmAddr++)&0xf]; // 8
  455. *s++ = HexChars[(*AtmAddr)>>4];
  456. *s++ = HexChars[(*AtmAddr++)&0xf]; // 9
  457. *s++ = '.';
  458. *s++ = HexChars[(*AtmAddr)>>4];
  459. *s++ = HexChars[(*AtmAddr++)&0xf]; // 10
  460. *s++ = HexChars[(*AtmAddr)>>4];
  461. *s++ = HexChars[(*AtmAddr++)&0xf]; // 11
  462. *s++ = '.';
  463. *s++ = HexChars[(*AtmAddr)>>4];
  464. *s++ = HexChars[(*AtmAddr++)&0xf]; // 12
  465. *s++ = HexChars[(*AtmAddr)>>4];
  466. *s++ = HexChars[(*AtmAddr++)&0xf]; // 13
  467. *s++ = '.';
  468. *s++ = HexChars[(*AtmAddr)>>4];
  469. *s++ = HexChars[(*AtmAddr++)&0xf]; // 14
  470. *s++ = HexChars[(*AtmAddr)>>4];
  471. *s++ = HexChars[(*AtmAddr++)&0xf]; // 15
  472. *s++ = HexChars[(*AtmAddr)>>4];
  473. *s++ = HexChars[(*AtmAddr++)&0xf]; // 16
  474. *s++ = HexChars[(*AtmAddr)>>4];
  475. *s++ = HexChars[(*AtmAddr++)&0xf]; // 17
  476. *s++ = HexChars[(*AtmAddr)>>4];
  477. *s++ = HexChars[(*AtmAddr++)&0xf]; // 18
  478. *s++ = HexChars[(*AtmAddr)>>4];
  479. *s++ = HexChars[(*AtmAddr++)&0xf]; // 19
  480. *s++ = '.';
  481. *s++ = HexChars[(*AtmAddr)>>4];
  482. *s++ = HexChars[(*AtmAddr++)&0xf]; // 20
  483. *s = '\0';
  484. return String;
  485. }
  486. VOID
  487. AasDisplayArpCache(
  488. PIOCTL_QUERY_CACHE pArpCache
  489. )
  490. {
  491. PARPENTRY pEntry = pArpCache->Entries.Entries;
  492. UINT i;
  493. for (i = 0; i < pArpCache->Entries.NumberOfEntriesInBuffer; i++)
  494. {
  495. DisplayMessage(FALSE, MSG_AAS_ARP_CACHE_ENTRY,
  496. IpAddrToString(&(pEntry->IpAddr)),
  497. AtmAddrToString(&pEntry->AtmAddress));
  498. pEntry ++;
  499. }
  500. }
  501. VOID
  502. AasDisplayMarsCache(
  503. PIOCTL_QUERY_MARS_CACHE pMarsCache
  504. )
  505. {
  506. PMARSENTRY pEntry = pMarsCache->MarsCache.Entries;
  507. UINT i;
  508. for (i = 0;
  509. i < pMarsCache->MarsCache.NumberOfEntriesInBuffer;
  510. i++, pEntry++)
  511. {
  512. UINT j;
  513. char* szIpAddr = IpAddrToString(&(pEntry->IpAddr));
  514. char rgBlanks[128];
  515. ATM_ADDRESS *pAtmAddr = (ATM_ADDRESS*)
  516. ((PUCHAR)pEntry + pEntry->OffsetAtmAddresses);
  517. FillMemory(rgBlanks, lstrlen(szIpAddr), ' ');
  518. rgBlanks[lstrlen(szIpAddr)]=0;
  519. #if 0
  520. printf("Entry[i] @ 0x%lx: Ip=%u.%u.%u.%u NumAddr=%lu Offset=%lu\n",
  521. pEntry,
  522. ((PUCHAR)&pEntry->IpAddr)[0],
  523. ((PUCHAR)&pEntry->IpAddr)[1],
  524. ((PUCHAR)&pEntry->IpAddr)[2],
  525. ((PUCHAR)&pEntry->IpAddr)[3],
  526. pEntry->NumAtmAddresses,
  527. pEntry->OffsetAtmAddresses);
  528. #endif // 0
  529. for (j = 0;
  530. j < pEntry->NumAtmAddresses;
  531. j++, pAtmAddr++)
  532. {
  533. // printf("\t pAddr=%lx\n", pAtmAddr);
  534. if (!j)
  535. {
  536. if (pEntry->IpAddr == 0)
  537. {
  538. DisplayMessage(FALSE, MSG_AAS_ARP_PROMIS_CACHE_ENTRY,
  539. AtmAddrToString(pAtmAddr));
  540. }
  541. else
  542. {
  543. DisplayMessage(FALSE, MSG_AAS_ARP_CACHE_ENTRY,
  544. IpAddrToString(&(pEntry->IpAddr)),
  545. AtmAddrToString(pAtmAddr));
  546. }
  547. }
  548. else
  549. {
  550. DisplayMessage(FALSE, MSG_AAS_ARP_CACHE_ENTRY,
  551. rgBlanks,
  552. AtmAddrToString(pAtmAddr));
  553. }
  554. }
  555. }
  556. }
  557. VOID
  558. AasDisplayArpStats(
  559. PARP_SERVER_STATISTICS pArpStats
  560. )
  561. {
  562. #if 0
  563. Recvd Pkts: ->TotalRecvPkts (->DiscardedRecvPkts discarded)
  564. Arp Entries: ->CurrentArpEntries current ( ->MaxArpEntries max)
  565. Arp Responses: ->Acks acks ( ->Naks naks)
  566. Client VCs: ->CurrentClientVCs current (->MaxClientVCs max)
  567. Incoming Calls: ->TotalIncomingCalls total (->FailedIncomingCalls failed)
  568. Received: 10000 total (100 discarded)
  569. Entries: 10 current (15 max)
  570. Responses: 1000 acks (200 naks)
  571. Client VCs: 5 current (12 max)
  572. Incoming Calls: 500 total (20 failed)
  573. #endif //
  574. DisplayMessage(FALSE, MSG_AAS_C01_ARP_STATS);
  575. DisplayMessage(FALSE, MSG_STATS_ELAPSED_TIME, pArpStats->ElapsedSeconds);
  576. DisplayMessage(FALSE, MSG_ARPS_RECVD_PKTS, pArpStats->TotalRecvPkts,
  577. pArpStats->DiscardedRecvPkts);
  578. DisplayMessage(FALSE, MSG_ARPS_ARP_ENTRIES, pArpStats->CurrentArpEntries,
  579. pArpStats->MaxArpEntries);
  580. DisplayMessage(FALSE, MSG_ARPS_ARP_RESPONSES, pArpStats->Acks,
  581. pArpStats->Naks);
  582. DisplayMessage(FALSE, MSG_ARPS_CLIENT_VCS, pArpStats->CurrentClientVCs,
  583. pArpStats->MaxClientVCs);
  584. DisplayMessage(FALSE, MSG_ARPS_INCOMING_CALLS, pArpStats->TotalIncomingCalls);
  585. // pArpStats->TotalActiveVCs
  586. }
  587. VOID
  588. AasDisplayMarsStats(
  589. PMARS_SERVER_STATISTICS pMarsStats
  590. )
  591. {
  592. DisplayMessage(FALSE, MSG_AAS_C02_MARS_STATS);
  593. DisplayMessage(FALSE, MSG_MARS_RECVD_PKTS, pMarsStats->TotalRecvPkts,
  594. pMarsStats->DiscardedRecvPkts);
  595. DisplayMessage(FALSE, MSG_MARS_RECVD_MCDATA_PKTS,pMarsStats->TotalMCDataPkts,
  596. pMarsStats->DiscardedMCDataPkts,
  597. pMarsStats->ReflectedMCDataPkts);
  598. DisplayMessage(FALSE, MSG_MARS_MEMBERS, pMarsStats->CurrentClusterMembers,
  599. pMarsStats->MaxClusterMembers);
  600. DisplayMessage(FALSE, MSG_MARS_PROMIS, pMarsStats->CurrentPromiscuous,
  601. pMarsStats->MaxPromiscuous);
  602. DisplayMessage(FALSE, MSG_MARS_ADD_PARTY, pMarsStats->TotalCCVCAddParties,
  603. pMarsStats->FailedCCVCAddParties);
  604. DisplayMessage(FALSE, MSG_MARS_REGISTRATION, pMarsStats->RegistrationRequests,
  605. pMarsStats->FailedRegistrations);
  606. DisplayMessage(FALSE, MSG_MARS_JOINS, pMarsStats->TotalJoins,
  607. pMarsStats->FailedJoins,
  608. pMarsStats->DuplicateJoins);
  609. DisplayMessage(FALSE, MSG_MARS_LEAVES, pMarsStats->TotalLeaves,
  610. pMarsStats->FailedLeaves);
  611. DisplayMessage(FALSE, MSG_MARS_REQUESTS, pMarsStats->TotalRequests);
  612. DisplayMessage(FALSE, MSG_MARS_RESPONSES, pMarsStats->VCMeshAcks
  613. +pMarsStats->MCSAcks,
  614. pMarsStats->Naks);
  615. DisplayMessage(FALSE, MSG_MARS_VC_MESH, pMarsStats->SuccessfulVCMeshJoins,
  616. pMarsStats->VCMeshAcks);
  617. DisplayMessage(FALSE, MSG_MARS_GROUPS, pMarsStats->CurrentGroups,
  618. pMarsStats->MaxGroups);
  619. DisplayMessage(FALSE, MSG_MARS_GROUP_SIZE, pMarsStats->MaxAddressesPerGroup);
  620. }
  621. void
  622. DoAAS(OPTIONS *po)
  623. {
  624. HANDLE DeviceHandle;
  625. char InterfacesBuffer[1024];
  626. PINTERFACES pInterfaces = (PINTERFACES) InterfacesBuffer;
  627. ULONG cbInterfaces = sizeof(InterfacesBuffer);
  628. #if 0
  629. PUNICODE_STRING pAdapterName;
  630. PUNICODE_STRING pElanName;
  631. ULONG i, j;
  632. BOOL Result;
  633. #endif // 0
  634. DisplayMessage(FALSE, MSG_ATMARPS_BANNER);
  635. DeviceHandle = OpenDevice(pDeviceName);
  636. if (DeviceHandle == INVALID_HANDLE_VALUE)
  637. {
  638. DisplayMessage(FALSE, MSG_ERROR_OPENING_ATMARPS);
  639. return;
  640. }
  641. //
  642. // First check the version
  643. //
  644. if (!CheckVersion(DeviceHandle))
  645. {
  646. CloseDevice(DeviceHandle);
  647. return;
  648. }
  649. //
  650. // get the list of available adapters
  651. //
  652. if (!AasGetInterfaces(DeviceHandle, pInterfaces, cbInterfaces))
  653. {
  654. CloseDevice(DeviceHandle);
  655. return;
  656. }
  657. // printf ( " Looping through interfaces...\n");
  658. //
  659. // Loop thru the interfaces, displaying info about each.
  660. //
  661. {
  662. UINT u=0;
  663. for (u=0;u<pInterfaces->NumberOfInterfaces;u++)
  664. {
  665. CHAR Buffer[4000];
  666. ULONG cbBuffer = sizeof(Buffer);
  667. PIOCTL_QUERY_CACHE pArpCache
  668. = (PIOCTL_QUERY_CACHE) Buffer;
  669. PIOCTL_QUERY_MARS_CACHE pMarsCache
  670. = (PIOCTL_QUERY_MARS_CACHE) Buffer;
  671. INTERFACE_NAME *pInterface = (pInterfaces->Interfaces)+u;
  672. PARP_SERVER_STATISTICS pArpStats = (PARP_SERVER_STATISTICS) Buffer;
  673. PMARS_SERVER_STATISTICS pMarsStats = (PMARS_SERVER_STATISTICS) Buffer;
  674. UINT StartIndex;
  675. //
  676. // Display the interface name -- must be null terminated.
  677. //
  678. {
  679. WCHAR *pwc = pInterface->Buffer+pInterface->Length/sizeof(WCHAR);
  680. WCHAR wc = *pwc;
  681. *pwc = 0;
  682. DisplayMessage(FALSE, MSG_ADAPTER, pInterface->Buffer );
  683. *pwc = wc;
  684. }
  685. if (po->DispCache)
  686. {
  687. StartIndex = pArpCache->StartEntryIndex = 0;
  688. DisplayMessage(FALSE, MSG_AAS_C00_ARP_CACHE);
  689. while (AasGetArpCache(DeviceHandle, pInterface, pArpCache, cbBuffer) &&
  690. pArpCache->Entries.NumberOfEntriesInBuffer)
  691. {
  692. AasDisplayArpCache(pArpCache);
  693. StartIndex += pArpCache->Entries.NumberOfEntriesInBuffer;
  694. pArpCache->StartEntryIndex = StartIndex;
  695. if (StartIndex == pArpCache->Entries.TotalNumberOfEntries)
  696. {
  697. break;
  698. }
  699. }
  700. StartIndex = pMarsCache->StartEntryIndex = 0;
  701. DisplayMessage(FALSE, MSG_AAS_C00_MARS_CACHE);
  702. while (AasGetMarsCache(DeviceHandle, pInterface, pMarsCache, cbBuffer) &&
  703. pMarsCache->MarsCache.NumberOfEntriesInBuffer)
  704. {
  705. AasDisplayMarsCache(pMarsCache);
  706. StartIndex += pMarsCache->MarsCache.NumberOfEntriesInBuffer;
  707. pMarsCache->StartEntryIndex = StartIndex;
  708. }
  709. }
  710. if (po->DispStats)
  711. {
  712. if (AasGetArpStats(DeviceHandle, pInterface, pArpStats))
  713. {
  714. AasDisplayArpStats(pArpStats);
  715. }
  716. if (AasGetMarsStats(DeviceHandle, pInterface, pMarsStats))
  717. {
  718. AasDisplayMarsStats(pMarsStats);
  719. }
  720. }
  721. if (po->DoResetStats)
  722. {
  723. AasResetStatistics(DeviceHandle, pInterface);
  724. }
  725. }
  726. }
  727. #if 0
  728. //
  729. // Loop thru the adapters getting each adapter's elan list
  730. //
  731. pAdapterName = &pAdapterList->AdapterList;
  732. for (i = 0; i < pAdapterList->AdapterCountReturned; i++)
  733. {
  734. DisplayMessage(FALSE, MSG_ADAPTER,
  735. (PWSTR)((PUCHAR)pAdapterName + sizeof(UNICODE_STRING)));
  736. if (GetElanList(DeviceHandle, pAdapterName))
  737. {
  738. //
  739. // Loop thru the elan list getting ELAN info
  740. //
  741. pElanName = &pElanList->ElanList;
  742. for (j = 0; j < pElanList->ElanCountReturned; j++)
  743. {
  744. DisplayMessage(FALSE, MSG_ELAN,
  745. (PWSTR)((PUCHAR)pElanName + sizeof(UNICODE_STRING)));
  746. if (GetElanInfo(DeviceHandle, pAdapterName, pElanName))
  747. {
  748. DisplayElanInfo();
  749. }
  750. if (GetElanArpTable(DeviceHandle, pAdapterName, pElanName))
  751. {
  752. DisplayElanArpTable();
  753. }
  754. if (GetElanConnTable(DeviceHandle, pAdapterName, pElanName))
  755. {
  756. DisplayElanConnTable();
  757. }
  758. //
  759. // next elan
  760. //
  761. pElanName = (PUNICODE_STRING)((PUCHAR)pElanName +
  762. sizeof(UNICODE_STRING) + pElanName->Length);
  763. }
  764. }
  765. //
  766. // next adapter
  767. //
  768. pAdapterName = (PUNICODE_STRING)((PUCHAR)pAdapterName +
  769. sizeof(UNICODE_STRING) + pAdapterName->Length);
  770. }
  771. #endif // 0
  772. CloseDevice(DeviceHandle);
  773. return;
  774. }