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.

467 lines
12 KiB

  1. #ifndef _IPX_ADAPTER_
  2. #define _IPX_ADAPTER_
  3. #include <ntddndis.h>
  4. #include "tdi.h"
  5. #include "isnkrnl.h"
  6. #include "ipxrtdef.h"
  7. // Adapter state changes
  8. #define ADAPTER_CREATED 1
  9. #define ADAPTER_DELETED 2
  10. #define ADAPTER_UP 3
  11. #define ADAPTER_DOWN 4
  12. //*** Adapter Info ***
  13. // this information is communicated whenever an adapter gets
  14. // created or gets connected
  15. typedef struct _ADAPTER_INFO {
  16. ULONG InterfaceIndex; // relevant only for demand dial WAN interfaces
  17. UCHAR Network[4];
  18. UCHAR LocalNode[6];
  19. UCHAR RemoteNode[6];
  20. ULONG LinkSpeed;
  21. ULONG PacketType;
  22. ULONG MaxPacketSize;
  23. NDIS_MEDIUM NdisMedium;
  24. ULONG ConnectionId;
  25. WCHAR pszAdpName[MAX_ADAPTER_NAME_LEN];
  26. } ADAPTER_INFO, *PADAPTER_INFO;
  27. typedef struct _ADAPTERS_GLOBAL_PARAMETERS {
  28. ULONG AdaptersCount;
  29. } ADAPTERS_GLOBAL_PARAMETERS, *PADAPTERS_GLOBAL_PARAMETERS;
  30. typedef struct _IPXWAN_INFO {
  31. UCHAR Network[4];
  32. UCHAR LocalNode[6];
  33. UCHAR RemoteNode[6];
  34. } IPXWAN_INFO, *PIPXWAN_INFO;
  35. typedef struct _ADDRESS_RESERVED {
  36. UCHAR Reserved[FIELD_OFFSET(IPX_DATAGRAM_OPTIONS2, Data)];
  37. } ADDRESS_RESERVED, *PADDRESS_RESERVED;
  38. #define GetNicId(pReserved) ((PIPX_DATAGRAM_OPTIONS2)pReserved)->DgrmOptions.LocalTarget.NicId
  39. /*++
  40. I p x C r e a t e A d a p t e r C o n f i g u r a t i o n P o r t
  41. Routine Description:
  42. Register client that wants to be updated of any changes in
  43. adapter state
  44. Arguments:
  45. NotificationEvent - event to be signaled when adapter state changes
  46. AdptGlobalParameters - parameters that common to all adapters
  47. Return Value:
  48. Handle to configuration port thru which changes in adapter state
  49. are reported. Returns INVALID_HANDLE_VALUE if port could not be created
  50. --*/
  51. HANDLE WINAPI
  52. IpxCreateAdapterConfigurationPort (
  53. IN HANDLE NotificationEvent,
  54. OUT PADAPTERS_GLOBAL_PARAMETERS AdptGlobalParameters
  55. );
  56. /*++
  57. I p x W a n C r e a t e A d a p t e r C o n f i g u r a t i o n P o r t
  58. Routine Description:
  59. Same as above, but creates port that only reports ADAPTER_UP
  60. events on WAN adapters that require IPXWAN negotiation.
  61. IpxGetQueuedAdapterConfigurationStatus on this port should be
  62. followed by IpxWanSetAdapterConfiguration obtained during the
  63. negotiation process, and ADAPTER_UP event will then be reported
  64. to other clients (including forwarder dirver)
  65. */
  66. HANDLE WINAPI
  67. IpxWanCreateAdapterConfigurationPort (
  68. IN HANDLE NotificationEvent,
  69. OUT PADAPTERS_GLOBAL_PARAMETERS AdptGlobalParameters
  70. );
  71. /*++
  72. I p x D e l e t e A d a p t e r C o n f i g u r a t i o n P o r t
  73. Routine Description:
  74. Unregister client
  75. Arguments:
  76. Handle - configuration port handle
  77. Return Value:
  78. NO_ERROR
  79. ERROR_INVALID_PARAMETER
  80. ERROR_GEN_FAILURE
  81. --*/
  82. DWORD WINAPI
  83. IpxDeleteAdapterConfigurationPort (
  84. IN HANDLE Handle
  85. );
  86. /*++
  87. G e t Q u e u e d A d a p t e r C o n f i g u r a t i o n S t a t u s
  88. Routine Description:
  89. Get info from the list of adapter info chages queued to the
  90. configuration info port
  91. Arguments:
  92. Handle - configuration port handle
  93. AdapterIndex - number of adapter being reported
  94. AdapterConfigurationStatus - new adapter status
  95. AdapterParameters - adapter parameters
  96. Return Value:
  97. NO_ERROR - new information is reported
  98. ERROR_NO_MORE_ITEMS - there is nothing to report
  99. Windows error code - operation failed
  100. --*/
  101. DWORD WINAPI
  102. IpxGetQueuedAdapterConfigurationStatus(
  103. IN HANDLE Handle,
  104. OUT PULONG AdapterIndex,
  105. OUT PULONG AdapterConfigurationStatus,
  106. OUT PADAPTER_INFO AdapterInfo
  107. );
  108. /*++
  109. I p x W a n S e t A d a p t e r C o n f i g u r a t i o n
  110. Routine Description:
  111. Sets adapter configuration to be reported to both user and
  112. kernel mode clients (through the ADAPTER_UP/LINE_UP events)
  113. Arguments:
  114. AdapterIndex - number of adapter being set
  115. IpxWanInfo - IPXWAN negotiated parameters
  116. Return Value:
  117. NO_ERROR - adapter info set successfully
  118. Windows error code - operation failed
  119. --*/
  120. DWORD
  121. IpxWanSetAdapterConfiguration (
  122. IN ULONG AdapterIndex,
  123. IN PIPXWAN_INFO IpxWanInfo
  124. );
  125. /*++
  126. I p x W a n Q u e r y I n a c t i v i t y T i m e r
  127. Routine Description:
  128. Returns value of inactivity timer associated with WAN line
  129. Arguments:
  130. ConnectionId - connection id that identifies WAN line (used only
  131. if *AdapterIndex==INVALID_NICID
  132. AdapterIndex - adapter index that identifies WAN line (preferred
  133. over connection id), if *AdapterIndex==INVALID_NICID
  134. the value of connection id is used to identify the
  135. WAN line and value of AdapterIndex is returned.
  136. InactivityCounter - value of inactivity counter.
  137. Return Value:
  138. NO_ERROR - inactivity timer reading is returned
  139. Windows error code - operation failed
  140. --*/
  141. DWORD
  142. IpxWanQueryInactivityTimer (
  143. IN ULONG ConnectionId,
  144. IN OUT PULONG AdapterIndex,
  145. OUT PULONG InactivityCounter
  146. );
  147. /*++
  148. G e t A d a p t e r N a m e W
  149. Routine Description:
  150. Returns UNICODE name of the adapter associated with given index
  151. Arguments:
  152. AdapterIndex - index of adapter
  153. AdapterNameSize - size of adapter name (in bytes), including terminal wchar NULL
  154. AdapterNameBuffer - buffer to receive adapter name
  155. Return Value:
  156. NO_ERROR - adapter name is in the buffer
  157. ERROR_INVALID_PARAMETER - adapter with given index does not exist
  158. ERROR_INSUFFICIENT_BUFFER - buffer in to small. Updates AdapterNameSize to
  159. the correct value.
  160. Other windows error code - operation failed
  161. --*/
  162. DWORD WINAPI
  163. GetAdapterNameW(
  164. IN ULONG AdapterIndex,
  165. IN OUT PULONG AdapterNameSize,
  166. OUT LPWSTR AdapterNameBuffer);
  167. /*++
  168. C r e a t e S o c k e t P o r t
  169. Routine Description:
  170. Creates port to communicate over IPX socket
  171. Arguments:
  172. Socket - IPX socket number to use (network byte order)
  173. Return Value:
  174. Handle to communication port that provides async interface
  175. to IPX stack. Returns INVALID_HANDLE_VALUE if port can not be opened
  176. --*/
  177. HANDLE WINAPI
  178. CreateSocketPort(
  179. IN USHORT Socket
  180. );
  181. /*++
  182. D e l e t e S o c k e t P o r t
  183. Routine Description:
  184. Cancel all the outstandng requests and dispose of all the resources
  185. allocated for communication port
  186. Arguments:
  187. Handle - Handle to communication port to be disposed of
  188. Return Value:
  189. NO_ERROR - success
  190. Windows error code - operation failed
  191. --*/
  192. DWORD WINAPI
  193. DeleteSocketPort(
  194. IN HANDLE Handle
  195. );
  196. /*++
  197. I p x R e c v P a c k e t
  198. Routine Description:
  199. Enqueue request to receive IPX packet and return immediately. Event will
  200. be signalled or comletion routine will be called when done
  201. Arguments:
  202. Handle - Handle to adapter & socket to use
  203. AdapterIdx - adapter on which to packet was received (set upon completion)
  204. IpxPacket - buffer for ipx packet (complete with header)
  205. IpxPacketLength - length of the buffer
  206. pReserved - buffer to get info from IPX stack
  207. lpOverlapped - structure to be used for async IO:
  208. Internal - Reserved
  209. InternalHigh - Reserved
  210. Offset - not used
  211. OffsetHigh - not used
  212. hEvent - event to be signalled when IO completes or NULL
  213. if CompletionRoutine is to be called
  214. CompletionRoutine - to be called when IO operation is completes
  215. Return Value:
  216. NO_ERROR - if lpOverlapped->hEvent!=NULL, then send has successfully completed
  217. (do not need to wait on event), otherwise, send operation has
  218. started and completion routine will be called when done
  219. ERROR_IO_PENDING - only returned if lpOverlapped->hEvent!=NULL and send could not
  220. be completed immediately, event will be signalled when
  221. operation is done: call GetOverlapedResult to retrieve result of
  222. the operation
  223. other (windows error code) - operation could not be started (completion routine
  224. won't be called)
  225. --*/
  226. DWORD WINAPI
  227. IpxRecvPacket(
  228. IN HANDLE Handle,
  229. OUT PUCHAR IpxPacket,
  230. IN ULONG IpxPacketLength,
  231. IN PADDRESS_RESERVED lpReserved,
  232. LPOVERLAPPED lpOverlapped,
  233. LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine
  234. );
  235. /*++
  236. I p x S e n d P a c k e t
  237. Routine Description:
  238. Enqueue request to receive IPX packet and return immediately. Event will
  239. be signalled or comletion routine will be called when done
  240. Arguments:
  241. Handle - Handle to adapter & socket to use
  242. AdapterIdx - adapter on which to send
  243. IpxPacket - ipx packet complete with header
  244. IpxPacketLength - length of the packet
  245. pReserved - buffer to supply info to IPX stack
  246. lpOverlapped - structure to be used for async IO:
  247. Internal - reserved
  248. InternalHigh - reserved
  249. Offset - not used
  250. OffsetHigh - not used
  251. hEvent - event to be signalled when IO completes or NULL
  252. if CompletionRoutine is to be called
  253. CompletionRoutine - to be called when IO operation is completes
  254. Return Value:
  255. NO_ERROR - if lpOverlapped->hEvent!=NULL, then recv has successfully completed
  256. (do not need to wait on event), otherwise, recv operation has
  257. started and completion routine will be called when done
  258. ERROR_IO_PENDING - only returned if lpOverlapped->hEvent!=NULL and recv could not
  259. be completed immediately, event will be signalled when
  260. operation is done: call GetOverlapedResult to retrieve result of
  261. the operation
  262. other (windows error code) - operation could not be started (completion routine
  263. won't be called)
  264. --*/
  265. DWORD WINAPI
  266. IpxSendPacket (
  267. IN HANDLE Handle,
  268. IN ULONG AdapterIdx,
  269. IN PUCHAR IpxPacket,
  270. IN ULONG IpxPacketLength,
  271. IN PADDRESS_RESERVED lpReserved,
  272. LPOVERLAPPED lpOverlapped,
  273. LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine
  274. );
  275. /*++
  276. I p x G e t O v e r l a p p e d R e s u l t
  277. Routine Description:
  278. GetOverlappedResult wrapper: gives adptif.dll a chance to adjust
  279. returned parameters (currently number of bytes transferred).
  280. Arguments:
  281. Same as in GetOverlappedResult (see SDK doc)
  282. Return Value:
  283. Same as in GetOverlappedResult (see SDK doc)
  284. --*/
  285. BOOL
  286. IpxGetOverlappedResult (
  287. HANDLE Handle,
  288. LPOVERLAPPED lpOverlapped,
  289. LPDWORD lpNumberOfBytesTransferred,
  290. BOOL bWait
  291. );
  292. /*++
  293. I p x G e t Q u e u e d C o m p l e t i o n S t a t u s
  294. Routine Description:
  295. GetQueuedCompletionStatus wrapper: gives adptif.dll a chance to adjust
  296. returned parameters (currently number of bytes transferred)
  297. Arguments:
  298. Same as in GetQueuedCompletionStatus (see SDK doc)
  299. Return Value:
  300. Same as in GetQueuedCompletionStatus (see SDK doc)
  301. --*/
  302. BOOL
  303. IpxGetQueuedCompletionStatus(
  304. HANDLE CompletionPort,
  305. LPDWORD lpNumberOfBytesTransferred,
  306. PULONG_PTR lpCompletionKey,
  307. LPOVERLAPPED *lpOverlapped,
  308. DWORD dwMilliseconds
  309. );
  310. /*++
  311. I p x A d j u s t I o C o m p l e t i o n P a r a m s
  312. Routine Description:
  313. Adjust io completion parameters for io performed
  314. by IpxSendPacket or IpxReceivePacket and completed
  315. through the mechanisms other than routines provided
  316. above
  317. Arguments:
  318. lpOverlapped - overlapped structure passed to
  319. Ipx(Send/Recv)Packet routines
  320. lpNumberOfBytesTransferred - adjusted number of bytes
  321. transferred in io
  322. error - win32 error code
  323. Return Value:
  324. None
  325. --*/
  326. VOID
  327. IpxAdjustIoCompletionParams (
  328. IN OUT LPOVERLAPPED lpOverlapped,
  329. OUT LPDWORD lpNumberOfBytesTransferred,
  330. OUT LPDWORD error
  331. );
  332. /*++
  333. I p x P o s t Q u e u e d C o m p l e t i o n S t a t u s
  334. Routine Description:
  335. PostQueuedCompletionStatus wrapper: gives adptif.dll a chance to
  336. setup lpOverlapped so it can be correctly processed by
  337. the IpxGetQueueCompletionStatus and IpxGetOverlappedResult
  338. Arguments:
  339. Same as in PostQueuedCompletionStatus (see SDK doc)
  340. Return Value:
  341. Same as in PostQueuedCompletionStatus (see SDK doc)
  342. --*/
  343. BOOL
  344. IpxPostQueuedCompletionStatus(
  345. HANDLE CompletionPort,
  346. DWORD dwNumberOfBytesTransferred,
  347. DWORD dwCompletionKey,
  348. LPOVERLAPPED lpOverlapped
  349. );
  350. #endif // _IPX_ADAPTER_