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.

1212 lines
26 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. #include <tdint.h>
  4. #include <arpdef.h>
  5. #include <iprtdef.h>
  6. #include <winsock.h>
  7. #define ROUTE_TABLE_SIZE 32
  8. FLAG_INFO FlagsNTE[] =
  9. {
  10. { NTE_VALID, "NTE_Valid" },
  11. { NTE_COPY, "NTE_Copy" },
  12. { NTE_PRIMARY, "NTE_Primary" },
  13. { NTE_ACTIVE, "NTE_Active" },
  14. { NTE_DYNAMIC, "NTE_Dynamic" },
  15. { NTE_DHCP, "NTE_DHCP" },
  16. { NTE_DISCONNECTED, "NTE_Disconnected" },
  17. { NTE_TIMER_STARTED, "NTE_TimerStarted" },
  18. { NTE_IF_DELETING, "NTE_IF_Deleting" },
  19. { 0, NULL }
  20. };
  21. FLAG_INFO FlagsIF[] =
  22. {
  23. { IF_FLAGS_P2P, "IF_Point_to_Point" },
  24. { IF_FLAGS_DELETING, "IF_Deleting" },
  25. { IF_FLAGS_NOIPADDR, "IF_NoIPAddr" },
  26. { IF_FLAGS_P2MP, "IF_P2MP" },
  27. { IF_FLAGS_REMOVING_POWER, "IF_REMOVING_POWER" },
  28. { IF_FLAGS_POWER_DOWN, "IF_POWER_DOWN" },
  29. { IF_FLAGS_REMOVING_DEVICE, "IF_REMOVING_DEVICE" },
  30. { IF_FLAGS_NOLINKBCST, "IF_FLAGS_NOLINKBCST" },
  31. { 0, NULL }
  32. };
  33. FLAG_INFO FlagsRCE[] =
  34. {
  35. { RCE_VALID, "RCE_Valid" },
  36. { RCE_CONNECTED, "RCE_Connected" },
  37. { RCE_REFERENCED, "RCE_Referenced" },
  38. { RCE_DEADGW, "RCE_Deadgw" },
  39. { 0, NULL }
  40. };
  41. FLAG_INFO FlagsRTE[] =
  42. {
  43. { RTE_VALID, "RTE_Valid" },
  44. { RTE_INCREASE, "RTE_Increase" },
  45. { RTE_IF_VALID, "RTE_If_Valid" },
  46. { RTE_DEADGW, "RTE_DeadGW" },
  47. { RTE_NEW, "RTE_New" },
  48. { 0, NULL }
  49. };
  50. VOID
  51. DumpLog
  52. (
  53. );
  54. DECLARE_API( dumplog )
  55. {
  56. DumpLog();
  57. return;
  58. }
  59. VOID
  60. DumpIPH(
  61. ULONG IPH
  62. );
  63. DECLARE_API( IPH )
  64. {
  65. ULONG addressToDump = 0;
  66. if ( *args ) {
  67. sscanf(args, "%lx", &addressToDump);
  68. }
  69. DumpIPH( addressToDump );
  70. return;
  71. }
  72. ULONG_PTR
  73. DumpNTE(
  74. ULONG NTEAddr,
  75. VERBOSITY Verbosity
  76. );
  77. DECLARE_API( nte )
  78. {
  79. ULONG addressToDump = 0;
  80. ULONG result;
  81. if ( *args ) {
  82. sscanf(args, "%lx", &addressToDump);
  83. }
  84. DumpNTE( addressToDump, VERBOSITY_NORMAL );
  85. return;
  86. }
  87. ULONG_PTR
  88. DumpInterface(
  89. ULONG InterfaceAddr,
  90. VERBOSITY Verbosity
  91. );
  92. DECLARE_API( interface )
  93. {
  94. ULONG addressToDump = 0;
  95. ULONG result;
  96. if ( *args ) {
  97. sscanf(args, "%lx", &addressToDump);
  98. }
  99. DumpInterface( addressToDump, VERBOSITY_NORMAL );
  100. return;
  101. }
  102. VOID
  103. DumpIFList
  104. (
  105. VERBOSITY Verbosity
  106. );
  107. DECLARE_API( iflist )
  108. {
  109. char buf[128];
  110. buf[0] = '\0';
  111. if ( *args ) {
  112. sscanf(args, "%s", buf);
  113. }
  114. if (buf[0] == '\0') {
  115. dprintf( "VERBOSITY_NORMAL\n" );
  116. DumpIFList( VERBOSITY_NORMAL );
  117. } else {
  118. dprintf( "VERBOSITY_FULL\n" );
  119. DumpIFList( VERBOSITY_FULL );
  120. }
  121. return;
  122. }
  123. VOID
  124. DumpNTEList
  125. (
  126. VERBOSITY Verbosity
  127. );
  128. DECLARE_API( ntelist )
  129. {
  130. char buf[128];
  131. buf[0] = '\0';
  132. if ( *args ) {
  133. sscanf(args, "%s", buf);
  134. }
  135. if (buf[0] == '\0') {
  136. dprintf( "VERBOSITY_NORMAL\n" );
  137. DumpNTEList( VERBOSITY_NORMAL );
  138. } else {
  139. dprintf( "VERBOSITY_FULL\n" );
  140. DumpNTEList( VERBOSITY_FULL );
  141. }
  142. return;
  143. }
  144. ULONG
  145. DumpRCE(
  146. ULONG RCEAddr,
  147. VERBOSITY Verbosity
  148. );
  149. DECLARE_API( rce )
  150. {
  151. ULONG addressToDump = 0;
  152. ULONG result;
  153. if ( *args ) {
  154. sscanf(args, "%lx", &addressToDump);
  155. }
  156. DumpRCE( addressToDump, VERBOSITY_NORMAL );
  157. return;
  158. }
  159. ULONG
  160. DumpRTE(
  161. ULONG RTEAddr,
  162. VERBOSITY Verbosity
  163. );
  164. DECLARE_API( rte )
  165. {
  166. ULONG addressToDump = 0;
  167. ULONG result;
  168. if ( *args ) {
  169. sscanf(args, "%lx", &addressToDump);
  170. }
  171. DumpRTE( addressToDump, VERBOSITY_NORMAL );
  172. return;
  173. }
  174. ULONG
  175. DumpATE(
  176. ULONG ATEAddr,
  177. VERBOSITY Verbosity
  178. );
  179. DECLARE_API( ate )
  180. {
  181. ULONG addressToDump = 0;
  182. ULONG result;
  183. if ( *args ) {
  184. sscanf(args, "%lx", &addressToDump);
  185. }
  186. DumpATE( addressToDump, VERBOSITY_NORMAL );
  187. return;
  188. }
  189. ULONG
  190. DumpAI(
  191. ULONG AIAddr,
  192. VERBOSITY Verbosity
  193. );
  194. DECLARE_API( ai )
  195. {
  196. ULONG addressToDump = 0;
  197. ULONG result;
  198. if ( *args ) {
  199. sscanf(args, "%lx", &addressToDump);
  200. }
  201. DumpAI( addressToDump, VERBOSITY_NORMAL );
  202. return;
  203. }
  204. VOID
  205. DumpARPTable
  206. (
  207. ULONG ARPTableAddr,
  208. VERBOSITY Verbosity
  209. );
  210. DECLARE_API( arptable )
  211. {
  212. ULONG addressToDump = 0;
  213. ULONG result;
  214. if ( *args ) {
  215. sscanf(args, "%lx", &addressToDump);
  216. }
  217. DumpARPTable( addressToDump, VERBOSITY_NORMAL );
  218. return;
  219. }
  220. #ifdef _obj
  221. # undef _obj
  222. # undef _objAddr
  223. # undef _objType
  224. # undef _objTypeName
  225. #endif
  226. #define _obj NTE
  227. #define _objAddr NTEToDump
  228. #define _objType NetTableEntry
  229. #define _objTypeName "NetTableEntry"
  230. ULONG_PTR
  231. DumpNTE
  232. (
  233. ULONG _objAddr,
  234. VERBOSITY Verbosity
  235. )
  236. /*++
  237. Routine Description:
  238. Dumps the fields of the specified DEVICE_CONTEXT structure
  239. Arguments:
  240. DeviceToDump - The device context object to display
  241. Full - Display a partial listing if 0, full listing otherwise.
  242. Return Value:
  243. None
  244. --*/
  245. {
  246. _objType _obj;
  247. ULONG result;
  248. unsigned int index;
  249. BOOL bActive;
  250. if ( !ReadMemory( _objAddr,
  251. &_obj,
  252. sizeof( _obj ),
  253. &result ))
  254. {
  255. dprintf("%08lx: Could not read %s structure.\n", _objAddr, _objTypeName );
  256. return(0);
  257. }
  258. if ( Verbosity == VERBOSITY_ONE_LINER )
  259. {
  260. dprintf( "NOT IMPLEMENTED" );
  261. return(0);
  262. }
  263. dprintf( "%s @ %08lx\n", _objTypeName, _objAddr );
  264. PrintStartStruct();
  265. PrintFieldName( "nte_next" );
  266. dprint_addr_list( ( ULONG_PTR )_obj.nte_next,
  267. FIELD_OFFSET( _objType, nte_next ));
  268. PrintIPAddress( nte_addr );
  269. PrintIPAddress( nte_mask );
  270. PrintPtr( nte_if );
  271. PrintFieldName( "nte_ifnext" );
  272. dprint_addr_list( ( ULONG_PTR )_obj.nte_ifnext,
  273. FIELD_OFFSET( _objType, nte_ifnext ));
  274. PrintFlags( nte_flags, FlagsNTE );
  275. PrintUShort( nte_context );
  276. PrintULong( nte_instance );
  277. PrintPtr( nte_pnpcontext );
  278. PrintLock( nte_lock );
  279. PrintPtr( nte_ralist );
  280. PrintPtr( nte_echolist );
  281. PrintCTETimer( nte_timer );
  282. PrintAddr( nte_timerblock );
  283. PrintUShort( nte_mss );
  284. PrintULong( nte_icmpseq );
  285. PrintPtr( nte_igmplist );
  286. PrintPtr( nte_addrhandle );
  287. PrintIPAddress( nte_rtrdiscaddr );
  288. PrintUChar( nte_rtrdiscstate );
  289. PrintUChar( nte_rtrdisccount );
  290. PrintUChar( nte_rtrdiscovery );
  291. PrintUChar( nte_deleting );
  292. PrintPtr( nte_rtrlist );
  293. PrintULong( nte_igmpcount );
  294. PrintEndStruct();
  295. return( (ULONG_PTR)_obj.nte_next );
  296. }
  297. VOID
  298. DumpNTEList
  299. (
  300. VERBOSITY Verbosity
  301. )
  302. {
  303. ULONG Listlen=0;
  304. ULONG NteAddr;
  305. ULONG result;
  306. NetTableEntry **NteList, **PreservedPtr;
  307. ULONG_PTR CurrentNTE;
  308. ULONG index;
  309. ULONG NET_TABLE_SIZE;
  310. NteAddr = GetUlongValue( "tcpip!NewNetTableList" );
  311. NET_TABLE_SIZE = GetUlongValue( "tcpip!NET_TABLE_SIZE" );
  312. NteList = malloc(sizeof( NetTableEntry * ) * NET_TABLE_SIZE);
  313. if (NteList == NULL) {
  314. dprintf("malloc failed\n");
  315. return;
  316. }
  317. PreservedPtr = NteList;
  318. // Listlen = GetUlongValue( "tcpip!NumNTE" );
  319. if ( !ReadMemory( NteAddr,
  320. &NteList[0],
  321. 4 * NET_TABLE_SIZE,
  322. &result ))
  323. {
  324. dprintf("%08lx: Could not read the list.\n", NteAddr);
  325. return;
  326. }
  327. for (index=0; index<NET_TABLE_SIZE; index++) {
  328. CurrentNTE = (ULONG_PTR)NteList[index];
  329. while (CurrentNTE) {
  330. dprintf("The hash is %d \n", index);
  331. CurrentNTE = DumpNTE(CurrentNTE, Verbosity );
  332. Listlen++;
  333. }
  334. }
  335. dprintf("total %d \n", Listlen);
  336. free(NteList);
  337. return;
  338. }
  339. #ifdef _obj
  340. # undef _obj
  341. # undef _objAddr
  342. # undef _objType
  343. # undef _objTypeName
  344. #endif
  345. #define _obj IF
  346. #define _objAddr InterfaceToDump
  347. #define _objType Interface
  348. #define _objTypeName "Interface"
  349. ULONG_PTR
  350. DumpInterface
  351. (
  352. ULONG _objAddr,
  353. VERBOSITY Verbosity
  354. )
  355. /*++
  356. Routine Description:
  357. Dumps the fields of the specified DEVICE_CONTEXT structure
  358. Arguments:
  359. DeviceToDump - The device context object to display
  360. Full - Display a partial listing if 0, full listing otherwise.
  361. Return Value:
  362. None
  363. --*/
  364. {
  365. _objType _obj;
  366. ULONG result;
  367. unsigned int index;
  368. BOOL bActive;
  369. if ( !ReadMemory( _objAddr,
  370. &_obj,
  371. sizeof( _obj ),
  372. &result ))
  373. {
  374. dprintf("%08lx: Could not read %s structure.\n", _objAddr, _objTypeName );
  375. return(0);
  376. }
  377. if ( Verbosity == VERBOSITY_ONE_LINER )
  378. {
  379. dprintf( "NOT IMPLEMENTED" );
  380. return(0);
  381. }
  382. dprintf( "%s @ %08lx\n", _objTypeName, _objAddr );
  383. PrintStartStruct();
  384. PrintFieldName( "if_next" );
  385. dprint_addr_list( ( ULONG_PTR )_obj.if_next,
  386. FIELD_OFFSET( _objType, if_next ));
  387. PrintPtr( if_lcontext );
  388. PrintSymbolPtr( if_xmit );
  389. PrintSymbolPtr( if_transfer );
  390. PrintSymbolPtr( if_close );
  391. PrintSymbolPtr( if_invalidate );
  392. PrintSymbolPtr( if_addaddr );
  393. PrintSymbolPtr( if_deladdr );
  394. PrintSymbolPtr( if_qinfo );
  395. PrintSymbolPtr( if_setinfo );
  396. PrintSymbolPtr( if_getelist );
  397. PrintSymbolPtr( if_dondisreq );
  398. PrintSymbolPtr( if_dowakeupptrn );
  399. PrintSymbolPtr( if_pnpcomplete );
  400. PrintSymbolPtr( if_setndisrequest );
  401. PrintSymbolPtr( if_arpresolveip );
  402. PrintSymbolPtr( if_arpflushate );
  403. PrintSymbolPtr( if_arpflushallate );
  404. PrintULong( if_numgws );
  405. for (index = 0; index < MAX_DEFAULT_GWS; index++) {
  406. PrintIPAddress(if_gw[index]);
  407. }
  408. PrintUShort( if_rtrdiscovery );
  409. PrintUShort( if_dhcprtrdiscovery );
  410. PrintPtr( if_tdpacket );
  411. PrintULong( if_index );
  412. PrintULong( if_mediatype );
  413. PrintUChar( if_accesstype );
  414. PrintUChar( if_conntype );
  415. PrintUChar( if_mcastttl );
  416. PrintUChar( if_mcastflags );
  417. PrintULong( if_lastupcall );
  418. PrintULong( if_ntecount );
  419. PrintFieldName( "if_nte" );
  420. dprint_addr_list( ( ULONG_PTR )_obj.if_nte,
  421. FIELD_OFFSET( NetTableEntry, nte_ifnext ));
  422. PrintIPAddress( if_bcast );
  423. PrintULong( if_mtu );
  424. PrintULong( if_speed );
  425. PrintFlags( if_flags, FlagsIF );
  426. PrintULong( if_addrlen );
  427. PrintPtr( if_addr );
  428. PrintULong( IgmpVersion );
  429. PrintULong( IgmpVer1Timeout );
  430. PrintULong( IgmpVer2Timeout );
  431. PrintULong( IgmpGeneralTimer );
  432. PrintULong( if_refcount );
  433. PrintPtr( if_block );
  434. PrintPtr( if_pnpcontext );
  435. PrintPtr( if_tdibindhandle );
  436. PrintXULong( if_llipflags );
  437. PrintAddr( if_configname );
  438. PrintUString( if_configname );
  439. PrintAddr( if_devname );
  440. PrintUString( if_devname );
  441. PrintAddr( if_name );
  442. PrintUString( if_name );
  443. PrintPtr( if_ipsecsniffercontext );
  444. PrintLock( if_lock );
  445. #if FFP_SUPPORT
  446. PrintULong( if_ffpversion );
  447. PrintULong( if_ffpdriver );
  448. #endif
  449. PrintULong( if_OffloadFlags ); // Checksum capability holder.
  450. PrintULong( if_MaxOffLoadSize );
  451. PrintULong( if_MaxSegments );
  452. PrintAddr( if_TcpLargeSend );
  453. PrintULong( if_TcpWindowSize );
  454. PrintULong( if_TcpInitialRTT );
  455. PrintULong( if_TcpDelAckTicks );
  456. PrintULong( if_promiscuousmode ); // promiscuous mode or not
  457. PrintULong( if_InitInProgress );
  458. PrintPtr( if_link );
  459. PrintSymbolPtr( if_closelink );
  460. PrintULong( if_mediastatus );
  461. PrintULong( if_iftype);
  462. PrintUChar( if_absorbfwdpkts );
  463. PrintULong( if_pnpcap );
  464. PrintPtr( if_dampnext );
  465. PrintULong( if_damptimer );
  466. PrintULong( if_resetInProgress );
  467. PrintEndStruct();
  468. return( (ULONG_PTR)_obj.if_next );
  469. }
  470. VOID
  471. DumpIFList
  472. (
  473. VERBOSITY Verbosity
  474. )
  475. {
  476. ULONG Listlen;
  477. ULONG_PTR IFAddr;
  478. ULONG result;
  479. IFAddr = GetUlongValue( "tcpip!IFList" );
  480. Listlen = GetUlongValue( "tcpip!NumIF" );
  481. dprintf("Dumping IFList @ %08lx\n",
  482. IFAddr, Listlen );
  483. while (IFAddr) {
  484. IFAddr = DumpInterface(IFAddr, Verbosity );
  485. }
  486. return;
  487. }
  488. #ifdef _obj
  489. # undef _obj
  490. # undef _objAddr
  491. # undef _objType
  492. # undef _objTypeName
  493. #endif
  494. #define _obj RCE
  495. #define _objAddr RCEToDump
  496. #define _objType RouteCacheEntry
  497. #define _objTypeName "RouteCacheEntry"
  498. ULONG
  499. DumpRCE
  500. (
  501. ULONG _objAddr,
  502. VERBOSITY Verbosity
  503. )
  504. /*++
  505. Routine Description:
  506. Dumps the fields of the specified DEVICE_CONTEXT structure
  507. Arguments:
  508. DeviceToDump - The device context object to display
  509. Full - Display a partial listing if 0, full listing otherwise.
  510. Return Value:
  511. None
  512. --*/
  513. {
  514. _objType _obj;
  515. ULONG result;
  516. unsigned int index;
  517. BOOL bActive;
  518. if ( !ReadMemory( _objAddr,
  519. &_obj,
  520. sizeof( _obj ),
  521. &result ))
  522. {
  523. dprintf("%08lx: Could not read %s structure.\n", _objAddr, _objTypeName );
  524. return(0);
  525. }
  526. if ( Verbosity == VERBOSITY_ONE_LINER )
  527. {
  528. dprintf( "NOT IMPLEMENTED" );
  529. return(0);
  530. }
  531. dprintf( "%s @ %08lx\n", _objTypeName, _objAddr );
  532. PrintStartStruct();
  533. PrintFieldName( "rce_next" );
  534. dprint_addr_list( ( ULONG_PTR )_obj.rce_next,
  535. FIELD_OFFSET( _objType, rce_next ));
  536. PrintPtr( rce_rte );
  537. PrintIPAddress( rce_dest );
  538. PrintIPAddress( rce_src );
  539. PrintFlags( rce_flags, FlagsRCE );
  540. PrintUChar( rce_dtype );
  541. PrintULong( rce_usecnt );
  542. PrintPtr( rce_context[0] );
  543. PrintPtr( rce_context[1] );
  544. PrintLock( rce_lock );
  545. PrintULong ( rce_OffloadFlags ); // interface chksum capability flags
  546. PrintAddr( rce_TcpLargeSend );
  547. PrintULong( rce_TcpWindowSize );
  548. PrintULong( rce_TcpInitialRTT );
  549. PrintULong( rce_TcpDelAckTicks );
  550. PrintULong( rce_cnt );
  551. PrintULong( rce_mediaspeed );
  552. PrintEndStruct();
  553. return( (ULONG_PTR)_obj.rce_next );
  554. }
  555. #ifdef _obj
  556. # undef _obj
  557. # undef _objAddr
  558. # undef _objType
  559. # undef _objTypeName
  560. #endif
  561. #define _obj RTE
  562. #define _objAddr RTEToDump
  563. #define _objType RouteTableEntry
  564. #define _objTypeName "RouteTableEntry"
  565. ULONG
  566. DumpRTE
  567. (
  568. ULONG _objAddr,
  569. VERBOSITY Verbosity
  570. )
  571. /*++
  572. Routine Description:
  573. Dumps the fields of the specified DEVICE_CONTEXT structure
  574. Arguments:
  575. DeviceToDump - The device context object to display
  576. Full - Display a partial listing if 0, full listing otherwise.
  577. Return Value:
  578. None
  579. --*/
  580. {
  581. _objType _obj;
  582. ULONG result;
  583. unsigned int index;
  584. BOOL bActive;
  585. if ( !ReadMemory( _objAddr,
  586. &_obj,
  587. sizeof( _obj ),
  588. &result ))
  589. {
  590. dprintf("%08lx: Could not read %s structure.\n", _objAddr, _objTypeName );
  591. return(0);
  592. }
  593. if ( Verbosity == VERBOSITY_ONE_LINER )
  594. {
  595. dprintf( "NOT IMPLEMENTED" );
  596. return(0);
  597. }
  598. dprintf( "%s @ %08lx\n", _objTypeName, _objAddr );
  599. PrintStartStruct();
  600. PrintFieldName( "rte_next" );
  601. dprint_addr_list( ( ULONG_PTR )_obj.rte_next,
  602. FIELD_OFFSET( _objType, rte_next ));
  603. PrintIPAddress( rte_dest );
  604. PrintIPAddress( rte_mask );
  605. PrintIPAddress( rte_addr );
  606. PrintPtr( rte_rcelist );
  607. PrintPtr( rte_if );
  608. PrintULong( rte_priority );
  609. PrintULong( rte_metric );
  610. PrintULong( rte_mtu );
  611. PrintUShort( rte_type );
  612. PrintFlags( rte_flags, FlagsRTE );
  613. PrintULong( rte_admintype );
  614. PrintULong( rte_proto );
  615. PrintULong( rte_valid );
  616. PrintULong( rte_mtuchange );
  617. PrintPtr( rte_context );
  618. PrintPtr( rte_arpcontext[0] );
  619. PrintPtr( rte_arpcontext[1] );
  620. PrintPtr( rte_todg );
  621. PrintPtr( rte_fromdg );
  622. PrintULong( rte_rces );
  623. PrintPtr( rte_link );
  624. PrintPtr( rte_nextlinkrte );
  625. PrintEndStruct();
  626. return( (ULONG_PTR)_obj.rte_next );
  627. }
  628. #ifdef _obj
  629. # undef _obj
  630. # undef _objAddr
  631. # undef _objType
  632. # undef _objTypeName
  633. #endif
  634. #define _obj ATE
  635. #define _objAddr ATEToDump
  636. #define _objType ARPTableEntry
  637. #define _objTypeName "ARPTableEntry"
  638. ULONG
  639. DumpATE
  640. (
  641. ULONG _objAddr,
  642. VERBOSITY Verbosity
  643. )
  644. /*++
  645. Routine Description:
  646. Dumps the fields of the specified DEVICE_CONTEXT structure
  647. Arguments:
  648. DeviceToDump - The device context object to display
  649. Full - Display a partial listing if 0, full listing otherwise.
  650. Return Value:
  651. None
  652. --*/
  653. {
  654. _objType _obj;
  655. ULONG result;
  656. unsigned int index;
  657. BOOL bActive;
  658. UCHAR MacAddr[ARP_802_ADDR_LENGTH];
  659. if ( !ReadMemory( _objAddr,
  660. &_obj,
  661. sizeof( _obj ),
  662. &result ))
  663. {
  664. dprintf("%08lx: Could not read %s structure.\n", _objAddr, _objTypeName );
  665. return(0);
  666. }
  667. if ( Verbosity == VERBOSITY_ONE_LINER )
  668. {
  669. dprintf( "NOT IMPLEMENTED" );
  670. return(0);
  671. }
  672. dprintf( "%s @ %08lx\n", _objTypeName, _objAddr );
  673. PrintStartStruct();
  674. PrintFieldName( "ate_next" );
  675. dprint_addr_list( ( ULONG_PTR )_obj.ate_next,
  676. FIELD_OFFSET( _objType, ate_next ));
  677. PrintULong( ate_valid );
  678. PrintIPAddress( ate_dest );
  679. PrintPtr( ate_packet );
  680. PrintPtr( ate_rce );
  681. PrintLock( ate_lock );
  682. PrintULong( ate_useticks );
  683. PrintUChar( ate_addrlength );
  684. PrintUChar( ate_state );
  685. PrintULong( ate_userarp );
  686. PrintPtr( ate_resolveonly );
  687. PrintAddr( ate_addr );
  688. if ( !ReadMemory( AddressOf( ate_addr ),
  689. &MacAddr,
  690. sizeof( MacAddr ),
  691. &result ))
  692. {
  693. dprintf("%08lx: Could not read %s structure.\n", _objAddr, _objTypeName );
  694. return(0);
  695. }
  696. PrintMacAddr( ate_addr, MacAddr );
  697. PrintEndStruct();
  698. return( (ULONG)_obj.ate_next );
  699. }
  700. #ifdef _obj
  701. # undef _obj
  702. # undef _objAddr
  703. # undef _objType
  704. # undef _objTypeName
  705. #endif
  706. #define _obj AI
  707. #define _objAddr AIToDump
  708. #define _objType ARPInterface
  709. #define _objTypeName "ARPInterface"
  710. ULONG
  711. DumpAI
  712. (
  713. ULONG _objAddr,
  714. VERBOSITY Verbosity
  715. )
  716. /*++
  717. Routine Description:
  718. Dumps the fields of the specified DEVICE_CONTEXT structure
  719. Arguments:
  720. DeviceToDump - The device context object to display
  721. Full - Display a partial listing if 0, full listing otherwise.
  722. Return Value:
  723. None
  724. --*/
  725. {
  726. _objType _obj;
  727. ULONG result;
  728. unsigned int index;
  729. BOOL bActive;
  730. if ( !ReadMemory( _objAddr,
  731. &_obj,
  732. sizeof( _obj ),
  733. &result ))
  734. {
  735. dprintf("%08lx: Could not read %s structure.\n", _objAddr, _objTypeName );
  736. return(0);
  737. }
  738. if ( Verbosity == VERBOSITY_ONE_LINER )
  739. {
  740. dprintf( "NOT IMPLEMENTED" );
  741. return(0);
  742. }
  743. dprintf( "%s @ %08lx\n", _objTypeName, _objAddr );
  744. PrintStartStruct();
  745. PrintLL( ai_linkage );
  746. PrintPtr( ai_context );
  747. #if FFP_SUPPORT
  748. PrintPtr( ai_driver );
  749. #endif
  750. PrintPtr( ai_handle );
  751. PrintULong( ai_media );
  752. PrintPtr( ai_ppool );
  753. PrintLock( ai_lock );
  754. PrintLock( ai_ARPTblLock );
  755. PrintPtr( ai_ARPTbl );
  756. PrintAddr( ai_ipaddr );
  757. PrintPtr( ai_parpaddr );
  758. PrintIPAddress( ai_bcast );
  759. PrintULong( ai_inoctets );
  760. PrintULong( ai_inpcount[0] );
  761. PrintULong( ai_inpcount[1] );
  762. PrintULong( ai_inpcount[2] );
  763. PrintULong( ai_outoctets );
  764. PrintULong( ai_outpcount[0] );
  765. PrintULong( ai_outpcount[1] );
  766. PrintULong( ai_qlen );
  767. PrintMacAddr( ai_addr, _obj.ai_addr );
  768. PrintUChar( ai_state );
  769. PrintUChar( ai_addrlen );
  770. PrintXUChar( ai_bcastmask );
  771. PrintXUChar( ai_bcastval );
  772. PrintUChar( ai_bcastoff );
  773. PrintUChar( ai_hdrsize );
  774. PrintUChar( ai_snapsize );
  775. PrintUChar( ai_pad[0] );
  776. PrintUChar( ai_pad[1] );
  777. PrintULong( ai_pfilter );
  778. PrintULong( ai_count );
  779. PrintULong( ai_parpcount );
  780. PrintCTETimer( ai_timer );
  781. PrintBool( ai_timerstarted );
  782. PrintBool( ai_stoptimer );
  783. PrintAddr( ai_timerblock );
  784. PrintAddr( ai_block );
  785. PrintUShort( ai_mtu );
  786. PrintUChar( ai_adminstate );
  787. PrintUChar( ai_operstate );
  788. PrintULong( ai_speed );
  789. PrintULong( ai_lastchange );
  790. PrintULong( ai_indiscards );
  791. PrintULong( ai_inerrors );
  792. PrintULong( ai_uknprotos );
  793. PrintULong( ai_outdiscards );
  794. PrintULong( ai_outerrors );
  795. PrintULong( ai_desclen );
  796. PrintULong( ai_index );
  797. PrintULong( ai_ifinst );
  798. PrintULong( ai_atinst );
  799. PrintPtr( ai_desc );
  800. PrintPtr( ai_mcast );
  801. PrintULong( ai_mcastcnt );
  802. PrintULong( ai_ipaddrcnt );
  803. PrintULong( ai_telladdrchng );
  804. PrintULong( ai_promiscuous );
  805. #if FFP_SUPPORT
  806. PrintULong( ai_ffpversion );
  807. PrintULong( ai_ffplastflush );
  808. #endif
  809. PrintULong ( ai_OffloadFlags ); // H/W checksum capability flag
  810. PrintAddr ( ai_TcpLargeSend );
  811. PrintULong( ai_wakeupcap );
  812. PrintUShort( ai_devicename.Length );
  813. PrintUShort( ai_devicename.MaximumLength );
  814. PrintPtr( ai_devicename.Buffer );
  815. PrintEndStruct();
  816. return(0);
  817. }
  818. VOID
  819. DumpARPTable
  820. (
  821. ULONG ARPTableAddr,
  822. VERBOSITY Verbosity
  823. )
  824. {
  825. ARPTableEntry **ARPTable, **PreservedPtr;
  826. ARPInterface AI;
  827. LIST_ENTRY *ALE;
  828. LIST_ENTRY ArpListEntry;
  829. ULONG_PTR AIList;
  830. ULONG ATE;
  831. ULONG TabAddr;
  832. ULONG TabLen;
  833. ULONG result;
  834. UINT index;
  835. UINT count = 0;
  836. if (ARPTableAddr)
  837. {
  838. //
  839. // ARPTable address given: dump all ARPTableEntry's starting from
  840. // that address
  841. //
  842. TabAddr = ARPTableAddr;
  843. TabLen = ARP_TABLE_SIZE;
  844. dprintf("Dumping ARPTable @ %08lx - maximum ARPTableSize = %08lx\n", TabAddr, TabLen);
  845. ARPTable = malloc(sizeof(ARPTableEntry *) * TabLen);
  846. if (ARPTable == NULL) {
  847. dprintf("malloc failed in DumpARPTable.\n");
  848. return;
  849. }
  850. PreservedPtr = ARPTable;
  851. if (!ReadMemory(TabAddr,
  852. &ARPTable[0],
  853. sizeof(ARPTableEntry *) * TabLen,
  854. &result))
  855. {
  856. dprintf("%08lx: Could not read %s structure.\n", TabAddr, "ARPTable");
  857. free(ARPTable);
  858. return;
  859. }
  860. for (index = 0; index < TabLen; index++) {
  861. if (*ARPTable != NULL) {
  862. ATE = (ULONG_PTR)*ARPTable;
  863. while (ATE) {
  864. ATE = DumpATE(ATE, Verbosity);
  865. count++;
  866. }
  867. }
  868. ARPTable++;
  869. }
  870. dprintf("\n %d Active ARPTable entries.\n", count);
  871. free(PreservedPtr);
  872. } else {
  873. //
  874. // ARPTable address not given, dump all ARPTableEntry's using
  875. // ARPTable found in ARPInterface
  876. //
  877. AIList = GetExpression("tcpip!ArpInterfaceList");
  878. if (!ReadMemory(AIList,
  879. &ArpListEntry,
  880. sizeof(LIST_ENTRY),
  881. &result))
  882. {
  883. dprintf("%08lx: Could not read %s structure.\n",
  884. AIList,
  885. "LIST_ENTRY");
  886. return;
  887. }
  888. ALE = ArpListEntry.Flink;
  889. while (ALE != (PLIST_ENTRY)AIList) {
  890. if (!ReadMemory((ULONG_PTR)ALE,
  891. &ArpListEntry,
  892. sizeof(LIST_ENTRY),
  893. &result))
  894. {
  895. dprintf("%08lx: Could not read %s structure.\n",
  896. ALE,
  897. "LIST_ENTRY");
  898. return;
  899. }
  900. if (!ReadMemory((ULONG_PTR)STRUCT_OF(ARPInterface, ALE, ai_linkage),
  901. &AI,
  902. sizeof(ARPInterface),
  903. &result))
  904. {
  905. dprintf("%08lx: Could not read %s structure.\n",
  906. STRUCT_OF(ARPInterface, ALE, ai_linkage),
  907. "ArpInterface");
  908. return;
  909. }
  910. //
  911. // check address before making the recursive call to avoid
  912. // loop if one ARPInterface has no ARPTable
  913. //
  914. if (AI.ai_ARPTbl) {
  915. DumpARPTable((ULONG_PTR)AI.ai_ARPTbl, Verbosity);
  916. }
  917. ALE = ArpListEntry.Flink;
  918. }
  919. }
  920. return;
  921. }
  922. VOID
  923. DumpLog
  924. (
  925. )
  926. {
  927. #if 0 // Currently, there is no such log support in tcpip
  928. ULONG LogAddr;
  929. UCHAR TraceBuffer[TRACE_BUFFER_SIZE]; //80 * 128;
  930. int result;
  931. int i;
  932. LogAddr = GetUlongValue( "tcpip!IPTraceBuffer" );
  933. if (!LogAddr) {
  934. dprintf("Error in tcpip!IPTraceBuffer: Please try reload\n");
  935. return;
  936. }
  937. dprintf("Dumping IP Log @ %08lx \n",LogAddr);
  938. if ( !ReadMemory( LogAddr,
  939. &TraceBuffer[0],
  940. sizeof(UCHAR) * TRACE_BUFFER_SIZE,
  941. &result ))
  942. {
  943. dprintf("%08lx: Could not read log\n", LogAddr);
  944. return;
  945. }
  946. for (i=0; i <INDEX_LIMIT; i++)
  947. dprintf("%s", &TraceBuffer[i*TRACE_STRING_LENGTH]);
  948. #else
  949. return;
  950. #endif
  951. }
  952. #ifdef _obj
  953. # undef _obj
  954. # undef _objAddr
  955. # undef _objType
  956. # undef _objTypeName
  957. #endif
  958. #define _obj IPH
  959. #define _objAddr IPHToDump
  960. #define _objType IPHeader
  961. #define _objTypeName "IPHeader"
  962. VOID
  963. DumpIPH(
  964. ULONG _objAddr
  965. )
  966. /*++
  967. Routine Description:
  968. Dumps the fields of the specified DEVICE_CONTEXT structure
  969. Arguments:
  970. DeviceToDump - The device context object to display
  971. Full - Display a partial listing if 0, full listing otherwise.
  972. Return Value:
  973. None
  974. --*/
  975. {
  976. _objType _obj;
  977. ULONG result;
  978. unsigned int index;
  979. BOOL bActive;
  980. if ( !ReadMemory( _objAddr,
  981. &_obj,
  982. sizeof( _obj ),
  983. &result ))
  984. {
  985. dprintf("%08lx: Could not read %s structure.\n", _objAddr, _objTypeName );
  986. return;
  987. }
  988. dprintf( "%s @ %08lx\n", _objTypeName, _objAddr );
  989. PrintStartStruct();
  990. PrintUChar(iph_verlen);
  991. PrintUChar(iph_tos);
  992. PrintIPAddress(iph_src);
  993. PrintIPAddress(iph_dest)
  994. PrintEndStruct();
  995. return;
  996. }