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.

865 lines
22 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. bind.h
  5. Abstract:
  6. Private include file for the ISN transport. It defines the
  7. structures used for binding between IPX and the upper drivers.
  8. Author:
  9. Adam Barr (adamba) 04-Oct-1993
  10. Revision History:
  11. Sanjay Anand (SanjayAn) 5-July-1995
  12. Bug fixes - tagged [SA]
  13. Ting Cai (TingCai) Sept-18-1998
  14. Port the to 64-bit environment
  15. #ifdef SUNDOWN
  16. ULONG FwdAdapterContext
  17. #else
  18. ULONG_PTR FwdAdapterContext
  19. #endif
  20. --*/
  21. #ifndef _ISN_BIND_
  22. #define _ISN_BIND_
  23. //
  24. // Retrieve the common definitions.
  25. //
  26. #include <isnkrnl.h>
  27. //
  28. // Define the IOCTL used for binding between the upper
  29. // drivers and IPX.
  30. //
  31. #define _IPX_CONTROL_CODE(request,method) \
  32. CTL_CODE(FILE_DEVICE_TRANSPORT, request, method, FILE_ANY_ACCESS)
  33. #define IOCTL_IPX_INTERNAL_BIND _IPX_CONTROL_CODE( 0x1234, METHOD_BUFFERED )
  34. //
  35. // [FW] Error codes - reusing NTSTATUS codes
  36. //
  37. #define STATUS_ADAPTER_ALREADY_OPENED STATUS_UNSUCCESSFUL
  38. #define STATUS_ADAPTER_ALREADY_CLOSED STATUS_UNSUCCESSFUL
  39. #define STATUS_FILTER_FAILED STATUS_UNSUCCESSFUL
  40. #define STATUS_DROP_SILENTLY STATUS_UNSUCCESSFUL
  41. //
  42. // Identifier for the drivers in ISN.
  43. //
  44. #define IDENTIFIER_NB 0
  45. #define IDENTIFIER_SPX 1
  46. #define IDENTIFIER_RIP 2
  47. #define IDENTIFIER_IPX 3
  48. #ifdef _PNP_POWER
  49. //
  50. // This the number of PVOIDs in the beginning of the SEND_RESERVED
  51. // section of a packet header, to be set aside by the ISN clients (NB/SPX)
  52. // for IPX's private use.
  53. //
  54. #define SEND_RESERVED_COMMON_SIZE 8
  55. #endif
  56. //
  57. // Definition of a RIP router table entry.
  58. //
  59. typedef struct _IPX_ROUTE_ENTRY {
  60. UCHAR Network[4];
  61. USHORT NicId;
  62. UCHAR NextRouter[6];
  63. NDIS_HANDLE NdisBindingContext;
  64. USHORT Flags;
  65. USHORT Timer;
  66. UINT Segment;
  67. USHORT TickCount;
  68. USHORT HopCount;
  69. LIST_ENTRY AlternateRoute;
  70. LIST_ENTRY NicLinkage;
  71. struct {
  72. LIST_ENTRY Linkage;
  73. ULONG Reserved[1];
  74. } PRIVATE;
  75. } IPX_ROUTE_ENTRY, * PIPX_ROUTE_ENTRY;
  76. //
  77. // Definition of the Flags values.
  78. //
  79. #define IPX_ROUTER_PERMANENT_ENTRY 0x0001 // entry should never be deleted
  80. #define IPX_ROUTER_LOCAL_NET 0x0002 // locally attached network
  81. #define IPX_ROUTER_SCHEDULE_ROUTE 0x0004 // call ScheduleRouteHandler after using
  82. #define IPX_ROUTER_GLOBAL_WAN_NET 0x0008 // this is for rip's global network number
  83. //
  84. // Definition of the structure provided on a find
  85. // route/find route completion call.
  86. //
  87. //
  88. // [SA] Bug #15094 added node number to the structure.
  89. //
  90. //
  91. // [FW] Added Hop and Tick counts so this structure can be passed
  92. // as such to the Forwarder - hop and tick counts are queried in actions
  93. //
  94. typedef struct _IPX_FIND_ROUTE_REQUEST {
  95. UCHAR Network[4];
  96. UCHAR Node[6] ;
  97. IPX_LOCAL_TARGET LocalTarget;
  98. USHORT TickCount; // [FW]
  99. USHORT HopCount; // [FW]
  100. UCHAR Identifier;
  101. UCHAR Type;
  102. UCHAR Reserved1[2];
  103. PVOID Reserved2;
  104. LIST_ENTRY Linkage;
  105. } IPX_FIND_ROUTE_REQUEST, *PIPX_FIND_ROUTE_REQUEST;
  106. //
  107. // Definitions for the Type value.
  108. //
  109. #define IPX_FIND_ROUTE_NO_RIP 1 // fail if net is not in database
  110. #define IPX_FIND_ROUTE_RIP_IF_NEEDED 2 // return net if in database, otherwise RIP out
  111. #define IPX_FIND_ROUTE_FORCE_RIP 3 // re-RIP even if net is in database
  112. //
  113. // Structure used when querying the line information
  114. // for a specific NID ID.
  115. //
  116. typedef struct _IPX_LINE_INFO {
  117. UINT LinkSpeed;
  118. UINT MaximumPacketSize;
  119. UINT MaximumSendSize;
  120. UINT MacOptions;
  121. } IPX_LINE_INFO, *PIPX_LINE_INFO;
  122. //
  123. // Functions provided by the upper driver.
  124. //
  125. //
  126. // [FW] Added the ForwarderAdapterContext to the paramters
  127. // SPX/NB can ignore this for now
  128. //
  129. typedef BOOLEAN
  130. (*IPX_INTERNAL_RECEIVE) (
  131. IN NDIS_HANDLE MacBindingHandle,
  132. IN NDIS_HANDLE MacReceiveContext,
  133. IN ULONG_PTR FwdAdapterContext, // [FW]
  134. IN PIPX_LOCAL_TARGET RemoteAddress,
  135. IN ULONG MacOptions,
  136. IN PUCHAR LookaheadBuffer,
  137. IN UINT LookaheadBufferSize,
  138. IN UINT LookaheadBufferOffset,
  139. IN UINT PacketSize,
  140. IN PMDL pMdl
  141. );
  142. typedef VOID
  143. (*IPX_INTERNAL_RECEIVE_COMPLETE) (
  144. IN USHORT NicId
  145. );
  146. //
  147. // [FW] Status and ScheduleRoute removed from the bind input
  148. // [ZZZZZZZZZ]
  149. typedef VOID
  150. (*IPX_INTERNAL_STATUS) (
  151. IN USHORT NicId,
  152. IN NDIS_STATUS GeneralStatus,
  153. IN PVOID StatusBuffer,
  154. IN UINT StatusBufferLength
  155. );
  156. typedef VOID
  157. (*IPX_INTERNAL_SCHEDULE_ROUTE) (
  158. IN PIPX_ROUTE_ENTRY RouteEntry
  159. );
  160. typedef VOID
  161. (*IPX_INTERNAL_SEND_COMPLETE) (
  162. IN PNDIS_PACKET Packet,
  163. IN NDIS_STATUS Status
  164. );
  165. typedef VOID
  166. (*IPX_INTERNAL_TRANSFER_DATA_COMPLETE) (
  167. IN PNDIS_PACKET Packet,
  168. IN NDIS_STATUS Status,
  169. IN UINT BytesTransferred
  170. );
  171. typedef VOID
  172. (*IPX_INTERNAL_FIND_ROUTE_COMPLETE) (
  173. IN PIPX_FIND_ROUTE_REQUEST FindRouteRequest,
  174. IN BOOLEAN FoundRoute
  175. );
  176. typedef VOID
  177. (*IPX_INTERNAL_LINE_UP) (
  178. IN USHORT NicId,
  179. IN PIPX_LINE_INFO LineInfo,
  180. IN NDIS_MEDIUM DeviceType,
  181. IN PVOID ConfigurationData
  182. );
  183. typedef VOID
  184. (*IPX_INTERNAL_LINE_DOWN) (
  185. IN USHORT NicId,
  186. IN ULONG_PTR FwdAdapterContext
  187. );
  188. #if defined(_PNP_POWER)
  189. //
  190. // following opcodes are used when calling the
  191. // above handler.
  192. //
  193. typedef enum _IPX_PNP_OPCODE {
  194. IPX_PNP_ADD_DEVICE, // 0 - addition of the first adapter
  195. IPX_PNP_DELETE_DEVICE, // 1 - deletion of the last adapter
  196. IPX_PNP_TRANSLATE_DEVICE, // 2 - translate device resource
  197. IPX_PNP_TRANSLATE_ADDRESS, // 3 - translate address resource
  198. IPX_PNP_ADDRESS_CHANGE, // 4 - Adapter address or Reserved address changed
  199. IPX_PNP_QUERY_POWER, // 5 - NDIS queries if power can go off
  200. IPX_PNP_SET_POWER, // 6 - NDIS tells that power is going off
  201. IPX_PNP_QUERY_REMOVE, // 7 - NDIS queries if adapter can be removed
  202. IPX_PNP_CANCEL_REMOVE, // 8 - NDIS cancels the query_remove
  203. IPX_PNP_MAX_OPCODES, // 9
  204. } IPX_PNP_OPCODE, *PIPX_PNP_OPCODE;
  205. //
  206. // PnP event notification handler.
  207. //
  208. typedef NTSTATUS
  209. (*IPX_INTERNAL_PNP_NOTIFICATION) (
  210. IN IPX_PNP_OPCODE PnPOpcode,
  211. IN OUT PVOID PnpData
  212. );
  213. //
  214. // Pointer to this structure is passed in PnPData portion of
  215. // the above handler when the opcode is ADD_DEVICE or DELETE_DEVICE.
  216. //
  217. typedef struct _IPX_PNP_INFO {
  218. ULONG NetworkAddress;
  219. UCHAR NodeAddress[6];
  220. BOOLEAN NewReservedAddress; // where the above is a new reserved
  221. // address for the Ipx clients.
  222. BOOLEAN FirstORLastDevice; // is this a first card arrival or last card deletion.
  223. IPX_LINE_INFO LineInfo; // New LineInfo.
  224. NIC_HANDLE NicHandle;
  225. } IPX_PNP_INFO, *PIPX_PNP_INFO;
  226. #endif _PNP_POWER
  227. //
  228. // [FW] New entry points provided by the Kernel Forwarder.
  229. // These are not filled in by NB and SPX.
  230. //
  231. /*++
  232. Routine Description:
  233. This routine is provided by the Kernel Forwarder to filter packets being sent out
  234. by NB/SPX/TDI thru' IPX - does not include those sent out by the Forwarder (external sends)
  235. Arguments:
  236. LocalTarget - the NicId and next hop router MAC address
  237. FwdAdapterContext - Forwarder's context - preferred NIC if not INVALID_CONTEXT_VALUE
  238. Packet - packet to be sent out
  239. IpxHeader - points to the IPX header
  240. Data - points to after the IPX header - needed in spoofing of keepalives.
  241. PacketLength - length of the packet
  242. fIterate - a flag to indicate if this is a packet for the iteration of which the
  243. Fwd takes responsibility - typically type 20 NetBIOS frames
  244. Return Value:
  245. STATUS_SUCCESS - if the preferred NIC was OK and packet passed filtering
  246. STATUS_NETWORK_UNREACHABLE - if the preferred was not OK or packet failed filtering
  247. STATUS_PENDING - if preferred NIC was OK but line down
  248. Forwarder should give us a different status than STATUS_NETWORK_UNREACHABLE for changed NIC
  249. --*/
  250. typedef NTSTATUS
  251. (*IPX_FW_INTERNAL_SEND) (
  252. IN OUT PIPX_LOCAL_TARGET LocalTarget,
  253. IN ULONG_PTR FwdAdapterContext,
  254. IN PNDIS_PACKET Packet,
  255. IN PUCHAR IpxHeader,
  256. IN PUCHAR Data,
  257. IN ULONG PacketLength,
  258. IN BOOLEAN fIterate
  259. );
  260. /*++
  261. Routine Description:
  262. This routine is provided by the Kernel Forwarder to find the route to a given node and network
  263. Arguments:
  264. Network - the destination network
  265. Node - destination node
  266. RouteEntry - filled in by the Forwarder if a route exists
  267. Return Value:
  268. STATUS_SUCCESS
  269. STATUS_NETWORK_UNREACHABLE - if the findroute failed
  270. --*/
  271. typedef NTSTATUS
  272. (*IPX_FW_FIND_ROUTE) (
  273. IN PUCHAR Network,
  274. IN PUCHAR Node,
  275. OUT PIPX_FIND_ROUTE_REQUEST RouteEntry
  276. );
  277. /*++
  278. Routine Description:
  279. This routine is provided by the Kernel Forwarder to find the route to a given node and network
  280. Arguments:
  281. FwdAdapterContext - Forwarder's context
  282. RemoteAddress - the address the packet came on
  283. LookAheadBuffer - packet header that came in
  284. LookAheadBufferSize - size of the lookaheadbuffer
  285. Return Value:
  286. STATUS_SUCCESS
  287. STATUS_FILTER_FAILED - if the packet was not allowed by the filter
  288. --*/
  289. typedef NTSTATUS
  290. (*IPX_FW_INTERNAL_RECEIVE) (
  291. IN ULONG_PTR FwdAdapterContext,
  292. IN PIPX_LOCAL_TARGET RemoteAddress,
  293. IN PUCHAR LookAheadBuffer,
  294. IN UINT LookAheadBufferSize
  295. );
  296. //
  297. // Input to the bind IOCTL
  298. //
  299. //
  300. // [FW] Removed the status and schedule route handlers
  301. //
  302. typedef struct _IPX_INTERNAL_BIND_INPUT {
  303. USHORT Version;
  304. UCHAR Identifier;
  305. BOOLEAN BroadcastEnable;
  306. UINT LookaheadRequired;
  307. UINT ProtocolOptions;
  308. IPX_INTERNAL_RECEIVE ReceiveHandler;
  309. IPX_INTERNAL_RECEIVE_COMPLETE ReceiveCompleteHandler;
  310. IPX_INTERNAL_STATUS StatusHandler;
  311. IPX_INTERNAL_SEND_COMPLETE SendCompleteHandler;
  312. IPX_INTERNAL_TRANSFER_DATA_COMPLETE TransferDataCompleteHandler;
  313. IPX_INTERNAL_FIND_ROUTE_COMPLETE FindRouteCompleteHandler;
  314. IPX_INTERNAL_LINE_UP LineUpHandler;
  315. IPX_INTERNAL_LINE_DOWN LineDownHandler;
  316. IPX_INTERNAL_SCHEDULE_ROUTE ScheduleRouteHandler;
  317. #if defined(_PNP_POWER)
  318. IPX_INTERNAL_PNP_NOTIFICATION PnPHandler;
  319. #endif _PNP_POWER
  320. IPX_FW_INTERNAL_SEND InternalSendHandler;
  321. IPX_FW_FIND_ROUTE FindRouteHandler;
  322. IPX_FW_INTERNAL_RECEIVE InternalReceiveHandler;
  323. ULONG RipParameters;
  324. } IPX_INTERNAL_BIND_INPUT, * PIPX_INTERNAL_BIND_INPUT;
  325. #if defined(_PNP_POWER)
  326. #define ISN_VERSION 2
  327. #endif _PNP_POWER
  328. //
  329. // Bit mask values for RipParameters.
  330. //
  331. #define IPX_RIP_PARAM_GLOBAL_NETWORK 0x00000001 // single network for all WANS
  332. //
  333. // Functions provided by the lower driver.
  334. //
  335. typedef NDIS_STATUS
  336. (*IPX_INTERNAL_SEND) (
  337. IN PIPX_LOCAL_TARGET RemoteAddress,
  338. IN PNDIS_PACKET Packet,
  339. IN ULONG PacketLength,
  340. IN ULONG IncludedHeaderLength
  341. );
  342. typedef VOID
  343. (*IPX_INTERNAL_FIND_ROUTE) (
  344. IN PIPX_FIND_ROUTE_REQUEST FindRouteRequest
  345. );
  346. typedef NTSTATUS
  347. (*IPX_INTERNAL_QUERY) (
  348. IN ULONG InternalQueryType,
  349. #if defined(_PNP_POWER)
  350. IN PNIC_HANDLE NicHandle OPTIONAL,
  351. #else
  352. IN USHORT NicId OPTIONAL,
  353. #endif _PNP_POWER
  354. IN OUT PVOID Buffer,
  355. IN ULONG BufferLength,
  356. OUT PULONG BufferLengthNeeded OPTIONAL
  357. );
  358. typedef VOID
  359. (*IPX_INTERNAL_TRANSFER_DATA)(
  360. OUT PNDIS_STATUS Status,
  361. IN NDIS_HANDLE NdisBindingHandle,
  362. IN NDIS_HANDLE MacReceiveContext,
  363. IN UINT ByteOffset,
  364. IN UINT BytesToTransfer,
  365. IN OUT PNDIS_PACKET Packet,
  366. OUT PUINT BytesTransferred
  367. );
  368. typedef VOID
  369. (*IPX_INTERNAL_PNP_COMPLETE) (
  370. IN PNET_PNP_EVENT NetPnPEvent,
  371. IN NTSTATUS Status
  372. );
  373. //
  374. // Definitions of the internal query types. In all cases
  375. // STATUS_SUCCESS is returned if the request succeeds, and
  376. // STATUS_BUFFER_TOO_SMALL is returned, and BufferLengthNeeded
  377. // set if specified, if the buffer is too short. Other
  378. // return codes are defined below. The routine never pends.
  379. //
  380. //
  381. // This is used to query the line info. NicId specifies which one
  382. // to query. Buffer contains an IPX_LINE_INFO structure which is
  383. // used to return the information. Other return values:
  384. //
  385. // STATUS_INVALID_PARAMETER - NicId is invalid.
  386. //
  387. #define IPX_QUERY_LINE_INFO 1
  388. //
  389. // This is used to query the maximum NicId. NicId is unused. The
  390. // Buffer contains a USHORT which is used to return the information.
  391. //
  392. #define IPX_QUERY_MAXIMUM_NIC_ID 2
  393. //
  394. // This is used to determine if the IPX address specified was sent
  395. // by our local machine. If the address is the source address of a
  396. // received frame, NicId should be the ID that was indicated; otherwise
  397. // it should be set to 0. Buffer holds a TDI_ADDRESS_IPX. This
  398. // call returns STATUS_SUCCESS if the address is local, and
  399. // STATUS_NO_SUCH_DEVICE if not.
  400. //
  401. #define IPX_QUERY_IS_ADDRESS_LOCAL 3
  402. //
  403. // This is used to query the receive buffer space of a given NicId.
  404. // Buffer contains a ULONG which is used to return the information.
  405. // It returns STATUS_INVALID_PARAMETER if NicId is invalid.
  406. //
  407. #define IPX_QUERY_RECEIVE_BUFFER_SPACE 4
  408. //
  409. // This is used to query the local IPX address of a given NicId.
  410. // Buffer contains a TDI_ADDRESS_IPX structure (the Socket is
  411. // returned as 0). If it is queried on net 0 it returns the
  412. // virtual network if there is one, otherwise STATUS_INVALID_PARAMETER.
  413. // It returns STATUS_INVALID_PARAMETER if NicId is invalid.
  414. //
  415. #define IPX_QUERY_IPX_ADDRESS 5
  416. //
  417. // This is used to return the source routing information for
  418. // a give remote address. NicId will be the NIC the packet was
  419. // received from. The IPX_SOURCE_ROUTING_QUERY is contained
  420. // in Buffer. Always returns STATUS_SUCCESS, although the
  421. // SourceRoutingLength may be 0 for unknown remotes.
  422. //
  423. // The source routing is return in the direction it was received
  424. // from the remote, not the direction used in replying. The
  425. // MaximumSendSize includes the IPX header (as it does in
  426. // IPX_LINE_INFO).
  427. //
  428. #define IPX_QUERY_SOURCE_ROUTING 6
  429. typedef struct _IPX_SOURCE_ROUTING_INFO {
  430. USHORT Identifier; // input: the caller's IDENTIFIER_SPX, _NB, etc.
  431. UCHAR RemoteAddress[6]; // input: the remote address
  432. UCHAR SourceRouting[18]; // output: room for the maximum source route
  433. USHORT SourceRoutingLength; // output: the valid length of source route
  434. ULONG MaximumSendSize; // output: based on nic and source routing
  435. } IPX_SOURCE_ROUTING_INFO, * PIPX_SOURCE_ROUTING_INFO;
  436. //
  437. // This is used to query the maximum NicId over which outgoing type
  438. // 20 packets should be sent. It will be less than or equal to
  439. // the IPX_QUERY_MAXIMUM_NIC_ID value. What's excluded are down wan
  440. // lines and dialin wan lines if DisableDialinNetbios bit 1 is set.
  441. //
  442. #define IPX_QUERY_MAX_TYPE_20_NIC_ID 7
  443. #if defined(_PNP_POWER)
  444. //
  445. // This are used by NB to pass down these TDI queries which cannot
  446. // be completed in NB.
  447. //
  448. #define IPX_QUERY_DATA_LINK_ADDRESS 8
  449. #define IPX_QUERY_NETWORK_ADDRESS 9
  450. #endif _PNP_POWER
  451. #define IPX_QUERY_MEDIA_TYPE 10
  452. #define IPX_QUERY_DEVICE_RELATION 11
  453. //
  454. // Output of a non-RIP bind.
  455. //
  456. typedef struct _IPX_INTERNAL_BIND_OUTPUT {
  457. USHORT Version;
  458. UCHAR Node[6];
  459. UCHAR Network[4];
  460. USHORT MacHeaderNeeded;
  461. USHORT IncludedHeaderOffset;
  462. IPX_LINE_INFO LineInfo;
  463. IPX_INTERNAL_SEND SendHandler;
  464. IPX_INTERNAL_FIND_ROUTE FindRouteHandler;
  465. IPX_INTERNAL_QUERY QueryHandler;
  466. IPX_INTERNAL_TRANSFER_DATA TransferDataHandler;
  467. IPX_INTERNAL_PNP_COMPLETE PnPCompleteHandler;
  468. } IPX_INTERNAL_BIND_OUTPUT, * PIPX_INTERNAL_BIND_OUTPUT;
  469. //
  470. // Lower driver functions provided only for RIP.
  471. //
  472. typedef UINT
  473. (*IPX_INTERNAL_GET_SEGMENT) (
  474. IN UCHAR Network[4]
  475. );
  476. typedef PIPX_ROUTE_ENTRY
  477. (*IPX_INTERNAL_GET_ROUTE) (
  478. IN UINT Segment,
  479. IN UCHAR Network[4]
  480. );
  481. typedef BOOLEAN
  482. (*IPX_INTERNAL_ADD_ROUTE) (
  483. IN UINT Segment,
  484. IN PIPX_ROUTE_ENTRY RouteEntry
  485. );
  486. typedef BOOLEAN
  487. (*IPX_INTERNAL_DELETE_ROUTE) (
  488. IN UINT Segment,
  489. IN PIPX_ROUTE_ENTRY RouteEntry
  490. );
  491. typedef PIPX_ROUTE_ENTRY
  492. (*IPX_INTERNAL_GET_FIRST_ROUTE) (
  493. IN UINT Segment
  494. );
  495. typedef PIPX_ROUTE_ENTRY
  496. (*IPX_INTERNAL_GET_NEXT_ROUTE) (
  497. IN UINT Segment
  498. );
  499. typedef VOID
  500. (*IPX_INTERNAL_INCREMENT_WAN_INACTIVITY) (
  501. #ifdef _PNP_LATER
  502. IN NIC_HANDLE NicHandle
  503. #else
  504. IN USHORT NicId
  505. #endif
  506. );
  507. typedef ULONG
  508. (*IPX_INTERNAL_QUERY_WAN_INACTIVITY) (
  509. #ifdef _PNP_LATER
  510. IN NIC_HANDLE NicHandle
  511. #else
  512. IN USHORT NicId
  513. #endif
  514. );
  515. /*++
  516. Routine Description:
  517. This routine is called by the Kernel Forwarder to open an adapter
  518. Arguments:
  519. AdapterIndex - index of the adapter to open (NICid for now - will change to a struct
  520. with a version number, signature and the NicId
  521. FwdAdapterContext - Forwarder's context
  522. IpxAdapterContext - our context (for now we use the NICid - for pnp will change
  523. this to contain a signature and version #)
  524. Return Value:
  525. STATUS_INVALID_HANDLE if the AdapterIndex handle was invalid
  526. STATUS_ADAPTER_ALREADY_OPENED if the Adapter is being opened a second time
  527. STATUS_SUCCESS
  528. --*/
  529. typedef NTSTATUS
  530. (*IPX_FW_OPEN_ADAPTER) (
  531. IN NIC_HANDLE AdapterIndex,
  532. IN ULONG_PTR FwdAdapterContext,
  533. OUT PNIC_HANDLE IpxAdapterContext
  534. );
  535. /*++
  536. Routine Description:
  537. This routine is called by the Kernel Forwarder to close an adapter
  538. Arguments:
  539. IpxAdapterContext - our context (for now we use the NICid - for pnp will change
  540. this to contain a signature and version#)
  541. Return Value:
  542. STATUS_ADAPTER_ALREADY_CLOSED - if the adapter is being closed a second time
  543. STATUS_SUCCESS
  544. --*/
  545. typedef NTSTATUS
  546. (*IPX_FW_CLOSE_ADAPTER) (
  547. IN NIC_HANDLE IpxAdapterContext
  548. );
  549. /*++
  550. Routine Description:
  551. This routine is called by the Kernel Forwarder to indicate that a pending
  552. internal send to it has completed.
  553. Arguments:
  554. LocalTarget - if Status is OK, this has the local target for the send.
  555. Packet - A pointer to the NDIS_PACKET that we sent.
  556. PacketLength - length of the packet (including the IPX header)
  557. Status - the completion status of the send - STATUS_SUCCESS or STATUS_NETWORK_UNREACHABLE
  558. Return Value:
  559. none.
  560. --*/
  561. typedef VOID
  562. (*IPX_FW_INTERNAL_SEND_COMPLETE) (
  563. IN PIPX_LOCAL_TARGET LocalTarget,
  564. IN PNDIS_PACKET Packet,
  565. IN ULONG PacketLength,
  566. IN NTSTATUS Status
  567. );
  568. //
  569. // Describes a single network.
  570. //
  571. typedef struct _IPX_NIC_DATA {
  572. USHORT NicId;
  573. UCHAR Node[6];
  574. UCHAR Network[4];
  575. IPX_LINE_INFO LineInfo;
  576. NDIS_MEDIUM DeviceType;
  577. ULONG EnableWanRouter;
  578. } IPX_NIC_DATA, * PIPX_NIC_DATA;
  579. //
  580. // Describes all networks.
  581. //
  582. typedef struct _IPX_NIC_INFO_BUFFER {
  583. USHORT NicCount;
  584. USHORT VirtualNicId;
  585. UCHAR VirtualNetwork[4];
  586. IPX_NIC_DATA NicData[1];
  587. } IPX_NIC_INFO_BUFFER, * PIPX_NIC_INFO_BUFFER;
  588. //
  589. // Output from a RIP bind (the actual structure size is
  590. // based on the number of IPX_NIC_DATA elements in the
  591. // final IPX_NIC_INFO_BUFFER structure).
  592. //
  593. typedef struct _IPX_INTERNAL_BIND_RIP_OUTPUT {
  594. USHORT Version;
  595. USHORT MaximumNicCount;
  596. USHORT MacHeaderNeeded;
  597. USHORT IncludedHeaderOffset;
  598. IPX_INTERNAL_SEND SendHandler;
  599. UINT SegmentCount;
  600. KSPIN_LOCK * SegmentLocks;
  601. IPX_INTERNAL_GET_SEGMENT GetSegmentHandler;
  602. IPX_INTERNAL_GET_ROUTE GetRouteHandler;
  603. IPX_INTERNAL_ADD_ROUTE AddRouteHandler;
  604. IPX_INTERNAL_DELETE_ROUTE DeleteRouteHandler;
  605. IPX_INTERNAL_GET_FIRST_ROUTE GetFirstRouteHandler;
  606. IPX_INTERNAL_GET_NEXT_ROUTE GetNextRouteHandler;
  607. IPX_INTERNAL_INCREMENT_WAN_INACTIVITY IncrementWanInactivityHandler;
  608. IPX_INTERNAL_QUERY_WAN_INACTIVITY QueryWanInactivityHandler;
  609. IPX_INTERNAL_TRANSFER_DATA TransferDataHandler;
  610. IPX_FW_OPEN_ADAPTER OpenAdapterHandler;
  611. IPX_FW_CLOSE_ADAPTER CloseAdapterHandler;
  612. IPX_FW_INTERNAL_SEND_COMPLETE InternalSendCompleteHandler;
  613. IPX_NIC_INFO_BUFFER NicInfoBuffer;
  614. } IPX_INTERNAL_BIND_RIP_OUTPUT, * PIPX_INTERNAL_BIND_RIP_OUTPUT;
  615. //
  616. // [FW] Used by the forwarder to fill up the localtarget
  617. //
  618. #ifdef _PNP_LATER
  619. #define NIC_HANDLE_FROM_NIC(_nichandle, _nic) \
  620. _nichandle.NicId = _nic; \
  621. _nichandle.Signature = IPX_BINDING_SIGNATURE; \
  622. if (_nic == 0) { \
  623. _nichandle.Version = 0; \
  624. } else { \
  625. _nichandle.Version = IpxDevice->Bindings[_nic].Version; \
  626. }
  627. #else
  628. #define NIC_HANDLE_FROM_NIC(_nichandle, _nic) \
  629. _nichandle.NicId = (USHORT)_nic;
  630. #endif
  631. //
  632. // VOID
  633. // ADAPTER_CONTEXT_TO_LOCAL_TARGET(
  634. // IN NIC_HANDLE _context;
  635. // IN PIPX_LOCAL_TARGET _localtarget;
  636. // );
  637. //
  638. #define ADAPTER_CONTEXT_TO_LOCAL_TARGET(_context, _localtarget) \
  639. (_localtarget)->NicHandle.NicId = (_context).NicId;
  640. //
  641. // VOID
  642. // CONSTANT_ADAPTER_CONTEXT_TO_LOCAL_TARGET(
  643. // IN NIC_HANDLE _context;
  644. // IN PIPX_LOCAL_TARGET _localtarget;
  645. // );
  646. //
  647. #define CONSTANT_ADAPTER_CONTEXT_TO_LOCAL_TARGET(_context, _localtarget) \
  648. (_localtarget)->NicHandle.NicId = (USHORT)(_context);
  649. //
  650. // [FW] Used to indicate to the Forwarder that a preferred NIC is not given
  651. // in InternalSend
  652. //
  653. #define INVALID_CONTEXT_VALUE 0xffffffff
  654. //
  655. // [FW] This is the value returned (in FindRoute) to IPX from the Forwarder in case of a demand dial Nic.
  656. // On an InternalSend, this is passed up to the FWD, which brings up the line and returns the good LocalTarget
  657. //
  658. #define DEMAND_DIAL_ADAPTER_CONTEXT 0xffffffff
  659. //
  660. // Adapter context used by the FWD to represent a send to the virtual net.
  661. // IPX maps this to the loopback adapter.
  662. //
  663. #define VIRTUAL_NET_ADAPTER_CONTEXT 0x1 //0xfffffffe // -2
  664. //
  665. // Context passed up to the FWD on a loopback send.
  666. //
  667. #define VIRTUAL_NET_FORWARDER_CONTEXT 0x1 // 0xfffffffe // -2
  668. //
  669. // Special NIC id used by NB/SPX to send packets over all NICs.
  670. //
  671. #define ITERATIVE_NIC_ID 0xfffd // -3
  672. #endif // _ISN_BIND_