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.

235 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 1995-1998 Microsoft Corporation
  3. Module Name:
  4. apitest.h
  5. Abstract:
  6. Contains defines for testing the RTMv2 API.
  7. Author:
  8. Chaitanya Kodeboyina (chaitk) 26-Aug-1998
  9. Revision History:
  10. --*/
  11. #ifndef __APITEST_H
  12. #define __APITEST_H
  13. #include <winsock2.h>
  14. #include <routprot.h>
  15. #include "rtmv2.h"
  16. #include "rtmcnfg.h"
  17. #include "rtmmgmt.h"
  18. #include "rtm.h"
  19. #include "rmrtm.h"
  20. //
  21. // Constants
  22. //
  23. #define MAX_FNAME_LEN 255
  24. #define MAX_LINE_LEN 255
  25. #define BITSINBYTE 8
  26. #define ADDRSIZE 32
  27. #define NUMBYTES 4
  28. #define MAXLEVEL 32
  29. #define MAX_INSTANCES 10
  30. #define MAX_ADDR_FAMS 10
  31. #define MAX_ENTITIES 10
  32. #define MAX_METHODS 10
  33. #define MAX_HANDLES 25
  34. #define MAX_ROUTES 64000
  35. #define ERROR_IPLMISC_BASE -100
  36. #define ERROR_WRONG_CMDUSAGE ERROR_IPLMISC_BASE - 1
  37. #define ERROR_OPENING_DATABASE ERROR_IPLMISC_BASE - 2
  38. #define ERROR_MAX_NUM_ROUTES ERROR_IPLMISC_BASE - 3
  39. //
  40. // Structures
  41. //
  42. // Set of exported entity methods (a copy of one in rtmv2.h - but with const 7)
  43. typedef struct _MY_ENTITY_EXPORT_METHODS
  44. {
  45. USHORT NumMethods;
  46. RTM_ENTITY_EXPORT_METHOD Methods[7];
  47. }
  48. MY_ENTITY_EXPORT_METHODS, *PMY_ENTITY_EXPORT_METHODS;
  49. // A structure that represents all entity properties
  50. typedef struct _ENTITY_CHARS
  51. {
  52. BOOL Rtmv2Registration;
  53. RTM_ENTITY_INFO EntityInformation;
  54. RTM_EVENT_CALLBACK EventCallback;
  55. PMY_ENTITY_EXPORT_METHODS ExportMethods;
  56. CHAR RoutesFileName[MAX_FNAME_LEN];
  57. RTM_REGN_PROFILE RegnProfile;
  58. ULONGLONG TotalChangedDests;
  59. }
  60. ENTITY_CHARS, *PENTITY_CHARS;
  61. //
  62. // Useful Misc Macros
  63. //
  64. #define FHalf(B) (B) >> 4
  65. #define BHalf(B) (B) & 0xF
  66. #define Print printf
  67. #define Assert(S) assert(S)
  68. #define SUCCESS(S) (S == NO_ERROR)
  69. #define ErrorF(S, F, E) { \
  70. fprintf(stderr, S, F, E); \
  71. DebugBreak(); \
  72. }
  73. #define FatalF(S, F, E) { \
  74. ErrorF(S, F, E); \
  75. exit(E); \
  76. }
  77. #define Check(E, F) { \
  78. if (!SUCCESS(E)) \
  79. { \
  80. FatalF("-%2d- failed with status %lu\n",F,E);\
  81. } \
  82. }
  83. #define ClearMemory(pm, nb) memset((pm), 0, (nb))
  84. //
  85. // Profiling Macros
  86. //
  87. #if PROF
  88. #define PROFVARS LARGE_INTEGER PCStart; /* PerformanceCountStart */ \
  89. LARGE_INTEGER PCStop; /* PerformanceCountStop */ \
  90. LARGE_INTEGER PCFreq; /* PerformanceCountFreq */ \
  91. double timer; \
  92. double duration; \
  93. \
  94. QueryPerformanceFrequency(&PCFreq); \
  95. // Print("Perf Counter Resolution = %.3f ns\n\n", \
  96. // (double) 1000 * 1000 * 1000 / PCFreq.QuadPart);
  97. #define STARTPROF QueryPerformanceCounter(&PCStart);
  98. #define STOPPROF QueryPerformanceCounter(&PCStop);
  99. #define INITPROF duration = 0;
  100. #define ADDPROF timer = (double)(PCStop.QuadPart - PCStart.QuadPart) \
  101. * 1000 * 1000 * 1000 / PCFreq.QuadPart; \
  102. duration += timer; \
  103. // Print("Add : %.3f ns\n\n", timer);
  104. #define SUBPROF timer = (double)(PCStop.QuadPart - PCStart.QuadPart) \
  105. * 1000 * 1000 * 1000 / PCFreq.QuadPart; \
  106. duration -= timer; \
  107. // Print("Sub : %.3f ns\n\n", timer);
  108. #define PRINTPROF // Print("Total Time Taken To Finish : %.3f ns\n", \
  109. // duration);
  110. #endif // if PROF
  111. //
  112. // Other Misc Macros
  113. //
  114. // Macro to allocate a RTM_DEST_INFO on the stack
  115. #define ALLOC_RTM_DEST_INFO(NumViews, NumInfos) \
  116. (PRTM_DEST_INFO) _alloca(RTM_SIZE_OF_DEST_INFO(NumViews) * NumInfos)
  117. //
  118. // Prototypes
  119. //
  120. DWORD
  121. Rtmv1EntityThreadProc (
  122. IN LPVOID ThreadParam
  123. );
  124. DWORD
  125. ValidateRouteCallback(
  126. IN PVOID Route
  127. );
  128. VOID
  129. RouteChangeCallback(
  130. IN DWORD Flags,
  131. IN PVOID CurBestRoute,
  132. IN PVOID PrevBestRoute
  133. );
  134. VOID
  135. ConvertRouteToV1Route (
  136. IN Route *ThisRoute,
  137. OUT RTM_IP_ROUTE *V1Route
  138. );
  139. VOID
  140. ConvertV1RouteToRoute (
  141. IN RTM_IP_ROUTE *V1Route,
  142. OUT Route *ThisRoute
  143. );
  144. DWORD
  145. Rtmv2EntityThreadProc (
  146. IN LPVOID ThreadParam
  147. );
  148. DWORD
  149. EntityEventCallback (
  150. IN RTM_ENTITY_HANDLE RtmRegHandle,
  151. IN RTM_EVENT_TYPE EventType,
  152. IN PVOID Context1,
  153. IN PVOID Context2
  154. );
  155. VOID
  156. EntityExportMethod (
  157. IN RTM_ENTITY_HANDLE CallerHandle,
  158. IN RTM_ENTITY_HANDLE CalleeHandle,
  159. IN RTM_ENTITY_METHOD_INPUT *Input,
  160. OUT RTM_ENTITY_METHOD_OUTPUT *Output
  161. );
  162. #endif // __APITEST_H