Source code of Windows XP (NT5)
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.

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