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.

458 lines
11 KiB

  1. //============================================================================
  2. // Copyright (c) 1995, Microsoft Corporation
  3. //
  4. // File: api.h
  5. //
  6. // History:
  7. // Abolade Gbadegesin August 31, 1995 Created
  8. //
  9. // Declarations for BOOTP Relay Agent's interface to Router Manager
  10. //============================================================================
  11. #ifndef _API_H_
  12. #define _API_H_
  13. //
  14. // enum: IPBOOTP_STATUS_CODE
  15. //
  16. // these codes are the possible values for the BOOTP's status.
  17. // they are used in the field IPBOOTP_GLOBALS::IG_Status, and
  18. // when each API or worker-function is entered, the status
  19. // determines whether the function will proceed.
  20. //
  21. typedef enum _IPBOOTP_STATUS_CODE {
  22. IPBOOTP_STATUS_STARTING = 100,
  23. IPBOOTP_STATUS_RUNNING = 101,
  24. IPBOOTP_STATUS_STOPPING = 102,
  25. IPBOOTP_STATUS_STOPPED = 103
  26. } IPBOOTP_STATUS_CODE, *PIPBOOTP_STATUS_CODE;
  27. //
  28. // struct: IPBOOTP_GLOBALS
  29. //
  30. // When more than one lock must be acquired, the order must be as follows;
  31. // locks for fields listed on the same line should never be owned at once
  32. // by any given thread:
  33. //
  34. // IG_IfTable.IT_RWL
  35. // IG_RWL
  36. // IG_RecvQueue IG_EventQueue
  37. // IG_CS
  38. //
  39. typedef struct _IPBOOTP_GLOBALS {
  40. CRITICAL_SECTION IG_CS;
  41. IPBOOTP_STATUS_CODE IG_Status;
  42. READ_WRITE_LOCK IG_RWL;
  43. DWORD IG_TraceID;
  44. DWORD IG_LoggingLevel;
  45. HANDLE IG_LoggingHandle;
  46. PIPBOOTP_GLOBAL_CONFIG IG_Config;
  47. PIF_TABLE IG_IfTable;
  48. PSUPPORT_FUNCTIONS IG_FunctionTable;
  49. HANDLE IG_EventEvent;
  50. PLOCKED_LIST IG_EventQueue;
  51. HANDLE IG_GlobalHeap;
  52. HANDLE IG_InputEvent;
  53. HANDLE IG_InputEventHandle;
  54. PLOCKED_LIST IG_RecvQueue;
  55. LONG IG_RecvQueueSize;
  56. LONG IG_ActivityCount;
  57. HANDLE IG_ActivitySemaphore;
  58. DWORD IG_DhcpInformServer;
  59. #if DBG
  60. DWORD IG_MibTraceID;
  61. HANDLE IG_MibTimerHandle;
  62. HANDLE IG_TimerQueueHandle;
  63. #endif
  64. } IPBOOTP_GLOBALS, *PIPBOOTP_GLOBALS;
  65. //
  66. // external declaration of the global IPBOOTP struct
  67. //
  68. extern IPBOOTP_GLOBALS ig;
  69. //
  70. // config struct size macros
  71. //
  72. #define GC_SIZEOF(gc) (sizeof(IPBOOTP_GLOBAL_CONFIG) + \
  73. (gc)->GC_ServerCount * sizeof(DWORD))
  74. #define IC_SIZEOF(ic) sizeof(IPBOOTP_IF_CONFIG)
  75. //
  76. // IP address conversion macro
  77. //
  78. #define INET_NTOA(addr) inet_ntoa( *(PIN_ADDR)&(addr) )
  79. //
  80. // memory allocation macros
  81. //
  82. #define BOOTP_ALLOC(size) HeapAlloc(ig.IG_GlobalHeap, 0, size)
  83. #define BOOTP_FREE(ptr) HeapFree(ig.IG_GlobalHeap, 0, ptr)
  84. //
  85. // macro invoked when entering API and worker functions
  86. // returns TRUE if API should continue, FALSE otherwise;
  87. //
  88. #define ENTER_BOOTP_API() EnterBootpAPI()
  89. #define ENTER_BOOTP_WORKER() EnterBootpWorker()
  90. //
  91. // macro invoked when leaving API and worker functions
  92. //
  93. #define LEAVE_BOOTP_API() LeaveBootpWorker()
  94. #define LEAVE_BOOTP_WORKER() LeaveBootpWorker()
  95. //
  96. // Event logging macros
  97. //
  98. #define LOGLEVEL ig.IG_LoggingLevel
  99. #define LOGHANDLE ig.IG_LoggingHandle
  100. #define LOGERR RouterLogError
  101. #define LOGWARN RouterLogWarning
  102. #define LOGINFO RouterLogInformation
  103. #define LOGWARNDATA RouterLogWarningData
  104. // Error logging
  105. #define LOGERR0(msg,err) \
  106. if (LOGLEVEL >= IPBOOTP_LOGGING_ERROR) \
  107. LOGERR(LOGHANDLE,IPBOOTPLOG_ ## msg,0,NULL,(err))
  108. #define LOGERR1(msg,a,err) \
  109. if (LOGLEVEL >= IPBOOTP_LOGGING_ERROR) \
  110. LOGERR(LOGHANDLE,IPBOOTPLOG_ ## msg,1,&(a),(err))
  111. #define LOGERR2(msg,a,b,err) \
  112. if (LOGLEVEL >= IPBOOTP_LOGGING_ERROR) { \
  113. LPSTR _asz[2] = { (a), (b) }; \
  114. LOGERR(LOGHANDLE,IPBOOTPLOG_ ## msg,2,_asz,(err)); \
  115. }
  116. #define LOGERR3(msg,a,b,c,err) \
  117. if (LOGLEVEL >= IPBOOTP_LOGGING_ERROR) { \
  118. LPSTR _asz[3] = { (a), (b), (c) }; \
  119. LOGERR(LOGHANDLE,IPBOOTPLOG_ ## msg,3,_asz,(err)); \
  120. }
  121. #define LOGERR4(msg,a,b,c,d,err) \
  122. if (LOGLEVEL >= IPBOOTP_LOGGING_ERROR) { \
  123. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  124. LOGERR(LOGHANDLE,IPBOOTPLOG_ ## msg,4,_asz,(err)); \
  125. }
  126. // Warning logging
  127. #define LOGWARN0(msg,err) \
  128. if (LOGLEVEL >= IPBOOTP_LOGGING_WARN) \
  129. LOGWARN(LOGHANDLE,IPBOOTPLOG_ ## msg,0,NULL,(err))
  130. #define LOGWARN1(msg,a,err) \
  131. if (LOGLEVEL >= IPBOOTP_LOGGING_WARN) \
  132. LOGWARN(LOGHANDLE,IPBOOTPLOG_ ## msg,1,&(a),(err))
  133. #define LOGWARN2(msg,a,b,err) \
  134. if (LOGLEVEL >= IPBOOTP_LOGGING_WARN) { \
  135. LPSTR _asz[2] = { (a), (b) }; \
  136. LOGWARN(LOGHANDLE,IPBOOTPLOG_ ## msg,2,_asz,(err)); \
  137. }
  138. #define LOGWARN3(msg,a,b,c,err) \
  139. if (LOGLEVEL >= IPBOOTP_LOGGING_WARN) { \
  140. LPSTR _asz[3] = { (a), (b), (c) }; \
  141. LOGWARN(LOGHANDLE,IPBOOTPLOG_ ## msg,3,_asz,(err)); \
  142. }
  143. #define LOGWARN4(msg,a,b,c,d,err) \
  144. if (LOGLEVEL >= IPBOOTP_LOGGING_WARN) { \
  145. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  146. LOGWARN(LOGHANDLE,IPBOOTPLOG_ ## msg,4,_asz,(err)); \
  147. }
  148. #define LOGWARNDATA2(msg,a,b,dw,buf) \
  149. if (LOGLEVEL >= IPBOOTP_LOGGING_WARN) { \
  150. LPSTR _asz[2] = { (a), (b) }; \
  151. LOGWARNDATA(LOGHANDLE,IPBOOTPLOG_ ## msg,2,_asz,(dw),(buf)); \
  152. }
  153. // Information logging
  154. #define LOGINFO0(msg,err) \
  155. if (LOGLEVEL >= IPBOOTP_LOGGING_INFO) \
  156. LOGINFO(LOGHANDLE,IPBOOTPLOG_ ## msg,0,NULL,(err))
  157. #define LOGINFO1(msg,a,err) \
  158. if (LOGLEVEL >= IPBOOTP_LOGGING_INFO) \
  159. LOGINFO(LOGHANDLE,IPBOOTPLOG_ ## msg,1,&(a),(err))
  160. #define LOGINFO2(msg,a,b,err) \
  161. if (LOGLEVEL >= IPBOOTP_LOGGING_INFO) { \
  162. LPSTR _asz[2] = { (a), (b) }; \
  163. LOGINFO(LOGHANDLE,IPBOOTPLOG_ ## msg,2,_asz,(err)); \
  164. }
  165. #define LOGINFO3(msg,a,b,c,err) \
  166. if (LOGLEVEL >= IPBOOTP_LOGGING_INFO) { \
  167. LPSTR _asz[3] = { (a), (b), (c) }; \
  168. LOGINFO(LOGHANDLE,IPBOOTPLOG_ ## msg,3,_asz,(err)); \
  169. }
  170. #define LOGINFO4(msg,a,b,c,d,err) \
  171. if (LOGLEVEL >= IPBOOTP_LOGGING_INFO) { \
  172. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  173. LOGINFO(LOGHANDLE,IPBOOTPLOG_ ## msg,4,_asz,(err)); \
  174. }
  175. //
  176. // constants and macros used for tracing
  177. //
  178. #define IPBOOTP_TRACE_ANY ((DWORD)0xffff0000 | TRACE_USE_MASK)
  179. #define IPBOOTP_TRACE_ENTER ((DWORD)0x00010000 | TRACE_USE_MASK)
  180. #define IPBOOTP_TRACE_LEAVE ((DWORD)0x00020000 | TRACE_USE_MASK)
  181. #define IPBOOTP_TRACE_IF ((DWORD)0x00040000 | TRACE_USE_MASK)
  182. #define IPBOOTP_TRACE_SEND ((DWORD)0x00080000 | TRACE_USE_MASK)
  183. #define IPBOOTP_TRACE_RECEIVE ((DWORD)0x00100000 | TRACE_USE_MASK)
  184. #define IPBOOTP_TRACE_CONFIG ((DWORD)0x00200000 | TRACE_USE_MASK)
  185. #define IPBOOTP_TRACE_REQUEST ((DWORD)0x00400000 | TRACE_USE_MASK)
  186. #define IPBOOTP_TRACE_REPLY ((DWORD)0x00800000 | TRACE_USE_MASK)
  187. #define IPBOOTP_TRACE_START ((DWORD)0x01000000 | TRACE_USE_MASK)
  188. #define IPBOOTP_TRACE_STOP ((DWORD)0x02000000 | TRACE_USE_MASK)
  189. #define TRACEID ig.IG_TraceID
  190. //
  191. // macros used to generate output; the first argument indicates the
  192. // level of tracing with which the output is associated
  193. //
  194. #define TRACE0(l,a) \
  195. if (TRACEID != INVALID_TRACEID) TracePrintfEx(TRACEID, IPBOOTP_TRACE_ ## l, a)
  196. #define TRACE1(l,a,b) \
  197. if (TRACEID != INVALID_TRACEID) TracePrintfEx(TRACEID, IPBOOTP_TRACE_ ## l, a, b)
  198. #define TRACE2(l,a,b,c) \
  199. if (TRACEID != INVALID_TRACEID) TracePrintfEx(TRACEID, IPBOOTP_TRACE_ ## l, a, b, c)
  200. #define TRACE3(l,a,b,c,d) \
  201. if (TRACEID != INVALID_TRACEID) TracePrintfEx(TRACEID, IPBOOTP_TRACE_ ## l, a, b, c, d)
  202. #define TRACE4(l,a,b,c,d,e) \
  203. if (TRACEID != INVALID_TRACEID) TracePrintfEx(TRACEID, IPBOOTP_TRACE_ ## l, a, b, c, d, e)
  204. #define TRACE5(l,a,b,c,d,e,f) \
  205. if (TRACEID != INVALID_TRACEID) TracePrintfEx(TRACEID, IPBOOTP_TRACE_ ## l, a, b, c, d, e, f)
  206. //
  207. // function declarations for router manager interface:
  208. //
  209. DWORD
  210. APIENTRY
  211. RegisterProtocol(
  212. IN OUT PMPR_ROUTING_CHARACTERISTICS pRoutingChar,
  213. IN OUT PMPR_SERVICE_CHARACTERISTICS pServiceChar
  214. );
  215. DWORD
  216. WINAPI
  217. StartProtocol (
  218. HANDLE NotificationEvent,
  219. SUPPORT_FUNCTIONS *SupportFunctions,
  220. LPVOID GlobalInfo,
  221. ULONG StructureVersion,
  222. ULONG StructureSize,
  223. ULONG StructureCount
  224. );
  225. DWORD
  226. WINAPI
  227. StartComplete (
  228. VOID
  229. );
  230. DWORD
  231. APIENTRY
  232. StopProtocol(
  233. VOID
  234. );
  235. DWORD WINAPI
  236. GetGlobalInfo (
  237. PVOID OutGlobalInfo,
  238. PULONG GlobalInfoSize,
  239. PULONG StructureVersion,
  240. PULONG StructureSize,
  241. PULONG StructureCount
  242. );
  243. DWORD WINAPI
  244. SetGlobalInfo (
  245. PVOID GlobalInfo,
  246. ULONG StructureVersion,
  247. ULONG StructureSize,
  248. ULONG StructureCount
  249. );
  250. DWORD WINAPI
  251. AddInterface (
  252. PWCHAR pwszInterfaceName,
  253. ULONG InterfaceIndex,
  254. NET_INTERFACE_TYPE InterfaceType,
  255. DWORD MediaType,
  256. WORD AccessType,
  257. WORD ConnectionType,
  258. PVOID InterfaceInfo,
  259. ULONG StructureVersion,
  260. ULONG StructureSize,
  261. ULONG StructureCount
  262. );
  263. DWORD
  264. APIENTRY
  265. DeleteInterface(
  266. IN DWORD dwIndex
  267. );
  268. DWORD
  269. APIENTRY
  270. GetEventMessage(
  271. OUT ROUTING_PROTOCOL_EVENTS *pEvent,
  272. OUT MESSAGE *pResult
  273. );
  274. DWORD WINAPI
  275. GetInterfaceConfigInfo (
  276. ULONG InterfaceIndex,
  277. PVOID OutInterfaceInfo,
  278. PULONG InterfaceInfoSize,
  279. PULONG StructureVersion,
  280. PULONG StructureSize,
  281. PULONG StructureCount
  282. );
  283. DWORD WINAPI
  284. SetInterfaceConfigInfo (
  285. ULONG InterfaceIndex,
  286. PVOID InterfaceInfo,
  287. ULONG StructureVersion,
  288. ULONG StructureSize,
  289. ULONG StructureCount
  290. );
  291. DWORD WINAPI
  292. InterfaceStatus(
  293. ULONG InterfaceIndex,
  294. BOOL InterfaceActive,
  295. DWORD StatusType,
  296. PVOID StatusInfo
  297. );
  298. DWORD
  299. APIENTRY
  300. MibCreate(
  301. IN DWORD dwInputSize,
  302. IN PVOID pInputData
  303. );
  304. DWORD
  305. APIENTRY
  306. MibDelete(
  307. IN DWORD dwInputSize,
  308. IN PVOID pInputData
  309. );
  310. DWORD
  311. APIENTRY
  312. MibGet(
  313. IN DWORD dwInputSize,
  314. IN PVOID pInputData,
  315. IN OUT PDWORD pdwOutputSize,
  316. OUT PVOID pOutputData
  317. );
  318. DWORD
  319. APIENTRY
  320. MibSet(
  321. IN DWORD dwInputSize,
  322. IN PVOID pInputData
  323. );
  324. DWORD
  325. APIENTRY
  326. MibGetFirst(
  327. IN DWORD dwInputSize,
  328. IN PVOID pInputData,
  329. IN OUT PDWORD pdwOutputSize,
  330. OUT PVOID pOutputData
  331. );
  332. DWORD
  333. APIENTRY
  334. MibGetNext(
  335. IN DWORD dwInputSize,
  336. IN PVOID pInputData,
  337. IN OUT PDWORD pdwOutputSize,
  338. OUT PVOID pOutputData
  339. );
  340. DWORD
  341. InputThread(
  342. PVOID pvParam
  343. );
  344. DWORD
  345. UpdateArpCache(
  346. DWORD dwIfIndex,
  347. DWORD dwAddress,
  348. PBYTE pbMacAddr,
  349. DWORD dwMacAddrLength,
  350. BOOL bAddEntry,
  351. SUPPORT_FUNCTIONS *pFunctions
  352. );
  353. DWORD
  354. QueueBootpWorker(
  355. WORKERFUNCTION pWorker,
  356. PVOID pContext
  357. );
  358. BOOL
  359. EnterBootpWorker(
  360. );
  361. VOID
  362. LeaveBootpWorker(
  363. );
  364. BOOL
  365. EnterBootpAPI(
  366. );
  367. #endif // _API_H_