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.

1178 lines
35 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. kdps.c
  5. Abstract:
  6. Packet scheduler KD extension
  7. Author:
  8. Rajesh Sundaram (1st Aug, 1998)
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #include <winsock.h>
  13. //
  14. // forwards
  15. //
  16. //
  17. // globals
  18. //
  19. PCHAR AdapterMode[] = {
  20. "",
  21. "Diffserv",
  22. "RSVP"
  23. };
  24. PCHAR AdapterState[] = {
  25. "",
  26. "AdapterStateInitializing",
  27. "AdapterStateRunning",
  28. "AdapterStateWaiting",
  29. "AdapterStateDisabled",
  30. "AdapterStateClosing",
  31. "AdapterStateClosed"
  32. };
  33. /* forwards */
  34. VOID
  35. DumpAdapterStats(
  36. PPS_ADAPTER_STATS Stats,
  37. PCHAR Indent
  38. );
  39. /* end forwards */
  40. DllInit(
  41. HANDLE hModule,
  42. DWORD dwReason,
  43. DWORD dwReserved
  44. )
  45. {
  46. switch (dwReason) {
  47. case DLL_THREAD_ATTACH:
  48. break;
  49. case DLL_THREAD_DETACH:
  50. break;
  51. case DLL_PROCESS_DETACH:
  52. break;
  53. case DLL_PROCESS_ATTACH:
  54. break;
  55. }
  56. return TRUE;
  57. }
  58. DECLARE_API( adapter )
  59. /*
  60. * dump a PS adapter structure
  61. */
  62. {
  63. PADAPTER TargetAdapter;
  64. ADAPTER LocalAdapter;
  65. PADAPTER LastAdapter;
  66. LIST_ENTRY LocalListHead;
  67. PLIST_ENTRY TargetListHead;
  68. PWSTR PSName;
  69. PWSTR MPName;
  70. PWSTR WMIName;
  71. PWSTR ProfileName;
  72. PWSTR RegistryPath;
  73. BOOLEAN DumpAllAdapters = FALSE;
  74. ULONG bytes;
  75. if ( *args == '\0' ) {
  76. //
  77. // run down the adapter list, dumping the contents of each one
  78. //
  79. TargetListHead = (PLIST_ENTRY)GetExpression( "PSCHED!AdapterList" );
  80. if ( !TargetListHead ) {
  81. dprintf("Can't convert psched!AdapterList symbol\n");
  82. return;
  83. }
  84. PSName = 0;
  85. MPName = 0;
  86. WMIName = 0;
  87. ProfileName = 0;
  88. RegistryPath = 0;
  89. //
  90. // read adapter listhead out of target's memory
  91. //
  92. KD_READ_MEMORY(TargetListHead, &LocalListHead, sizeof(LIST_ENTRY));
  93. TargetAdapter = (PADAPTER)LocalListHead.Flink;
  94. LastAdapter = (PADAPTER)TargetListHead;
  95. DumpAllAdapters = TRUE;
  96. } else {
  97. TargetAdapter = (PADAPTER)GetExpression( args );
  98. if ( !TargetAdapter ) {
  99. dprintf("bad string conversion (%s) \n", args );
  100. return;
  101. }
  102. LastAdapter = 0;
  103. }
  104. while ( TargetAdapter != LastAdapter ) {
  105. //
  106. // read adapter struct out of target's memory
  107. //
  108. KD_READ_MEMORY(TargetAdapter, &LocalAdapter, sizeof(ADAPTER));
  109. PSName = 0;
  110. MPName = 0;
  111. WMIName = 0;
  112. ProfileName = 0;
  113. RegistryPath = 0;
  114. //
  115. // alloc some mem for the PS and MP device names and get them too
  116. //
  117. if(LocalAdapter.UpperBinding.Length) {
  118. bytes = ( LocalAdapter.UpperBinding.Length + 1);
  119. PSName = (PWSTR)malloc( bytes );
  120. if ( PSName != NULL ) {
  121. KD_READ_MEMORY(LocalAdapter.UpperBinding.Buffer, PSName, bytes-1);
  122. }
  123. }
  124. if(LocalAdapter.MpDeviceName.Length) {
  125. bytes = ( LocalAdapter.MpDeviceName.Length + 1);
  126. MPName = (PWSTR)malloc( bytes );
  127. if ( MPName != NULL ) {
  128. KD_READ_MEMORY((ULONG)(LocalAdapter.MpDeviceName.Buffer),
  129. MPName,
  130. bytes-1);
  131. }
  132. }
  133. if(LocalAdapter.WMIInstanceName.Length) {
  134. bytes = ( LocalAdapter.WMIInstanceName.Length + 1);
  135. WMIName = (PWSTR)malloc( bytes );
  136. if ( WMIName != NULL ) {
  137. KD_READ_MEMORY(LocalAdapter.WMIInstanceName.Buffer, WMIName, bytes-1);
  138. }
  139. }
  140. if(LocalAdapter.ProfileName.Length) {
  141. bytes = ( LocalAdapter.ProfileName.Length + 1 );
  142. ProfileName = (PWSTR)malloc( bytes );
  143. if ( ProfileName != NULL ) {
  144. KD_READ_MEMORY(LocalAdapter.ProfileName.Buffer, ProfileName, bytes-1);
  145. }
  146. }
  147. if(LocalAdapter.RegistryPath.Length) {
  148. bytes = ( LocalAdapter.RegistryPath.Length + 1 );
  149. RegistryPath = (PWSTR)malloc( bytes );
  150. if ( RegistryPath != NULL ) {
  151. KD_READ_MEMORY(LocalAdapter.RegistryPath.Buffer, RegistryPath, bytes-1);
  152. }
  153. }
  154. dprintf( "\nAdapter @ %08X \n\n", TargetAdapter);
  155. dprintf( " Next Adapter @ %08X ", &TargetAdapter->Linkage);
  156. if(&TargetAdapter->Linkage == LocalAdapter.Linkage.Flink) {
  157. dprintf(" (empty) ");
  158. }
  159. dprintf( " \n");
  160. dprintf( " Lock @ %08X\n", &TargetAdapter->Lock);
  161. dprintf( " RefCount = %d\n", LocalAdapter.RefCount );
  162. dprintf( " MpDeviceName = %ws \n", MPName);
  163. dprintf( " UpperBinding = %ws \n", PSName);
  164. dprintf( " WMIInstanceName = %ws \n", WMIName);
  165. dprintf( " ProfileName = %ws \n", ProfileName);
  166. dprintf( " RegistryPath = %ws \n", RegistryPath);
  167. dprintf( " MiniportHandle (PsNdisHandle) = %x \n", LocalAdapter.PsNdisHandle);
  168. dprintf( " BindingHandle (LowerMpHandle) = %x \n", LocalAdapter.LowerMpHandle);
  169. dprintf( " Outstanding NDIS request = %d \n", LocalAdapter.OutstandingNdisRequests);
  170. dprintf( " ShutdownMask = \n");
  171. if(LocalAdapter.ShutdownMask & SHUTDOWN_CLOSE_WAN_ADDR_FAMILY)
  172. dprintf(" SHUTDOWN_CLOSE_WAN_ADDR_FAMILY \n");
  173. if(LocalAdapter.ShutdownMask & SHUTDOWN_DELETE_PIPE )
  174. dprintf(" SHUTDOWN_DELETE_PIPE \n");
  175. if(LocalAdapter.ShutdownMask & SHUTDOWN_FREE_PS_CONTEXT )
  176. dprintf(" SHUTDOWN_FREE_PS_CONTEXT \n");
  177. if(LocalAdapter.ShutdownMask & SHUTDOWN_UNBIND_CALLED )
  178. dprintf(" SHUTDOWN_UNBIND_CALLED \n");
  179. if(LocalAdapter.ShutdownMask & SHUTDOWN_MPHALT_CALLED )
  180. dprintf(" SHUTDOWN_MPHALT_CALLED \n");
  181. if(LocalAdapter.ShutdownMask & SHUTDOWN_CLEANUP_ADAPTER )
  182. dprintf(" SHUTDOWN_CLEANUP_ADAPTER \n");
  183. if(LocalAdapter.ShutdownMask & SHUTDOWN_PROTOCOL_UNLOAD )
  184. dprintf(" SHUTDOWN_PROTOCOL_UNLOAD \n");
  185. if(LocalAdapter.ShutdownMask & SHUTDOWN_BIND_CALLED )
  186. dprintf(" SHUTDOWN_BIND_CALLED \n");
  187. if(LocalAdapter.ShutdownMask & SHUTDOWN_MPINIT_CALLED )
  188. dprintf(" SHUTDOWN_MPINIT_CALLED \n");
  189. if(!DumpAllAdapters) {
  190. dprintf( " IpNetAddressList @ %08X \n", LocalAdapter.IpNetAddressList);
  191. dprintf( " IpxNetAddressList @ %08X \n", LocalAdapter.IpxNetAddressList);
  192. dprintf( " PsMpState = %s\n", AdapterState [ LocalAdapter.PsMpState]);
  193. dprintf( " BlockingEvent @ %08X\n", &TargetAdapter->BlockingEvent );
  194. dprintf( " FinalStatus = %08X\n", LocalAdapter.FinalStatus );
  195. dprintf( " Media Type = %d\n", LocalAdapter.MediaType );
  196. dprintf( " Total Size = %d\n", LocalAdapter.TotalSize );
  197. dprintf( " HeaderSize = %d\n", LocalAdapter.HeaderSize );
  198. dprintf( " IPHeaderOffset = %d\n", LocalAdapter.IPHeaderOffset );
  199. dprintf( "\n");
  200. dprintf( " Admission Control details \n");
  201. dprintf( " ------------------------- \n");
  202. dprintf( " RawLinkSpeed = %d \n", LocalAdapter.RawLinkSpeed);
  203. dprintf( " BestEffortLimit = %d \n", LocalAdapter.BestEffortLimit);
  204. dprintf( " NonBestEffortLimit = %d \n", LocalAdapter.NonBestEffortLimit);
  205. dprintf( " ReservationLimitValue = %d \n", LocalAdapter.ReservationLimitValue);
  206. dprintf( " Link Speed = %dbps\n", LocalAdapter.LinkSpeed);
  207. dprintf( " RemainingBandWidth = %dBps\n", LocalAdapter.RemainingBandWidth );
  208. dprintf( " VCIndex = %d\n", LocalAdapter.VcIndex.QuadPart );
  209. dprintf( " PipeHasResources = %s \n", LocalAdapter.PipeHasResources ? "TRUE" : "FALSE");
  210. dprintf( "\n");
  211. dprintf( " NDIS Handles, etc \n");
  212. dprintf( " ----------------- \n");
  213. dprintf( " BindContext = %08X \n", LocalAdapter.BindContext);
  214. dprintf( " Send PacketPoolHandle = %08X \n", LocalAdapter.SendPacketPool);
  215. dprintf( " Recv PacketPoolHandle = %08X \n", LocalAdapter.RecvPacketPool);
  216. dprintf( "\n");
  217. dprintf( " Best Effort VC \n");
  218. dprintf( " -------------- \n");
  219. dprintf( " BestEffortVc = %08X \n", &TargetAdapter->BestEffortVc);
  220. dprintf( " GPC Client VC List @ %08X ", &TargetAdapter->GpcClientVcList);
  221. if(&TargetAdapter->GpcClientVcList == LocalAdapter.GpcClientVcList.Flink)
  222. {
  223. dprintf( " (empty) ");
  224. }
  225. dprintf("\n");
  226. dprintf( " CfinfosInstalled = %d \n", LocalAdapter.CfInfosInstalled);
  227. dprintf( " FlowsInstalled = %d \n", LocalAdapter.FlowsInstalled);
  228. #if DBG
  229. dprintf( " GpcNotifyPending = %d \n", LocalAdapter.GpcNotifyPending);
  230. #endif
  231. dprintf( " \n");
  232. dprintf( " Scheduling Components \n");
  233. dprintf( " --------------------- \n");
  234. dprintf( " PsComponent = %08X \n", LocalAdapter.PsComponent);
  235. dprintf( " PsPipeContext = %08X \n", LocalAdapter.PsPipeContext);
  236. dprintf( " PipeContextLength = %d \n", LocalAdapter.PipeContextLength);
  237. dprintf( " FlowContextLength = %d \n", LocalAdapter.FlowContextLength);
  238. dprintf( " PacketContextLength = %d \n", LocalAdapter.PacketContextLength);
  239. dprintf( " ClassMapContextLength = %d \n", LocalAdapter.ClassMapContextLength);
  240. dprintf( " PipeFlags = %08X\n", LocalAdapter.PipeFlags );
  241. dprintf( " MaxOutstandingSends = 0x%08X \n", LocalAdapter.MaxOutstandingSends);
  242. dprintf( "\n");
  243. dprintf( "\n");
  244. dprintf( " NDISWAN \n");
  245. dprintf( " ------- \n");
  246. dprintf( " WanCmHandle = %08X \n", LocalAdapter.WanCmHandle);
  247. dprintf( " WanBindingState = %08X \n", LocalAdapter.WanBindingState);
  248. dprintf( " WanLinkCount = %08X \n", LocalAdapter.WanLinkCount);
  249. dprintf( " WanLinkList @ %08X ", &TargetAdapter->WanLinkList);
  250. if(&TargetAdapter->WanLinkList == LocalAdapter.WanLinkList.Flink) {
  251. dprintf( " (empty) \n");
  252. }
  253. else {
  254. dprintf( " Next = %08X \n", LocalAdapter.WanLinkList.Flink);
  255. }
  256. dprintf( " ISSLOWPacketSize = %08X \n", LocalAdapter.ISSLOWPacketSize);
  257. dprintf( " ISSLOWFragmentSize = %08X \n", LocalAdapter.ISSLOWFragmentSize);
  258. dprintf( " ISSLOWTokenRate = %08X \n", LocalAdapter.ISSLOWTokenRate);
  259. dprintf("\n");
  260. dprintf( " Adaptermode = %s \n", AdapterMode[LocalAdapter.AdapterMode]);
  261. }
  262. dprintf( "\n" );
  263. if ( PSName != NULL )
  264. free( PSName );
  265. if ( MPName != NULL )
  266. free( MPName );
  267. if ( WMIName != NULL)
  268. free ( WMIName);
  269. if ( RegistryPath != NULL)
  270. free(RegistryPath);
  271. if ( ProfileName != NULL)
  272. free(ProfileName);
  273. if ( !DumpAllAdapters ) {
  274. break;
  275. } else {
  276. TargetAdapter = (PADAPTER)LocalAdapter.Linkage.Flink;
  277. }
  278. if (CheckControlC()) {
  279. return;
  280. }
  281. }
  282. } // adapter
  283. DECLARE_API( cvc )
  284. {
  285. GPC_CLIENT_VC LocalClientVC;
  286. PGPC_CLIENT_VC TargetClientVC;
  287. if ( *args == '\0' ) {
  288. dprintf("ClientVC <address of ClientVC structure>\n");
  289. return;
  290. }
  291. TargetClientVC = (PGPC_CLIENT_VC)GetExpression( args );
  292. if ( !TargetClientVC) {
  293. dprintf("bad string conversion (%s) \n", args );
  294. return;
  295. }
  296. //
  297. // read ClientVC struct out of target's memory
  298. //
  299. KD_READ_MEMORY(TargetClientVC, &LocalClientVC, sizeof(GPC_CLIENT_VC));
  300. DumpGpcClientVc("", TargetClientVC, &LocalClientVC);
  301. } // cvc
  302. DECLARE_API( astats )
  303. /*
  304. * dump an adapter's stats structure
  305. */
  306. {
  307. PADAPTER TargetAdapter;
  308. ADAPTER LocalAdapter;
  309. PADAPTER LastAdapter;
  310. LIST_ENTRY LocalListHead;
  311. PLIST_ENTRY TargetListHead;
  312. PWSTR Name;
  313. BOOLEAN DumpAllAdapters = FALSE;
  314. ULONG bytes;
  315. if ( *args == '\0' ) {
  316. //
  317. // run down the adapter list, dumping the contents of each one
  318. //
  319. TargetListHead = (PLIST_ENTRY)GetExpression( "psched!AdapterList" );
  320. if ( !TargetListHead ) {
  321. dprintf("Can't convert psched!AdapterList symbol\n");
  322. return;
  323. }
  324. //
  325. // read adapter listhead out of target's memory
  326. //
  327. KD_READ_MEMORY(TargetListHead, &LocalListHead, sizeof(LIST_ENTRY));
  328. TargetAdapter = (PADAPTER)LocalListHead.Flink;
  329. LastAdapter = (PADAPTER)TargetListHead;
  330. DumpAllAdapters = TRUE;
  331. } else {
  332. TargetAdapter = (PADAPTER)GetExpression( args );
  333. if ( !TargetAdapter ) {
  334. dprintf("bad string conversion (%s) \n", args );
  335. return;
  336. }
  337. LastAdapter = 0;
  338. }
  339. while ( TargetAdapter != LastAdapter ) {
  340. //
  341. // read adapter struct out of target's memory
  342. //
  343. KD_READ_MEMORY(TargetAdapter, &LocalAdapter, sizeof(ADAPTER));
  344. //
  345. // alloc some mem for the name and get that too
  346. //
  347. bytes = ( LocalAdapter.WMIInstanceName.Length + 1 ) * sizeof( WCHAR );
  348. Name = (PWSTR)malloc( bytes );
  349. if ( Name != NULL ) {
  350. KD_READ_MEMORY(((PADAPTER)TargetAdapter+1), Name, bytes);
  351. }
  352. dprintf( "\nAdapter Stats @ %08X (%ws)\n\n", TargetAdapter, Name );
  353. DumpAdapterStats( &LocalAdapter.Stats, " " );
  354. if ( Name != NULL )
  355. free( Name );
  356. if ( !DumpAllAdapters ) {
  357. break;
  358. } else {
  359. TargetAdapter = (PADAPTER)LocalAdapter.Linkage.Flink;
  360. }
  361. if (CheckControlC()) {
  362. return;
  363. }
  364. }
  365. } // astats
  366. VOID
  367. DumpAdapterStats(
  368. PPS_ADAPTER_STATS Stats,
  369. PCHAR Indent
  370. )
  371. {
  372. dprintf( "%sOut of Packets = %d\n", Indent, Stats->OutOfPackets );
  373. dprintf( "%sFlows Opened = %d\n", Indent, Stats->FlowsOpened );
  374. dprintf( "%sFlows Closed = %d\n", Indent, Stats->FlowsClosed );
  375. dprintf( "%sFlows Rejected = %d\n", Indent, Stats->FlowsRejected );
  376. dprintf( "%sFlows Modified = %d\n", Indent, Stats->FlowsModified );
  377. dprintf( "%sFlows ModsRejected = %d\n", Indent, Stats->FlowModsRejected );
  378. dprintf( "%sFlows MaxSimultaneousFlows = %d\n", Indent, Stats->MaxSimultaneousFlows );
  379. }
  380. DECLARE_API( help )
  381. {
  382. dprintf("PS kd extensions\n\n");
  383. dprintf("adapter [address] - dump adapter structure\n");
  384. dprintf("astats [adapter address] - dump adapter stats\n");
  385. dprintf("cvc <address> - dump client VC struct\n");
  386. dprintf("diff <address> - dump diffserv mapping \n");
  387. dprintf("fstats [vc address] - dump VC stats\n");
  388. dprintf("help - This help screen \n");
  389. dprintf("iph <address> - Dumps the IP header \n");
  390. dprintf("list <address> - Dumps the entries of a list \n");
  391. dprintf("lock <address> - Dumps the lock info \n");
  392. dprintf("ndisp <address> - Dumps the NDIS_PACKET \n");
  393. dprintf("netl <address> - Dumps the NETWORK_ADDRESS_LIST structure \n");
  394. dprintf("psdso Struct [<address>] - Structo on the structure \n");
  395. dprintf("tt [<filename>] - Dumps psched log on c:\\tmp\\<filename> or stdout \n");
  396. dprintf("upri <address> - Dumps the 802.1p value \n");
  397. dprintf("vc <adapter address> - Dumps the list of VCs on an adapter \n");
  398. dprintf("version - Displays version information \n");
  399. dprintf("wan <adapter address> - Dumps the list of WanLinks on an adapter \n");
  400. dprintf("wanlink <address> - Dumps the Wanlink Structure\n");
  401. }
  402. DECLARE_API( ndisp )
  403. {
  404. PNDIS_PACKET TargetPacket;
  405. NDIS_PACKET LocalPacket;
  406. MDL *CurrentMdl;
  407. LONG MDLCnt = 0;
  408. if ( *args == '\0' ) {
  409. dprintf("ndisp <address of NDIS_PACKET> \n");
  410. return;
  411. }
  412. TargetPacket = (PNDIS_PACKET)GetExpression( args );
  413. if ( !TargetPacket ) {
  414. dprintf("bad string conversion (%s) \n", args );
  415. return;
  416. }
  417. //
  418. // read client struct out of target's memory
  419. //
  420. KD_READ_MEMORY((ULONG)TargetPacket, &LocalPacket, sizeof(NDIS_PACKET));
  421. dprintf("\nNDIS_PACKET @ %08X \n", TargetPacket);
  422. dprintf(" Private \n");
  423. dprintf(" Physical Count : 0x%x (%d) \n", LocalPacket.Private.PhysicalCount,
  424. LocalPacket.Private.PhysicalCount);
  425. dprintf(" TotalLength : 0x%x (%d) \n", LocalPacket.Private.TotalLength,
  426. LocalPacket.Private.TotalLength);
  427. dprintf(" Head : 0x%x \n", LocalPacket.Private.Head);
  428. dprintf(" Tail : 0x%x \n", LocalPacket.Private.Tail);
  429. dprintf(" Pool : 0x%x \n", LocalPacket.Private.Pool);
  430. dprintf(" Count : 0x%x (%d) \n", LocalPacket.Private.Count,
  431. LocalPacket.Private.Count);
  432. dprintf(" Flags : 0x%x (%d) \n", LocalPacket.Private.Flags,
  433. LocalPacket.Private.Flags);
  434. dprintf(" ValidCounts : 0x%x (%d) \n", LocalPacket.Private.ValidCounts,
  435. LocalPacket.Private.ValidCounts);
  436. dprintf(" NdisPacketFlags : 0x%x (%d) \n", LocalPacket.Private.NdisPacketFlags,
  437. LocalPacket.Private.NdisPacketFlags);
  438. dprintf(" NdisPacketOobOffset : 0x%x (%d) \n", LocalPacket.Private.NdisPacketOobOffset,
  439. LocalPacket.Private.NdisPacketOobOffset);
  440. CurrentMdl = LocalPacket.Private.Head;
  441. while(CurrentMdl != 0) {
  442. MDL *TargetMdl;
  443. MDL LocalMdl;
  444. dprintf("\n MDL # %d\n", ++MDLCnt);
  445. TargetMdl = CurrentMdl;
  446. if ( !TargetMdl ) {
  447. dprintf("bad string conversion (%s) \n", CurrentMdl );
  448. return;
  449. }
  450. //
  451. // read client struct out of target's memory
  452. //
  453. KD_READ_MEMORY( TargetMdl, &LocalMdl, sizeof(MDL));
  454. dprintf(" Next : 0x%x \n", LocalMdl.Next);
  455. dprintf(" Size : 0x%x (%d) \n", LocalMdl.Size, LocalMdl.Size);
  456. dprintf(" MdlFlags : 0x%x (%d) \n", LocalMdl.MdlFlags,
  457. LocalMdl.MdlFlags);
  458. dprintf(" Process : 0x%x \n", LocalMdl.Process);
  459. dprintf(" MappedSystemVa : 0x%x \n", LocalMdl.MappedSystemVa);
  460. dprintf(" StartVa : 0x%x \n", LocalMdl.StartVa);
  461. dprintf(" ByteCount : 0x%x (%d) \n", LocalMdl.ByteCount,
  462. LocalMdl.ByteCount);
  463. dprintf(" ByteOffset : 0x%x (%d) \n", LocalMdl.ByteOffset,
  464. LocalMdl.ByteOffset);
  465. CurrentMdl = LocalMdl.Next;
  466. }
  467. }
  468. DECLARE_API(iph)
  469. {
  470. IPHeader *TargetPacket;
  471. IPHeader LocalPacket;
  472. LONG MDLCnt = 0;
  473. if ( *args == '\0' ) {
  474. dprintf("iph <address of IP header> \n");
  475. return;
  476. }
  477. TargetPacket = (IPHeader *) GetExpression( args );
  478. if ( !TargetPacket ) {
  479. dprintf("bad string conversion (%s) \n", args );
  480. return;
  481. }
  482. //
  483. // read client struct out of target's memory
  484. //
  485. KD_READ_MEMORY(TargetPacket, &LocalPacket, sizeof(IPHeader));
  486. dprintf("IPHeader @ %08X \n", TargetPacket);
  487. dprintf(" Version : %x \n", (LocalPacket.iph_verlen >> 4 ) & 0x0f);
  488. dprintf(" Header Length : %x \n", LocalPacket.iph_verlen & 0x0f);
  489. dprintf(" TOS : %x \n", LocalPacket.iph_tos);
  490. dprintf(" Length : %x \n", ntohs(LocalPacket.iph_length));
  491. dprintf(" ID : %x \n", ntohs(LocalPacket.iph_id));
  492. dprintf(" Offset : %x \n", ntohs(LocalPacket.iph_offset));
  493. dprintf(" TTL : %x \n", LocalPacket.iph_ttl);
  494. dprintf(" Protocol : ");
  495. switch(LocalPacket.iph_protocol) {
  496. case 1:
  497. dprintf("ICMP (%d) \n", LocalPacket.iph_protocol);
  498. break;
  499. case 2:
  500. dprintf("IGMP (%d) \n", LocalPacket.iph_protocol);
  501. break;
  502. case 6:
  503. dprintf("TCP (%d) \n", LocalPacket.iph_protocol);
  504. break;
  505. case 17:
  506. dprintf("UDP (%d) \n", LocalPacket.iph_protocol);
  507. break;
  508. default:
  509. dprintf("Unknown (%d) \n", LocalPacket.iph_protocol);
  510. break;
  511. }
  512. //
  513. // Validate Header checksum
  514. //
  515. dprintf(" Checksum : %x ", LocalPacket.iph_xsum);
  516. if(IPHeaderXsum(&LocalPacket, sizeof(IPHeader)) == 0) {
  517. dprintf("(Good) \n");
  518. }
  519. else {
  520. dprintf("(Bad) \n");
  521. }
  522. {
  523. struct in_addr ip;
  524. ip.s_addr = LocalPacket.iph_src;
  525. dprintf(" Source : %s \n", inet_ntoa(ip));
  526. ip.s_addr = LocalPacket.iph_dest;
  527. dprintf(" Dest : %s \n", inet_ntoa(ip));
  528. }
  529. }
  530. DECLARE_API( upri )
  531. {
  532. PNDIS_PACKET TargetPacket;
  533. NDIS_PACKET LocalPacket;
  534. MDL *CurrentMdl;
  535. LONG MDLCnt = 0;
  536. NDIS_PACKET_EXTENSION PerPacketInfo;
  537. if ( *args == '\0' ) {
  538. dprintf("ndisp <address of NDIS_PACKET> \n");
  539. return;
  540. }
  541. TargetPacket = (PNDIS_PACKET)GetExpression( args );
  542. if ( !TargetPacket ) {
  543. dprintf("bad string conversion (%s) \n", args );
  544. return;
  545. }
  546. //
  547. // read client struct out of target's memory
  548. //
  549. KD_READ_MEMORY(TargetPacket, &LocalPacket, sizeof(NDIS_PACKET));
  550. TargetPacket = (PNDIS_PACKET)((PUCHAR)TargetPacket +
  551. LocalPacket.Private.NdisPacketOobOffset +
  552. sizeof(NDIS_PACKET_OOB_DATA));
  553. KD_READ_MEMORY(TargetPacket, &PerPacketInfo, sizeof(NDIS_PACKET_EXTENSION));
  554. dprintf("802.1p Priority in packet is 0x%x \n",
  555. PerPacketInfo.NdisPacketInfo[Ieee8021pPriority]);
  556. return;
  557. }
  558. DECLARE_API( wanlink )
  559. {
  560. PPS_WAN_LINK Target;
  561. PS_WAN_LINK Local;
  562. PCHAR DialUsage[] = {"DU_CALLIN", "DU_CALLOUT", "DU_ROUTER"};
  563. if ( *args == '\0' ) {
  564. dprintf("wanlink <address of wanlink> \n");
  565. return;
  566. }
  567. Target= (PPS_WAN_LINK) GetExpression( args );
  568. if ( !Target) {
  569. dprintf("bad string conversion (%s) \n", args );
  570. return;
  571. }
  572. //
  573. // read client struct out of target's memory
  574. //
  575. KD_READ_MEMORY(Target, &Local, sizeof(PS_WAN_LINK));
  576. dprintf("WanLink @ %08X \n", Target);
  577. dprintf(" RefCount : %d \n", Local.RefCount);
  578. dprintf(" Dial Usage : %s \n", DialUsage[Local.DialUsage]);
  579. dprintf(" RawLinkSpeed : %d \n", Local.RawLinkSpeed);
  580. dprintf(" LinkSpeed : %d \n", Local.LinkSpeed);
  581. dprintf(" Lock : 0x%x \n", Local.Lock);
  582. dprintf(" Stats @ 0x%x \n", &Target->Stats);
  583. dprintf(" Addresses \n");
  584. dprintf(" --------- \n");
  585. dprintf(" Remote Address : %02x:%02x:%02x:%02x:%02x:%02x \n",
  586. Local.OriginalRemoteMacAddress[0], Local.OriginalRemoteMacAddress[1],
  587. Local.OriginalRemoteMacAddress[2], Local.OriginalRemoteMacAddress[3],
  588. Local.OriginalRemoteMacAddress[4], Local.OriginalRemoteMacAddress[5]);
  589. dprintf(" Local Address : %02x:%02x:%02x:%02x:%02x:%02x \n",
  590. Local.OriginalLocalMacAddress[0], Local.OriginalLocalMacAddress[1],
  591. Local.OriginalLocalMacAddress[2], Local.OriginalLocalMacAddress[3],
  592. Local.OriginalLocalMacAddress[4], Local.OriginalLocalMacAddress[5]);
  593. dprintf(" Protocol \n");
  594. dprintf(" -------- \n");
  595. dprintf(" ProtocolType : ");
  596. switch(Local.ProtocolType) {
  597. case PROTOCOL_IP:
  598. {
  599. struct in_addr ip;
  600. dprintf("IP \n");
  601. ip.s_addr = Local.LocalIpAddress;
  602. dprintf(" Address (Local) : %s \n", inet_ntoa(ip));
  603. ip.s_addr = Local.RemoteIpAddress;
  604. dprintf(" Address (Remote) : %s \n", inet_ntoa(ip));
  605. }
  606. break;
  607. case PROTOCOL_IPX:
  608. dprintf("IPX \n");
  609. dprintf(" Address (Local) : %d \n", Local.LocalIpxAddress);
  610. dprintf(" Address (Remote) : %d \n", Local.RemoteIpxAddress);
  611. break;
  612. default:
  613. dprintf("Unknown \n");
  614. break;
  615. }
  616. return;
  617. }
  618. DECLARE_API( vc )
  619. /*
  620. * dump all the VCs on an adapter
  621. */
  622. {
  623. PADAPTER TargetAdapter;
  624. ADAPTER LocalAdapter;
  625. PGPC_CLIENT_VC Target;
  626. GPC_CLIENT_VC Local;
  627. LIST_ENTRY TargetList;
  628. PLIST_ENTRY pL;
  629. ULONG bytes;
  630. if ( *args != '\0' ) {
  631. TargetAdapter = (PADAPTER)GetExpression( args );
  632. if ( !TargetAdapter ) {
  633. dprintf("bad string conversion (%s) \n", args );
  634. return;
  635. }
  636. //
  637. // read adapter struct out of target's memory
  638. //
  639. KD_READ_MEMORY(TargetAdapter, &LocalAdapter, sizeof(ADAPTER));
  640. TargetList = LocalAdapter.GpcClientVcList;
  641. pL = (PLIST_ENTRY) TargetList.Flink;
  642. while ( pL != &TargetAdapter->GpcClientVcList) {
  643. //
  644. // read ClientVC struct out of target's memory
  645. //
  646. Target = CONTAINING_RECORD(pL, GPC_CLIENT_VC, Linkage);
  647. KD_READ_MEMORY(Target, &Local, sizeof(GPC_CLIENT_VC));
  648. dprintf(" ---------------------------------------------- \n");
  649. dprintf( " GpcClientVc @ %08X: State %d, Flags 0x%x, Ref %d \n\n", Target,
  650. Local.ClVcState, Local.Flags, Local.RefCount);
  651. pL = Local.Linkage.Flink;
  652. }
  653. }
  654. }
  655. DECLARE_API(fstats)
  656. {
  657. GPC_CLIENT_VC LocalClientVC;
  658. PGPC_CLIENT_VC TargetClientVC;
  659. if ( *args == '\0' ) {
  660. dprintf("Flow Stats <address of ClientVC structure>\n");
  661. return;
  662. }
  663. TargetClientVC = (PGPC_CLIENT_VC) GetExpression( args );
  664. if ( !TargetClientVC) {
  665. dprintf("bad string conversion (%s) \n", args );
  666. return;
  667. }
  668. //
  669. // read ClientVC struct out of target's memory
  670. //
  671. KD_READ_MEMORY(TargetClientVC, &LocalClientVC, sizeof(GPC_CLIENT_VC));
  672. dprintf( " Stats for Vc %x \n", TargetClientVC);
  673. dprintf( " ----------------- \n");
  674. dprintf( " VC Stats \n");
  675. dprintf( " Dropped Packets = %d \n", LocalClientVC.Stats.DroppedPackets);
  676. dprintf( " Packets Scheduled = %d \n", LocalClientVC.Stats.PacketsScheduled);
  677. dprintf( " Packets Transmitted = %d \n", LocalClientVC.Stats.PacketsTransmitted);
  678. dprintf( " Bytes Transmitted = %ld\n", LocalClientVC.Stats.BytesTransmitted.QuadPart);
  679. dprintf( " Bytes Scheduled = %ld\n", LocalClientVC.Stats.BytesScheduled.QuadPart);
  680. dprintf( " Conformr Stats \n");
  681. dprintf( " Shaper stats \n");
  682. dprintf( " SequencerStats \n");
  683. }
  684. DECLARE_API(netl)
  685. {
  686. PNETWORK_ADDRESS_LIST Target;
  687. NETWORK_ADDRESS_LIST Local;
  688. LONG i;
  689. if ( *args == '\0' ) {
  690. dprintf("netl <address>\n");
  691. return;
  692. }
  693. Target = (PNETWORK_ADDRESS_LIST) GetExpression( args );
  694. if ( !Target) {
  695. dprintf("bad string conversion (%s) \n", args );
  696. return;
  697. }
  698. //
  699. // read ClientVC struct out of target's memory
  700. //
  701. KD_READ_MEMORY(Target, &Local, FIELD_OFFSET(NETWORK_ADDRESS_LIST,Address));
  702. dprintf("Network Address List @ 0x%x \n", Target);
  703. dprintf(" AddressCount = %d \n", Local.AddressCount);
  704. dprintf(" AddressType = %d \n\n", Local.AddressType);
  705. Target = (PNETWORK_ADDRESS_LIST)((PUCHAR)Target + FIELD_OFFSET(NETWORK_ADDRESS_LIST, Address));
  706. for(i=0; i<Local.AddressCount; i++)
  707. {
  708. NETWORK_ADDRESS_IP ipAddr;
  709. NETWORK_ADDRESS_IPX ipxAddr;
  710. NETWORK_ADDRESS LocalN;
  711. //
  712. // Parse the NETWORK_ADDRESS
  713. //
  714. KD_READ_MEMORY(Target, &LocalN, FIELD_OFFSET(NETWORK_ADDRESS, Address));
  715. dprintf(" AddressLength = %d \n", LocalN.AddressLength);
  716. dprintf(" AddressType = %d \n", LocalN.AddressType);
  717. //
  718. // Read the Address
  719. //
  720. Target = (PNETWORK_ADDRESS_LIST)((PUCHAR)Target + FIELD_OFFSET(NETWORK_ADDRESS, Address));
  721. switch(LocalN.AddressType)
  722. {
  723. case NDIS_PROTOCOL_ID_TCP_IP:
  724. {
  725. struct in_addr ip;
  726. KD_READ_MEMORY(Target, &ipAddr, sizeof(NETWORK_ADDRESS_IP));
  727. ip.s_addr = ipAddr.in_addr;
  728. dprintf(" sin_port = %d \n", ipAddr.sin_port);
  729. dprintf(" in_addr = %s \n", inet_ntoa(ip));
  730. break;
  731. }
  732. default:
  733. dprintf(" *** ERROR : Unrecognized protocol \n");
  734. break;
  735. }
  736. dprintf(" ---------------------------- \n");
  737. }
  738. }
  739. DECLARE_API( wan )
  740. /*
  741. * dump all the VCs on an adapter
  742. */
  743. {
  744. PADAPTER TargetAdapter;
  745. ADAPTER LocalAdapter;
  746. PPS_WAN_LINK Target;
  747. PS_WAN_LINK Local;
  748. LIST_ENTRY TargetList;
  749. PLIST_ENTRY pL;
  750. ULONG bytes;
  751. if ( *args != '\0' ) {
  752. TargetAdapter = (PADAPTER)GetExpression( args );
  753. if ( !TargetAdapter ) {
  754. dprintf("bad string conversion (%s) \n", args );
  755. return;
  756. }
  757. //
  758. // read adapter struct out of target's memory
  759. //
  760. KD_READ_MEMORY(TargetAdapter, &LocalAdapter, sizeof(ADAPTER));
  761. TargetList = LocalAdapter.WanLinkList;
  762. pL = (PLIST_ENTRY) TargetList.Flink;
  763. while ( pL != &TargetAdapter->WanLinkList) {
  764. //
  765. // read ClientVC struct out of target's memory
  766. //
  767. Target = CONTAINING_RECORD(pL, PS_WAN_LINK, Linkage);
  768. KD_READ_MEMORY(Target, &Local, sizeof(PS_WAN_LINK));
  769. dprintf(" ---------------------------------------------- \n");
  770. dprintf( " WanLink @ %08X\n\n", Target);
  771. pL = Local.Linkage.Flink;
  772. }
  773. }
  774. }
  775. DECLARE_API( lock )
  776. {
  777. #if DBG
  778. PPS_SPIN_LOCK Target;
  779. PS_SPIN_LOCK Local;
  780. ULONG bytes;
  781. if ( *args != '\0' ) {
  782. Target = (PPS_SPIN_LOCK)GetExpression( args );
  783. if ( !Target) {
  784. dprintf("bad string conversion (%s) \n", args );
  785. return;
  786. }
  787. //
  788. // read adapter struct out of target's memory
  789. //
  790. KD_READ_MEMORY(Target, &Local, sizeof(PS_SPIN_LOCK));
  791. if(Local.LockAcquired == TRUE)
  792. {
  793. dprintf(" Acquired : TRUE \n");
  794. dprintf(" LastAcquiredFile : %s \n", Local.LastAcquiredFile);
  795. dprintf(" LastAcquiredLine : %d \n", Local.LastAcquiredLine);
  796. }
  797. else
  798. {
  799. dprintf(" Acquired : FALSE \n");
  800. dprintf(" LastReleasedFile : %s \n", Local.LastReleasedFile);
  801. dprintf(" LastReleasedLine : %d \n", Local.LastReleasedLine);
  802. }
  803. }
  804. return;
  805. #endif
  806. }
  807. DECLARE_API(diff)
  808. {
  809. PDIFFSERV_MAPPING TargetA;
  810. DIFFSERV_MAPPING LocalA;
  811. int i;
  812. if ( *args == '\0' )
  813. {
  814. dprintf("diff <address>\n");
  815. return;
  816. }
  817. TargetA = (PDIFFSERV_MAPPING)GetExpression( args );
  818. if ( !TargetA) {
  819. dprintf("bad string conversion (%s) \n", args );
  820. return;
  821. }
  822. dprintf("TOS : The Entire 8 bit DSField as it appears in the IP header \n");
  823. dprintf("DSCP : The differentiated services code point (higher order 6 bits of above) \n");
  824. dprintf("Prec : The precedence value (above field with bits swapped around \n");
  825. dprintf("OC-TOS : The Entire 8 bit DS field on outbound packets for conforming packets\n");
  826. dprintf("ONC-TOS: The Entire 8 bit DS field on outbound packets for non-conforming packets\n");
  827. dprintf("\n");
  828. dprintf("TOS DSCP Prec OC-TOS ONC-TOS VC \n");
  829. dprintf("---------------------------------------------------------------------------------------\n");
  830. for(i=0; i<PREC_MAX_VALUE; i++)
  831. {
  832. //
  833. // read ClientVC struct out of target's memory
  834. //
  835. KD_READ_MEMORY(TargetA, &LocalA, sizeof(DIFFSERV_MAPPING));
  836. TargetA = (PDIFFSERV_MAPPING)((PUCHAR)TargetA + sizeof(DIFFSERV_MAPPING));
  837. //if(LocalA.Vc != 0)
  838. {
  839. dprintf("0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%8x\n",
  840. i<<2,
  841. i,
  842. //BitShift(i),
  843. 0,
  844. LocalA.ConformingOutboundDSField,
  845. LocalA.NonConformingOutboundDSField,
  846. LocalA.Vc);
  847. }
  848. }
  849. dprintf("---------------------------------------------------------------------------------------\n");
  850. }
  851. DECLARE_API( list )
  852. {
  853. LIST_ENTRY Target, Local, TargetList;
  854. PLIST_ENTRY head, pL;
  855. ULONG bytes;
  856. if ( *args != '\0' ) {
  857. head = pL = (PLIST_ENTRY) GetExpression( args );
  858. if ( !pL) {
  859. dprintf("bad string conversion (%s) \n", args );
  860. return;
  861. }
  862. //
  863. // read adapter struct out of target's memory
  864. //
  865. KD_READ_MEMORY(pL, &Local, sizeof(LIST_ENTRY));
  866. while ( Local.Flink != head)
  867. {
  868. pL = Local.Flink;
  869. if(pL == 0)
  870. {
  871. dprintf("Local = %x %x \n", Local.Flink, Local.Blink);
  872. }
  873. else
  874. {
  875. dprintf("%x \n", pL);
  876. }
  877. KD_READ_MEMORY(pL, &Local, sizeof(LIST_ENTRY));
  878. }
  879. }
  880. }