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.

1175 lines
36 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. dprintf( " \n");
  229. dprintf( " Scheduling Components \n");
  230. dprintf( " --------------------- \n");
  231. dprintf( " PsComponent = %08X \n", LocalAdapter.PsComponent);
  232. dprintf( " PsPipeContext = %08X \n", LocalAdapter.PsPipeContext);
  233. dprintf( " PipeContextLength = %d \n", LocalAdapter.PipeContextLength);
  234. dprintf( " FlowContextLength = %d \n", LocalAdapter.FlowContextLength);
  235. dprintf( " PacketContextLength = %d \n", LocalAdapter.PacketContextLength);
  236. dprintf( " ClassMapContextLength = %d \n", LocalAdapter.ClassMapContextLength);
  237. dprintf( " PipeFlags = %08X\n", LocalAdapter.PipeFlags );
  238. dprintf( " MaxOutstandingSends = 0x%08X \n", LocalAdapter.MaxOutstandingSends);
  239. dprintf( "\n");
  240. dprintf( "\n");
  241. dprintf( " NDISWAN \n");
  242. dprintf( " ------- \n");
  243. dprintf( " WanCmHandle = %08X \n", LocalAdapter.WanCmHandle);
  244. dprintf( " WanBindingState = %08X \n", LocalAdapter.WanBindingState);
  245. dprintf( " WanLinkCount = %08X \n", LocalAdapter.WanLinkCount);
  246. dprintf( " WanLinkList @ %08X ", &TargetAdapter->WanLinkList);
  247. if(&TargetAdapter->WanLinkList == LocalAdapter.WanLinkList.Flink) {
  248. dprintf( " (empty) \n");
  249. }
  250. else {
  251. dprintf( " Next = %08X \n", LocalAdapter.WanLinkList.Flink);
  252. }
  253. dprintf( " ISSLOWPacketSize = %08X \n", LocalAdapter.ISSLOWPacketSize);
  254. dprintf( " ISSLOWFragmentSize = %08X \n", LocalAdapter.ISSLOWFragmentSize);
  255. dprintf( " ISSLOWTokenRate = %08X \n", LocalAdapter.ISSLOWTokenRate);
  256. dprintf("\n");
  257. dprintf( " Adaptermode = %s \n", AdapterMode[LocalAdapter.AdapterMode]);
  258. }
  259. dprintf( "\n" );
  260. if ( PSName != NULL )
  261. free( PSName );
  262. if ( MPName != NULL )
  263. free( MPName );
  264. if ( WMIName != NULL)
  265. free ( WMIName);
  266. if ( RegistryPath != NULL)
  267. free(RegistryPath);
  268. if ( ProfileName != NULL)
  269. free(ProfileName);
  270. if ( !DumpAllAdapters ) {
  271. break;
  272. } else {
  273. TargetAdapter = (PADAPTER)LocalAdapter.Linkage.Flink;
  274. }
  275. if (CheckControlC()) {
  276. return;
  277. }
  278. }
  279. } // adapter
  280. DECLARE_API( cvc )
  281. {
  282. GPC_CLIENT_VC LocalClientVC;
  283. PGPC_CLIENT_VC TargetClientVC;
  284. if ( *args == '\0' ) {
  285. dprintf("ClientVC <address of ClientVC structure>\n");
  286. return;
  287. }
  288. TargetClientVC = (PGPC_CLIENT_VC)GetExpression( args );
  289. if ( !TargetClientVC) {
  290. dprintf("bad string conversion (%s) \n", args );
  291. return;
  292. }
  293. //
  294. // read ClientVC struct out of target's memory
  295. //
  296. KD_READ_MEMORY(TargetClientVC, &LocalClientVC, sizeof(GPC_CLIENT_VC));
  297. DumpGpcClientVc("", TargetClientVC, &LocalClientVC);
  298. } // cvc
  299. DECLARE_API( astats )
  300. /*
  301. * dump an adapter's stats structure
  302. */
  303. {
  304. PADAPTER TargetAdapter;
  305. ADAPTER LocalAdapter;
  306. PADAPTER LastAdapter;
  307. LIST_ENTRY LocalListHead;
  308. PLIST_ENTRY TargetListHead;
  309. PWSTR Name;
  310. BOOLEAN DumpAllAdapters = FALSE;
  311. ULONG bytes;
  312. if ( *args == '\0' ) {
  313. //
  314. // run down the adapter list, dumping the contents of each one
  315. //
  316. TargetListHead = (PLIST_ENTRY)GetExpression( "psched!AdapterList" );
  317. if ( !TargetListHead ) {
  318. dprintf("Can't convert psched!AdapterList symbol\n");
  319. return;
  320. }
  321. //
  322. // read adapter listhead out of target's memory
  323. //
  324. KD_READ_MEMORY(TargetListHead, &LocalListHead, sizeof(LIST_ENTRY));
  325. TargetAdapter = (PADAPTER)LocalListHead.Flink;
  326. LastAdapter = (PADAPTER)TargetListHead;
  327. DumpAllAdapters = TRUE;
  328. } else {
  329. TargetAdapter = (PADAPTER)GetExpression( args );
  330. if ( !TargetAdapter ) {
  331. dprintf("bad string conversion (%s) \n", args );
  332. return;
  333. }
  334. LastAdapter = 0;
  335. }
  336. while ( TargetAdapter != LastAdapter ) {
  337. //
  338. // read adapter struct out of target's memory
  339. //
  340. KD_READ_MEMORY(TargetAdapter, &LocalAdapter, sizeof(ADAPTER));
  341. //
  342. // alloc some mem for the name and get that too
  343. //
  344. bytes = ( LocalAdapter.WMIInstanceName.Length + 1 ) * sizeof( WCHAR );
  345. Name = (PWSTR)malloc( bytes );
  346. if ( Name != NULL ) {
  347. KD_READ_MEMORY(((PADAPTER)TargetAdapter+1), Name, bytes);
  348. }
  349. dprintf( "\nAdapter Stats @ %08X (%ws)\n\n", TargetAdapter, Name );
  350. DumpAdapterStats( &LocalAdapter.Stats, " " );
  351. if ( Name != NULL )
  352. free( Name );
  353. if ( !DumpAllAdapters ) {
  354. break;
  355. } else {
  356. TargetAdapter = (PADAPTER)LocalAdapter.Linkage.Flink;
  357. }
  358. if (CheckControlC()) {
  359. return;
  360. }
  361. }
  362. } // astats
  363. VOID
  364. DumpAdapterStats(
  365. PPS_ADAPTER_STATS Stats,
  366. PCHAR Indent
  367. )
  368. {
  369. dprintf( "%sOut of Packets = %d\n", Indent, Stats->OutOfPackets );
  370. dprintf( "%sFlows Opened = %d\n", Indent, Stats->FlowsOpened );
  371. dprintf( "%sFlows Closed = %d\n", Indent, Stats->FlowsClosed );
  372. dprintf( "%sFlows Rejected = %d\n", Indent, Stats->FlowsRejected );
  373. dprintf( "%sFlows Modified = %d\n", Indent, Stats->FlowsModified );
  374. dprintf( "%sFlows ModsRejected = %d\n", Indent, Stats->FlowModsRejected );
  375. dprintf( "%sFlows MaxSimultaneousFlows = %d\n", Indent, Stats->MaxSimultaneousFlows );
  376. }
  377. DECLARE_API( help )
  378. {
  379. dprintf("PS kd extensions\n\n");
  380. dprintf("adapter [address] - dump adapter structure\n");
  381. dprintf("astats [adapter address] - dump adapter stats\n");
  382. dprintf("cvc <address> - dump client VC struct\n");
  383. dprintf("diff <address> - dump diffserv mapping \n");
  384. dprintf("fstats [vc address] - dump VC stats\n");
  385. dprintf("help - This help screen \n");
  386. dprintf("iph <address> - Dumps the IP header \n");
  387. dprintf("list <address> - Dumps the entries of a list \n");
  388. dprintf("lock <address> - Dumps the lock info \n");
  389. dprintf("ndisp <address> - Dumps the NDIS_PACKET \n");
  390. dprintf("netl <address> - Dumps the NETWORK_ADDRESS_LIST structure \n");
  391. dprintf("psdso Struct [<address>] - Structo on the structure \n");
  392. dprintf("tt [<filename>] - Dumps psched log on c:\\tmp\\<filename> or stdout \n");
  393. dprintf("upri <address> - Dumps the 802.1p value \n");
  394. dprintf("vc <adapter address> - Dumps the list of VCs on an adapter \n");
  395. dprintf("version - Displays version information \n");
  396. dprintf("wan <adapter address> - Dumps the list of WanLinks on an adapter \n");
  397. dprintf("wanlink <address> - Dumps the Wanlink Structure\n");
  398. }
  399. DECLARE_API( ndisp )
  400. {
  401. PNDIS_PACKET TargetPacket;
  402. NDIS_PACKET LocalPacket;
  403. MDL *CurrentMdl;
  404. LONG MDLCnt = 0;
  405. if ( *args == '\0' ) {
  406. dprintf("ndisp <address of NDIS_PACKET> \n");
  407. return;
  408. }
  409. TargetPacket = (PNDIS_PACKET)GetExpression( args );
  410. if ( !TargetPacket ) {
  411. dprintf("bad string conversion (%s) \n", args );
  412. return;
  413. }
  414. //
  415. // read client struct out of target's memory
  416. //
  417. KD_READ_MEMORY((ULONG)TargetPacket, &LocalPacket, sizeof(NDIS_PACKET));
  418. dprintf("\nNDIS_PACKET @ %08X \n", TargetPacket);
  419. dprintf(" Private \n");
  420. dprintf(" Physical Count : 0x%x (%d) \n", LocalPacket.Private.PhysicalCount,
  421. LocalPacket.Private.PhysicalCount);
  422. dprintf(" TotalLength : 0x%x (%d) \n", LocalPacket.Private.TotalLength,
  423. LocalPacket.Private.TotalLength);
  424. dprintf(" Head : 0x%x \n", LocalPacket.Private.Head);
  425. dprintf(" Tail : 0x%x \n", LocalPacket.Private.Tail);
  426. dprintf(" Pool : 0x%x \n", LocalPacket.Private.Pool);
  427. dprintf(" Count : 0x%x (%d) \n", LocalPacket.Private.Count,
  428. LocalPacket.Private.Count);
  429. dprintf(" Flags : 0x%x (%d) \n", LocalPacket.Private.Flags,
  430. LocalPacket.Private.Flags);
  431. dprintf(" ValidCounts : 0x%x (%d) \n", LocalPacket.Private.ValidCounts,
  432. LocalPacket.Private.ValidCounts);
  433. dprintf(" NdisPacketFlags : 0x%x (%d) \n", LocalPacket.Private.NdisPacketFlags,
  434. LocalPacket.Private.NdisPacketFlags);
  435. dprintf(" NdisPacketOobOffset : 0x%x (%d) \n", LocalPacket.Private.NdisPacketOobOffset,
  436. LocalPacket.Private.NdisPacketOobOffset);
  437. CurrentMdl = LocalPacket.Private.Head;
  438. while(CurrentMdl != 0) {
  439. MDL *TargetMdl;
  440. MDL LocalMdl;
  441. dprintf("\n MDL # %d\n", ++MDLCnt);
  442. TargetMdl = CurrentMdl;
  443. if ( !TargetMdl ) {
  444. dprintf("bad string conversion (%s) \n", CurrentMdl );
  445. return;
  446. }
  447. //
  448. // read client struct out of target's memory
  449. //
  450. KD_READ_MEMORY( TargetMdl, &LocalMdl, sizeof(MDL));
  451. dprintf(" Next : 0x%x \n", LocalMdl.Next);
  452. dprintf(" Size : 0x%x (%d) \n", LocalMdl.Size, LocalMdl.Size);
  453. dprintf(" MdlFlags : 0x%x (%d) \n", LocalMdl.MdlFlags,
  454. LocalMdl.MdlFlags);
  455. dprintf(" Process : 0x%x \n", LocalMdl.Process);
  456. dprintf(" MappedSystemVa : 0x%x \n", LocalMdl.MappedSystemVa);
  457. dprintf(" StartVa : 0x%x \n", LocalMdl.StartVa);
  458. dprintf(" ByteCount : 0x%x (%d) \n", LocalMdl.ByteCount,
  459. LocalMdl.ByteCount);
  460. dprintf(" ByteOffset : 0x%x (%d) \n", LocalMdl.ByteOffset,
  461. LocalMdl.ByteOffset);
  462. CurrentMdl = LocalMdl.Next;
  463. }
  464. }
  465. DECLARE_API(iph)
  466. {
  467. IPHeader *TargetPacket;
  468. IPHeader LocalPacket;
  469. LONG MDLCnt = 0;
  470. if ( *args == '\0' ) {
  471. dprintf("iph <address of IP header> \n");
  472. return;
  473. }
  474. TargetPacket = (IPHeader *) GetExpression( args );
  475. if ( !TargetPacket ) {
  476. dprintf("bad string conversion (%s) \n", args );
  477. return;
  478. }
  479. //
  480. // read client struct out of target's memory
  481. //
  482. KD_READ_MEMORY(TargetPacket, &LocalPacket, sizeof(IPHeader));
  483. dprintf("IPHeader @ %08X \n", TargetPacket);
  484. dprintf(" Version : %x \n", (LocalPacket.iph_verlen >> 4 ) & 0x0f);
  485. dprintf(" Header Length : %x \n", LocalPacket.iph_verlen & 0x0f);
  486. dprintf(" TOS : %x \n", LocalPacket.iph_tos);
  487. dprintf(" Length : %x \n", ntohs(LocalPacket.iph_length));
  488. dprintf(" ID : %x \n", ntohs(LocalPacket.iph_id));
  489. dprintf(" Offset : %x \n", ntohs(LocalPacket.iph_offset));
  490. dprintf(" TTL : %x \n", LocalPacket.iph_ttl);
  491. dprintf(" Protocol : ");
  492. switch(LocalPacket.iph_protocol) {
  493. case 1:
  494. dprintf("ICMP (%d) \n", LocalPacket.iph_protocol);
  495. break;
  496. case 2:
  497. dprintf("IGMP (%d) \n", LocalPacket.iph_protocol);
  498. break;
  499. case 6:
  500. dprintf("TCP (%d) \n", LocalPacket.iph_protocol);
  501. break;
  502. case 17:
  503. dprintf("UDP (%d) \n", LocalPacket.iph_protocol);
  504. break;
  505. default:
  506. dprintf("Unknown (%d) \n", LocalPacket.iph_protocol);
  507. break;
  508. }
  509. //
  510. // Validate Header checksum
  511. //
  512. dprintf(" Checksum : %x ", LocalPacket.iph_xsum);
  513. if(IPHeaderXsum(&LocalPacket, sizeof(IPHeader)) == 0) {
  514. dprintf("(Good) \n");
  515. }
  516. else {
  517. dprintf("(Bad) \n");
  518. }
  519. {
  520. struct in_addr ip;
  521. ip.s_addr = LocalPacket.iph_src;
  522. dprintf(" Source : %s \n", inet_ntoa(ip));
  523. ip.s_addr = LocalPacket.iph_dest;
  524. dprintf(" Dest : %s \n", inet_ntoa(ip));
  525. }
  526. }
  527. DECLARE_API( upri )
  528. {
  529. PNDIS_PACKET TargetPacket;
  530. NDIS_PACKET LocalPacket;
  531. MDL *CurrentMdl;
  532. LONG MDLCnt = 0;
  533. NDIS_PACKET_EXTENSION PerPacketInfo;
  534. if ( *args == '\0' ) {
  535. dprintf("ndisp <address of NDIS_PACKET> \n");
  536. return;
  537. }
  538. TargetPacket = (PNDIS_PACKET)GetExpression( args );
  539. if ( !TargetPacket ) {
  540. dprintf("bad string conversion (%s) \n", args );
  541. return;
  542. }
  543. //
  544. // read client struct out of target's memory
  545. //
  546. KD_READ_MEMORY(TargetPacket, &LocalPacket, sizeof(NDIS_PACKET));
  547. TargetPacket = (PNDIS_PACKET)((PUCHAR)TargetPacket +
  548. LocalPacket.Private.NdisPacketOobOffset +
  549. sizeof(NDIS_PACKET_OOB_DATA));
  550. KD_READ_MEMORY(TargetPacket, &PerPacketInfo, sizeof(NDIS_PACKET_EXTENSION));
  551. dprintf("802.1p Priority in packet is 0x%x \n",
  552. PerPacketInfo.NdisPacketInfo[Ieee8021pPriority]);
  553. return;
  554. }
  555. DECLARE_API( wanlink )
  556. {
  557. PPS_WAN_LINK Target;
  558. PS_WAN_LINK Local;
  559. PCHAR DialUsage[] = {"DU_CALLIN", "DU_CALLOUT", "DU_ROUTER"};
  560. if ( *args == '\0' ) {
  561. dprintf("wanlink <address of wanlink> \n");
  562. return;
  563. }
  564. Target= (PPS_WAN_LINK) GetExpression( args );
  565. if ( !Target) {
  566. dprintf("bad string conversion (%s) \n", args );
  567. return;
  568. }
  569. //
  570. // read client struct out of target's memory
  571. //
  572. KD_READ_MEMORY(Target, &Local, sizeof(PS_WAN_LINK));
  573. dprintf("WanLink @ %08X \n", Target);
  574. dprintf(" RefCount : %d \n", Local.RefCount);
  575. dprintf(" Dial Usage : %s \n", DialUsage[Local.DialUsage]);
  576. dprintf(" RawLinkSpeed : %d \n", Local.RawLinkSpeed);
  577. dprintf(" LinkSpeed : %d \n", Local.LinkSpeed);
  578. dprintf(" Lock : 0x%x \n", Local.Lock);
  579. dprintf(" Stats @ 0x%x \n", &Target->Stats);
  580. dprintf(" Addresses \n");
  581. dprintf(" --------- \n");
  582. dprintf(" Remote Address : %02x:%02x:%02x:%02x:%02x:%02x \n",
  583. Local.OriginalRemoteMacAddress[0], Local.OriginalRemoteMacAddress[1],
  584. Local.OriginalRemoteMacAddress[2], Local.OriginalRemoteMacAddress[3],
  585. Local.OriginalRemoteMacAddress[4], Local.OriginalRemoteMacAddress[5]);
  586. dprintf(" Local Address : %02x:%02x:%02x:%02x:%02x:%02x \n",
  587. Local.OriginalLocalMacAddress[0], Local.OriginalLocalMacAddress[1],
  588. Local.OriginalLocalMacAddress[2], Local.OriginalLocalMacAddress[3],
  589. Local.OriginalLocalMacAddress[4], Local.OriginalLocalMacAddress[5]);
  590. dprintf(" Protocol \n");
  591. dprintf(" -------- \n");
  592. dprintf(" ProtocolType : ");
  593. switch(Local.ProtocolType) {
  594. case PROTOCOL_IP:
  595. {
  596. struct in_addr ip;
  597. dprintf("IP \n");
  598. ip.s_addr = Local.LocalIpAddress;
  599. dprintf(" Address (Local) : %s \n", inet_ntoa(ip));
  600. ip.s_addr = Local.RemoteIpAddress;
  601. dprintf(" Address (Remote) : %s \n", inet_ntoa(ip));
  602. }
  603. break;
  604. case PROTOCOL_IPX:
  605. dprintf("IPX \n");
  606. dprintf(" Address (Local) : %d \n", Local.LocalIpxAddress);
  607. dprintf(" Address (Remote) : %d \n", Local.RemoteIpxAddress);
  608. break;
  609. default:
  610. dprintf("Unknown \n");
  611. break;
  612. }
  613. return;
  614. }
  615. DECLARE_API( vc )
  616. /*
  617. * dump all the VCs on an adapter
  618. */
  619. {
  620. PADAPTER TargetAdapter;
  621. ADAPTER LocalAdapter;
  622. PGPC_CLIENT_VC Target;
  623. GPC_CLIENT_VC Local;
  624. LIST_ENTRY TargetList;
  625. PLIST_ENTRY pL;
  626. ULONG bytes;
  627. if ( *args != '\0' ) {
  628. TargetAdapter = (PADAPTER)GetExpression( args );
  629. if ( !TargetAdapter ) {
  630. dprintf("bad string conversion (%s) \n", args );
  631. return;
  632. }
  633. //
  634. // read adapter struct out of target's memory
  635. //
  636. KD_READ_MEMORY(TargetAdapter, &LocalAdapter, sizeof(ADAPTER));
  637. TargetList = LocalAdapter.GpcClientVcList;
  638. pL = (PLIST_ENTRY) TargetList.Flink;
  639. while ( pL != &TargetAdapter->GpcClientVcList) {
  640. //
  641. // read ClientVC struct out of target's memory
  642. //
  643. Target = CONTAINING_RECORD(pL, GPC_CLIENT_VC, Linkage);
  644. KD_READ_MEMORY(Target, &Local, sizeof(GPC_CLIENT_VC));
  645. dprintf(" ---------------------------------------------- \n");
  646. dprintf( " GpcClientVc @ %08X: State %d, Flags 0x%x, Ref %d \n\n", Target,
  647. Local.ClVcState, Local.Flags, Local.RefCount);
  648. pL = Local.Linkage.Flink;
  649. }
  650. }
  651. }
  652. DECLARE_API(fstats)
  653. {
  654. GPC_CLIENT_VC LocalClientVC;
  655. PGPC_CLIENT_VC TargetClientVC;
  656. if ( *args == '\0' ) {
  657. dprintf("Flow Stats <address of ClientVC structure>\n");
  658. return;
  659. }
  660. TargetClientVC = (PGPC_CLIENT_VC) GetExpression( args );
  661. if ( !TargetClientVC) {
  662. dprintf("bad string conversion (%s) \n", args );
  663. return;
  664. }
  665. //
  666. // read ClientVC struct out of target's memory
  667. //
  668. KD_READ_MEMORY(TargetClientVC, &LocalClientVC, sizeof(GPC_CLIENT_VC));
  669. dprintf( " Stats for Vc %x \n", TargetClientVC);
  670. dprintf( " ----------------- \n");
  671. dprintf( " VC Stats \n");
  672. dprintf( " Dropped Packets = %d \n", LocalClientVC.Stats.DroppedPackets);
  673. dprintf( " Packets Scheduled = %d \n", LocalClientVC.Stats.PacketsScheduled);
  674. dprintf( " Packets Transmitted = %d \n", LocalClientVC.Stats.PacketsTransmitted);
  675. dprintf( " Bytes Transmitted = %ld\n", LocalClientVC.Stats.BytesTransmitted.QuadPart);
  676. dprintf( " Bytes Scheduled = %ld\n", LocalClientVC.Stats.BytesScheduled.QuadPart);
  677. dprintf( " Conformr Stats \n");
  678. dprintf( " Shaper stats \n");
  679. dprintf( " SequencerStats \n");
  680. }
  681. DECLARE_API(netl)
  682. {
  683. PNETWORK_ADDRESS_LIST Target;
  684. NETWORK_ADDRESS_LIST Local;
  685. LONG i;
  686. if ( *args == '\0' ) {
  687. dprintf("netl <address>\n");
  688. return;
  689. }
  690. Target = (PNETWORK_ADDRESS_LIST) GetExpression( args );
  691. if ( !Target) {
  692. dprintf("bad string conversion (%s) \n", args );
  693. return;
  694. }
  695. //
  696. // read ClientVC struct out of target's memory
  697. //
  698. KD_READ_MEMORY(Target, &Local, FIELD_OFFSET(NETWORK_ADDRESS_LIST,Address));
  699. dprintf("Network Address List @ 0x%x \n", Target);
  700. dprintf(" AddressCount = %d \n", Local.AddressCount);
  701. dprintf(" AddressType = %d \n\n", Local.AddressType);
  702. Target = (PNETWORK_ADDRESS_LIST)((PUCHAR)Target + FIELD_OFFSET(NETWORK_ADDRESS_LIST, Address));
  703. for(i=0; i<Local.AddressCount; i++)
  704. {
  705. NETWORK_ADDRESS_IP ipAddr;
  706. NETWORK_ADDRESS_IPX ipxAddr;
  707. NETWORK_ADDRESS LocalN;
  708. //
  709. // Parse the NETWORK_ADDRESS
  710. //
  711. KD_READ_MEMORY(Target, &LocalN, FIELD_OFFSET(NETWORK_ADDRESS, Address));
  712. dprintf(" AddressLength = %d \n", LocalN.AddressLength);
  713. dprintf(" AddressType = %d \n", LocalN.AddressType);
  714. //
  715. // Read the Address
  716. //
  717. Target = (PNETWORK_ADDRESS_LIST)((PUCHAR)Target + FIELD_OFFSET(NETWORK_ADDRESS, Address));
  718. switch(LocalN.AddressType)
  719. {
  720. case NDIS_PROTOCOL_ID_TCP_IP:
  721. {
  722. struct in_addr ip;
  723. KD_READ_MEMORY(Target, &ipAddr, sizeof(NETWORK_ADDRESS_IP));
  724. ip.s_addr = ipAddr.in_addr;
  725. dprintf(" sin_port = %d \n", ipAddr.sin_port);
  726. dprintf(" in_addr = %s \n", inet_ntoa(ip));
  727. break;
  728. }
  729. default:
  730. dprintf(" *** ERROR : Unrecognized protocol \n");
  731. break;
  732. }
  733. dprintf(" ---------------------------- \n");
  734. }
  735. }
  736. DECLARE_API( wan )
  737. /*
  738. * dump all the VCs on an adapter
  739. */
  740. {
  741. PADAPTER TargetAdapter;
  742. ADAPTER LocalAdapter;
  743. PPS_WAN_LINK Target;
  744. PS_WAN_LINK Local;
  745. LIST_ENTRY TargetList;
  746. PLIST_ENTRY pL;
  747. ULONG bytes;
  748. if ( *args != '\0' ) {
  749. TargetAdapter = (PADAPTER)GetExpression( args );
  750. if ( !TargetAdapter ) {
  751. dprintf("bad string conversion (%s) \n", args );
  752. return;
  753. }
  754. //
  755. // read adapter struct out of target's memory
  756. //
  757. KD_READ_MEMORY(TargetAdapter, &LocalAdapter, sizeof(ADAPTER));
  758. TargetList = LocalAdapter.WanLinkList;
  759. pL = (PLIST_ENTRY) TargetList.Flink;
  760. while ( pL != &TargetAdapter->WanLinkList) {
  761. //
  762. // read ClientVC struct out of target's memory
  763. //
  764. Target = CONTAINING_RECORD(pL, PS_WAN_LINK, Linkage);
  765. KD_READ_MEMORY(Target, &Local, sizeof(PS_WAN_LINK));
  766. dprintf(" ---------------------------------------------- \n");
  767. dprintf( " WanLink @ %08X\n\n", Target);
  768. pL = Local.Linkage.Flink;
  769. }
  770. }
  771. }
  772. DECLARE_API( lock )
  773. {
  774. #if DBG
  775. PPS_SPIN_LOCK Target;
  776. PS_SPIN_LOCK Local;
  777. ULONG bytes;
  778. if ( *args != '\0' ) {
  779. Target = (PPS_SPIN_LOCK)GetExpression( args );
  780. if ( !Target) {
  781. dprintf("bad string conversion (%s) \n", args );
  782. return;
  783. }
  784. //
  785. // read adapter struct out of target's memory
  786. //
  787. KD_READ_MEMORY(Target, &Local, sizeof(PS_SPIN_LOCK));
  788. if(Local.LockAcquired == TRUE)
  789. {
  790. dprintf(" Acquired : TRUE \n");
  791. dprintf(" LastAcquiredFile : %s \n", Local.LastAcquiredFile);
  792. dprintf(" LastAcquiredLine : %d \n", Local.LastAcquiredLine);
  793. }
  794. else
  795. {
  796. dprintf(" Acquired : FALSE \n");
  797. dprintf(" LastReleasedFile : %s \n", Local.LastReleasedFile);
  798. dprintf(" LastReleasedLine : %d \n", Local.LastReleasedLine);
  799. }
  800. }
  801. return;
  802. #endif
  803. }
  804. DECLARE_API(diff)
  805. {
  806. PDIFFSERV_MAPPING TargetA;
  807. DIFFSERV_MAPPING LocalA;
  808. int i;
  809. if ( *args == '\0' )
  810. {
  811. dprintf("diff <address>\n");
  812. return;
  813. }
  814. TargetA = (PDIFFSERV_MAPPING)GetExpression( args );
  815. if ( !TargetA) {
  816. dprintf("bad string conversion (%s) \n", args );
  817. return;
  818. }
  819. dprintf("TOS : The Entire 8 bit DSField as it appears in the IP header \n");
  820. dprintf("DSCP : The differentiated services code point (higher order 6 bits of above) \n");
  821. dprintf("Prec : The precedence value (above field with bits swapped around \n");
  822. dprintf("OC-TOS : The Entire 8 bit DS field on outbound packets for conforming packets\n");
  823. dprintf("ONC-TOS: The Entire 8 bit DS field on outbound packets for non-conforming packets\n");
  824. dprintf("\n");
  825. dprintf("TOS DSCP Prec OC-TOS ONC-TOS VC \n");
  826. dprintf("---------------------------------------------------------------------------------------\n");
  827. for(i=0; i<PREC_MAX_VALUE; i++)
  828. {
  829. //
  830. // read ClientVC struct out of target's memory
  831. //
  832. KD_READ_MEMORY(TargetA, &LocalA, sizeof(DIFFSERV_MAPPING));
  833. TargetA = (PDIFFSERV_MAPPING)((PUCHAR)TargetA + sizeof(DIFFSERV_MAPPING));
  834. //if(LocalA.Vc != 0)
  835. {
  836. dprintf("0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%8x\n",
  837. i<<2,
  838. i,
  839. //BitShift(i),
  840. 0,
  841. LocalA.ConformingOutboundDSField,
  842. LocalA.NonConformingOutboundDSField,
  843. LocalA.Vc);
  844. }
  845. }
  846. dprintf("---------------------------------------------------------------------------------------\n");
  847. }
  848. DECLARE_API( list )
  849. {
  850. LIST_ENTRY Target, Local, TargetList;
  851. PLIST_ENTRY head, pL;
  852. ULONG bytes;
  853. if ( *args != '\0' ) {
  854. head = pL = (PLIST_ENTRY) GetExpression( args );
  855. if ( !pL) {
  856. dprintf("bad string conversion (%s) \n", args );
  857. return;
  858. }
  859. //
  860. // read adapter struct out of target's memory
  861. //
  862. KD_READ_MEMORY(pL, &Local, sizeof(LIST_ENTRY));
  863. while ( Local.Flink != head)
  864. {
  865. pL = Local.Flink;
  866. if(pL == 0)
  867. {
  868. dprintf("Local = %x %x \n", Local.Flink, Local.Blink);
  869. }
  870. else
  871. {
  872. dprintf("%x \n", pL);
  873. }
  874. KD_READ_MEMORY(pL, &Local, sizeof(LIST_ENTRY));
  875. }
  876. }
  877. }