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.

261 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1999, Microsoft Corporation
  3. Module Name:
  4. sample\networkentry.h
  5. Abstract:
  6. The file contains definitions for the network entry and associated data
  7. structures.
  8. --*/
  9. #ifndef _NETWORKENTRY_H_
  10. #define _NETWORKENTRY_H_
  11. //
  12. // TYPE DEFINITIONS FOR INTERFACE MANAGEMENT
  13. //
  14. //
  15. // struct: BINDING_ENTRY
  16. //
  17. // stores interface bindings, ip addresses to which an interface is bound.
  18. // all ip addresses are in network byte order.
  19. //
  20. // protected by the read-write lock NETWORK_ENTRY::rwlLock.
  21. //
  22. typedef struct _BINDING_ENTRY
  23. {
  24. IPADDRESS ipAddress;
  25. IPADDRESS ipMask;
  26. } BINDING_ENTRY, *PBINDING_ENTRY;
  27. DWORD
  28. BE_CreateTable (
  29. IN PIP_ADAPTER_BINDING_INFO pBinding,
  30. OUT PBINDING_ENTRY *ppbeBindingTable,
  31. OUT PIPADDRESS pipLowestAddress);
  32. DWORD
  33. BE_DestroyTable (
  34. IN PBINDING_ENTRY pbeBindingTable);
  35. #ifdef DEBUG
  36. DWORD
  37. BE_DisplayTable (
  38. IN PBINDING_ENTRY pbeBindingTable,
  39. IN ULONG ulNumBindings);
  40. #else
  41. #define BE_Display(pbe)
  42. #endif // DEBUG
  43. //
  44. // VOID
  45. // BE_FindTable (
  46. // IN PBINDING_ENTRY pbeBindingTable,
  47. // IN ULONG ulNumBindings,
  48. // IN IPADDRESS ipAddress,
  49. // IN IPADDRESS ipMask,
  50. // OUT PULONG pulIndex
  51. // );
  52. //
  53. #define BE_FindTable(table, num, address, mask, pindex) \
  54. { \
  55. for (*(pindex) = 0; *(pindex) < (num); (*(pindex))++) \
  56. if (!IP_COMPARE((table)[*(pindex)].ipAddress, (address)) and \
  57. !IP_COMPARE((table)[*(pindex)].ipMask, (mask))) \
  58. break; \
  59. }
  60. //
  61. // struct: INTERFACE_ENTRY
  62. //
  63. // stores per-interface information.
  64. //
  65. // protected by the read-write lock NETWORK_ENTRY::rwlLock.
  66. //
  67. // mib get modes
  68. typedef enum { GET_EXACT, GET_FIRST, GET_NEXT } MODE;
  69. typedef struct _INTERFACE_ENTRY
  70. {
  71. // Hash Table Link (primary access structure)
  72. LIST_ENTRY leInterfaceTableLink;
  73. // Index Sorted List Link (secondary access structure)
  74. LIST_ENTRY leIndexSortedListLink;
  75. // Interface Name (logging)
  76. PWCHAR pwszIfName;
  77. // Interface Index
  78. DWORD dwIfIndex;
  79. // Interface Address Bindings
  80. ULONG ulNumBindings;
  81. PBINDING_ENTRY pbeBindingTable;
  82. // Interface Flags ENABLED, BOUND, ACTIVE, MULTIACCESS
  83. DWORD dwFlags;
  84. // Interface Address (lowest binding ip address for now) & Socket
  85. IPADDRESS ipAddress;
  86. SOCKET sRawSocket;
  87. // Receive Event and Registered Wait
  88. HANDLE hReceiveEvent;
  89. HANDLE hReceiveWait;
  90. // Periodic Timer
  91. HANDLE hPeriodicTimer;
  92. // Interface Configuration
  93. DWORD ulMetric;
  94. // Interface Statistics
  95. IPSAMPLE_IF_STATS iisStats;
  96. } INTERFACE_ENTRY, *PINTERFACE_ENTRY;
  97. #define IEFLAG_ACTIVE 0x00000001
  98. #define IEFLAG_BOUND 0x00000002
  99. #define IEFLAG_MULTIACCESS 0x00000004
  100. #define INTERFACE_IS_ACTIVE(i) \
  101. ((i)->dwFlags & IEFLAG_ACTIVE)
  102. #define INTERFACE_IS_INACTIVE(i) \
  103. !INTERFACE_IS_ACTIVE(i)
  104. #define INTERFACE_IS_BOUND(i) \
  105. ((i)->dwFlags & IEFLAG_BOUND)
  106. #define INTERFACE_IS_UNBOUND(i) \
  107. !INTERFACE_IS_BOUND(i)
  108. #define INTERFACE_IS_MULTIACCESS(i) \
  109. ((i)->dwFlags & IEFLAG_MULTIACCESS)
  110. #define INTERFACE_IS_POINTTOPOINT(i) \
  111. !INTERFACE_IS_MULTIACCESS(i)
  112. DWORD
  113. IE_Create (
  114. IN PWCHAR pwszIfName,
  115. IN DWORD dwIfIndex,
  116. IN WORD wAccessType,
  117. OUT PINTERFACE_ENTRY *ppieInterfaceEntry);
  118. DWORD
  119. IE_Destroy (
  120. IN PINTERFACE_ENTRY pieInterfaceEntry);
  121. #ifdef DEBUG
  122. DWORD
  123. IE_Display (
  124. IN PINTERFACE_ENTRY pieInterfaceEntry);
  125. #else
  126. #define IE_Display(pieInterfaceEntry)
  127. #endif // DEBUG
  128. DWORD
  129. IE_Insert (
  130. IN PINTERFACE_ENTRY pieIfEntry);
  131. DWORD
  132. IE_Delete (
  133. IN DWORD dwIfIndex,
  134. OUT PINTERFACE_ENTRY *ppieIfEntry);
  135. BOOL
  136. IE_IsPresent (
  137. IN DWORD dwIfIndex);
  138. DWORD
  139. IE_Get (
  140. IN DWORD dwIfIndex,
  141. OUT PINTERFACE_ENTRY *ppieIfEntry);
  142. DWORD
  143. IE_GetIndex (
  144. IN DWORD dwIfIndex,
  145. IN MODE mMode,
  146. OUT PINTERFACE_ENTRY *ppieIfEntry);
  147. DWORD
  148. IE_BindInterface (
  149. IN PINTERFACE_ENTRY pie,
  150. IN PIP_ADAPTER_BINDING_INFO pBinding);
  151. DWORD
  152. IE_UnBindInterface (
  153. IN PINTERFACE_ENTRY pie);
  154. DWORD
  155. IE_ActivateInterface (
  156. IN PINTERFACE_ENTRY pie);
  157. DWORD
  158. IE_DeactivateInterface (
  159. IN PINTERFACE_ENTRY pie);
  160. //
  161. // struct: NETWORK_ENTRY
  162. //
  163. // stores interface table and other network related information.
  164. // the interface table is a hashed on the interface index.
  165. //
  166. // protected by the read-write lock NETWORK_ENTRY::rwlLock.
  167. //
  168. // must be acquired exclusively when entries are being added or deleted
  169. // from the table, and when the states of entries are being changed.
  170. //
  171. // must be acquired non-exclusively on all other acceses.
  172. //
  173. typedef struct _NETWORK_ENTRY
  174. {
  175. // Lock
  176. READ_WRITE_LOCK rwlLock;
  177. PHASH_TABLE phtInterfaceTable; // primary access structure
  178. LIST_ENTRY leIndexSortedList; // secondary access structure
  179. } NETWORK_ENTRY, *PNETWORK_ENTRY;
  180. DWORD
  181. NE_Create (
  182. OUT PNETWORK_ENTRY *ppneNetworkEntry);
  183. DWORD
  184. NE_Destroy (
  185. IN PNETWORK_ENTRY pneNetworkEntry);
  186. #ifdef DEBUG
  187. DWORD
  188. NE_Display (
  189. IN PNETWORK_ENTRY pneNetworkEntry);
  190. #else
  191. #define NE_Display(pneNetworkEntry)
  192. #endif // DEBUG
  193. #endif // _NETWORKENTRY_H_