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.

1557 lines
32 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. cmd.c
  5. Abstract:
  6. IEEE1394 ARP Admin Utility.
  7. Usage:
  8. a13adm
  9. Revision History:
  10. Who When What
  11. -------- -------- ---------------------------------------------
  12. josephj 04-10-1999 Created
  13. --*/
  14. #include "common.h"
  15. #ifndef NDIS_STATUS
  16. #define NDIS_STATUS ULONG
  17. #endif
  18. #define ANSI_ARP_CLIENT_DOS_DEVICE_NAME "\\\\.\\ARP1394"
  19. #define DUMMY 0
  20. #define FAKE_DUMP 0
  21. VOID
  22. DoBusInfoCmd(
  23. HANDLE DeviceHandle,
  24. PARP1394_IOCTL_COMMAND pCmd
  25. );
  26. #if DUMMY
  27. BOOL
  28. DummyDeviceIoControl(
  29. HANDLE DeviceHandle,
  30. UINT Ioctl,
  31. PARP1394_IOCTL_COMMAND pInCmd,
  32. UINT Size,
  33. PARP1394_IOCTL_COMMAND pOutCmd,
  34. UINT OutSize,
  35. PUINT pBytesReturned,
  36. PVOID Blah
  37. );
  38. #define DeviceIoControl DummyDeviceIoControl
  39. #endif // DUMMY
  40. HANDLE
  41. OpenDevice(
  42. CHAR *pDeviceName
  43. );
  44. extern CHAR *g_szPacketName;
  45. VOID
  46. CloseDevice(
  47. HANDLE DeviceHandle
  48. );
  49. VOID
  50. DumpArpCache(
  51. PARP1394_IOCTL_GET_ARPCACHE pGetCacheCmd
  52. );
  53. VOID
  54. DumpPacketStats(
  55. PARP1394_IOCTL_GET_PACKET_STATS pStatsCmd
  56. );
  57. VOID
  58. DumpTaskStats(
  59. PARP1394_IOCTL_GET_TASK_STATS pStatsCmd
  60. );
  61. VOID
  62. DumpArpStats(
  63. PARP1394_IOCTL_GET_ARPCACHE_STATS pStatsCmd
  64. );
  65. VOID
  66. DumpCallStats(
  67. PARP1394_IOCTL_GET_CALL_STATS pStatsCmd
  68. );
  69. VOID
  70. DumpPacketCounts(
  71. PARP1394_PACKET_COUNTS pPktCounts,
  72. BOOL fRecv,
  73. char *szDescription
  74. );
  75. VOID
  76. Dump1394UniqueID(
  77. UINT64 UniqueID
  78. );
  79. VOID
  80. DumpNicInfo(
  81. ARP1394_IOCTL_NICINFO *pNicInfo
  82. );
  83. #if OBSOLETE
  84. VOID
  85. DumpBusInfo(
  86. PNIC1394_BUSINFO pBi
  87. );
  88. #endif // OBSOLETE
  89. VOID
  90. DumpChannelInfo(
  91. PNIC1394_CHANNELINFO pCi
  92. );
  93. VOID
  94. DumpRemoteNodeInfo(
  95. PNIC1394_REMOTENODEINFO pRni
  96. );
  97. VOID
  98. arpDumpChannelMap(
  99. UINT64 Map
  100. );
  101. VOID
  102. arpDumpPktStats(
  103. char *szPrefix,
  104. NIC1394_PACKET_STATS *pPs
  105. );
  106. VOID
  107. DumpEuidMapInfo(
  108. PARP1394_IOCTL_EUID_NODE_MAC_INFO pEuidInfo
  109. );
  110. VOID
  111. DoCmd(
  112. PARP1394_IOCTL_COMMAND pCmd
  113. )
  114. {
  115. BOOL fRet = FALSE;
  116. PUCHAR pc;
  117. HANDLE DeviceHandle;
  118. DWORD BytesReturned;
  119. BOOL fDumpNicInfo=FALSE;
  120. // Special case -- DumpNicInfo.
  121. //
  122. if (pCmd->Hdr.Op == ARP1394_IOCTL_OP_GET_NICINFO)
  123. {
  124. PNIC1394_NICINFO pNi = &pCmd->IoctlNicInfo.Info;
  125. if (pNi->Hdr.Op == NIC1394_NICINFO_OP_BUSINFO)
  126. {
  127. fDumpNicInfo = TRUE;
  128. }
  129. }
  130. pc = (PUCHAR)&pCmd->Hdr.IfIpAddress;
  131. // Open device
  132. //
  133. DeviceHandle = OpenDevice(ANSI_ARP_CLIENT_DOS_DEVICE_NAME);
  134. if (DeviceHandle == INVALID_HANDLE_VALUE)
  135. {
  136. printf("Could not access IP/1394 ARP Client module.\n");
  137. }
  138. else if (fDumpNicInfo)
  139. {
  140. DoBusInfoCmd(DeviceHandle, pCmd);
  141. CloseDevice(DeviceHandle);
  142. }
  143. else
  144. {
  145. BOOL fResetStats = (pCmd->Hdr.Op == ARP1394_IOCTL_OP_RESET_STATS);
  146. printf("Opened handle 0x%p\n", DeviceHandle);
  147. // Submit Ioctl
  148. //
  149. fRet = DeviceIoControl(
  150. DeviceHandle,
  151. ARP_IOCTL_CLIENT_OPERATION,
  152. pCmd,
  153. sizeof(*pCmd),
  154. pCmd,
  155. sizeof(*pCmd),
  156. &BytesReturned,
  157. NULL
  158. );
  159. //
  160. // Special case "resetstats" -- we reset both ARP and NIC stats
  161. //
  162. if (fResetStats)
  163. {
  164. ARP1394_IOCTL_COMMAND Cmd = *pCmd;
  165. PNIC1394_NICINFO pNi = &Cmd.IoctlNicInfo.Info;
  166. Cmd.Hdr.Op = ARP1394_IOCTL_OP_GET_NICINFO;
  167. pNi->Hdr.Version = NIC1394_NICINFO_VERSION;
  168. pNi->Hdr.Op = NIC1394_NICINFO_OP_RESETSTATS;
  169. // Submit Ioctl
  170. //
  171. fRet = DeviceIoControl(
  172. DeviceHandle,
  173. ARP_IOCTL_CLIENT_OPERATION,
  174. &Cmd,
  175. sizeof(Cmd),
  176. &Cmd,
  177. sizeof(Cmd),
  178. &BytesReturned,
  179. NULL
  180. );
  181. }
  182. // Close device
  183. //
  184. CloseDevice(DeviceHandle);
  185. if (!fRet)
  186. {
  187. printf("Request failed with error code 0x%08lx\n", GetLastError());
  188. }
  189. }
  190. if (!fRet)
  191. {
  192. return; // EARLY RETURN
  193. BytesReturned=0;
  194. }
  195. // Display results.
  196. //
  197. switch(pCmd->Hdr.Op)
  198. {
  199. case ARP1394_IOCTL_OP_GET_ARPCACHE:
  200. DumpArpCache(&pCmd->GetArpCache);
  201. break;
  202. case ARP1394_IOCTL_OP_ADD_STATIC_ENTRY:
  203. {
  204. PARP1394_IOCTL_ADD_ARP_ENTRY pAddCmd = &pCmd->AddArpEntry;
  205. printf(
  206. "Added the following static arp entry to IF %d.%d.%d.%d:\n",
  207. pc[0], pc[1], pc[2], pc[3]
  208. );
  209. pc = (PUCHAR)&pAddCmd->IpAddress;
  210. printf(
  211. " %d.%d.%d.%d -> ",
  212. pc[0], pc[1], pc[2], pc[3]
  213. );
  214. Dump1394UniqueID(pAddCmd->HwAddress.UniqueID);
  215. printf("\n");
  216. }
  217. break;
  218. case ARP1394_IOCTL_OP_DEL_STATIC_ENTRY:
  219. {
  220. PARP1394_IOCTL_DEL_ARP_ENTRY pDelCmd = &pCmd->DelArpEntry;
  221. printf(
  222. "Deleted all entries from IF %d.%d.%d.%d for the following destinations:\n",
  223. pc[0], pc[1], pc[2], pc[3]
  224. );
  225. pc = (PUCHAR)&pDelCmd->IpAddress;
  226. printf(
  227. " %d.%d.%d.%d\n",
  228. pc[0], pc[1], pc[2], pc[3]
  229. );
  230. }
  231. break;
  232. case ARP1394_IOCTL_OP_GET_PACKET_STATS:
  233. DumpPacketStats(&pCmd->GetPktStats);
  234. break;
  235. case ARP1394_IOCTL_OP_GET_TASK_STATS:
  236. DumpTaskStats(&pCmd->GetTaskStats);
  237. break;
  238. case ARP1394_IOCTL_OP_GET_ARPCACHE_STATS:
  239. DumpArpStats(&pCmd->GetArpStats);
  240. break;
  241. case ARP1394_IOCTL_OP_GET_CALL_STATS:
  242. DumpCallStats(&pCmd->GetCallStats);
  243. break;
  244. case ARP1394_IOCTL_OP_RESET_STATS:
  245. printf(
  246. "Reset arp and nic statistics collection on IF %d.%d.%d.%d.\n\n",
  247. pc[0], pc[1], pc[2], pc[3]
  248. );
  249. break;
  250. case ARP1394_IOCTL_OP_REINIT_INTERFACE:
  251. printf(
  252. "Reinited IF %d.%d.%d.%d.\n\n",
  253. pc[0], pc[1], pc[2], pc[3]
  254. );
  255. break;
  256. case ARP1394_IOCTL_OP_RECV_PACKET:
  257. printf(
  258. "Simulated receive of %lu-byte packet \"%s\" on IF %d.%d.%d.%d.\n\n",
  259. pCmd->RecvPacket.PacketSize,
  260. g_szPacketName,
  261. pc[0], pc[1], pc[2], pc[3]
  262. );
  263. break;
  264. case ARP1394_IOCTL_OP_ETHERNET_START_EMULATION:
  265. printf(
  266. "Requested ARP to START Ethernet emulation on adapter \"%s\"\n\n",
  267. g_szPacketName
  268. );
  269. break;
  270. case ARP1394_IOCTL_OP_ETHERNET_STOP_EMULATION:
  271. printf(
  272. "Requested ARP to STOP Ethernet emulation on adapter \"%s\"\n\n",
  273. g_szPacketName
  274. );
  275. break;
  276. case ARP1394_IOCTL_OP_GET_NICINFO:
  277. DumpNicInfo(&pCmd->IoctlNicInfo);
  278. break;
  279. case ARP1394_IOCTL_OP_GET_EUID_NODE_MAC_TABLE:
  280. DumpEuidMapInfo(&pCmd->EuidNodeMacInfo);
  281. break;
  282. default:
  283. printf("HAIII!!!\n");
  284. break;
  285. }
  286. }
  287. VOID
  288. DumpArpCache(
  289. PARP1394_IOCTL_GET_ARPCACHE pGetCacheCmd
  290. )
  291. {
  292. UINT u;
  293. PARP1394_ARP_ENTRY pEntry = pGetCacheCmd->Entries;
  294. PUCHAR pc;
  295. #if FAKE_DUMP
  296. pGetCacheCmd->NumEntriesInArpCache = 30;
  297. pGetCacheCmd->NumEntriesUsed = 2;
  298. pGetCacheCmd->Index = 0;
  299. ((PULONG)&(pEntry[0].HwAddress.UniqueID))[0] = 0x12;
  300. ((PULONG)&(pEntry[0].HwAddress.UniqueID))[1] = 0x34;
  301. pEntry[0].IpAddress = 0x0100000a;
  302. ((PULONG)&(pEntry[1].HwAddress.UniqueID))[0] = 0x56;
  303. ((PULONG)&(pEntry[1].HwAddress.UniqueID))[1] = 0x78;
  304. pEntry[1].IpAddress = 0x0200000a;
  305. #endif // FAKE_DUMP
  306. pc = (PUCHAR)&pGetCacheCmd->Hdr.IfIpAddress;
  307. printf("Arp Cache of IF %d.%d.%d.%d [", pc[0], pc[1], pc[2], pc[3]);
  308. Dump1394UniqueID(pGetCacheCmd->LocalHwAddress.UniqueID);
  309. printf(
  310. " (%04lx:%08lx)]\n",
  311. pGetCacheCmd->LocalHwAddress.Off_Low,
  312. pGetCacheCmd->LocalHwAddress.Off_High
  313. );
  314. for (u=0;u<pGetCacheCmd->NumEntriesUsed;u++,pEntry++)
  315. {
  316. PUCHAR pc1 = (PUCHAR)&pEntry->IpAddress;
  317. printf(
  318. " %d.%d.%d.%d -> ",
  319. pc1[0], pc1[1], pc1[2], pc1[3]
  320. );
  321. Dump1394UniqueID(pEntry->HwAddress.UniqueID);
  322. printf("\n");
  323. }
  324. }
  325. VOID
  326. DumpPacketStats(
  327. PARP1394_IOCTL_GET_PACKET_STATS pStatsCmd
  328. )
  329. {
  330. PUCHAR pc;
  331. pc = (PUCHAR)&pStatsCmd->Hdr.IfIpAddress;
  332. printf("Packet stats for IF %d.%d.%d.%d\n", pc[0], pc[1], pc[2], pc[3]);
  333. printf(" Duration: %d seconds\n", pStatsCmd->StatsDuration);
  334. printf(" Total sends: %d\n", pStatsCmd->TotSends);
  335. printf(" Fast sends: %d\n", pStatsCmd->FastSends);
  336. printf(" Medium sends: %d\n", pStatsCmd->MediumSends);
  337. printf(" Slow sends: %d\n", pStatsCmd->SlowSends);
  338. printf(" Backfills: %d\n", pStatsCmd->BackFills);
  339. printf(" Header buf uses: %d\n", pStatsCmd->HeaderBufUses);
  340. printf(" Header buf cache hits: %d\n", pStatsCmd->HeaderBufCacheHits);
  341. //
  342. // Some recv stats
  343. //
  344. printf(" Total receives: %d\n", pStatsCmd->TotRecvs);
  345. printf(" No-copy receives: %d\n", pStatsCmd->NoCopyRecvs);
  346. printf(" Copy receives: %d\n", pStatsCmd->CopyRecvs);
  347. printf(" Resource receives: %d\n", pStatsCmd->ResourceRecvs);
  348. //
  349. // Packet counts
  350. //
  351. DumpPacketCounts(&pStatsCmd->SendFifoCounts, FALSE, "FIFO sends");
  352. DumpPacketCounts(&pStatsCmd->RecvFifoCounts, TRUE, "FIFO receives");
  353. DumpPacketCounts(&pStatsCmd->SendChannelCounts, FALSE, "Channel sends");
  354. DumpPacketCounts(&pStatsCmd->RecvChannelCounts, TRUE, "Channel receives");
  355. }
  356. VOID
  357. DumpTaskStats(
  358. PARP1394_IOCTL_GET_TASK_STATS pStatsCmd
  359. )
  360. {
  361. PUCHAR pc;
  362. pc = (PUCHAR)&pStatsCmd->Hdr.IfIpAddress;
  363. printf("Task stats for IF %d.%d.%d.%d\n", pc[0], pc[1], pc[2], pc[3]);
  364. printf(" Duration: %d seconds\n", pStatsCmd->StatsDuration);
  365. printf(" Total tasks: %d\n", pStatsCmd->TotalTasks);
  366. printf(" Current tasks: %d\n", pStatsCmd->CurrentTasks);
  367. //
  368. // Task times
  369. //
  370. {
  371. int i;
  372. #if 0
  373. |<=1us | ...100us |...1ms |...10ms | >10ms
  374. ---------+--------+----------+---------+---------+--------
  375. |10000000| 10000000 |10000000 |10000000 | 100
  376. |(100000)| (100000) |(100000 |(100000) | (100)
  377. #endif // 0
  378. printf("Task times:\n");
  379. printf(" |<=1ms |...100ms |...1s |...10s | >10s\n");
  380. printf(" +---------+---------+---------+---------+--------\n");
  381. printf(" ");
  382. for (i=0;i<ARP1394_NUM_TASKTIME_SLOTS;i++)
  383. {
  384. #if FAKE_DUMP
  385. pStatsCmd->TimeCounts[i] = i*100000;
  386. #endif // FAKE_DUMP
  387. printf(" |%8lu", pStatsCmd->TimeCounts[i]);
  388. }
  389. printf("\n");
  390. }
  391. }
  392. VOID
  393. DumpArpStats(
  394. PARP1394_IOCTL_GET_ARPCACHE_STATS pStatsCmd
  395. )
  396. {
  397. PUCHAR pc;
  398. pc = (PUCHAR)&pStatsCmd->Hdr.IfIpAddress;
  399. printf("Arp cache stats for IF %d.%d.%d.%d\n", pc[0], pc[1], pc[2], pc[3]);
  400. printf(" Duration: %d seconds\n", pStatsCmd->StatsDuration);
  401. printf(" Total queries: %d\n", pStatsCmd->TotalQueries);
  402. printf(" Successful queries: %d\n", pStatsCmd->SuccessfulQueries);
  403. printf(" Failed queries: %d\n", pStatsCmd->FailedQueries);
  404. printf(" Total responses: %d\n", pStatsCmd->TotalResponses);
  405. printf(" Total lookups: %d\n", pStatsCmd->TotalLookups);
  406. printf(" Links per lookup: %d\n", pStatsCmd->TraverseRatio);
  407. }
  408. VOID
  409. DumpCallStats(
  410. PARP1394_IOCTL_GET_CALL_STATS pStatsCmd
  411. )
  412. {
  413. PUCHAR pc;
  414. pc = (PUCHAR)&pStatsCmd->Hdr.IfIpAddress;
  415. printf("Call stats for IF %d.%d.%d.%d\n", pc[0], pc[1], pc[2], pc[3]);
  416. printf(
  417. " Total send FIFO make-calls: %d\n",
  418. pStatsCmd->TotalSendFifoMakeCalls
  419. );
  420. printf(
  421. " Successful send FIFO make-calls: %d\n",
  422. pStatsCmd->SuccessfulSendFifoMakeCalls
  423. );
  424. printf(
  425. " Failed send FIFO make-calls: %d\n",
  426. pStatsCmd->FailedSendFifoMakeCalls
  427. );
  428. printf(
  429. " Incoming closes on send FIFOs: %d\n",
  430. pStatsCmd->IncomingClosesOnSendFifos
  431. );
  432. printf(
  433. " Total channel make-calls: %d\n",
  434. pStatsCmd->TotalChannelMakeCalls
  435. );
  436. printf(
  437. " Successful channel make-calls: %d\n",
  438. pStatsCmd->SuccessfulChannelMakeCalls
  439. );
  440. printf(
  441. " Failed channel make-calls: %d\n",
  442. pStatsCmd->FailedChannelMakeCalls
  443. );
  444. printf(
  445. " Incoming closes on channels: %d\n",
  446. pStatsCmd->IncomingClosesOnChannels
  447. );
  448. }
  449. VOID
  450. DumpPacketCounts(
  451. PARP1394_PACKET_COUNTS pPktCounts,
  452. BOOL fRecv,
  453. char *szDescription
  454. )
  455. {
  456. int i,j;
  457. char *rgTitles[ARP1394_NUM_PKTSIZE_SLOTS+1] =
  458. {
  459. " <= 128",
  460. " 129-256",
  461. " 257-1K ",
  462. " 1K-2K ",
  463. " > 2K ",
  464. " "
  465. };
  466. #if 0
  467. size\time|<=1us | ...100us |...1ms |...10ms | >10ms
  468. ---------+--------+----------+---------+---------+--------
  469. <= 128 |10000000| 10000000 |10000000 |10000000 | 100
  470. |(100000)| (100000) |(100000 |(100000) | (100)
  471. ...256 |10000000| 10000000 |10000000 |10000000 |10000000
  472. |(100000)| (100000) |(100000 |(100000) | (100)
  473. ...1K |10000000| 10000000 |10000000 |10000000 |10000000
  474. |(100000)| (100000) |(100000 |(100000) | (100)
  475. ...2K |10000000| 10000000 |10000000 |10000000 |10000000
  476. |(100000)| (100000) |(100000 |(100000) | (100)
  477. > 2K |10000000| 10000000 |10000000 |10000000 |10000000
  478. |(100000)| (100000) |(100000 |(100000) | (100)
  479. #endif // 0
  480. printf("\n%s packet counts:\n", szDescription);
  481. if (fRecv)
  482. {
  483. printf(" size | \n");
  484. printf(" ---------+---------\n");
  485. }
  486. else
  487. {
  488. printf(" size\\time|<=100us |...1ms |...10ms |...100ms | >100ms\n");
  489. printf(" ---------+---------+---------+---------+---------+--------\n");
  490. }
  491. for (i=0;i<ARP1394_NUM_PKTSIZE_SLOTS;i++)
  492. {
  493. UINT u;
  494. UINT GoodCounts=0;
  495. UINT BadCounts=0;
  496. //
  497. // Compute total goodcounts and badcounts for this size bin.
  498. //
  499. for (j=0;j<ARP1394_NUM_PKTTIME_SLOTS;j++)
  500. {
  501. GoodCounts += pPktCounts->GoodCounts[i][j];
  502. BadCounts += pPktCounts->BadCounts[i][j];
  503. }
  504. if (GoodCounts ==0 && BadCounts==0)
  505. {
  506. continue; // No packets in this size bin.
  507. }
  508. printf("%s", rgTitles[i]);
  509. for (j=0;j<ARP1394_NUM_PKTTIME_SLOTS;j++)
  510. {
  511. u = (fRecv)? GoodCounts : pPktCounts->GoodCounts[i][j];
  512. if (u)
  513. {
  514. printf(" |%8lu", u);
  515. }
  516. else
  517. {
  518. printf(" | ");
  519. }
  520. if (fRecv) break;
  521. }
  522. printf("\n%s",rgTitles[ARP1394_NUM_PKTSIZE_SLOTS]);
  523. for (j=0;j<ARP1394_NUM_PKTTIME_SLOTS;j++)
  524. {
  525. u = (fRecv)? BadCounts : pPktCounts->BadCounts[i][j];
  526. if (u)
  527. {
  528. printf(" |(%6lu)", u);
  529. }
  530. else
  531. {
  532. printf(" | ");
  533. }
  534. if (fRecv) break;
  535. }
  536. printf("\n");
  537. }
  538. }
  539. HANDLE
  540. OpenDevice(
  541. CHAR *pDeviceName
  542. )
  543. {
  544. DWORD DesiredAccess;
  545. DWORD ShareMode;
  546. LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL;
  547. DWORD CreationDistribution;
  548. DWORD FlagsAndAttributes;
  549. HANDLE TemplateFile;
  550. HANDLE Handle;
  551. DesiredAccess = GENERIC_READ|GENERIC_WRITE;
  552. ShareMode = 0;
  553. CreationDistribution = OPEN_EXISTING;
  554. FlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
  555. TemplateFile = (HANDLE)INVALID_HANDLE_VALUE;
  556. #if DUMMY
  557. Handle = (HANDLE) 0x1;
  558. #else // !DUMMY
  559. Handle = CreateFile(
  560. pDeviceName,
  561. DesiredAccess,
  562. ShareMode,
  563. lpSecurityAttributes,
  564. CreationDistribution,
  565. FlagsAndAttributes,
  566. TemplateFile
  567. );
  568. #endif // !DUMMY
  569. return (Handle);
  570. }
  571. VOID
  572. CloseDevice(
  573. HANDLE DeviceHandle
  574. )
  575. {
  576. #if !DUMMY
  577. CloseHandle(DeviceHandle);
  578. #endif
  579. }
  580. VOID Dump1394UniqueID(UINT64 UniqueID)
  581. {
  582. unsigned char *pc = (char *) &UniqueID;
  583. printf(
  584. "%02lx-%02lx-%02lx-%02lx-%02lx-%02lx-%02lx-%02lx",
  585. pc[4], pc[5], pc[6], pc[7],
  586. pc[0], pc[1], pc[2], pc[3]
  587. );
  588. }
  589. VOID DumpENetAddress(ENetAddr ENetAddress)
  590. {
  591. unsigned char *pc = (char *) &ENetAddress;
  592. printf(
  593. "%02lx-%02lx-%02lx-%02lx-%02lx-%02lx",
  594. pc[0], pc[1], pc[2], pc[3],pc[4], pc[5]);
  595. }
  596. #if DUMMY
  597. BOOL
  598. nicFillBusInfo(
  599. IN OUT PNIC1394_BUSINFO pBi
  600. );
  601. BOOL
  602. nicFillChannelInfo(
  603. IN OUT PNIC1394_CHANNELINFO pCi
  604. );
  605. BOOL
  606. nicFillRemoteNodeInfo(
  607. IN OUT PNIC1394_REMOTENODEINFO pRni
  608. );
  609. BOOL
  610. nicFillNicInfo (
  611. PNIC1394_NICINFO pInNicInfo,
  612. PNIC1394_NICINFO pOutNicInfo
  613. )
  614. {
  615. BOOL Ret = FALSE;
  616. #if 0
  617. pBi->ChannelMapLow = (0x1<<1) | (0x1<<3) | (0x1<<5) | (0x1<<7);
  618. pBi->ChannelMapHigh = (0x1<<8) | (0x1<<10) | (0x1<<12) | (0x1<<14);
  619. pBi->NumBusResets = 12345;
  620. pBi->SecondsSinceLastBusReset = 3600;
  621. pBi->NumRemoteNodes = 3;
  622. pLi = &pBi->LocalNodeInfo;
  623. pLi->UniqueID = 0xabcd;
  624. pLi->NodeAddress = 0x31;
  625. pLi->MaxRecvBlockSize=0x32;
  626. pLi->MaxRecvSpeed =0x33;
  627. pRi = pBi->RemoteNodeInfo;
  628. u = pBi->NumRemoteNodes;
  629. for (; u; u--, pRi++)
  630. {
  631. if (u==1) pRi->Flags = ARP1394_IOCTL_REMOTEFLAGS_ACTIVE;
  632. else if (u==2) pRi->Flags = ARP1394_IOCTL_REMOTEFLAGS_LOADING;
  633. else pRi->Flags = ARP1394_IOCTL_REMOTEFLAGS_UNLOADING;
  634. pRi->UniqueID = u;
  635. pRi->NodeAddress = u+1;
  636. pRi->MaxRecvBlockSize =u+2;
  637. pRi->MaxRecvSpeed =u+3;
  638. pRi->MaxSpeedBetweenNodes=u+4;
  639. }
  640. #endif // 0
  641. do
  642. {
  643. //
  644. // First check internal version
  645. //
  646. if (pInNicInfo->Hdr.Version != NIC1394_NICINFO_VERSION)
  647. {
  648. printf("DummyIoctl: NICINFO.Version mismatch. Want %lu got %lu\n",
  649. NIC1394_NICINFO_VERSION,
  650. pInNicInfo->Hdr.Version
  651. );
  652. break;
  653. }
  654. //
  655. // Struct-copy the old to the new. It's wasteful, but we don't want
  656. // to dig into how much of the in buffer contains valid data.
  657. //
  658. *pOutNicInfo = *pInNicInfo;
  659. //
  660. // Rest is op-specific
  661. //
  662. switch(pOutNicInfo->Hdr.Op)
  663. {
  664. case NIC1394_NICINFO_OP_BUSINFO:
  665. Ret = nicFillBusInfo(&pOutNicInfo->BusInfo);
  666. break;
  667. case NIC1394_NICINFO_OP_REMOTENODEINFO:
  668. Ret = nicFillRemoteNodeInfo(&pOutNicInfo->RemoteNodeInfo);
  669. break;
  670. case NIC1394_NICINFO_OP_CHANNELINFO:
  671. Ret = nicFillChannelInfo(&pOutNicInfo->ChannelInfo);
  672. break;
  673. case NIC1394_NICINFO_OP_RESETSTATS:
  674. printf("DummyIoctl: RESETTING NIC STATS!\n");
  675. Ret = TRUE;
  676. break;
  677. default:
  678. printf( "DummyIoctl: NICINFO.Op (%lu) is unknown.\n",
  679. pInNicInfo->Hdr.Op
  680. );
  681. break;
  682. }
  683. } while (FALSE);
  684. return Ret;
  685. }
  686. NIC1394_LOCAL_NODE_INFO
  687. BogusLocalNodeInfo =
  688. {
  689. 456, //UniqueID
  690. 457, //BusGeneration
  691. 4, //NodeAddress
  692. 0, //Reserved
  693. 2, //MaxRecvBlockSize
  694. 3, //MaxRecvSpeed
  695. };
  696. NIC1394_PACKET_STATS
  697. BogusPktStats =
  698. {
  699. 345, // TotNdisPackets
  700. 346, // NdisPacketsFailures
  701. 347, // TotBusPackets
  702. 348 // BusPacketFailures
  703. };
  704. BOOL
  705. nicFillBusInfo(
  706. IN OUT PNIC1394_BUSINFO pBi
  707. )
  708. {
  709. //
  710. // Fill with Dummy data
  711. //
  712. pBi->NumBusResets = 1234;
  713. pBi->SecondsSinceBusReset = 1235;
  714. pBi->Flags = NIC1394_BUSINFO_LOCAL_IS_IRM;
  715. pBi->NumOutstandingIrps = 1236;
  716. pBi->LocalNodeInfo = BogusLocalNodeInfo;
  717. //
  718. // CHANNEL RELATED INFORMATION
  719. //
  720. pBi->Channel.BusMap = 0x123;
  721. pBi->Channel.ActiveChannelMap = 0x456;
  722. pBi->Channel.Bcr = 0x790;
  723. pBi->Channel.BcSendPktStats = BogusPktStats;
  724. pBi->Channel.BcRecvPktStats = BogusPktStats;
  725. pBi->Channel.SendPktStats = BogusPktStats;
  726. pBi->Channel.RecvPktStats = BogusPktStats;
  727. //
  728. // FIFO RELATED INFORMATION.
  729. //
  730. pBi->Fifo.Recv_Off_Low = 0x1bc;
  731. pBi->Fifo.Recv_Off_High = 0xdef;
  732. pBi->Fifo.RecvPktStats = BogusPktStats;
  733. pBi->Fifo.SendPktStats = BogusPktStats;
  734. pBi->Fifo.NumFreeRecvBuffers = 33;
  735. pBi->Fifo.MinFreeRecvBuffers = 34;
  736. pBi->Fifo.NumOutstandingReassemblies = 8;
  737. pBi->Fifo.MaxOutstandingReassemblies = 9;
  738. strcpy(pBi->Private.FormatA, " 0x%08lx Gadzooks\n");
  739. pBi->Private.A0 = 0x99;
  740. //
  741. // Information about remote nodes. More information about each of these nodes
  742. // may be queried using *OP_REMOTE_NODEINFO
  743. //
  744. pBi->NumRemoteNodes = 1;
  745. pBi->RemoteNodeUniqueIDS[0] = 0x1234;
  746. return TRUE;
  747. }
  748. BOOL
  749. nicFillChannelInfo(
  750. IN OUT PNIC1394_CHANNELINFO pCi
  751. )
  752. {
  753. return TRUE;
  754. }
  755. BOOL
  756. nicFillRemoteNodeInfo(
  757. IN OUT PNIC1394_REMOTENODEINFO pRni
  758. )
  759. {
  760. pRni->UniqueID = 0xabc;
  761. pRni->NodeAddress = 2;
  762. pRni->EffectiveMaxBlockSize = 3;
  763. pRni->MaxRec = 4;
  764. pRni->MaxSpeedBetweenNodes = 5;
  765. pRni->Flags = NIC1394_REMOTEINFO_ACTIVE;
  766. pRni->SendFifoPktStats = BogusPktStats;
  767. pRni->RecvFifoPktStats = BogusPktStats;
  768. pRni->RecvChannelPktStats = BogusPktStats;
  769. return TRUE;
  770. }
  771. BOOL
  772. DummyDeviceIoControl(
  773. HANDLE DeviceHandle,
  774. UINT Ioctl,
  775. PARP1394_IOCTL_COMMAND pInCmd,
  776. UINT Size,
  777. PARP1394_IOCTL_COMMAND pOutCmd,
  778. UINT OutSize,
  779. PUINT pBytesReturned,
  780. PVOID Blah
  781. )
  782. {
  783. BOOL fRet = FALSE;
  784. if (Ioctl != ARP_IOCTL_CLIENT_OPERATION) return FALSE;
  785. switch(pInCmd->Hdr.Op)
  786. {
  787. default:
  788. printf ("UNKNOWN IOCTL!\n");
  789. fRet = TRUE;
  790. break;
  791. case ARP1394_IOCTL_OP_RESET_STATS:
  792. printf ("RESET ARP STATS!\n");
  793. break;
  794. case ARP1394_IOCTL_OP_RECV_PACKET:
  795. printf ("DUMMY IOCTL: Prrocessing ioctl RECV packet.\n");
  796. fRet = TRUE;
  797. break;
  798. case ARP1394_IOCTL_OP_GET_NICINFO:
  799. {
  800. fRet = nicFillNicInfo (
  801. &pInCmd->IoctlNicInfo.Info,
  802. &pOutCmd->IoctlNicInfo.Info
  803. );
  804. }
  805. break;
  806. }
  807. return fRet;
  808. }
  809. #endif // DUMMY
  810. VOID
  811. DumpNicInfo(
  812. ARP1394_IOCTL_NICINFO *pINi
  813. )
  814. {
  815. PNIC1394_NICINFO pNi = &pINi->Info;
  816. unsigned char *pc = (PUCHAR)&pINi->Hdr.IfIpAddress;
  817. do
  818. {
  819. //
  820. // First check internal version
  821. //
  822. if (pNi->Hdr.Version != NIC1394_NICINFO_VERSION)
  823. {
  824. printf(" NICINFO.Version mismatch. Want %lu got %lu\n",
  825. NIC1394_NICINFO_VERSION,
  826. pNi->Hdr.Version
  827. );
  828. break;
  829. }
  830. //
  831. // Rest is op-specific
  832. //
  833. switch(pNi->Hdr.Op)
  834. {
  835. case NIC1394_NICINFO_OP_BUSINFO:
  836. printf("\nUnexpected commande!\n"); // We handle this command earlier.
  837. break;
  838. case NIC1394_NICINFO_OP_REMOTENODEINFO:
  839. printf("\nNode information for node %lu on IF %d.%d.%d.%d\n\n",
  840. pNi->RemoteNodeInfo.NodeAddress,
  841. pc[0], pc[1], pc[2], pc[3]);
  842. DumpRemoteNodeInfo(&pNi->RemoteNodeInfo);
  843. break;
  844. case NIC1394_NICINFO_OP_CHANNELINFO:
  845. printf("\nChannel information for channel %lu on IF %d.%d.%d.%d\n\n",
  846. pNi->ChannelInfo.Channel,
  847. pc[0], pc[1], pc[2], pc[3]);
  848. DumpChannelInfo(&pNi->ChannelInfo);
  849. break;
  850. case NIC1394_NICINFO_OP_RESETSTATS:
  851. printf("\nReset NIC stats for IF %d.%d.%d.%d\n\n",
  852. pc[0], pc[1], pc[2], pc[3]);
  853. break;
  854. default:
  855. printf( " NICINFO.Op (%lu) is unknown.\n",
  856. pNi->Hdr.Op
  857. );
  858. break;
  859. }
  860. } while (FALSE);
  861. }
  862. #if OBSOLETE
  863. VOID
  864. DumpBusInfo(
  865. PNIC1394_BUSINFO pBi
  866. )
  867. {
  868. PUCHAR pc;
  869. printf(
  870. " Generation: %02lu; Bus resets: %02lu; Last reset: %lu seconds ago.",
  871. pBi->LocalNodeInfo.BusGeneration,
  872. pBi->NumBusResets,
  873. pBi->SecondsSinceBusReset
  874. );
  875. printf(
  876. " Outstanding IRPs: %02lu;",
  877. pBi->NumOutstandingIrps
  878. );
  879. //
  880. // Flags
  881. //
  882. if (pBi->Flags & NIC1394_BUSINFO_LOCAL_IS_IRM)
  883. {
  884. printf(
  885. " Flags: IRM\n"
  886. );
  887. }
  888. else
  889. {
  890. printf(
  891. " Flags: <none>\n"
  892. );
  893. }
  894. //
  895. // CHANNEL INFO
  896. //
  897. printf("\n Channel information:\n");
  898. printf (" Channels in bus map:");
  899. arpDumpChannelMap( pBi->Channel.BusMap);
  900. printf (" Locally active channels:");
  901. arpDumpChannelMap( pBi->Channel.ActiveChannelMap);
  902. printf(
  903. " BCR: 0x%08lx\n",
  904. pBi->Channel.Bcr
  905. );
  906. arpDumpPktStats(" BC Sends:", &pBi->Channel.BcSendPktStats);
  907. arpDumpPktStats(" BC Recvs:", &pBi->Channel.BcRecvPktStats);
  908. //
  909. // RECV FIFO
  910. //
  911. printf("\n Recv FIFO information:\n");
  912. printf(
  913. " Addr: 0x%lx:0x%lx; Free recv bufs:%lu (%lu max)\n",
  914. pBi->Fifo.Recv_Off_High,
  915. pBi->Fifo.Recv_Off_Low,
  916. pBi->Fifo.NumFreeRecvBuffers,
  917. pBi->Fifo.MinFreeRecvBuffers
  918. );
  919. printf(
  920. " Recv reassemblies: %lu outstanding; %lu max outstanding; %lu aborted\n",
  921. pBi->Fifo.NumOutstandingReassemblies,
  922. pBi->Fifo.MaxOutstandingReassemblies,
  923. pBi->Fifo.NumAbortedReassemblies
  924. );
  925. //
  926. // Private information
  927. //
  928. if (*pBi->Private.FormatA || *pBi->Private.FormatB)
  929. {
  930. printf("\n Private information:\n");
  931. if (*pBi->Private.FormatA)
  932. {
  933. printf(
  934. pBi->Private.FormatA,
  935. pBi->Private.A0,
  936. pBi->Private.A1,
  937. pBi->Private.A2,
  938. pBi->Private.A3
  939. );
  940. }
  941. if (*pBi->Private.FormatB)
  942. {
  943. printf(
  944. pBi->Private.FormatB,
  945. pBi->Private.B0,
  946. pBi->Private.B1,
  947. pBi->Private.B2,
  948. pBi->Private.B3
  949. );
  950. }
  951. }
  952. {
  953. UINT64 *pUID;
  954. PNIC1394_LOCAL_NODE_INFO pLi;
  955. UINT u = pBi->NumRemoteNodes;
  956. printf("\n Node Information:\n");
  957. printf(
  958. " GUID Node Size Speed SpeedTo State\n"
  959. );
  960. pLi = &pBi->LocalNodeInfo;
  961. printf(" *");
  962. Dump1394UniqueID(pLi->UniqueID);
  963. printf(
  964. " %02lx %02lx %02lx %s\n",
  965. pLi->NodeAddress,
  966. pLi->MaxRecvBlockSize,
  967. pLi->MaxRecvSpeed,
  968. "local"
  969. );
  970. pUID = pBi->RemoteNodeUniqueIDS;
  971. for (; u; u--, pUID++) // pRi++
  972. {
  973. #if 0
  974. ARP1394_IOCTL_REMOTE_NODE_INFO Ri;
  975. PARP1394_IOCTL_REMOTE_NODE_INFO pRi = NULL;
  976. char *szState = "unknown";
  977. printf(" ");
  978. Dump1394UniqueID(*pUID);
  979. if (GetRemoteNodeInfo(
  980. if (pRi!=NULL)
  981. {
  982. if (pRi->Flags & ARP1394_IOCTL_REMOTEFLAGS_ACTIVE)
  983. {
  984. szState = "active";
  985. }
  986. if (pRi->Flags & ARP1394_IOCTL_REMOTEFLAGS_LOADING)
  987. {
  988. szState = "loading";
  989. }
  990. if (pRi->Flags & ARP1394_IOCTL_REMOTEFLAGS_UNLOADING)
  991. {
  992. szState = "unloading";
  993. }
  994. printf(
  995. " %02lx %02lx %02lx %02lx %s\n",
  996. pRi->NodeAddress,
  997. pRi->MaxRecvBlockSize,
  998. pRi->MaxRecvSpeed,
  999. pRi->MaxSpeedBetweenNodes,
  1000. szState
  1001. );
  1002. }
  1003. printf("\n");
  1004. #endif // 0
  1005. }
  1006. }
  1007. }
  1008. #endif // OBSOLETE
  1009. VOID
  1010. DumpChannelInfo(
  1011. PNIC1394_CHANNELINFO pCi
  1012. )
  1013. {
  1014. printf("DUMP OF CHANNELINFO\n");
  1015. }
  1016. VOID
  1017. DumpRemoteNodeInfo(
  1018. PNIC1394_REMOTENODEINFO pRni
  1019. )
  1020. {
  1021. printf("DUMP OF REMOTENODEINFO\n");
  1022. }
  1023. VOID
  1024. arpDumpChannelMap(
  1025. UINT64 Map
  1026. )
  1027. {
  1028. UINT ChannelMapLow = (UINT) (Map & 0xffffffff);
  1029. UINT ChannelMapHigh = (UINT) (Map >> 32);
  1030. if (ChannelMapLow==0 && ChannelMapHigh==0)
  1031. {
  1032. printf (" <none>\n");
  1033. }
  1034. else
  1035. {
  1036. UINT c;
  1037. #define Bit(_Val, _Bit) (((_Val) & (1<<_Bit))!=0)
  1038. for (c=0;c<32;c++)
  1039. {
  1040. if (Bit(ChannelMapLow, c))
  1041. {
  1042. printf (" %lu", c);
  1043. }
  1044. }
  1045. for (c=0;c<32;c++)
  1046. {
  1047. if (Bit(ChannelMapHigh, c))
  1048. {
  1049. printf (" %lu", c+32);
  1050. }
  1051. }
  1052. printf ("\n");
  1053. }
  1054. }
  1055. VOID
  1056. arpDumpPktStats(
  1057. char *szPrefix,
  1058. NIC1394_PACKET_STATS *pPs
  1059. )
  1060. {
  1061. printf("%s ndis: %06lu total, %05lu failed; bus: %06lu total, %05lu failed\n",
  1062. szPrefix,
  1063. pPs->TotNdisPackets,
  1064. pPs->NdisPacketsFailures,
  1065. pPs->TotBusPackets,
  1066. pPs->BusPacketFailures
  1067. );
  1068. }
  1069. VOID
  1070. DoBusInfoCmd(
  1071. HANDLE DeviceHandle,
  1072. PARP1394_IOCTL_COMMAND pCmd
  1073. )
  1074. {
  1075. PNIC1394_NICINFO pNi = &pCmd->IoctlNicInfo.Info;
  1076. PNIC1394_BUSINFO pBi = &pNi->BusInfo;
  1077. unsigned char *pc = (PUCHAR)&pCmd->Hdr.IfIpAddress;
  1078. BOOL fRet;
  1079. DWORD BytesReturned;
  1080. if (pCmd->Hdr.Op != ARP1394_IOCTL_OP_GET_NICINFO
  1081. || pNi->Hdr.Op != NIC1394_NICINFO_OP_BUSINFO)
  1082. {
  1083. printf("DoBusInfoCmd: unexpected pCmd!\n");
  1084. return;
  1085. }
  1086. // Submit NICINFO.BUSINFO Ioctl
  1087. //
  1088. fRet = DeviceIoControl(
  1089. DeviceHandle,
  1090. ARP_IOCTL_CLIENT_OPERATION,
  1091. pCmd,
  1092. sizeof(*pCmd),
  1093. pCmd,
  1094. sizeof(*pCmd),
  1095. &BytesReturned,
  1096. NULL
  1097. );
  1098. //
  1099. //
  1100. if (!fRet)
  1101. {
  1102. printf("Request failed with error code 0x%08lx\n", GetLastError());
  1103. return;
  1104. }
  1105. printf(
  1106. " Generation: %02lu; Bus resets: %02lu; Last reset: %lu seconds ago.",
  1107. pBi->LocalNodeInfo.BusGeneration,
  1108. pBi->NumBusResets,
  1109. pBi->SecondsSinceBusReset
  1110. );
  1111. #if 0
  1112. printf(
  1113. " Outstanding IRPs: %02lu;",
  1114. pBi->NumOutstandingIrps
  1115. );
  1116. #endif // 0
  1117. //
  1118. // Flags
  1119. //
  1120. if (pBi->Flags & NIC1394_BUSINFO_LOCAL_IS_IRM)
  1121. {
  1122. printf(
  1123. " Flags: IRM\n"
  1124. );
  1125. }
  1126. else
  1127. {
  1128. printf(
  1129. " Flags: <none>\n"
  1130. );
  1131. }
  1132. //
  1133. // CHANNEL INFO
  1134. //
  1135. printf("\n Channel information:\n");
  1136. printf (" Channels in bus map:");
  1137. arpDumpChannelMap(pBi->Channel.BusMap);
  1138. printf (" Locally active channels:");
  1139. arpDumpChannelMap( pBi->Channel.ActiveChannelMap);
  1140. printf(
  1141. " BCR: 0x%08lx\n",
  1142. pBi->Channel.Bcr
  1143. );
  1144. arpDumpPktStats(" BC Sends:", &pBi->Channel.BcSendPktStats);
  1145. arpDumpPktStats(" BC Recvs:", &pBi->Channel.BcRecvPktStats);
  1146. //
  1147. // RECV FIFO
  1148. //
  1149. printf("\n FIFO information:\n");
  1150. printf(
  1151. " Addr: 0x%lx:0x%lx; Free recv bufs:%lu (%lu max)\n",
  1152. pBi->Fifo.Recv_Off_High,
  1153. pBi->Fifo.Recv_Off_Low,
  1154. pBi->Fifo.NumFreeRecvBuffers,
  1155. pBi->Fifo.MinFreeRecvBuffers
  1156. );
  1157. printf(
  1158. " Recv reassemblies: %lu outstanding; %lu max outstanding; %lu aborted\n",
  1159. pBi->Fifo.NumOutstandingReassemblies,
  1160. pBi->Fifo.MaxOutstandingReassemblies,
  1161. pBi->Fifo.NumAbortedReassemblies
  1162. );
  1163. arpDumpPktStats(" FIFO Sends:", &pBi->Fifo.SendPktStats);
  1164. arpDumpPktStats(" FIFO Recvs:", &pBi->Fifo.RecvPktStats);
  1165. //
  1166. // Private information
  1167. //
  1168. if (*pBi->Private.FormatA || *pBi->Private.FormatB)
  1169. {
  1170. printf("\n Private information:\n");
  1171. if (*pBi->Private.FormatA)
  1172. {
  1173. printf(
  1174. pBi->Private.FormatA,
  1175. pBi->Private.A0,
  1176. pBi->Private.A1,
  1177. pBi->Private.A2,
  1178. pBi->Private.A3
  1179. );
  1180. }
  1181. if (*pBi->Private.FormatB)
  1182. {
  1183. printf(
  1184. pBi->Private.FormatB,
  1185. pBi->Private.B0,
  1186. pBi->Private.B1,
  1187. pBi->Private.B2,
  1188. pBi->Private.B3
  1189. );
  1190. }
  1191. }
  1192. {
  1193. UINT64 *pUID;
  1194. PNIC1394_LOCAL_NODE_INFO pLi;
  1195. UINT u = pBi->NumRemoteNodes;
  1196. printf("\n Node Information:\n");
  1197. printf(
  1198. " GUID Node Maxrec SpeedTo State\n"
  1199. );
  1200. pLi = &pBi->LocalNodeInfo;
  1201. printf(" *");
  1202. Dump1394UniqueID(pLi->UniqueID);
  1203. printf(
  1204. " %02lx %02lx %02lx %s\n",
  1205. pLi->NodeAddress,
  1206. pLi->MaxRecvBlockSize,
  1207. pLi->MaxRecvSpeed,
  1208. "local"
  1209. );
  1210. pUID = pBi->RemoteNodeUniqueIDS;
  1211. for (; u; u--, pUID++) // pRi++
  1212. {
  1213. char *szState = "unknown";
  1214. printf(" ");
  1215. Dump1394UniqueID(*pUID);
  1216. {
  1217. ARP1394_IOCTL_COMMAND Cmd = *pCmd;
  1218. PNIC1394_NICINFO pNi2 = &Cmd.IoctlNicInfo.Info;
  1219. Cmd.Hdr.Op = ARP1394_IOCTL_OP_GET_NICINFO;
  1220. pNi2->Hdr.Version = NIC1394_NICINFO_VERSION;
  1221. pNi2->Hdr.Op = NIC1394_NICINFO_OP_REMOTENODEINFO;
  1222. pNi2->RemoteNodeInfo.UniqueID = *pUID;
  1223. pNi2->RemoteNodeInfo.NodeAddress = 0;
  1224. // Submit Ioctl
  1225. //
  1226. fRet = DeviceIoControl(
  1227. DeviceHandle,
  1228. ARP_IOCTL_CLIENT_OPERATION,
  1229. &Cmd,
  1230. sizeof(Cmd),
  1231. &Cmd,
  1232. sizeof(Cmd),
  1233. &BytesReturned,
  1234. NULL
  1235. );
  1236. if (fRet == FALSE)
  1237. {
  1238. printf (" <error reading node info>\n");
  1239. }
  1240. else
  1241. {
  1242. PNIC1394_REMOTENODEINFO pRi = &pNi2->RemoteNodeInfo;
  1243. if (pRi->Flags & NIC1394_REMOTEINFO_ACTIVE)
  1244. {
  1245. szState = "active";
  1246. }
  1247. if (pRi->Flags & NIC1394_REMOTEINFO_LOADING)
  1248. {
  1249. szState = "loading";
  1250. }
  1251. if (pRi->Flags & NIC1394_REMOTEINFO_UNLOADING)
  1252. {
  1253. szState = "unloading";
  1254. }
  1255. printf(
  1256. " %02lx %02lx %02lx %s\n",
  1257. pRi->NodeAddress,
  1258. pRi->MaxRec,
  1259. pRi->MaxSpeedBetweenNodes,
  1260. szState
  1261. );
  1262. }
  1263. }
  1264. }
  1265. }
  1266. }
  1267. VOID
  1268. DumpEuidMapInfo(
  1269. PARP1394_IOCTL_EUID_NODE_MAC_INFO pEuidInfo
  1270. )
  1271. {
  1272. PEUID_TOPOLOGY pMap = &pEuidInfo->Map;
  1273. UINT i =0;
  1274. printf ("Number of Remote Nodes = %x\n",pMap->NumberOfRemoteNodes);
  1275. if (pMap->NumberOfRemoteNodes ==0)
  1276. {
  1277. return;
  1278. }
  1279. printf ("Table :-\n");
  1280. // iterate through the number of remote nodes and print them out.
  1281. printf ("Node UniqueId MacAddress\n");
  1282. while (i<pMap->NumberOfRemoteNodes)
  1283. {
  1284. // Skip this node if it is an invalid node
  1285. if (pMap->Node[i].Euid ==0)
  1286. {
  1287. continue;
  1288. }
  1289. printf ("%x ",i);
  1290. Dump1394UniqueID(pMap->Node[i].Euid);
  1291. printf(" ");
  1292. DumpENetAddress (pMap->Node[i].ENetAddress);
  1293. printf("\n");
  1294. i++;
  1295. }
  1296. }