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.

465 lines
17 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. nbfconst.h
  5. Abstract:
  6. This header file defines manifest constants for the NT NBF transport
  7. provider. It is included by nbf.h.
  8. Author:
  9. Stephen E. Jones (stevej) 25-Oct-1989
  10. Revision History:
  11. David Beaver (dbeaver) 24-Sep-1990
  12. Remove pc586- and PDI-specific support. Add NDIS support. Note
  13. changes to be made here if MAC dependence of NDIS changes. (search
  14. for (PDI)
  15. --*/
  16. #ifndef _NBFCONST_
  17. #define _NBFCONST_
  18. //
  19. // DEBUGGING SUPPORT. DBG is a macro that is turned on at compile time
  20. // to enable debugging code in the system. If this is turned on, then
  21. // you can use the IF_NBFDBG(flags) macro in the NBF code to selectively
  22. // enable a piece of debugging code in the transport. This macro tests
  23. // NbfDebug, a global ULONG defined in NBFDRVR.C.
  24. //
  25. #if DBG
  26. #define NBF_DEBUG_SENDENG 0x00000001 // sendeng.c debugging.
  27. #define NBF_DEBUG_RCVENG 0x00000002 // rcveng.c debugging.
  28. #define NBF_DEBUG_IFRAMES 0x00000004 // displays sent/rec'd iframes.
  29. #define NBF_DEBUG_UFRAMES 0x00000008 // displays sent/rec'd uframes.
  30. #define NBF_DEBUG_DLCFRAMES 0x00000010 // displays sent/rec'd dlc frames.
  31. #define NBF_DEBUG_ADDRESS 0x00000020 // address.c debugging.
  32. #define NBF_DEBUG_CONNECT 0x00000040 // connect.c debugging.
  33. #define NBF_DEBUG_CONNOBJ 0x00000080 // connobj.c debugging.
  34. #define NBF_DEBUG_DEVCTX 0x00000100 // devctx.c debugging.
  35. #define NBF_DEBUG_DLC 0x00000200 // dlc.c data link engine debugging.
  36. #define NBF_DEBUG_PKTLOG 0x00000400 // used to debug packet logging
  37. #define NBF_DEBUG_PNP 0x00000800 // used in debugging PnP functions
  38. #define NBF_DEBUG_FRAMECON 0x00001000 // framecon.c debugging.
  39. #define NBF_DEBUG_FRAMESND 0x00002000 // framesnd.c debugging.
  40. #define NBF_DEBUG_DYNAMIC 0x00004000 // dynamic allocation debugging.
  41. #define NBF_DEBUG_LINK 0x00008000 // link.c debugging.
  42. #define NBF_DEBUG_RESOURCE 0x00010000 // resource allocation debugging.
  43. #define NBF_DEBUG_DISPATCH 0x00020000 // IRP request dispatching.
  44. #define NBF_DEBUG_PACKET 0x00040000 // packet.c debugging.
  45. #define NBF_DEBUG_REQUEST 0x00080000 // request.c debugging.
  46. #define NBF_DEBUG_TIMER 0x00100000 // timer.c debugging.
  47. #define NBF_DEBUG_DATAGRAMS 0x00200000 // datagram send/receive
  48. #define NBF_DEBUG_REGISTRY 0x00400000 // registry access.
  49. #define NBF_DEBUG_NDIS 0x00800000 // NDIS related information
  50. #define NBF_DEBUG_LINKTREE 0x01000000 // Link splay tree debugging
  51. #define NBF_DEBUG_TEARDOWN 0x02000000 // link/connection teardown info
  52. #define NBF_DEBUG_REFCOUNTS 0x04000000 // link/connection ref/deref information
  53. #define NBF_DEBUG_IRP 0x08000000 // irp completion debugging
  54. #define NBF_DEBUG_SETUP 0x10000000 // debug session setup
  55. //
  56. // past here are debug things that are really frequent; don't use them
  57. // unless you want LOTS of output
  58. //
  59. #define NBF_DEBUG_TIMERDPC 0x20000000 // the timer DPC
  60. #define NBF_DEBUG_PKTCONTENTS 0x40000000 // dump packet contents in dbg
  61. #define NBF_DEBUG_TRACKTDI 0x80000000 // store tdi info when set
  62. extern ULONG NbfDebug; // in NBFDRVR.C.
  63. extern BOOLEAN NbfDisconnectDebug; // in NBFDRVR.C.
  64. #define TRACK_TDI_LIMIT 25
  65. #define TRACK_TDI_CAPTURE 36 // chosen to make debug line up nice
  66. typedef struct {
  67. PVOID Request;
  68. PIRP Irp;
  69. PVOID Connection;
  70. UCHAR Contents[TRACK_TDI_CAPTURE];
  71. } NBF_SEND;
  72. typedef struct {
  73. PVOID Request;
  74. PIRP Irp;
  75. NTSTATUS Status;
  76. PVOID NothingYet;
  77. } NBF_SEND_COMPLETE;
  78. typedef struct {
  79. PVOID Request;
  80. PIRP Irp;
  81. PVOID Connection;
  82. PVOID NothingYet;
  83. } NBF_RECEIVE;
  84. typedef struct {
  85. PVOID Request;
  86. PIRP Irp;
  87. NTSTATUS Status;
  88. UCHAR Contents[TRACK_TDI_CAPTURE];
  89. } NBF_RECEIVE_COMPLETE;
  90. extern NBF_SEND NbfSends[TRACK_TDI_LIMIT+1];
  91. extern LONG NbfSendsNext;
  92. extern NBF_SEND_COMPLETE NbfCompletedSends[TRACK_TDI_LIMIT+1];
  93. extern LONG NbfCompletedSendsNext;
  94. extern NBF_RECEIVE NbfReceives[TRACK_TDI_LIMIT+1];
  95. extern LONG NbfReceivesNext;
  96. extern NBF_RECEIVE_COMPLETE NbfCompletedReceives[TRACK_TDI_LIMIT+1];
  97. extern LONG NbfCompletedReceivesNext;
  98. #endif
  99. //
  100. // some convenient constants used for timing. All values are in clock ticks.
  101. //
  102. #define MICROSECONDS 10
  103. #define MILLISECONDS 10000 // MICROSECONDS*1000
  104. #define SECONDS 10000000 // MILLISECONDS*1000
  105. //
  106. // temporary things used by nbf that are caused by the change-over from
  107. // (never implimented) PDI support to NDIS support. They may be removed pending
  108. // resolution of NDIS issues about MAC support.
  109. //
  110. #define PDI_SOURCE_ROUTE 0x00000002 // source routing field is specified.
  111. #define PDI_HARDWARE_ADDRESS 0x00000004 // hardware address field is specified.
  112. #define PDI_TRUNCATED 0x00000001 // PSDU was truncated.
  113. #define PDI_FRAGMENT 0x00000002 // PSDU was fragmented.
  114. #define PDI_BROADCAST 0x00000004 // PSDU was broadcast.
  115. #define PDI_MULTICAST 0x00000008 // PSDU was multicast/functional.
  116. #define PDI_SOURCE_ROUTING 0x00000010 // PSDU contained source routing information.
  117. //
  118. // MAJOR PROTOCOL IDENTIFIERS THAT CHARACTERIZE THIS DRIVER.
  119. //
  120. #define NBF_DEVICE_NAME L"\\Device\\Nbf"// name of our driver.
  121. #define NBF_NAME L"Nbf" // name for protocol chars.
  122. #define DSAP_NETBIOS_OVER_LLC 0xf0 // NETBEUI always has DSAP 0xf0.
  123. #define PSAP_LLC 0 // LLC always runs over PSAP 0.
  124. #define MAX_SOURCE_ROUTE_LENGTH 32 // max. bytes of SR. info.
  125. #define MAX_NETWORK_NAME_LENGTH 128 // # bytes in netname in TP_ADDRESS.
  126. #define MAX_USER_PACKET_DATA 1500 // max. user bytes per DFM/DOL.
  127. #define NBF_FILE_TYPE_CONTROL (ULONG)0x4701 // file is type control
  128. //
  129. // MAJOR CONFIGURATION PARAMETERS THAT WILL BE MOVED TO THE INIT-LARGE_INTEGER
  130. // CONFIGURATION MANAGER.
  131. //
  132. #define MAX_REQUESTS 30
  133. #define MAX_UI_FRAMES 25
  134. #define MAX_SEND_PACKETS 40
  135. #define MAX_RECEIVE_PACKETS 30
  136. #define MAX_RECEIVE_BUFFERS 15
  137. #define MAX_LINKS 10
  138. #define MAX_CONNECTIONS 10
  139. #define MAX_ADDRESSFILES 10
  140. #define MAX_ADDRESSES 10
  141. #define MIN_UI_FRAMES 5 // + one per address + one per connection
  142. #define MIN_SEND_PACKETS 20 // + one per link + one per connection
  143. #define MIN_RECEIVE_PACKETS 10 // + one per link + one per address
  144. #define MIN_RECEIVE_BUFFERS 5 // + one per address
  145. #define SEND_PACKET_RESERVED_LENGTH (sizeof (SEND_PACKET_TAG))
  146. #define RECEIVE_PACKET_RESERVED_LENGTH (sizeof (RECEIVE_PACKET_TAG))
  147. #define ETHERNET_HEADER_SIZE 14 // used for current NDIS compliance
  148. #define ETHERNET_PACKET_SIZE 1514
  149. #define MAX_DEFERRED_TRAVERSES 6 // number of times we can go through
  150. // the deferred operations queue and
  151. // not do anything without causing an
  152. // error indication
  153. //
  154. // NETBIOS PROTOCOL CONSTANTS.
  155. //
  156. #define NETBIOS_NAME_LENGTH 16
  157. #define NETBIOS_SESSION_LIMIT 254 // max # of sessions/link. (abs limit is 254)
  158. #define NAME_QUERY_RETRIES 3 // 2 retrie(s), plus the first one.
  159. #define ADD_NAME_QUERY_RETRIES 3 // 1 retrie(s) plus the first one.
  160. #define WAN_NAME_QUERY_RETRIES 5 // for NdisMediumWan only.
  161. #define NAME_QUERY_TIMEOUT (500*MILLISECONDS)
  162. #define ADD_NAME_QUERY_TIMEOUT (500*MILLISECONDS)
  163. //
  164. // DATA LINK PROTOCOL CONSTANTS.
  165. //
  166. // There are two timers, short and long. T1, T2, and the purge
  167. // timer are run off of the short timer, Ti and the adaptive timer
  168. // is run off of the long one.
  169. //
  170. #define SHORT_TIMER_DELTA (50*MILLISECONDS)
  171. #define LONG_TIMER_DELTA (1*SECONDS)
  172. #define DLC_MINIMUM_T1 (400 * MILLISECONDS)
  173. #define DLC_DEFAULT_T1 (600 * MILLISECONDS)
  174. #define DLC_DEFAULT_T2 (150 * MILLISECONDS)
  175. #define DLC_DEFAULT_TI (30 * SECONDS)
  176. #define DLC_RETRIES (8) // number of poll retries at LLC level.
  177. #define DLC_RETRANSMIT_THRESHOLD (10) // up to n retransmissions acceptable.
  178. #define DLC_WINDOW_LIMIT (10) // incr. to 127 when packet pool expanded.
  179. #define DLC_TIMER_ACCURACY 8 // << between BaseT1Timeout and CurrentT1Timeout
  180. #define TIMER_ADAPTIVE_TICKS ((DLC_DEFAULT_T1*60)/LONG_TIMER_DELTA) // time between adaptive runs.
  181. #define TIMER_PURGE_TICKS ((DLC_DEFAULT_T1*10)/SHORT_TIMER_DELTA) // time between adaptive purges.
  182. //
  183. // TDI defined timeouts
  184. //
  185. #define TDI_TIMEOUT_SEND 60L // sends go 120 seconds
  186. #define TDI_TIMEOUT_RECEIVE 0L // receives
  187. #define TDI_TIMEOUT_CONNECT 60L
  188. #define TDI_TIMEOUT_LISTEN 0L // listens default to never.
  189. #define TDI_TIMEOUT_DISCONNECT 60L // should be 30
  190. #define TDI_TIMEOUT_NAME_REGISTRATION 60L
  191. //
  192. // GENERAL CAPABILITIES STATEMENTS THAT CANNOT CHANGE.
  193. //
  194. #define NBF_MAX_TSDU_SIZE 65535 // maximum TSDU size supported by NetBIOS.
  195. #define NBF_MAX_DATAGRAM_SIZE 512 // maximum Datagram size supported by NetBIOS.
  196. #define NBF_MAX_CONNECTION_USER_DATA 0 // no user data supported on connect.
  197. #define NBF_SERVICE_FLAGS ( \
  198. TDI_SERVICE_FORCE_ACCESS_CHECK | \
  199. TDI_SERVICE_CONNECTION_MODE | \
  200. TDI_SERVICE_CONNECTIONLESS_MODE | \
  201. TDI_SERVICE_MESSAGE_MODE | \
  202. TDI_SERVICE_ERROR_FREE_DELIVERY | \
  203. TDI_SERVICE_BROADCAST_SUPPORTED | \
  204. TDI_SERVICE_MULTICAST_SUPPORTED | \
  205. TDI_SERVICE_DELAYED_ACCEPTANCE )
  206. #define NBF_MIN_LOOKAHEAD_DATA 256 // minimum guaranteed lookahead data.
  207. #define NBF_MAX_LOOKAHEAD_DATA 256 // maximum guaranteed lookahead data.
  208. #define NBF_MAX_LOOPBACK_LOOKAHEAD 192 // how much is copied over for loopback
  209. //
  210. // Number of TDI resources that we report.
  211. //
  212. #define NBF_TDI_RESOURCES 9
  213. //
  214. // NetBIOS name types used in the NetBIOS Frames Protocol Connectionless PDUs.
  215. //
  216. #define NETBIOS_NAME_TYPE_UNIQUE 0x00 // name is unique on the network.
  217. #define NETBIOS_NAME_TYPE_GROUP 0x01 // name is a group name.
  218. #define NETBIOS_NAME_TYPE_EITHER 0x02 // used in NbfMatchNetbiosAddress
  219. //
  220. // STATUS_QUERY request types. If the sender is following pre-2.1 protocol,
  221. // then a simple request-response exchange is performed. Later versions
  222. // store the "total number of names received so far" in the request type
  223. // field, except for the first request, which must contain a 1 in this field.
  224. //
  225. #define STATUS_QUERY_REQUEST_TYPE_PRE21 0x00 // request is 1.x or 2.0.
  226. #define STATUS_QUERY_REQUEST_TYPE_FIRST 0x01 // first request, 2.1 or above.
  227. //
  228. // If the LocalSessionNumber field contains a 0, then the request is really
  229. // a FIND.NAME. If the field is non-zero, then it is the local session
  230. // number that will be provided in all connection-oriented headers thereafter.
  231. //
  232. #define NAME_QUERY_LSN_FIND_NAME 0x00 // LSN for FIND.NAME request.
  233. //
  234. // NAME_RECOGNIZED LocalSessionNumber status values. If the connection
  235. // request was rejected, then one of the following values is placed in
  236. // the LocalSessionNumber field. NAME_RECOGNIZED can also be used as a
  237. // FIND.NAME response, in which case the NO_LISTENS status is overloaded
  238. // to also mean a FIND.NAME.
  239. //
  240. #define NAME_RECOGNIZED_LSN_NO_LISTENS 0x00 // no listens available.
  241. #define NAME_RECOGNIZED_LSN_FIND_NAME 0x00 // this is a find name response.
  242. #define NAME_RECOGNIZED_LSN_NO_RESOURCE 0xff // listen available, but no resources.
  243. //
  244. // STATUS_RESPONSE response types. If the sender is following pre-2.1
  245. // protocol, then a simple request-response exchange is performed. Later
  246. // versions store the "total number of names sent so far" in the request
  247. // type field. This value is cumulative, and includes the count of names
  248. // sent with the current response, as well as from previous responses.
  249. //
  250. #define STATUS_RESPONSE_PRE21 0x00 // request is 1.x or 2.0.
  251. #define STATUS_RESPONSE_FIRST 0x01 // first request, 2.1 or above.
  252. //
  253. // DATA_FIRST_MIDDLE option bitflags.
  254. //
  255. #define DFM_OPTIONS_RECEIVE_CONTINUE 0x01 // RECEIVE_CONTINUE requested.
  256. #define DFM_OPTIONS_NO_ACK 0x02 // no DATA_ACK frame expected.
  257. #define DFM_OPTIONS_RESYNCH 0x04 // set resynch indicator/this frame.
  258. #define DFM_OPTIONS_ACK_INCLUDED 0x08 // piggyback ack included.
  259. //
  260. // DATA_ONLY_LAST option bitflags.
  261. //
  262. #define DOL_OPTIONS_RESYNCH 0x01 // set resynch indicator/this frame.
  263. #define DOL_OPTIONS_NO_ACK 0x02 // no DATA_ACK frame expected.
  264. #define DOL_OPTIONS_ACK_W_DATA_ALLOWED 0x04 // piggyback ack allowed.
  265. #define DOL_OPTIONS_ACK_INCLUDED 0x08 // piggyback ack included.
  266. //
  267. // SESSION_CONFIRM option bitflags.
  268. //
  269. #define SESSION_CONFIRM_OPTIONS_20 0x01 // set if NETBIOS 2.0 or above.
  270. #define SESSION_CONFIRM_NO_ACK 0x80 // set if NO.ACK protocol supported.
  271. //
  272. // SESSION_END reason codes.
  273. //
  274. #define SESSION_END_REASON_HANGUP 0x0000 // normal termination via HANGUP.
  275. #define SESSION_END_REASON_ABEND 0x0001 // abnormal session termination.
  276. //
  277. // SESSION_INITIALIZE option bitflags.
  278. //
  279. #define SESSION_INIT_OPTIONS_20 0x01 // set if NETBIOS 2.0 or above.
  280. #define SESSION_INIT_OPTIONS_LF 0x0E // Maximum largest frame value
  281. #define SESSION_INIT_NO_ACK 0x80 // set if NO.ACK protocol supported.
  282. //
  283. // NO_RECEIVE option bitflags.
  284. //
  285. #define NO_RECEIVE_PARTIAL_NO_ACK 0x02 // NO.ACK data partially received.
  286. //
  287. // Resource IDs for query and error logging.
  288. //
  289. #define LINK_RESOURCE_ID 11
  290. #define ADDRESS_RESOURCE_ID 12
  291. #define ADDRESS_FILE_RESOURCE_ID 13
  292. #define CONNECTION_RESOURCE_ID 14
  293. #define REQUEST_RESOURCE_ID 15
  294. #define UI_FRAME_RESOURCE_ID 21
  295. #define PACKET_RESOURCE_ID 22
  296. #define RECEIVE_PACKET_RESOURCE_ID 23
  297. #define RECEIVE_BUFFER_RESOURCE_ID 24
  298. //
  299. // memory management additions
  300. //
  301. //
  302. // Fake IOCTLs used for kernel mode testing.
  303. //
  304. #define IOCTL_NBF_BASE FILE_DEVICE_TRANSPORT
  305. #define _NBF_CONTROL_CODE(request,method) \
  306. ((IOCTL_NBF_BASE)<<16 | (request<<2) | method)
  307. #define IOCTL_TDI_SEND_TEST _NBF_CONTROL_CODE(26,0)
  308. #define IOCTL_TDI_RECEIVE_TEST _NBF_CONTROL_CODE(27,0)
  309. #define IOCTL_TDI_SERVER_TEST _NBF_CONTROL_CODE(28,0)
  310. //
  311. // More debugging stuff
  312. //
  313. #define NBF_REQUEST_SIGNATURE ((CSHORT)0x4702)
  314. #define NBF_LINK_SIGNATURE ((CSHORT)0x4703)
  315. #define NBF_CONNECTION_SIGNATURE ((CSHORT)0x4704)
  316. #define NBF_ADDRESSFILE_SIGNATURE ((CSHORT)0x4705)
  317. #define NBF_ADDRESS_SIGNATURE ((CSHORT)0x4706)
  318. #define NBF_DEVICE_CONTEXT_SIGNATURE ((CSHORT)0x4707)
  319. #define NBF_PACKET_SIGNATURE ((CSHORT)0x4708)
  320. #if DBG
  321. extern PVOID * NbfConnectionTable;
  322. extern PVOID * NbfRequestTable;
  323. extern PVOID * NbfUiFrameTable;
  324. extern PVOID * NbfSendPacketTable;
  325. extern PVOID * NbfLinkTable;
  326. extern PVOID * NbfAddressFileTable;
  327. extern PVOID * NbfAddressTable;
  328. #endif
  329. //
  330. // Tags used in Memory Debugging
  331. //
  332. #define NBF_MEM_TAG_GENERAL_USE ' FBN'
  333. #define NBF_MEM_TAG_TP_ADDRESS 'aFBN'
  334. #define NBF_MEM_TAG_RCV_BUFFER 'bFBN'
  335. #define NBF_MEM_TAG_TP_CONNECTION 'cFBN'
  336. #define NBF_MEM_TAG_POOL_DESC 'dFBN'
  337. #define NBF_MEM_TAG_DEVICE_EXPORT 'eFBN'
  338. #define NBF_MEM_TAG_TP_ADDRESS_FILE 'fFBN'
  339. #define NBF_MEM_TAG_REGISTRY_PATH 'gFBN'
  340. #define NBF_MEM_TAG_TDI_CONNECTION_INFO 'iFBN'
  341. #define NBF_MEM_TAG_LOOPBACK_BUFFER 'kFBN'
  342. #define NBF_MEM_TAG_TP_LINK 'lFBN'
  343. #define NBF_MEM_TAG_NETBIOS_NAME 'nFBN'
  344. #define NBF_MEM_TAG_CONFIG_DATA 'oFBN'
  345. #define NBF_MEM_TAG_TP_PACKET 'pFBN'
  346. #define NBF_MEM_TAG_TDI_QUERY_BUFFER 'qFBN'
  347. #define NBF_MEM_TAG_TP_REQUEST 'rFBN'
  348. #define NBF_MEM_TAG_TDI_PROVIDER_STATS 'sFBN'
  349. #define NBF_MEM_TAG_CONNECTION_TABLE 'tFBN'
  350. #define NBF_MEM_TAG_TP_UI_FRAME 'uFBN'
  351. #define NBF_MEM_TAG_WORK_ITEM 'wFBN'
  352. #define NBF_MEM_TAG_DEVICE_PDO 'zFBN'
  353. #endif // _NBFCONST_
  354.