Source code of Windows XP (NT5)
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.

553 lines
12 KiB

  1. /*++
  2. Copyright (c) 1989-1993 Microsoft Corporation
  3. Module Name:
  4. isnipx.h
  5. Abstract:
  6. This module contains definitions specific to the
  7. IPX module of the ISN transport.
  8. Author:
  9. Adam Barr (adamba) 2-September-1993
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. #ifndef _ISNIPX_
  15. #define _ISNIPX_
  16. #define MAC_HEADER_SIZE ((IPX_MAXIMUM_MAC + 3) & ~3)
  17. #define RIP_PACKET_SIZE ((sizeof(RIP_PACKET) + 3) & ~3)
  18. #define IPX_HEADER_SIZE ((sizeof(IPX_HEADER) + 3) & ~3)
  19. //
  20. // Frame type definitions
  21. //
  22. #define ISN_FRAME_TYPE_ETHERNET_II 0
  23. #define ISN_FRAME_TYPE_802_3 1
  24. #define ISN_FRAME_TYPE_802_2 2
  25. #define ISN_FRAME_TYPE_SNAP 3
  26. #define ISN_FRAME_TYPE_ARCNET 4 // we ignore this
  27. #define ISN_FRAME_TYPE_MAX 4 // of the four standard ones
  28. #define ISN_FRAME_TYPE_AUTO 0xff
  29. //
  30. // This defines the size of the maximum MAC header required
  31. // (token-ring: MAC 14 bytes, RI 18 bytes, LLC 3 bytes, SNAP 5 bytes).
  32. //
  33. #define IPX_MAXIMUM_MAC 40
  34. //
  35. // This is an internal identifier used for RIP query packets.
  36. //
  37. #define IDENTIFIER_RIP_INTERNAL 4
  38. //
  39. // This is an internal identifier used for RIP response packets.
  40. //
  41. #define IDENTIFIER_RIP_RESPONSE 5
  42. //
  43. // This is the total number of "real" identifiers.
  44. //
  45. #define IDENTIFIER_TOTAL 4
  46. //
  47. // Some definitions (in the correct on-the-wire order).
  48. //
  49. #define RIP_PACKET_TYPE 0x01
  50. #define RIP_SOCKET 0x5304
  51. #define RIP_REQUEST 0x0100
  52. #define RIP_RESPONSE 0x0200
  53. #define RIP_DOWN 0x8200 // use high bit to indicate it
  54. #define SAP_PACKET_TYPE 0x04
  55. #define SAP_SOCKET 0x5204
  56. #define SPX_PACKET_TYPE 0x05
  57. #define NB_SOCKET 0x5504
  58. #include <packon.h>
  59. //
  60. // Definition of the IPX header.
  61. //
  62. typedef struct _IPX_HEADER {
  63. USHORT CheckSum;
  64. UCHAR PacketLength[2];
  65. UCHAR TransportControl;
  66. UCHAR PacketType;
  67. UCHAR DestinationNetwork[4];
  68. UCHAR DestinationNode[6];
  69. USHORT DestinationSocket;
  70. UCHAR SourceNetwork[4];
  71. UCHAR SourceNode[6];
  72. USHORT SourceSocket;
  73. } IPX_HEADER, *PIPX_HEADER;
  74. //
  75. // Definition of a RIP network entry.
  76. //
  77. typedef struct _RIP_NETWORK_ENTRY {
  78. ULONG NetworkNumber;
  79. USHORT HopCount;
  80. USHORT TickCount;
  81. } RIP_NETWORK_ENTRY, *PRIP_NETWORK_ENTRY;
  82. //
  83. // Definition of a single entry rip packet.
  84. //
  85. typedef struct _RIP_PACKET {
  86. USHORT Operation;
  87. RIP_NETWORK_ENTRY NetworkEntry;
  88. } RIP_PACKET, *PRIP_PACKET;
  89. #include <packoff.h>
  90. #define IPX_DEVICE_SIGNATURE 0x1401
  91. #define IPX_ADAPTER_SIGNATURE 0x1402
  92. #define IPX_BINDING_SIGNATURE 0x1403
  93. #define IPX_ADDRESS_SIGNATURE 0x1404
  94. #define IPX_ADDRESSFILE_SIGNATURE 0x1405
  95. #define IPX_RT_SIGNATURE 0x1406
  96. #define IPX_FILE_TYPE_CONTROL (ULONG)0x4701 // file is type control
  97. //
  98. // Defined granularity of RIP timeouts in milliseconds
  99. //
  100. #define RIP_GRANULARITY 55
  101. //
  102. // The default number of segments in the RIP table.
  103. //
  104. #define RIP_SEGMENTS 7
  105. //
  106. // Convert a ushort netware order <-> machine order
  107. //
  108. #define REORDER_USHORT(_Ushort) ((((_Ushort) & 0xff00) >> 8) | (((_Ushort) & 0x00ff) << 8))
  109. //
  110. // Convert a ulong netware order <-> machine order
  111. //
  112. #define REORDER_ULONG(_Ulong) \
  113. ((((_Ulong) & 0xff000000) >> 24) | \
  114. (((_Ulong) & 0x00ff0000) >> 8) | \
  115. (((_Ulong) & 0x0000ff00) << 8) | \
  116. (((_Ulong) & 0x000000ff) << 24))
  117. #if DBG
  118. extern ULONG IpxDebug;
  119. extern ULONG IpxMemoryDebug;
  120. #define IPX_MEMORY_LOG_SIZE 128
  121. extern UCHAR IpxDebugMemory[IPX_MEMORY_LOG_SIZE][192];
  122. extern PUCHAR IpxDebugMemoryLoc;
  123. extern PUCHAR IpxDebugMemoryEnd;
  124. VOID
  125. IpxDebugMemoryLog(
  126. IN PUCHAR FormatString,
  127. ...
  128. );
  129. #define IPX_DEBUG(_Flag, _Print) { \
  130. if (IpxDebug & (IPX_DEBUG_ ## _Flag)) { \
  131. DbgPrint ("IPX: "); \
  132. DbgPrint _Print; \
  133. } \
  134. if (IpxMemoryDebug & (IPX_DEBUG_ ## _Flag)) { \
  135. IpxDebugMemoryLog _Print; \
  136. } \
  137. }
  138. #else
  139. #define IPX_DEBUG(_Flag, _Print)
  140. #endif
  141. //
  142. // These definitions are for abstracting IRPs from the
  143. // transport for portability.
  144. //
  145. #if ISN_NT
  146. typedef IRP REQUEST, *PREQUEST;
  147. //
  148. // PREQUEST
  149. // IpxAllocateRequest(
  150. // IN PDEVICE Device,
  151. // IN PIRP Irp
  152. // );
  153. //
  154. // Allocates a request for the system-specific request structure.
  155. //
  156. #define IpxAllocateRequest(_Device,_Irp) \
  157. (_Irp)
  158. //
  159. // BOOLEAN
  160. // IF_NOT_ALLOCATED(
  161. // IN PREQUEST Request
  162. // );
  163. //
  164. // Checks if a request was not successfully allocated.
  165. //
  166. #define IF_NOT_ALLOCATED(_Request) \
  167. if (0)
  168. //
  169. // VOID
  170. // IpxFreeRequest(
  171. // IN PDEVICE Device,
  172. // IN PREQUEST Request
  173. // );
  174. //
  175. // Frees a previously allocated request.
  176. //
  177. #define IpxFreeRequest(_Device,_Request) \
  178. ;
  179. //
  180. // VOID
  181. // MARK_REQUEST_PENDING(
  182. // IN PREQUEST Request
  183. // );
  184. //
  185. // Marks that a request will pend.
  186. //
  187. #define MARK_REQUEST_PENDING(_Request) \
  188. IoMarkIrpPending(_Request)
  189. //
  190. // VOID
  191. // UNMARK_REQUEST_PENDING(
  192. // IN PREQUEST Request
  193. // );
  194. //
  195. // Marks that a request will not pend.
  196. //
  197. #define UNMARK_REQUEST_PENDING(_Request) \
  198. (((IoGetCurrentIrpStackLocation(_Request))->Control) &= ~SL_PENDING_RETURNED)
  199. //
  200. // UCHAR
  201. // REQUEST_MAJOR_FUNCTION
  202. // IN PREQUEST Request
  203. // );
  204. //
  205. // Returns the major function code of a request.
  206. //
  207. #define REQUEST_MAJOR_FUNCTION(_Request) \
  208. ((IoGetCurrentIrpStackLocation(_Request))->MajorFunction)
  209. //
  210. // UCHAR
  211. // REQUEST_MINOR_FUNCTION
  212. // IN PREQUEST Request
  213. // );
  214. //
  215. // Returns the minor function code of a request.
  216. //
  217. #define REQUEST_MINOR_FUNCTION(_Request) \
  218. ((IoGetCurrentIrpStackLocation(_Request))->MinorFunction)
  219. //
  220. // PNDIS_BUFFER
  221. // REQUEST_NDIS_BUFFER
  222. // IN PREQUEST Request
  223. // );
  224. //
  225. // Returns the NDIS buffer chain associated with a request.
  226. //
  227. #define REQUEST_NDIS_BUFFER(_Request) \
  228. ((PNDIS_BUFFER)((_Request)->MdlAddress))
  229. //
  230. // PVOID
  231. // REQUEST_OPEN_CONTEXT(
  232. // IN PREQUEST Request
  233. // );
  234. //
  235. // Gets the context associated with an opened address/connection/control channel.
  236. //
  237. #define REQUEST_OPEN_CONTEXT(_Request) \
  238. (((IoGetCurrentIrpStackLocation(_Request))->FileObject)->FsContext)
  239. //
  240. // PVOID
  241. // REQUEST_OPEN_TYPE(
  242. // IN PREQUEST Request
  243. // );
  244. //
  245. // Gets the type associated with an opened address/connection/control channel.
  246. //
  247. #define REQUEST_OPEN_TYPE(_Request) \
  248. (((IoGetCurrentIrpStackLocation(_Request))->FileObject)->FsContext2)
  249. //
  250. // PFILE_FULL_EA_INFORMATION
  251. // OPEN_REQUEST_EA_INFORMATION(
  252. // IN PREQUEST Request
  253. // );
  254. //
  255. // Returns the EA information associated with an open/close request.
  256. //
  257. #define OPEN_REQUEST_EA_INFORMATION(_Request) \
  258. ((PFILE_FULL_EA_INFORMATION)((_Request)->AssociatedIrp.SystemBuffer))
  259. #define OPEN_REQUEST_EA_LENGTH(_Request) \
  260. (((IoGetCurrentIrpStackLocation(_Request))->Parameters.DeviceIoControl.InputBufferLength))
  261. #define OPEN_REQUEST_RCV_LEN(_Request) \
  262. (((IoGetCurrentIrpStackLocation(_Request))->Parameters.DeviceIoControl.OutputBufferLength))
  263. #define REQUEST_SPECIAL_RECV(_Request) \
  264. (((IoGetCurrentIrpStackLocation(_Request))->Parameters.DeviceIoControl.IoControlCode) == MIPX_RCV_DATAGRAM)
  265. #define REQUEST_SPECIAL_SEND(_Request) \
  266. (((IoGetCurrentIrpStackLocation(_Request))->Parameters.DeviceIoControl.IoControlCode) == MIPX_SEND_DATAGRAM)
  267. #define REQUEST_CODE(_Request) \
  268. ((IoGetCurrentIrpStackLocation(_Request))->Parameters.DeviceIoControl.IoControlCode)
  269. //
  270. // The following value does not clash with TDI_TRANSPORT_ADDRESS_FILE value of
  271. // 0x1
  272. //
  273. #define ROUTER_ADDRESS_FILE 0x4
  274. //
  275. // PTDI_REQUEST_KERNEL
  276. // REQUEST_PARAMETERS(
  277. // IN PREQUEST Request
  278. // );
  279. //
  280. // Obtains a pointer to the parameters of a request.
  281. //
  282. #define REQUEST_PARAMETERS(_Request) \
  283. (&((IoGetCurrentIrpStackLocation(_Request))->Parameters))
  284. //
  285. // VOID
  286. // REQUEST_OPEN_CONTEXT_AND_PARAMS(
  287. // IN PREQUEST Request
  288. // OUT PVOID * OpenContext,
  289. // OUT PTDI_REQUEST_KERNEL * Parameters
  290. // );
  291. //
  292. // Simultaneously returns the open context and the parameters
  293. // for a request (this is an optimization since the send
  294. // datagram code needs them both).
  295. //
  296. #define REQUEST_OPEN_CONTEXT_AND_PARAMS(_Request,_OpenContext,_Parameters) { \
  297. PIO_STACK_LOCATION _IrpSp = IoGetCurrentIrpStackLocation(_Request); \
  298. *(_OpenContext) = _IrpSp->FileObject->FsContext; \
  299. *(_Parameters) = (PTDI_REQUEST_KERNEL)(&_IrpSp->Parameters); \
  300. }
  301. //
  302. // PLIST_ENTRY
  303. // REQUEST_LINKAGE(
  304. // IN PREQUEST Request
  305. // );
  306. //
  307. // Returns a pointer to a linkage field in the request.
  308. //
  309. #define REQUEST_LINKAGE(_Request) \
  310. (&((_Request)->Tail.Overlay.ListEntry))
  311. //
  312. // PREQUEST
  313. // LIST_ENTRY_TO_REQUEST(
  314. // IN PLIST_ENTRY ListEntry
  315. // );
  316. //
  317. // Returns a request given a linkage field in it.
  318. //
  319. #define LIST_ENTRY_TO_REQUEST(_ListEntry) \
  320. ((PREQUEST)(CONTAINING_RECORD(_ListEntry, REQUEST, Tail.Overlay.ListEntry)))
  321. //
  322. // NTSTATUS
  323. // REQUEST_STATUS(
  324. // IN PREQUEST Request
  325. // );
  326. //
  327. // Used to access the status field of a request.
  328. //
  329. #define REQUEST_STATUS(_Request) \
  330. (_Request)->IoStatus.Status
  331. //
  332. // ULONG
  333. // REQUEST_INFORMATION(
  334. // IN PREQUEST Request)
  335. // );
  336. //
  337. // Used to access the information field of a request.
  338. //
  339. #define REQUEST_INFORMATION(_Request) \
  340. (_Request)->IoStatus.Information
  341. //
  342. // VOID
  343. // IpxCompleteRequest(
  344. // IN PREQUEST Request
  345. // );
  346. //
  347. // Completes a request whose status and information fields have
  348. // been filled in.
  349. //
  350. #define IpxCompleteRequest(_Request) \
  351. IoCompleteRequest (_Request, IO_NETWORK_INCREMENT)
  352. #else
  353. //
  354. // These routines must be defined for portability to a VxD.
  355. //
  356. #endif
  357. #define IPX_INCREMENT(_Long, _Lock) InterlockedIncrement(_Long)
  358. #define IPX_DECREMENT(_Long, _Lock) InterlockedDecrement(_Long)
  359. #define IPX_ADD_ULONG(_Pulong, _Ulong, _Lock) InterlockedExchangeAdd(_Pulong, _Ulong)
  360. #define IPX_DEFINE_SYNC_CONTEXT(_SyncContext)
  361. #define IPX_BEGIN_SYNC(_SyncContext)
  362. #define IPX_END_SYNC(_SyncContext)
  363. #define IPX_DEFINE_LOCK_HANDLE(_LockHandle) CTELockHandle _LockHandle;
  364. #define IPX_DEFINE_LOCK_HANDLE_PARAM(_LockHandle) CTELockHandle _LockHandle;
  365. #define IPX_GET_LOCK(_Lock, _LockHandle) \
  366. CTEGetLock(_Lock, _LockHandle)
  367. #define IPX_FREE_LOCK(_Lock, _LockHandle) \
  368. CTEFreeLock(_Lock, _LockHandle)
  369. #define IPX_GET_LOCK1(_Lock, _LockHandle)
  370. #define IPX_FREE_LOCK1(_Lock, _LockHandle)
  371. #define IPX_REMOVE_HEAD_LIST(_Queue, _Lock) ExInterlockedRemoveHeadList(_Queue, _Lock)
  372. #define IPX_LIST_WAS_EMPTY(_Queue, _OldHead) ((_OldHead) == NULL)
  373. #define IPX_INSERT_HEAD_LIST(_Queue, _Entry, _Lock) ExInterlockedInsertHeadList(_Queue, _Entry, _Lock)
  374. #define IPX_INSERT_TAIL_LIST(_Queue, _Entry, _Lock) ExInterlockedInsertTailList(_Queue, _Entry, _Lock)
  375. #define IPX_POP_ENTRY_LIST(_Queue, _Lock) ExInterlockedPopEntrySList(_Queue, _Lock)
  376. #define IPX_PUSH_ENTRY_LIST(_Queue, _Entry, _Lock) ExInterlockedPushEntrySList(_Queue, _Entry, _Lock)
  377. //
  378. // This macro adds a ULONG to a LARGE_INTEGER.
  379. //
  380. #define ADD_TO_LARGE_INTEGER(_LargeInteger,_Ulong) \
  381. ExInterlockedAddLargeStatistic((_LargeInteger),(ULONG)(_Ulong))
  382. #define IPX_DEBUG_DEVICE 0x00000001
  383. #define IPX_DEBUG_ADAPTER 0x00000002
  384. #define IPX_DEBUG_ADDRESS 0x00000004
  385. #define IPX_DEBUG_SEND 0x00000008
  386. #define IPX_DEBUG_NDIS 0x00000010
  387. #define IPX_DEBUG_RECEIVE 0x00000020
  388. #define IPX_DEBUG_CONFIG 0x00000040
  389. #define IPX_DEBUG_PACKET 0x00000080
  390. #define IPX_DEBUG_RIP 0x00000100
  391. #define IPX_DEBUG_BIND 0x00000200
  392. #define IPX_DEBUG_ACTION 0x00000400
  393. #define IPX_DEBUG_BAD_PACKET 0x00000800
  394. #define IPX_DEBUG_SOURCE_ROUTE 0x00001000
  395. #define IPX_DEBUG_WAN 0x00002000
  396. #define IPX_DEBUG_AUTO_DETECT 0x00004000
  397. #define IPX_DEBUG_PNP 0x00008000
  398. #define IPX_DEBUG_LOOPB 0x00010000
  399. #define IPX_DEBUG_TEMP 0x00020000
  400. #endif
  401.