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.

257 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. routing\ip\wanarp\conn.h
  5. Abstract:
  6. Header for conn.c
  7. Revision History:
  8. AmritanR
  9. --*/
  10. //
  11. // Pointer to the connection table. Protected by g_rlConnTableLock
  12. //
  13. PULONG_PTR g_puipConnTable;
  14. //
  15. // The current size of the connection table. Protected by g_rlConnTableLock
  16. //
  17. ULONG g_ulConnTableSize;
  18. //
  19. // Current count of various connections. Also protected by the g_rlConnTableLock
  20. //
  21. ULONG g_rgulConns[DU_ROUTER + 1];
  22. //
  23. // Initial size of the connection table
  24. //
  25. #define WAN_INIT_CONN_TABLE_SIZE 16
  26. #define WAN_CONN_TABLE_INCREMENT 32
  27. #define WANARP_CONN_LOOKASIDE_DEPTH 16
  28. //
  29. // Hint to the next free slot. Protected by g_rlConnTableLock
  30. //
  31. ULONG g_ulNextConnIndex;
  32. //
  33. // The lock protecting all the above
  34. //
  35. RT_LOCK g_rlConnTableLock;
  36. //
  37. // The dial in interface and adapter. The server adapter is the first
  38. // adapter we find in the TCP/IP Parameters. The pointer is initialized
  39. // at bind time and then is unchanged. The g_pServerInterface is protected
  40. // by the g_rwlIfListLock
  41. //
  42. PUMODE_INTERFACE g_pServerInterface;
  43. PADAPTER g_pServerAdapter;
  44. #include <packon.h>
  45. //
  46. // To remove the contexts, we will cast the Ethernet header to the following
  47. // structure
  48. //
  49. typedef struct _ENET_CONTEXT_HALF_HDR
  50. {
  51. BYTE bUnused[2];
  52. ULONG ulSlot;
  53. }ENET_CONTEXT_HALF_HDR, *PENET_CONTEXT_HALF_HDR;
  54. #include <packoff.h>
  55. //++
  56. //
  57. // VOID
  58. // InsertConnIndexInAddr(
  59. // PBYTE pbyAddr,
  60. // ULONG ulIndex
  61. // )
  62. //
  63. // Inserts the index into the given ethernet address field
  64. //
  65. //--
  66. #define InsertConnIndexInAddr(a,i) \
  67. ((PENET_CONTEXT_HALF_HDR)(a))->ulSlot = (i)
  68. //++
  69. //
  70. // ULONG
  71. // GetConnIndexFromAddr(
  72. // PBYTE pbyAddr
  73. // )
  74. //
  75. // Retrieves the index from the given ethernet address field
  76. //
  77. //--
  78. #define GetConnIndexFromAddr(a) \
  79. ((PENET_CONTEXT_HALF_HDR)(a))->ulSlot
  80. //++
  81. //
  82. // PCONN_ENTRY
  83. // GetConnEntryGivenIndex(
  84. // ULONG ulIndex
  85. // )
  86. //
  87. // Retrieves the connection entry given the connection index
  88. // The connection table must be locked for this call
  89. // If an entry is found for the index, it is referenced and also
  90. // locked (if it is a DU_CALLIN connection)
  91. //
  92. //--
  93. #define GetConnEntryGivenIndex(i) \
  94. (PCONN_ENTRY)(g_puipConnTable[(i)]); \
  95. { \
  96. PCONN_ENTRY __pTemp; \
  97. __pTemp = (PCONN_ENTRY)g_puipConnTable[(i)]; \
  98. if(__pTemp != NULL) \
  99. { \
  100. ReferenceConnEntry(__pTemp); \
  101. } \
  102. }
  103. //
  104. // The lookaside list for connection entries
  105. //
  106. extern NPAGED_LOOKASIDE_LIST g_llConnBlocks;
  107. //++
  108. //
  109. // PCONN_ENTRY
  110. // AllocateConnection(
  111. // VOID
  112. // )
  113. //
  114. // Allocate a connection entry from g_llConnBlocks
  115. //
  116. //--
  117. #define AllocateConnection() \
  118. ExAllocateFromNPagedLookasideList(&g_llConnBlocks)
  119. //++
  120. //
  121. // VOID
  122. // FreeConnection(
  123. // PCONN_ENTRY pEntry
  124. // )
  125. //
  126. // Free a connection entry to g_llConnBlocks
  127. //
  128. //--
  129. #define FreeConnection(n) \
  130. ExFreeToNPagedLookasideList(&g_llConnBlocks, (n))
  131. VOID
  132. WanNdisStatus(
  133. NDIS_HANDLE nhHandle,
  134. NDIS_STATUS nsNdisStatus,
  135. PVOID pvStatusInfo,
  136. UINT uiStatusInfoSize
  137. );
  138. VOID
  139. WanNdisStatusComplete(
  140. NDIS_HANDLE nhHandle
  141. );
  142. NDIS_STATUS
  143. WanpLinkUpIndication(
  144. PNDIS_WAN_LINE_UP pInfoBuffer
  145. );
  146. NDIS_STATUS
  147. WanpLinkDownIndication(
  148. PNDIS_WAN_LINE_DOWN buffer
  149. );
  150. UINT
  151. WanDemandDialRequest(
  152. ROUTE_CONTEXT Context,
  153. IPAddr dwDest,
  154. IPAddr dwSource,
  155. BYTE byProtocol,
  156. PBYTE pbyBuffer,
  157. UINT uiLength,
  158. IPAddr dwHdrSrc
  159. );
  160. PCONN_ENTRY
  161. WanpCreateConnEntry(
  162. DIAL_USAGE duUsage
  163. );
  164. VOID
  165. WanIpCloseLink(
  166. PVOID pvAdapterContext,
  167. PVOID pvLinkContext
  168. );
  169. VOID
  170. WanpDeleteConnEntry(
  171. PCONN_ENTRY pConnEntry
  172. );
  173. VOID
  174. WanpNotifyRouterManager(
  175. PPENDING_NOTIFICATION pMsg,
  176. PUMODE_INTERFACE pInterface,
  177. PADAPTER pAdapter,
  178. PCONN_ENTRY pConnEntry,
  179. BOOLEAN bConnected
  180. );
  181. VOID
  182. WanpFreePacketAndBuffers(
  183. PNDIS_PACKET pnpPacket
  184. );
  185. PCONN_ENTRY
  186. WanpGetConnEntryGivenAddress(
  187. DWORD dwAddress
  188. );
  189. ULONG
  190. WanpRemoveAllConnections(
  191. VOID
  192. );
  193. BOOLEAN
  194. WanpIsConnectionTableEmpty(
  195. VOID
  196. );