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.

149 lines
7.6 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. rtinfo.h
  5. Abstract:
  6. Definitions of information block structuers used to exchange
  7. information in router API
  8. --*/
  9. #ifndef __ROUTING_RTINFO_H__
  10. #define __ROUTING_RTINFO_H__
  11. #if _MSC_VER > 1000
  12. #pragma once
  13. #endif
  14. //////////////////////////////////////////////////////////////////////////////
  15. // //
  16. // Information is passed to and from the Router Managers using a set of //
  17. // RTR_TOC_ENTRY structures. These structures are encapsulated by an //
  18. // RTR_INFO_BLOCK_HEADER. //
  19. // The general structure of this is: //
  20. // //
  21. // --- |-----------------------| --- //
  22. // | | | | //
  23. // | | RTR_INFO_BLOCK_HEADER | | //
  24. // | | | | //
  25. // | | TocEntriesCount = N | | //
  26. // | |-----------------------| | //
  27. // | | TocEntry[0] | | //
  28. // | | | | //
  29. // | | Offset of | | //
  30. // |<------ Associated Data | | //
  31. // | | | | //
  32. // | |-----------------------| | //
  33. // | Z Z | //
  34. // | | | | //
  35. // | |-----------------------| | //
  36. // | | TocEntry[N-1] | | //
  37. // | | | | //
  38. // | | Offset of | | //
  39. // | | Associated Data ------->| //
  40. // | | | | //
  41. // --- |-----------------------| | //
  42. // | Data for TocEntry[0] | | //
  43. // |-----------------------| | //
  44. // Z Z | //
  45. // |-----------------------| --- //
  46. // | Data for TocEntry[N-1]| //
  47. // |-----------------------| //
  48. // //
  49. //////////////////////////////////////////////////////////////////////////////
  50. //////////////////////////////////////////////////////////////////////////////
  51. // //
  52. // Each of the blocks of data must begin at a quadword aligned boundary. To //
  53. // get QUADWORD alignment, use the following macros. //
  54. // //
  55. // The block of data pointed to by an InfoBlock MUST be aligned. //
  56. // Use the alignment macro when writing the data portion into an infobase. //
  57. // This implies that for each ALIGN_POINTER operation done on a chunk //
  58. // of memory, the requested allocation must be ALIGN_SIZE greater //
  59. // than what is actually required (to be on the safe side) //
  60. // //
  61. //////////////////////////////////////////////////////////////////////////////
  62. #define ALIGN_SIZE 0x00000008
  63. #define ALIGN_SHIFT (ALIGN_SIZE - 0x00000001) // 0x00000007
  64. #define ALIGN_MASK_POINTER (~(UINT_PTR)ALIGN_SHIFT) // 0xfffffff8
  65. #define ALIGN_MASK_LENGTH (~ALIGN_SHIFT) // 0xfffffff8
  66. #define ALIGN_MASK (~ALIGN_SHIFT) // 0xfffffff8
  67. #define ALIGN_POINTER(ptr) { \
  68. (ptr) = (PVOID)((DWORD_PTR)(ptr) + ALIGN_SHIFT); \
  69. (ptr) = (PVOID)((DWORD_PTR)(ptr) & ALIGN_MASK_POINTER); \
  70. }
  71. #define ALIGN_LENGTH(length) { \
  72. (length) = (DWORD)((length) + ALIGN_SHIFT); \
  73. (length) = (DWORD)((length) & ALIGN_MASK_LENGTH); \
  74. }
  75. #define IS_ALIGNED(ptr) (((UINT_PTR)(ptr) & ALIGN_SHIFT) == 0x00000000)
  76. //////////////////////////////////////////////////////////////////////////////
  77. // //
  78. // Table of Contents Entry //
  79. // //
  80. //////////////////////////////////////////////////////////////////////////////
  81. //////////////////////////////////////////////////////////////////////////////
  82. // //
  83. // Each entry describes a structure type, location within the information //
  84. // block and number of entries of the same type. //
  85. // //
  86. //////////////////////////////////////////////////////////////////////////////
  87. typedef struct _RTR_TOC_ENTRY
  88. {
  89. ULONG InfoType; // Info structure type
  90. ULONG InfoSize; // Size of the info structure
  91. ULONG Count; // How many info structures of this type
  92. ULONG Offset; // Offset of the first structure, from the start
  93. // of the info block header.
  94. }RTR_TOC_ENTRY, *PRTR_TOC_ENTRY;
  95. //////////////////////////////////////////////////////////////////////////////
  96. // //
  97. // Info Block Header //
  98. // //
  99. //////////////////////////////////////////////////////////////////////////////
  100. //////////////////////////////////////////////////////////////////////////////
  101. // //
  102. // All Router information blocks start with this header //
  103. // //
  104. //////////////////////////////////////////////////////////////////////////////
  105. #define RTR_INFO_BLOCK_VERSION 1
  106. typedef struct _RTR_INFO_BLOCK_HEADER
  107. {
  108. ULONG Version; // Version of the structure
  109. ULONG Size; // size of the whole block, including version
  110. ULONG TocEntriesCount;// Number of entries
  111. RTR_TOC_ENTRY TocEntry[1]; // Table of content followed by the actual
  112. // information blocks
  113. } RTR_INFO_BLOCK_HEADER, *PRTR_INFO_BLOCK_HEADER;
  114. //
  115. // PVOID
  116. // GetInfoFromTocEntry(
  117. // IN PRTR_INFO_BLOCK_HEADER pInfoHdr,
  118. // IN PRTR_TOC_ENTRY pToc
  119. // )
  120. //
  121. #define GetInfoFromTocEntry(hdr,toc) \
  122. (((toc)->Offset < (hdr)->Size) ? ((PVOID)(((PBYTE)(hdr)) + (toc)->Offset)) : NULL)
  123. #endif //__ROUTING_RTINFO_H__