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.

344 lines
12 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. tcpipkd.h
  5. Abstract:
  6. Prototypes for utils, etc for TCP/IP KD ext.
  7. Author:
  8. Scott Holden (sholden) 24-Apr-1999
  9. Revision History:
  10. --*/
  11. #ifndef _TCPIPKD_H_
  12. #define _TCPIPKD_H_
  13. extern VERB g_Verbosity;
  14. char *
  15. mystrtok(
  16. char *string,
  17. char * control
  18. );
  19. ULONG
  20. GetUlongValue(
  21. PCHAR String
  22. );
  23. //
  24. // TCPIPDump_* will retrieve the global variable and dump -- it is a counter or value
  25. // without a default.
  26. //
  27. #define TCPIPDump_ULONG(_var) \
  28. KDDump_ULONG("tcpip!"#_var, #_var); \
  29. dprintf(ENDL)
  30. #define TCPIPDump_LONG(_var) \
  31. KDDump_LONG("tcpip!"#_var, #_var); \
  32. dprintf(ENDL)
  33. #define TCPIPDump_ushort(_var) \
  34. KDDump_ushort("tcpip!"#_var, #_var); \
  35. dprintf(ENDL)
  36. #define TCPIPDump_uint(_var) \
  37. TCPIPDump_ULONG(_var)
  38. #define TCPIPDump_int(_var) \
  39. TCPIPDump_LONG(_var)
  40. #define TCPIPDump_DWORD(_var) \
  41. TCPIPDump_ULONG(_var)
  42. #define TCPIPDump_BOOLEAN(_var) \
  43. KDDump_BOOLEAN("tcpip!"#_var, #_var); \
  44. dprintf(ENDL)
  45. #define TCPIPDump_uchar(_var) \
  46. KDDump_uchar("tcpip!"#_var, #_var); \
  47. dprintf(ENDL)
  48. #define TCPIPDump_PtrSymbol(_var) \
  49. KDDump_PtrSymbol("tcpip!"#_var, #_var); \
  50. dprintf(ENDL)
  51. #define TCPIPDump_Queue(_var) \
  52. KDDump_Queue("tcpip!"#_var, #_var); \
  53. dprintf(ENDL)
  54. //
  55. // TCPIPDumpCfg_* will retriev the global variable and dump -- it has a default value
  56. // which is also printed.
  57. //
  58. #define TCPIPDumpCfg_ULONG(_var, _def) \
  59. KDDump_ULONG("tcpip!"#_var, #_var); \
  60. dprintf(TAB "/" TAB "%-10u", _def); \
  61. dprintf(ENDL)
  62. #define TCPIPDumpCfg_LONG(_var, _def) \
  63. KDDump_LONG("tcpip!"#_var, #_var); \
  64. dprintf(TAB "/" TAB "%-10d", _def); \
  65. dprintf(ENDL)
  66. #define TCPIPDumpCfg_ushort(_var, _def) \
  67. KDDump_ushort("tcpip!"#_var, #_var); \
  68. dprintf(TAB "/" TAB "%-10hu", _def); \
  69. dprintf(ENDL)
  70. #define TCPIPDumpCfg_uint(_var, _def) \
  71. TCPIPDumpCfg_ULONG(_var, _def)
  72. #define TCPIPDumpCfg_int(_var, _def) \
  73. TCPIPDumpCfg_LONG(_var, _def)
  74. #define TCPIPDumpCfg_DWORD(_var, _def) \
  75. TCPIPDumpCfg_ULONG(_var, _def)
  76. #define TCPIPDumpCfg_BOOLEAN(_var, _def) \
  77. KDDump_BOOLEAN("tcpip!"#_var, #_var); \
  78. dprintf(TAB "/" TAB "%-10s", _def == TRUE ? "TRUE" : "FALSE"); \
  79. dprintf(ENDL)
  80. #define TCPIPDumpCfg_uchar(_var, _def) \
  81. KDDump_uchar("tcpip!"#_var, #_var); \
  82. dprintf(TAB "/" TAB "%-10u", _def); \
  83. dprintf(ENDL)
  84. //
  85. // Prototypes for functions which actually retrieve and dump the global variables.
  86. //
  87. BOOL
  88. KDDump_ULONG(
  89. PCHAR pVar,
  90. PCHAR pName
  91. );
  92. BOOL
  93. KDDump_LONG(
  94. PCHAR pVar,
  95. PCHAR pName
  96. );
  97. BOOL
  98. KDDump_BOOLEAN(
  99. PCHAR pVar,
  100. PCHAR pName
  101. );
  102. BOOL
  103. KDDump_uchar(
  104. PCHAR pVar,
  105. PCHAR pName
  106. );
  107. BOOL
  108. KDDump_ushort(
  109. PCHAR pVar,
  110. PCHAR pName
  111. );
  112. BOOL
  113. KDDump_PtrSymbol(
  114. PCHAR pVar,
  115. PCHAR pName
  116. );
  117. BOOL
  118. KDDump_Queue(
  119. PCHAR pVar,
  120. PCHAR pName
  121. );
  122. BOOL
  123. GetData(
  124. PVOID pvData,
  125. ULONG cbData,
  126. ULONG_PTR Address,
  127. PCSTR pszDataType
  128. );
  129. //
  130. // Allows easy declaration of dump functions. ie. for dumping TCB:
  131. // TCPIP_DBGEXT(TCB, tcb) => function called "tcb" calls DumpTCB.
  132. //
  133. _inline VOID
  134. ParseAddrArg(
  135. PCSTR pArgs,
  136. PULONG_PTR pAddr,
  137. VERB *pVerb
  138. )
  139. {
  140. char szArgs[256];
  141. ULONG cbArgs = strlen(pArgs);
  142. char *pszSrch;
  143. *pAddr = GetExpression(pArgs);
  144. if (cbArgs >= 256)
  145. {
  146. return;
  147. }
  148. strcpy(szArgs, pArgs);
  149. pszSrch = mystrtok(szArgs, " \t\n");
  150. if (pszSrch == NULL)
  151. {
  152. return;
  153. }
  154. pszSrch = mystrtok(NULL, " \t\n");
  155. if (pszSrch == NULL)
  156. {
  157. return;
  158. }
  159. *pVerb = atoi(pszSrch);
  160. if (*pVerb > VERB_MAX || *pVerb < VERB_MIN)
  161. {
  162. *pVerb = g_Verbosity;
  163. }
  164. return;
  165. }
  166. #define TCPIP_DBGEXT(_Structure, _Function) \
  167. DECLARE_API(_Function) \
  168. { \
  169. ULONG_PTR addr = 0; \
  170. BOOL fStatus; \
  171. _Structure object; \
  172. VERB verb = g_Verbosity; \
  173. \
  174. if (*args) \
  175. { \
  176. ParseAddrArg(args, &addr, &verb); \
  177. \
  178. fStatus = GetData( \
  179. &object, \
  180. sizeof(_Structure), \
  181. addr, \
  182. #_Structure); \
  183. \
  184. if (fStatus == FALSE) \
  185. { \
  186. dprintf("Failed to get %s %x" ENDL, #_Structure, addr); \
  187. return; \
  188. } \
  189. \
  190. fStatus = Dump##_Structure( \
  191. &object, \
  192. addr, \
  193. verb); \
  194. \
  195. if (fStatus == FALSE) \
  196. { \
  197. dprintf("Failed to dump %s %x" ENDL, #_Structure, addr); \
  198. return; \
  199. } \
  200. \
  201. return; \
  202. } \
  203. \
  204. dprintf("!%s <address>" ENDL, #_Function); \
  205. }
  206. #define TCPIP_DBGEXT_LIST(_Structure, _Function, _Next) \
  207. DECLARE_API(_Function) \
  208. { \
  209. ULONG_PTR addr = 0; \
  210. BOOL fStatus; \
  211. _Structure object; \
  212. VERB verb = g_Verbosity; \
  213. \
  214. if (*args) \
  215. { \
  216. ParseAddrArg(args, &addr, &verb); \
  217. \
  218. while (addr) \
  219. { \
  220. fStatus = GetData( \
  221. &object, \
  222. sizeof(_Structure), \
  223. addr, \
  224. #_Structure); \
  225. \
  226. if (fStatus == FALSE) \
  227. { \
  228. dprintf("Failed to get %s %x" ENDL, #_Structure, addr); \
  229. return; \
  230. } \
  231. \
  232. fStatus = Dump##_Structure( \
  233. &object, \
  234. addr, \
  235. verb); \
  236. \
  237. if (fStatus == FALSE) \
  238. { \
  239. dprintf("Failed to dump %s %x" ENDL, #_Structure, addr); \
  240. return; \
  241. } \
  242. \
  243. addr = (ULONG_PTR) object.##_Next; \
  244. \
  245. if (CheckControlC()) \
  246. { \
  247. return; \
  248. } \
  249. } \
  250. \
  251. return; \
  252. } \
  253. \
  254. dprintf("!%s <address>" ENDL, #_Function); \
  255. }
  256. #define TCPIP_SRCH_PTR_LIST 0x01 // Not search, but parse out start of list.
  257. #define TCPIP_SRCH_ALL 0x02
  258. #define TCPIP_SRCH_IPADDR 0x04
  259. #define TCPIP_SRCH_PORT 0x08
  260. #define TCPIP_SRCH_CONTEXT 0x10
  261. #define TCPIP_SRCH_PROT 0x20
  262. #define TCPIP_SRCH_STATS 0x40
  263. typedef struct _TCPIP_SRCH
  264. {
  265. ULONG ulOp;
  266. ULONG_PTR ListAddr;
  267. union
  268. {
  269. IPAddr ipaddr;
  270. ushort port;
  271. uchar prot;
  272. ulong context;
  273. };
  274. } TCPIP_SRCH, *PTCPIP_SRCH;
  275. PTCPIP_SRCH
  276. ParseSrch(
  277. PCSTR args,
  278. ULONG ulDefaultOp,
  279. ULONG ulAllowedOps
  280. );
  281. #endif // _TCPIPKD_H_