home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / rtinfo.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  7KB  |  137 lines

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