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.

514 lines
14 KiB

  1. #ifndef _WINSQUE_
  2. #define _WINSQUE_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /*
  7. TODO --
  8. Maybe: Coalesce different queue structures into one.
  9. */
  10. /*++
  11. Copyright (c) 1989 Microsoft Corporation
  12. Module Name:
  13. queue.c
  14. Abstract:
  15. This is the header file to be included for calling queue.c functions
  16. Functions:
  17. Portability:
  18. This module is portable.
  19. Author:
  20. Pradeep Bahl (PradeepB) Dec-1992
  21. Revision History:
  22. Modification Date Person Description of Modification
  23. ------------------ ------- ---------------------------
  24. --*/
  25. /*
  26. defines
  27. */
  28. #include <time.h>
  29. #include "wins.h"
  30. #include "comm.h"
  31. #include "assoc.h"
  32. #include "nmsdb.h"
  33. #include "nmsmsgf.h"
  34. #include "nmschl.h"
  35. #define QUE_NBT_WRK_ITM_SZ sizeof(NBT_REQ_WRK_ITM_T)
  36. /*
  37. QUE_INIT_BUFF_HEAP_SIZE -- This is the initial size of the heap
  38. for allocating queue items for the various
  39. queues
  40. */
  41. #define QUE_INIT_BUFF_HEAP_SIZE 10000
  42. #define WINS_QUEUE_HWM 500
  43. #define WINS_QUEUE_HWM_MAX 5000
  44. #define WINS_QUEUE_HWM_MIN 50
  45. /*
  46. macros
  47. */
  48. /*
  49. externs
  50. */
  51. //
  52. // forward declarator
  53. //
  54. struct _QUE_HD_T;
  55. extern struct _QUE_HD_T *pWinsQueQueHd[];
  56. /*
  57. forward declaration
  58. */
  59. typedef struct _QUE_HD_T QUE_HD_T;
  60. extern QUE_HD_T QueNbtWrkQueHd; //head for nbt req queue
  61. #if REG_N_QUERY_SEP > 0
  62. extern QUE_HD_T QueOtherNbtWrkQueHd; //head for nbt reg. req queue
  63. extern DWORD QueOtherNbtWrkQueMaxLen;
  64. #endif
  65. extern QUE_HD_T QueRplPullQueHd; //head for rpl pull thread's queue
  66. extern QUE_HD_T QueRplPushQueHd; //head for rpl push thread's queue
  67. extern QUE_HD_T QueNmsNrcqQueHd; //head for challenge queue used by NBT thds
  68. extern QUE_HD_T QueNmsRrcqQueHd; //head for challenge queue used by Replicator
  69. extern QUE_HD_T QueNmsCrqQueHd; //head for response queue for challenges sent
  70. extern QUE_HD_T QueWinsTmmQueHd; //head for timer manager queue
  71. extern QUE_HD_T QueWinsScvQueHd; //head for scavenger queue
  72. extern QUE_HD_T QueInvalidQueHd; //head for an invalid queue. Never inited
  73. extern HANDLE QueBuffHeapHdl; //handle to heap for use for queue items
  74. /*
  75. structure definitions
  76. */
  77. /*
  78. QUE_TYP_E -- enumerator for the various queue types.
  79. Used by QueInsertWrkItm and its callers
  80. Used by QueRemoveWrkItm and its callers
  81. This enumerator's value index the spQueHd (queue.c) array. Do not change the
  82. order of entries without changing QueHd's static initialization appropriately
  83. */
  84. typedef enum __QUE_TYP_E {
  85. QUE_E_NBT_REQ = 0, //nbt req queue
  86. #if REG_N_QUERY_SEP > 0
  87. QUE_E_OTHER_NBT_REQ, //reg/rel nbt req queue
  88. #endif
  89. QUE_E_RPLPULL, //pull thread queue
  90. QUE_E_RPLPUSH, //push thread queue
  91. QUE_E_NMSNRCQ, //nbt request challenge queue
  92. QUE_E_NMSRRCQ, //replicator request challenge queue
  93. QUE_E_NMSCRQ, //challenge response queue
  94. QUE_E_WINSTMQ, //timer queue
  95. QUE_E_WINSSCVQ, //Scavenger queue
  96. QUE_E_UNKNOWN_TYPQ, //Unknown type of queue
  97. QUE_E_TOTAL_NO_QS //Total no of queues
  98. } QUE_TYP_E, *PQUE_TYP_E;
  99. //
  100. // Work items for the different queues.
  101. //
  102. // NOTE NOTE NOTE -- The work items must have LIST_ENTRY
  103. // as the first field in them.
  104. //
  105. typedef struct _NBT_REQ_WRK_ITM_T {
  106. LIST_ENTRY Head;
  107. QUE_TYP_E QueTyp_e;
  108. COMM_HDL_T DlgHdl;
  109. MSG_T pMsg;
  110. MSG_LEN_T MsgLen;
  111. } NBT_REQ_WRK_ITM_T, *PNBT_REQ_WRK_ITM_T;
  112. //
  113. // CHL_REQ_WRK_ITM_T -- Name challenge queue work item. This is a work item
  114. // that can be used for any of the four name challenge
  115. // queues NRCQ, RRCQ, and CRQ
  116. //
  117. typedef struct _CHL_REQ_WRK_ITM_T {
  118. LIST_ENTRY Head;
  119. QUE_TYP_E QueTyp_e;
  120. COMM_HDL_T DlgHdl; //dlg handle
  121. MSG_T pMsg; //NBT message recd
  122. MSG_LEN_T MsgLen; //msg len
  123. DWORD QuesNamSecLen; //Length of question name sec.
  124. NMSDB_ROW_INFO_T NodeToReg; //Info of node To Register
  125. NMSDB_NODE_ADDS_T NodeAddsInCnf;
  126. BOOL fGroupInCnf; //whether the cnf record is group or unique
  127. DWORD OwnerIdInCnf;
  128. // BYTE NodeTypInCnf;
  129. // BYTE EntTypInCnf;
  130. COMM_ADD_T AddToReg;
  131. //COMM_ADD_T AddOfNodeInCnf;
  132. COMM_ADD_T AddOfRemWins; //address of remote WINS to
  133. //be sent the name reg request
  134. //so that the version number
  135. //of the record that caused
  136. //the conflict gets updated
  137. NMSCHL_CMD_TYP_E CmdTyp_e;
  138. WINS_CLIENT_E Client_e;
  139. NMSMSGF_NAM_REQ_TYP_E ReqTyp_e; //query or release
  140. DWORD NoOfAddsToUse;
  141. DWORD NoOfAddsToUseSv;
  142. } CHL_REQ_WRK_ITM_T, *PCHL_REQ_WRK_ITM_T;
  143. //
  144. // The response work item is the same as the challenge work item
  145. //
  146. typedef struct _CHL_REQ_WRK_ITM_T CHL_RSP_WRK_ITM_T, *PCHL_RSP_WRK_ITM_T;
  147. typedef struct _QUE_HD_T {
  148. LIST_ENTRY Head;
  149. CRITICAL_SECTION CrtSec;
  150. HANDLE EvtHdl;
  151. HANDLE HeapHdl;
  152. DWORD NoOfEntries;
  153. } QUE_HD_T, *PQUE_HD_T;
  154. /*
  155. QUE_CMD_TYP_E - Various Command Types that can be specified in the work item
  156. of one or more work queues
  157. */
  158. typedef enum QUE_CMD_TYP_E {
  159. QUE_E_CMD_REPLICATE = 0, //Replicate command directd to the Pull
  160. //thread as a result of administrative
  161. //action
  162. QUE_E_CMD_PULL_RANGE, //Pull Range command directd to the Pull
  163. //thread as a result of administrative
  164. //action
  165. QUE_E_CMD_REPLICATE_MSG, //Replicate message received by COMSYS TCP
  166. //thread
  167. QUE_E_CMD_SND_PUSH_NTF, //push update count to remote WINS. This is
  168. //a cmd to the Pull thread at the local WINS
  169. //(by an NBT thread) and a request to the
  170. //Pull thread at the remote WINS.
  171. QUE_E_CMD_SND_PUSH_NTF_PROP, //identical to the above except that
  172. //this one requests propagation along the
  173. //the chain of WINSs (Pull Partners)
  174. QUE_E_CMD_HDL_PUSH_NTF, //handle Push notification from a remote WINS.
  175. //This is a command forwarded to the PULL
  176. //thread by the Push thread
  177. QUE_E_CMD_CONFIG, //set configuration request
  178. QUE_E_CMD_DELETE_WINS, //Delete WINS from add-vers map tables (records
  179. //are also deleted)
  180. QUE_E_CMD_SET_TIMER, //set timer request to TMM
  181. QUE_E_CMD_CANCEL_TIMER, //cancel timer request to TMM
  182. QUE_E_CMD_MODIFY_TIMER, //modify timer reqyest to TMM
  183. QUE_E_CMD_TIMER_EXPIRED, //response to an earlier set timer request
  184. QUE_E_CMD_SCV_ADMIN, // Admin initiated request
  185. QUE_E_CMD_ADDR_CHANGE // Address of the local machine changed
  186. } QUE_CMD_TYP_E, *PQUE_CMD_TYP_E;
  187. /*
  188. Work item for the Replicator's queue
  189. It is used in the work queue of both the PULL thread and the
  190. PUSH thread.
  191. CmdTyp_e pClientCtx
  192. E_RPL NULL
  193. E_CONFIG address of list of RPL_CONFIG_REC_T records
  194. terminated by NULL
  195. E_REPLICATE address of list of RPL_CONFIG_REC_T records
  196. terminated by NULL
  197. E_TIMER_EXPIRE address of list of RPL_CONFIG_REC_T records
  198. terminated by NULL
  199. */
  200. //
  201. // The replicator, timer and Scavenger work items must have LIST_ENTRY,
  202. // QUE_TYP_E, and QUE_CMD_TYP_E as the top 3 fields in this order.
  203. //
  204. // Refer RplPullInit and RplPushInit to discover why.
  205. //
  206. typedef struct _QUE_RPL_REQ_WRK_ITM_T {
  207. LIST_ENTRY Head;
  208. QUE_TYP_E QueTyp_e;
  209. QUE_CMD_TYP_E CmdTyp_e;
  210. //
  211. // Don't change the order of the three fields above. Also,
  212. // they need to be at the top. See comment above
  213. //
  214. COMM_HDL_T DlgHdl;
  215. MSG_T pMsg;
  216. MSG_LEN_T MsgLen;
  217. LPVOID pClientCtx; /*client context. For example,
  218. *it may point to config
  219. *records (RPL_CONFIG_REC_T
  220. *in case the cmd is E_CONFIG
  221. */
  222. DWORD MagicNo; //used by IsTimeoutToBeIgnored()
  223. //in rplpull.c
  224. } QUE_RPL_REQ_WRK_ITM_T, *PQUE_RPL_REQ_WRK_ITM_T;
  225. //
  226. // SCV_REQ_WRK_ITM_E
  227. //
  228. typedef enum WINSINTF_SCV_OPC_E QUE_SCV_OPC_E, *PQUE_SCV_OPC_E;
  229. typedef struct _QUE_SCV_REQ_WRK_ITM_T {
  230. LIST_ENTRY Head;
  231. QUE_TYP_E QueTyp_e;
  232. QUE_CMD_TYP_E CmdTyp_e;
  233. WINSINTF_SCV_OPC_E Opcode_e;
  234. DWORD Age;
  235. BOOL fForce;
  236. } QUE_SCV_REQ_WRK_ITM_T, *PQUE_SCV_REQ_WRK_ITM_T;
  237. /*
  238. Que of timer manager
  239. */
  240. typedef struct _QUE_TMM_REQ_WRK_ITM_T {
  241. LIST_ENTRY Head;
  242. QUE_TYP_E QueTyp_e;
  243. QUE_CMD_TYP_E CmdTyp_e;
  244. //
  245. // Don't change the order of the three fields above. Also,
  246. // they need to be at the top. They have to be in the same order
  247. // and position within this and the _QUE_RPL_REQ_WRK_ITM_T data
  248. // structure
  249. //
  250. DWORD ReqId; //id of request
  251. WINS_CLIENT_E Client_e; //maybe not needed. Check ??
  252. time_t TimeInt; //Time Interval
  253. time_t AbsTime; //Absolute time
  254. DWORD DeltaTime; //Delta time
  255. HANDLE RspEvtHdl; //event to signal for response
  256. PQUE_HD_T pRspQueHd; //Que to put the response on
  257. LPVOID pClientCtx; /*client context. For example,
  258. *it may point to config
  259. *records (RPL_CONFIG_REC_T
  260. *in case the cmd is E_CONFIG
  261. */
  262. DWORD MagicNo; //used by IsTimeoutToBeIgnored()
  263. //in rplpull.c
  264. } QUE_TMM_REQ_WRK_ITM_T, *PQUE_TMM_REQ_WRK_ITM_T;
  265. /*
  266. function prototypes
  267. */
  268. extern
  269. STATUS
  270. QueInsertNbtWrkItm(
  271. IN PCOMM_HDL_T pDlgHdl,
  272. IN MSG_T pMsg,
  273. IN MSG_LEN_T MsgLen
  274. );
  275. extern
  276. STATUS
  277. QueRemoveNbtWrkItm(
  278. OUT PCOMM_HDL_T pDlgHdl,
  279. OUT PMSG_T ppMsg,
  280. OUT PMSG_LEN_T pMsgLen
  281. );
  282. #if REG_N_QUERY_SEP > 0
  283. extern
  284. STATUS
  285. QueInsertOtherNbtWrkItm(
  286. IN PCOMM_HDL_T pDlgHdl,
  287. IN MSG_T pMsg,
  288. IN MSG_LEN_T MsgLen
  289. );
  290. extern
  291. STATUS
  292. QueRemoveOtherNbtWrkItm(
  293. OUT PCOMM_HDL_T pDlgHdl,
  294. OUT PMSG_T ppMsg,
  295. OUT PMSG_LEN_T pMsgLen
  296. );
  297. #endif
  298. extern
  299. STATUS
  300. QueInsertChlReqWrkItm(
  301. IN NMSCHL_CMD_TYP_E CmdTyp_e,
  302. IN WINS_CLIENT_E Client_e,
  303. IN PCOMM_HDL_T pDlgHdl,
  304. IN MSG_T pMsg,
  305. IN MSG_LEN_T MsgLen,
  306. IN DWORD QuesNamSecLen,
  307. IN PNMSDB_ROW_INFO_T pNodeToReg,
  308. IN PNMSDB_STAT_INFO_T pNodeInCnf,
  309. //IN PCOMM_ADD_T pAddOfNodeInCnf,
  310. IN PCOMM_ADD_T pAddOfRemWins
  311. );
  312. extern
  313. STATUS
  314. QueRemoveChlReqWrkItm(
  315. IN HANDLE EvtHdl,
  316. IN OUT LPVOID *ppaWrkItm,
  317. OUT LPDWORD pNoOfReqs
  318. );
  319. extern
  320. STATUS
  321. QueInsertChlRspWrkItm(
  322. IN PCOMM_HDL_T pDlgHdl,
  323. IN MSG_T pMsg,
  324. IN MSG_LEN_T MsgLen
  325. );
  326. extern
  327. STATUS
  328. QueRemoveChlRspWrkItm(
  329. OUT LPVOID *ppWrkItm
  330. );
  331. extern
  332. STATUS
  333. QueInsertWrkItm (
  334. IN PLIST_ENTRY pWrkItm,
  335. IN QUE_TYP_E QueTyp_e,
  336. IN PQUE_HD_T pQueHdPassed
  337. );
  338. extern
  339. STATUS
  340. QueGetWrkItm (
  341. IN QUE_TYP_E QueTyp_e,
  342. OUT LPVOID *ppWrkItm
  343. );
  344. extern
  345. VOID
  346. QueAllocWrkItm(
  347. IN HANDLE HeapHdl,
  348. IN DWORD Size,
  349. OUT LPVOID *ppBuf
  350. );
  351. extern
  352. VOID
  353. QueDeallocWrkItm(
  354. IN HANDLE HeapHdl,
  355. IN LPVOID pBuff
  356. );
  357. extern
  358. STATUS
  359. QueInsertWrkItmAtHdOfList (
  360. IN PLIST_ENTRY pWrkItm,
  361. IN QUE_TYP_E QueTyp_e,
  362. IN PQUE_HD_T pQueHdPassed
  363. );
  364. extern
  365. STATUS
  366. QueInsertRplPushWrkItm (
  367. IN PLIST_ENTRY pWrkItm,
  368. IN BOOL fAlreadyInCrtSec
  369. );
  370. extern
  371. STATUS
  372. QueInsertNetNtfWrkItm (
  373. IN PLIST_ENTRY pWrkItm
  374. );
  375. extern
  376. STATUS
  377. QueInsertSndNtfWrkItm (
  378. IN PLIST_ENTRY pWrkItm
  379. );
  380. extern
  381. VOID
  382. QueChlWaitForRsp(
  383. VOID
  384. );
  385. extern
  386. VOID
  387. QueChlNoWaitForRsp(
  388. VOID
  389. );
  390. extern
  391. __inline
  392. STATUS
  393. QueInsertScvWrkItm(
  394. PLIST_ENTRY pWrkItm
  395. );
  396. extern
  397. __inline
  398. STATUS
  399. QueRemoveScvWrkItm(
  400. LPVOID *ppWrkItm
  401. );
  402. extern
  403. VOID
  404. WinsQueInit(
  405. LPTSTR pName,
  406. PQUE_HD_T pQueHd
  407. );
  408. #ifdef __cplusplus
  409. }
  410. #endif
  411. #endif //_WINSQUE_