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.

109 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1987-1999 Microsoft Corporation
  3. Module Name:
  4. midatlas.h
  5. Abstract:
  6. This module defines the data structure used in mapping MIDS to the corresponding requests/
  7. contexts associated with them.
  8. Notes:
  9. MID (Multiplex ID) is used at both the server and the client ( redirector ) to distinguish
  10. between the concurrently active requests on any connection. This data structure has been
  11. designed to meet the following criterion.
  12. 1) It should scale well to handle the differing capabilities of a server, e.g., the typical
  13. NT server permits 50 outstanding requests on any connection. The CORE level servers can go as
  14. low as one and on Gateway machines the desired number can be very high ( in the oreder of thousands)
  15. 2) The two primary operations that need to be handled well are
  16. i) mapping a MID to the context associated with it.
  17. -- This routine will be invoked to process every packet received along any connection
  18. at both the server and the client.
  19. ii) generating a new MID for sending requests to the server.
  20. -- This will be used at the client both for max. command enforcement as well as
  21. tagging each concurrent request with a unique id.
  22. The most common case is that of a connection between a NT client and a NT server. All
  23. design decisions have been made in order to ensure that the solutions are optimal
  24. for this case.
  25. The MID data structure must be efficiently able to manage the unique tagging and identification
  26. of a number of mids ( typically 50 ) from a possible combination of 65536 values. In order to
  27. ensure a proper time space tradeoff the lookup is organized as a three level hierarchy.
  28. The 16 bits used to represent a MID are split upinto three bit fields. The length of the
  29. rightmost field ( least signifiant ) is decided by the number of mids that are to be
  30. allocated on creation. The remaining length is split up equally between the next two
  31. fields, e.g., if 50 mids are to be allocated on creation , the length of the first field
  32. is 6 ( 64 ( 2 ** 6 ) is greater than 50 ), 5 and 5.
  33. --*/
  34. #ifndef _MIDATLAS_H_
  35. #define _MIDATLAS_H_
  36. typedef struct _MID_ATLAS_ {
  37. USHORT MaximumNumberOfMids;
  38. USHORT MidsAllocated;
  39. USHORT NumberOfMidsInUse;
  40. USHORT NumberOfMidsDiscarded;
  41. USHORT MaximumMidFieldWidth;
  42. USHORT Reserved;
  43. USHORT MidQuantum;
  44. UCHAR MidQuantumFieldWidth;
  45. UCHAR NumberOfLevels;
  46. LIST_ENTRY MidMapFreeList;
  47. LIST_ENTRY MidMapExpansionList;
  48. struct _MID_MAP_ *pRootMidMap;
  49. } MID_ATLAS, *PMID_ATLAS;
  50. typedef
  51. VOID (*PCONTEXT_DESTRUCTOR)(
  52. PVOID pContext);
  53. #define FsRtlGetMaximumNumberOfMids(pMidAtlas) \
  54. ((pMidAtlas)->MaximumNumberOfMids)
  55. #define FsRtlGetNumberOfMidsInUse(pMidAtlas) \
  56. ((pMidAtlas)->NumberOfMidsInUse)
  57. extern PMID_ATLAS
  58. FsRtlCreateMidAtlas(
  59. USHORT MaximumNumberOfEntries,
  60. USHORT InitialAllocation);
  61. extern VOID
  62. FsRtlDestroyMidAtlas(
  63. PMID_ATLAS pMidAtlas,
  64. PCONTEXT_DESTRUCTOR pContextDestructor);
  65. extern PVOID
  66. FsRtlMapMidToContext(
  67. PMID_ATLAS pMidAtlas,
  68. USHORT Mid);
  69. extern NTSTATUS
  70. FsRtlAssociateContextWithMid(
  71. PMID_ATLAS pMidAtlas,
  72. PVOID pContext,
  73. PUSHORT pNewMid);
  74. extern NTSTATUS
  75. FsRtlMapAndDissociateMidFromContext(
  76. PMID_ATLAS pMidAtlas,
  77. USHORT Mid,
  78. PVOID *pContextPointer);
  79. extern NTSTATUS
  80. FsRtlReassociateMid(
  81. PMID_ATLAS pMidAtlas,
  82. USHORT Mid,
  83. PVOID pNewContext);
  84. #endif
  85.