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.

342 lines
10 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. //
  15. // Prototypes. Utilities.
  16. //
  17. int
  18. CreateArgvArgc(
  19. CHAR *pProgName,
  20. CHAR *argv[20],
  21. CHAR *pCmdLine
  22. );
  23. unsigned long
  24. mystrtoul(
  25. const char *nptr,
  26. char **endptr,
  27. int base
  28. );
  29. int __cdecl
  30. mystricmp(
  31. const char *str1,
  32. const char *str2
  33. );
  34. //
  35. // Functions for dumping common types with common spacing.
  36. //
  37. _inline BOOL
  38. KDDump_ULONG(
  39. ULONG Value,
  40. PCHAR pName
  41. )
  42. {
  43. PrintFieldName(pName);
  44. dprintf("%-10u", Value);
  45. return (TRUE);
  46. }
  47. _inline BOOL
  48. KDDump_LONG(
  49. LONG Value,
  50. PCHAR pName
  51. )
  52. {
  53. PrintFieldName(pName);
  54. dprintf("%-10d", Value);
  55. return (TRUE);
  56. }
  57. _inline BOOL
  58. KDDump_BOOLEAN(
  59. BOOLEAN Value,
  60. PCHAR pName
  61. )
  62. {
  63. PrintFieldName(pName);
  64. dprintf("%-10s", Value == TRUE ? "TRUE" : "FALSE");
  65. return (TRUE);
  66. }
  67. _inline BOOL
  68. KDDump_uchar(
  69. UCHAR Value,
  70. PCHAR pName
  71. )
  72. {
  73. PrintFieldName(pName);
  74. dprintf("%-10u", Value);
  75. return (TRUE);
  76. }
  77. _inline BOOL
  78. KDDump_ushort(
  79. ushort Value,
  80. PCHAR pName
  81. )
  82. {
  83. PrintFieldName(pName);
  84. dprintf("%-10hu", Value);
  85. return (TRUE);
  86. }
  87. _inline BOOL
  88. KDDump_PtrSymbol(
  89. PVOID Value,
  90. PCHAR pName
  91. )
  92. {
  93. PrintFieldName(pName);
  94. DumpPtrSymbol(Value);
  95. return (TRUE);
  96. }
  97. _inline BOOL
  98. KDDump_Queue(
  99. Queue *Value,
  100. PCHAR pName
  101. )
  102. {
  103. PrintFieldName(pName);
  104. dprintf("q_next = %-10lx", Value->q_next);
  105. dprintf("q_prev = %-10lx", Value->q_prev);
  106. dprintf("%s", (Value->q_next == Value) ? "[Empty]" : "");
  107. return (TRUE);
  108. }
  109. //
  110. // TCPIPDump_* dumps the given variable. Wraps KDDump_* to get string names.
  111. //
  112. #define TCPIPDump_ULONG(_var) \
  113. KDDump_ULONG(_var, #_var); \
  114. dprintf(ENDL)
  115. #define TCPIPDump_LONG(_var) \
  116. KDDump_LONG(_var, #_var); \
  117. dprintf(ENDL)
  118. #define TCPIPDump_ushort(_var) \
  119. KDDump_ushort(_var, #_var); \
  120. dprintf(ENDL)
  121. #define TCPIPDump_uint(_var) \
  122. TCPIPDump_ULONG(_var)
  123. #define TCPIPDump_int(_var) \
  124. TCPIPDump_LONG(_var)
  125. #define TCPIPDump_DWORD(_var) \
  126. TCPIPDump_ULONG(_var)
  127. #define TCPIPDump_BOOLEAN(_var) \
  128. KDDump_BOOLEAN(_var, #_var); \
  129. dprintf(ENDL)
  130. #define TCPIPDump_uchar(_var) \
  131. KDDump_uchar(_var, #_var); \
  132. dprintf(ENDL)
  133. #define TCPIPDump_PtrSymbol(_var) \
  134. KDDump_PtrSymbol(_var, #_var); \
  135. dprintf(ENDL)
  136. #define TCPIPDump_Queue(_var) \
  137. KDDump_Queue(&_var, #_var); \
  138. dprintf(ENDL)
  139. //
  140. // TCPIPDumpCfg_* same as TCPIPDump_*, but it also has a default value
  141. // which is also printed.
  142. //
  143. #define TCPIPDumpCfg_ULONG(_var, _def) \
  144. KDDump_ULONG(_var, #_var); \
  145. dprintf(TAB "/" TAB "%-10u", _def); \
  146. dprintf(ENDL)
  147. #define TCPIPDumpCfg_LONG(_var, _def) \
  148. KDDump_LONG(_var, #_var); \
  149. dprintf(TAB "/" TAB "%-10d", _def); \
  150. dprintf(ENDL)
  151. #define TCPIPDumpCfg_ushort(_var, _def) \
  152. KDDump_ushort(_var, #_var); \
  153. dprintf(TAB "/" TAB "%-10hu", _def); \
  154. dprintf(ENDL)
  155. #define TCPIPDumpCfg_uint(_var, _def) \
  156. TCPIPDumpCfg_ULONG(_var, _def)
  157. #define TCPIPDumpCfg_int(_var, _def) \
  158. TCPIPDumpCfg_LONG(_var, _def)
  159. #define TCPIPDumpCfg_DWORD(_var, _def) \
  160. TCPIPDumpCfg_ULONG(_var, _def)
  161. #define TCPIPDumpCfg_BOOLEAN(_var, _def) \
  162. KDDump_BOOLEAN(_var, #_var); \
  163. dprintf(TAB "/" TAB "%-10s", _def == TRUE ? "TRUE" : "FALSE"); \
  164. dprintf(ENDL)
  165. #define TCPIPDumpCfg_uchar(_var, _def) \
  166. KDDump_uchar(_var, #_var); \
  167. dprintf(TAB "/" TAB "%-10u", _def); \
  168. dprintf(ENDL)
  169. _inline VOID
  170. ParseAddrArg(
  171. PVOID args[],
  172. PULONG_PTR pAddr,
  173. VERB *pVerb
  174. )
  175. {
  176. *pAddr = mystrtoul(args[0], NULL, 16);
  177. if (args[1]) {
  178. *pVerb = atoi(args[1]);
  179. }
  180. if (*pVerb > VERB_MAX || *pVerb < VERB_MIN)
  181. {
  182. *pVerb = g_Verbosity;
  183. }
  184. return;
  185. }
  186. //
  187. // Allows easy declaration of dump functions. ie. for dumping TCB:
  188. // TCPIP_DBGEXT(TCB, tcb) => function called "tcb" calls DumpTCB.
  189. //
  190. #define TCPIP_DBGEXT(_Structure, _Function) \
  191. VOID Tcpipkd_##_Function( \
  192. PVOID args[]) \
  193. { \
  194. ULONG_PTR addr = 0; \
  195. BOOL fStatus; \
  196. _Structure *pObject; \
  197. VERB verb = g_Verbosity; \
  198. \
  199. if (*args) { \
  200. ParseAddrArg(args, &addr, &verb); \
  201. pObject = (_Structure *)addr; \
  202. fStatus = Dump##_Structure( \
  203. pObject, addr, verb); \
  204. \
  205. if (fStatus == FALSE) \
  206. { \
  207. dprintf("Failed to dump %s %x" ENDL, #_Structure, addr); \
  208. return; \
  209. } \
  210. \
  211. return; \
  212. } \
  213. }
  214. #define TCPIP_DBGEXT_LIST(_Structure, _Function, _Next) \
  215. VOID Tcpipkd_##_Function( \
  216. PVOID args[]) \
  217. { \
  218. ULONG_PTR addr = 0; \
  219. BOOL fStatus; \
  220. _Structure *pObject; \
  221. VERB verb = g_Verbosity; \
  222. \
  223. if (*args) { \
  224. ParseAddrArg(args, &addr, &verb); \
  225. while (addr) { \
  226. pObject = (_Structure *)addr; \
  227. fStatus = Dump##_Structure( \
  228. pObject, \
  229. addr, \
  230. verb); \
  231. \
  232. if (fStatus == FALSE) { \
  233. dprintf("Failed to dump %s %x" ENDL, #_Structure, addr); \
  234. return; \
  235. } \
  236. \
  237. addr = (ULONG_PTR) pObject->##_Next; \
  238. } \
  239. return; \
  240. } \
  241. \
  242. dprintf("!%s <address>" ENDL, #_Function); \
  243. }
  244. #define TCPIP_SRCH_PTR_LIST 0x01 // Not search, but parse out start of list.
  245. #define TCPIP_SRCH_ALL 0x02
  246. #define TCPIP_SRCH_IPADDR 0x04
  247. #define TCPIP_SRCH_PORT 0x08
  248. #define TCPIP_SRCH_CONTEXT 0x10
  249. #define TCPIP_SRCH_PROT 0x20
  250. #define TCPIP_SRCH_STATS 0x40
  251. typedef struct _TCPIP_SRCH
  252. {
  253. ULONG ulOp;
  254. ULONG_PTR ListAddr;
  255. union
  256. {
  257. IPAddr ipaddr;
  258. ushort port;
  259. uchar prot;
  260. ulong context;
  261. };
  262. } TCPIP_SRCH, *PTCPIP_SRCH;
  263. NTSTATUS
  264. ParseSrch(
  265. PCHAR args[],
  266. ULONG ulDefaultOp,
  267. ULONG ulAllowedOps,
  268. PTCPIP_SRCH pSrch
  269. );
  270. VOID
  271. Tcpipkd_gtcp(PVOID args[]);
  272. VOID
  273. Tcpipkd_gip(PVOID args[]);
  274. #endif // _TCPIPKD_H_