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.

934 lines
36 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. tdi.h
  5. Abstract:
  6. This header file contains interface definitions for NT transport
  7. providers. This interface is documented in the NT Transport
  8. Driver Interface (TDI) Specification, Version 2.
  9. Revision History:
  10. --*/
  11. //
  12. // Include the types which are common to TDI and other network users
  13. //
  14. #ifndef _TDI_USER_
  15. #define _TDI_USER_
  16. #include <nettypes.h>
  17. #include <ntddtdi.h>
  18. //
  19. // Include Transport driver interface definitions
  20. // All of the following have two definitions; ones that correspond exactly to
  21. // the TDI spec, and those that correspond to the NT coding standards. They
  22. // should be equivalent.
  23. //
  24. typedef LONG TDI_STATUS;
  25. typedef PVOID CONNECTION_CONTEXT; // connection context
  26. //
  27. // Basic type used to represent an address at the transport level. There may
  28. // be many addresses represented in a single address structure. If there are
  29. // multiple addresses, a given provider must understand all of them or it can
  30. // use none of them. Note that it is acceptible for the provider to not know
  31. // how to use the address, as long as it knows the address type. Thus, a
  32. // TCP/IP NetBIOS provider may know both NetBIOS and TCP/IP addresses, but
  33. // use only the NetBIOS address; the TCP/IP address would (likely) be passed on
  34. // to the TCP/IP provider.
  35. //
  36. typedef UNALIGNED struct _TA_ADDRESS {
  37. USHORT AddressLength; // length in bytes of Address[] in this
  38. USHORT AddressType; // type of this address
  39. UCHAR Address[1]; // actually AddressLength bytes long
  40. } TA_ADDRESS, *PTA_ADDRESS;
  41. typedef struct _TRANSPORT_ADDRESS {
  42. LONG TAAddressCount; // number of addresses following
  43. TA_ADDRESS Address[1]; // actually TAAddressCount elements long
  44. } TRANSPORT_ADDRESS, *PTRANSPORT_ADDRESS;
  45. //
  46. // define some names for the EAs so people don't have to make them up.
  47. //
  48. #define TdiTransportAddress "TransportAddress"
  49. #define TdiConnectionContext "ConnectionContext"
  50. #define TDI_TRANSPORT_ADDRESS_LENGTH (sizeof (TdiTransportAddress) - 1)
  51. #define TDI_CONNECTION_CONTEXT_LENGTH (sizeof (TdiConnectionContext) - 1)
  52. //
  53. // Known Address types
  54. //
  55. #define TDI_ADDRESS_TYPE_UNSPEC ((USHORT)0) // unspecified
  56. #define TDI_ADDRESS_TYPE_UNIX ((USHORT)1) // local to host (pipes, portals)
  57. #define TDI_ADDRESS_TYPE_IP ((USHORT)2) // internetwork: UDP, TCP, etc.
  58. #define TDI_ADDRESS_TYPE_IMPLINK ((USHORT)3) // arpanet imp addresses
  59. #define TDI_ADDRESS_TYPE_PUP ((USHORT)4) // pup protocols: e.g. BSP
  60. #define TDI_ADDRESS_TYPE_CHAOS ((USHORT)5) // mit CHAOS protocols
  61. #define TDI_ADDRESS_TYPE_NS ((USHORT)6) // XEROX NS protocols
  62. #define TDI_ADDRESS_TYPE_IPX ((USHORT)6) // Netware IPX
  63. #define TDI_ADDRESS_TYPE_NBS ((USHORT)7) // nbs protocols
  64. #define TDI_ADDRESS_TYPE_ECMA ((USHORT)8) // european computer manufacturers
  65. #define TDI_ADDRESS_TYPE_DATAKIT ((USHORT)9) // datakit protocols
  66. #define TDI_ADDRESS_TYPE_CCITT ((USHORT)10) // CCITT protocols, X.25 etc
  67. #define TDI_ADDRESS_TYPE_SNA ((USHORT)11) // IBM SNA
  68. #define TDI_ADDRESS_TYPE_DECnet ((USHORT)12) // DECnet
  69. #define TDI_ADDRESS_TYPE_DLI ((USHORT)13) // Direct data link interface
  70. #define TDI_ADDRESS_TYPE_LAT ((USHORT)14) // LAT
  71. #define TDI_ADDRESS_TYPE_HYLINK ((USHORT)15) // NSC Hyperchannel
  72. #define TDI_ADDRESS_TYPE_APPLETALK ((USHORT)16) // AppleTalk
  73. #define TDI_ADDRESS_TYPE_NETBIOS ((USHORT)17) // Netbios Addresses
  74. #define TDI_ADDRESS_TYPE_8022 ((USHORT)18) //
  75. #define TDI_ADDRESS_TYPE_OSI_TSAP ((USHORT)19) //
  76. #define TDI_ADDRESS_TYPE_NETONE ((USHORT)20) // for WzMail
  77. #define TDI_ADDRESS_TYPE_VNS ((USHORT)21) // Banyan VINES IP
  78. #define TDI_ADDRESS_TYPE_NETBIOS_EX ((USHORT)22) // NETBIOS address extensions
  79. #define TDI_ADDRESS_TYPE_IP6 ((USHORT)23) // IP version 6
  80. #define TDI_ADDRESS_TYPE_NETBIOS_UNICODE_EX ((USHORT)24) // WCHAR Netbios address
  81. //
  82. // Definition of address structures. These need to be packed
  83. // and misaligned where necessary.
  84. //
  85. #include <packon.h>
  86. //
  87. // Unicode NetBIOS
  88. //
  89. enum eNameBufferType {
  90. NBT_READONLY = 0, // default
  91. NBT_WRITEONLY,
  92. NBT_READWRITE,
  93. NBT_WRITTEN
  94. };
  95. typedef UNALIGNED struct _TDI_ADDRESS_NETBIOS_UNICODE_EX {
  96. USHORT NetbiosNameType;
  97. enum eNameBufferType NameBufferType;
  98. UNICODE_STRING EndpointName; // Buffer should point to EndpointBuffer
  99. UNICODE_STRING RemoteName; // Buffer should point to RemoteNameBuffer
  100. WCHAR EndpointBuffer[17]; // UNICODE
  101. WCHAR RemoteNameBuffer[1]; // UNICODE
  102. } TDI_ADDRESS_NETBIOS_UNICODE_EX, *PTDI_ADDRESS_NETBIOS_UNICODE_EX;
  103. typedef UNALIGNED struct _TA_ADDRESS_NETBIOS_UNICODE_EX {
  104. LONG TAAddressCount;
  105. struct _AddrNetbiosWCharEx {
  106. USHORT AddressLength; // length in bytes of this address == ??
  107. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_NETBIOS_WCHAR_EX
  108. TDI_ADDRESS_NETBIOS_UNICODE_EX Address[1];
  109. } Address [1];
  110. } TA_NETBIOS_UNICODE_EX_ADDRESS, *PTA_NETBIOS_UNICODE_EX_ADDRESS;
  111. //
  112. // NetBIOS
  113. //
  114. typedef UNALIGNED struct _TDI_ADDRESS_NETBIOS {
  115. USHORT NetbiosNameType;
  116. UCHAR NetbiosName[16];
  117. } TDI_ADDRESS_NETBIOS, *PTDI_ADDRESS_NETBIOS;
  118. #define TDI_ADDRESS_NETBIOS_TYPE_UNIQUE ((USHORT)0x0000)
  119. #define TDI_ADDRESS_NETBIOS_TYPE_GROUP ((USHORT)0x0001)
  120. #define TDI_ADDRESS_NETBIOS_TYPE_QUICK_UNIQUE ((USHORT)0x0002)
  121. #define TDI_ADDRESS_NETBIOS_TYPE_QUICK_GROUP ((USHORT)0x0003)
  122. #define TDI_ADDRESS_LENGTH_NETBIOS sizeof (TDI_ADDRESS_NETBIOS)
  123. //
  124. // NETBIOS Extended address
  125. //
  126. typedef struct _TDI_ADDRESS_NETBIOS_EX {
  127. UCHAR EndpointName[16]; // the called name to be used in NETBT session setup
  128. TDI_ADDRESS_NETBIOS NetbiosAddress;
  129. } TDI_ADDRESS_NETBIOS_EX, *PTDI_ADDRESS_NETBIOS_EX;
  130. #define TDI_ADDRESS_LENGTH_NETBIOS_EX sizeof(TDI_ADDRESS_NETBIOS_EX)
  131. //
  132. // Xns address for UB
  133. //
  134. typedef struct _TDI_ADDRESS_NETONE {
  135. USHORT NetoneNameType;
  136. UCHAR NetoneName[20];
  137. } TDI_ADDRESS_NETONE, *PTDI_ADDRESS_NETONE;
  138. #define TDI_ADDRESS_NETONE_TYPE_UNIQUE ((USHORT)0x0000)
  139. #define TDI_ADDRESS_NETONE_TYPE_ROTORED ((USHORT)0x0001)
  140. #define TDI_ADDRESS_LENGTH_NETONE sizeof (TDI_ADDRESS_NETONE)
  141. //
  142. // AppleTalk
  143. //
  144. typedef struct _TDI_ADDRESS_APPLETALK {
  145. USHORT Network;
  146. UCHAR Node;
  147. UCHAR Socket;
  148. } TDI_ADDRESS_APPLETALK, *PTDI_ADDRESS_APPLETALK;
  149. #define TDI_ADDRESS_LENGTH_APPLETALK sizeof (TDI_ADDRESS_APPLETALK)
  150. //
  151. // 802.2 MAC addresses
  152. //
  153. typedef struct _TDI_ADDRESS_8022 {
  154. UCHAR MACAddress[6];
  155. } TDI_ADDRESS_8022, *PTDI_ADDRESS_8022;
  156. #define TDI_ADDRESS_LENGTH_8022 sizeof (TDI_ADDRESS_8022);
  157. //
  158. // IP address
  159. //
  160. typedef struct _TDI_ADDRESS_IP {
  161. USHORT sin_port;
  162. ULONG in_addr;
  163. UCHAR sin_zero[8];
  164. } TDI_ADDRESS_IP, *PTDI_ADDRESS_IP;
  165. #define TDI_ADDRESS_LENGTH_IP sizeof (TDI_ADDRESS_IP)
  166. //
  167. // IPv6 address
  168. //
  169. typedef struct _TDI_ADDRESS_IP6 {
  170. USHORT sin6_port;
  171. ULONG sin6_flowinfo;
  172. USHORT sin6_addr[8];
  173. ULONG sin6_scope_id;
  174. } TDI_ADDRESS_IP6, *PTDI_ADDRESS_IP6;
  175. #define TDI_ADDRESS_LENGTH_IP6 sizeof (TDI_ADDRESS_IP6)
  176. //
  177. // IPX address
  178. //
  179. typedef struct _TDI_ADDRESS_IPX {
  180. ULONG NetworkAddress;
  181. UCHAR NodeAddress[6];
  182. USHORT Socket;
  183. } TDI_ADDRESS_IPX, *PTDI_ADDRESS_IPX;
  184. #define TDI_ADDRESS_LENGTH_IPX sizeof (TDI_ADDRESS_IPX)
  185. //
  186. // XNS address (same as IPX)
  187. //
  188. typedef struct _TDI_ADDRESS_NS {
  189. ULONG NetworkAddress;
  190. UCHAR NodeAddress[6];
  191. USHORT Socket;
  192. } TDI_ADDRESS_NS, *PTDI_ADDRESS_NS;
  193. #define TDI_ADDRESS_LENGTH_NS sizeof (TDI_ADDRESS_NS)
  194. //
  195. // Banyan VINES IP address
  196. //
  197. typedef struct _TDI_ADDRESS_VNS {
  198. UCHAR net_address[4]; // network address (static)
  199. UCHAR subnet_addr[2]; // subnet address (dynamic)
  200. UCHAR port[2];
  201. UCHAR hops; // # hops for broadcasts
  202. UCHAR filler[5]; // filler, zeros
  203. } TDI_ADDRESS_VNS, *PTDI_ADDRESS_VNS;
  204. #define TDI_ADDRESS_LENGTH_VNS sizeof (TDI_ADDRESS_VNS)
  205. // OSI TSAP
  206. /*
  207. * The maximum size of the tranport address (tp_addr field of a
  208. * sockaddr_tp structure) is 64.
  209. */
  210. #define ISO_MAX_ADDR_LENGTH 64
  211. /*
  212. * There are two types of ISO addresses, hierarchical and
  213. * non-hierarchical. For hierarchical addresses, the tp_addr
  214. * field contains both the transport selector and the network
  215. * address. For non-hierarchical addresses, tp_addr contains only
  216. * the transport address, which must be translated by the ISO TP4
  217. * transport provider into the transport selector and network address.
  218. */
  219. #define ISO_HIERARCHICAL 0
  220. #define ISO_NON_HIERARCHICAL 1
  221. typedef struct _TDI_ADDRESS_OSI_TSAP {
  222. USHORT tp_addr_type; /* ISO_HIERARCHICAL or ISO_NON_HIERARCHICAL
  223. */
  224. USHORT tp_taddr_len; /* Length of transport address, <= 52 */
  225. USHORT tp_tsel_len; /* Length of transport selector, <= 32 */
  226. /* 0 if ISO_NON_HIERARCHICAL */
  227. UCHAR tp_addr[ISO_MAX_ADDR_LENGTH];
  228. } TDI_ADDRESS_OSI_TSAP, *PTDI_ADDRESS_OSI_TSAP;
  229. #define TDI_ADDRESS_LENGTH_OSI_TSAP sizeof (TDI_ADDRESS_OSI_TSAP)
  230. //
  231. // Some pre-defined structures to make life easier for
  232. // the 99.99% of us who use but one address.
  233. //
  234. typedef struct _TA_ADDRESS_NETBIOS {
  235. LONG TAAddressCount;
  236. struct _Addr {
  237. USHORT AddressLength; // length in bytes of this address == 18
  238. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_NETBIOS
  239. TDI_ADDRESS_NETBIOS Address[1];
  240. } Address [1];
  241. } TA_NETBIOS_ADDRESS, *PTA_NETBIOS_ADDRESS;
  242. typedef struct _TA_ADDRESS_NETBIOS_EX {
  243. LONG TAAddressCount;
  244. struct _AddrNetbiosEx {
  245. USHORT AddressLength; // length in bytes of this address == 36
  246. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_NETBIOS_EX
  247. TDI_ADDRESS_NETBIOS_EX Address[1];
  248. } Address [1];
  249. } TA_NETBIOS_EX_ADDRESS, *PTA_NETBIOS_EX_ADDRESS;
  250. typedef struct _TA_APPLETALK_ADDR {
  251. LONG TAAddressCount;
  252. struct _AddrAtalk {
  253. USHORT AddressLength; // length in bytes of this address == 4
  254. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_APPLETALK
  255. TDI_ADDRESS_APPLETALK Address[1];
  256. } Address[1];
  257. } TA_APPLETALK_ADDRESS, *PTA_APPLETALK_ADDRESS;
  258. typedef struct _TA_ADDRESS_IP {
  259. LONG TAAddressCount;
  260. struct _AddrIp {
  261. USHORT AddressLength; // length in bytes of this address == 14
  262. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_IP
  263. TDI_ADDRESS_IP Address[1];
  264. } Address [1];
  265. } TA_IP_ADDRESS, *PTA_IP_ADDRESS;
  266. typedef struct _TA_ADDRESS_IP6 {
  267. LONG TAAddressCount;
  268. struct _AddrIp6 {
  269. USHORT AddressLength; // length in bytes of this address == 24
  270. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_IP6
  271. TDI_ADDRESS_IP6 Address[1];
  272. } Address [1];
  273. } TA_IP6_ADDRESS, *PTA_IP6_ADDRESS;
  274. typedef struct _TA_ADDRESS_IPX {
  275. LONG TAAddressCount;
  276. struct _AddrIpx {
  277. USHORT AddressLength; // length in bytes of this address == 12
  278. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_IPX
  279. TDI_ADDRESS_IPX Address[1];
  280. } Address [1];
  281. } TA_IPX_ADDRESS, *PTA_IPX_ADDRESS;
  282. typedef struct _TA_ADDRESS_NS {
  283. LONG TAAddressCount;
  284. struct _AddrNs {
  285. USHORT AddressLength; // length in bytes of this address == 12
  286. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_NS
  287. TDI_ADDRESS_NS Address[1];
  288. } Address [1];
  289. } TA_NS_ADDRESS, *PTA_NS_ADDRESS;
  290. typedef struct _TA_ADDRESS_VNS {
  291. LONG TAAddressCount;
  292. struct _AddrVns {
  293. USHORT AddressLength; // length in bytes of this address == 14
  294. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_VNS
  295. TDI_ADDRESS_VNS Address[1];
  296. } Address [1];
  297. } TA_VNS_ADDRESS, *PTA_VNS_ADDRESS;
  298. #include <packoff.h>
  299. //
  300. // This structure is passed with every request to TDI. It describes that
  301. // request and the parameters to it.
  302. //
  303. typedef struct _TDI_REQUEST {
  304. union {
  305. HANDLE AddressHandle;
  306. CONNECTION_CONTEXT ConnectionContext;
  307. HANDLE ControlChannel;
  308. } Handle;
  309. PVOID RequestNotifyObject;
  310. PVOID RequestContext;
  311. TDI_STATUS TdiStatus;
  312. } TDI_REQUEST, *PTDI_REQUEST;
  313. //
  314. // Structure for information returned by the TDI provider. This structure is
  315. // filled in upon request completion.
  316. //
  317. typedef struct _TDI_REQUEST_STATUS {
  318. TDI_STATUS Status; // status of request completion
  319. PVOID RequestContext; // the request Context
  320. ULONG BytesTransferred; // number of bytes transferred in the request
  321. } TDI_REQUEST_STATUS, *PTDI_REQUEST_STATUS;
  322. //
  323. // connection primitives information structure. This is passed to the TDI calls
  324. // (Accept, Connect, xxx) that do connecting sorts of things.
  325. //
  326. typedef struct _TDI_CONNECTION_INFORMATION {
  327. LONG UserDataLength; // length of user data buffer
  328. PVOID UserData; // pointer to user data buffer
  329. LONG OptionsLength; // length of follwoing buffer
  330. PVOID Options; // pointer to buffer containing options
  331. LONG RemoteAddressLength; // length of following buffer
  332. PVOID RemoteAddress; // buffer containing the remote address
  333. } TDI_CONNECTION_INFORMATION, *PTDI_CONNECTION_INFORMATION;
  334. //
  335. // structure defining a counted string is defined in
  336. // \nt\public\sdk\inc\ntdefs.h as
  337. // typedef struct _STRING {
  338. // USHORT Length;
  339. // USHORT MaximumLength;
  340. // PCHAR Buffer;
  341. // } STRING;
  342. // typedef STRING *PSTRING;
  343. // typedef STRING ANSI_STRING;
  344. // typedef PSTRING PANSI_STRING;
  345. //
  346. //
  347. // Event types that are known
  348. //
  349. #define TDI_EVENT_CONNECT ((USHORT)0) // TDI_IND_CONNECT event handler.
  350. #define TDI_EVENT_DISCONNECT ((USHORT)1) // TDI_IND_DISCONNECT event handler.
  351. #define TDI_EVENT_ERROR ((USHORT)2) // TDI_IND_ERROR event handler.
  352. #define TDI_EVENT_RECEIVE ((USHORT)3) // TDI_IND_RECEIVE event handler.
  353. #define TDI_EVENT_RECEIVE_DATAGRAM ((USHORT)4) // TDI_IND_RECEIVE_DATAGRAM event handler.
  354. #define TDI_EVENT_RECEIVE_EXPEDITED ((USHORT)5) // TDI_IND_RECEIVE_EXPEDITED event handler.
  355. #define TDI_EVENT_SEND_POSSIBLE ((USHORT)6) // TDI_IND_SEND_POSSIBLE event handler
  356. //
  357. // Associate Address is done through NtDeviceIoControlFile, which passes this
  358. // structure as its input buffer. The Handle specified in the
  359. // NtDeviceIoControlFile is the handle of the connection returned in the
  360. // NtCreateFile call.
  361. //
  362. typedef struct _TDI_REQUEST_ASSOCIATE {
  363. TDI_REQUEST Request;
  364. HANDLE AddressHandle;
  365. } TDI_REQUEST_ASSOCIATE_ADDRESS, *PTDI_REQUEST_ASSOCIATE_ADDRESS;
  366. //
  367. // Disassociate Address passes no structure, uses the request code
  368. // IOCTL_TDI_DISASSOCIATE_ADDRESS. This call will never pend.
  369. //
  370. //
  371. // Connect is done through NtDeviceIoControlFile, which passes this
  372. // structure as its input buffer. The Handle specified in the
  373. // NtDeviceIoControlFile is the handle of the connection returned in the
  374. // NtCreateFile call.
  375. //
  376. typedef struct _TDI_CONNECT_REQUEST {
  377. TDI_REQUEST Request;
  378. PTDI_CONNECTION_INFORMATION RequestConnectionInformation;
  379. PTDI_CONNECTION_INFORMATION ReturnConnectionInformation;
  380. LARGE_INTEGER Timeout;
  381. } TDI_REQUEST_CONNECT, *PTDI_REQUEST_CONNECT;
  382. //
  383. // Accept is done through NtDeviceIoControlFile, which passes this
  384. // structure as its input buffer. The Handle specified in the
  385. // NtDeviceIoControlFile is the handle of the connection returned in the
  386. // NtCreateFile call. Accept is called by the user when a listen completes,
  387. // before any activity can occur on a connection. AcceptConnectionId specifies
  388. // the connection on which the connection is accepted; in most cases, this
  389. // will be null, which that the connection is to be accepted on the
  390. // connection on which the listen completed. If the transport provider supports
  391. // "forwarding" of connections (the idea that a particular connection listens
  392. // all the time, and creates new connections as needed for incoming connection
  393. // requests and attaches them to the listen), this is the mechanism used to
  394. // associate connections with the listen.
  395. //
  396. typedef struct _TDI_REQUEST_ACCEPT {
  397. TDI_REQUEST Request;
  398. PTDI_CONNECTION_INFORMATION RequestConnectionInformation;
  399. PTDI_CONNECTION_INFORMATION ReturnConnectionInformation;
  400. } TDI_REQUEST_ACCEPT, *PTDI_REQUEST_ACCEPT;
  401. //
  402. // Listen is done through NtDeviceIoControlFile, which passes this
  403. // structure as its input buffer. The Handle specified in the
  404. // NtDeviceIoControlFile is the handle of the connection returned in the
  405. // NtCreateFile call. RequestConnectionInformation contains information about
  406. // the remote address to be listen for connections from; if NULL, any address
  407. // is accepted. ReturnConnectionInformation returns information about the
  408. // remote node that actually connected.
  409. //
  410. typedef struct _TDI_REQUEST_LISTEN {
  411. TDI_REQUEST Request;
  412. PTDI_CONNECTION_INFORMATION RequestConnectionInformation;
  413. PTDI_CONNECTION_INFORMATION ReturnConnectionInformation;
  414. USHORT ListenFlags;
  415. } TDI_REQUEST_LISTEN, *PTDI_REQUEST_LISTEN;
  416. //
  417. // Disconnect is done through NtDeviceIoControlFile, which passes this
  418. // structure as its input buffer. The Handle specified in the
  419. // NtDeviceIoControlFile is the handle of the connection returned in the
  420. // NtCreateFile call. Disconnect differs from Close in offering more options.
  421. // For example, Close terminates all activity on a connection (immediately),
  422. // failing all outstanding requests, and tearing down the connection. With
  423. // some providers, Disconnect allows a "graceful" disconnect, causing new activity
  424. // to be rejected but allowing old activity to run down to completion.
  425. //
  426. typedef struct _TDI_DISCONNECT_REQUEST {
  427. TDI_REQUEST Request;
  428. LARGE_INTEGER Timeout;
  429. } TDI_REQUEST_DISCONNECT, *PTDI_REQUEST_DISCONNECT;
  430. //
  431. // Send is done through NtDeviceIoControlFile, which passes this
  432. // structure as its input buffer. The Handle specified in the
  433. // NtDeviceIoControlFile is the handle of the connection returned in the
  434. // NtCreateFile call. Note that it is possible to Send using the file system's
  435. // Write call. This will have the same effect as doing a Send with all flags
  436. // set to null.
  437. //
  438. typedef struct _TDI_REQUEST_SEND {
  439. TDI_REQUEST Request;
  440. USHORT SendFlags;
  441. } TDI_REQUEST_SEND, *PTDI_REQUEST_SEND;
  442. //
  443. // Receive is done through NtDeviceIoControlFile, which passes this
  444. // structure as its input buffer. The Handle specified in the
  445. // NtDeviceIoControlFile is the handle of the connection returned in the
  446. // NtCreateFile call. Note that it is possible to Receive using the file
  447. // system's Read call. Note further that receive returns a number of TDI_STATUS
  448. // values, which indicate things such as partial receives.
  449. //
  450. typedef struct _TDI_REQUEST_RECEIVE {
  451. TDI_REQUEST Request;
  452. USHORT ReceiveFlags;
  453. } TDI_REQUEST_RECEIVE, *PTDI_REQUEST_RECEIVE;
  454. //
  455. // SendDatagram is done through NtDeviceIoControlFile, which passes this
  456. // structure as its input buffer. The Handle specified in the
  457. // NtDeviceIoControlFile is the handle of the ADDRESS (note this is
  458. // different than above!!) returned in the NtCreateFile call. Send Datagram
  459. // specifies the address of the receiver through the SendDatagramInformation
  460. // structure, using RemoteAddress to point to the transport address of the
  461. // destination of the datagram.
  462. //
  463. typedef struct _TDI_REQUEST_SEND_DATAGRAM {
  464. TDI_REQUEST Request;
  465. PTDI_CONNECTION_INFORMATION SendDatagramInformation;
  466. } TDI_REQUEST_SEND_DATAGRAM, *PTDI_REQUEST_SEND_DATAGRAM;
  467. //
  468. // ReceiveDatagram is done through NtDeviceIoControlFile, which passes this
  469. // structure as its input buffer. The Handle specified in the
  470. // NtDeviceIoControlFile is the handle of the ADDRESS (note this is
  471. // different than above!!) returned in the NtCreateFile call. Receive Datagram
  472. // specifies the address from which to receive a datagram through the
  473. // ReceiveDatagramInformation structure, using RemoteAddress to point to the
  474. // transport address of the origin of the datagram. (Broadcast datagrams are
  475. // received by making the pointer NULL.) The actual address of the sender of
  476. // the datagram is returned in ReturnInformation.
  477. //
  478. // for the receive datagram call
  479. //
  480. typedef struct _TDI_REQUEST_RECEIVE_DATAGRAM {
  481. TDI_REQUEST Request;
  482. PTDI_CONNECTION_INFORMATION ReceiveDatagramInformation;
  483. PTDI_CONNECTION_INFORMATION ReturnInformation;
  484. USHORT ReceiveFlags;
  485. } TDI_REQUEST_RECEIVE_DATAGRAM, *PTDI_REQUEST_RECEIVE_DATAGRAM;
  486. //
  487. // SetEventHandler is done through NtDeviceIoControlFile, which passes this
  488. // structure as its input buffer. The Handle specified in the
  489. // NtDeviceIoControlFile is the handle of the ADDRESS (note this is
  490. // different than above!!) returned in the NtCreateFile call.
  491. typedef struct _TDI_REQUEST_SET_EVENT {
  492. TDI_REQUEST Request;
  493. LONG EventType;
  494. PVOID EventHandler;
  495. PVOID EventContext;
  496. } TDI_REQUEST_SET_EVENT_HANDLER, *PTDI_REQUEST_SET_EVENT_HANDLER;
  497. //
  498. // ReceiveIndicator values (from TdiReceive and TdiReceiveDatagram requests,
  499. // and also presented at TDI_IND_RECEIVE and TDI_IND_RECEIVE_DATAGRAM time).
  500. //
  501. // The TDI_RECEIVE_PARTIAL bit is no longer used at the kernel level
  502. // interface. TDI_RECEIVE_ENTIRE_MESSAGE has replaced it. Providers
  503. // may continue to set TDI_RECEIVE_PARTIAL when appropriate if they so
  504. // desire, but the TDI_RECEIVE_ENTIRE_MESSAGE bit must be set or
  505. // cleared as appropriate on all receive indications.
  506. //
  507. #define TDI_RECEIVE_BROADCAST 0x00000004 // received TSDU was broadcast.
  508. #define TDI_RECEIVE_MULTICAST 0x00000008 // received TSDU was multicast.
  509. #define TDI_RECEIVE_PARTIAL 0x00000010 // received TSDU is not fully presented.
  510. #define TDI_RECEIVE_NORMAL 0x00000020 // received TSDU is normal data
  511. #define TDI_RECEIVE_EXPEDITED 0x00000040 // received TSDU is expedited data
  512. #define TDI_RECEIVE_PEEK 0x00000080 // received TSDU is not released
  513. #define TDI_RECEIVE_NO_RESPONSE_EXP 0x00000100 // HINT: no back-traffic expected
  514. #define TDI_RECEIVE_COPY_LOOKAHEAD 0x00000200 // for kernel-mode indications
  515. #define TDI_RECEIVE_ENTIRE_MESSAGE 0x00000400 // opposite of RECEIVE_PARTIAL
  516. // (for kernel-mode indications)
  517. #define TDI_RECEIVE_AT_DISPATCH_LEVEL 0x00000800 // receive indication called
  518. // at dispatch level
  519. #define TDI_RECEIVE_CONTROL_INFO 0x00001000 // Control info is being passed up.
  520. //
  521. // Listen Flags
  522. //
  523. #define TDI_QUERY_ACCEPT 0x00000001 // complete TdiListen
  524. // without accepting
  525. // connection
  526. //
  527. // Options which are used for both SendOptions and ReceiveIndicators.
  528. //
  529. #define TDI_SEND_EXPEDITED ((USHORT)0x0020) // TSDU is/was urgent/expedited.
  530. #define TDI_SEND_PARTIAL ((USHORT)0x0040) // TSDU is/was terminated by an EOR.
  531. #define TDI_SEND_NO_RESPONSE_EXPECTED ((USHORT)0x0080) // HINT: no back traffic expected.
  532. #define TDI_SEND_NON_BLOCKING ((USHORT)0x0100) // don't block if no buffer space in protocol
  533. #define TDI_SEND_AND_DISCONNECT ((USHORT)0x0200) // Piggy back disconnect to remote and do not
  534. // indicate disconnect from remote
  535. //
  536. // Disconnect Flags
  537. //
  538. #define TDI_DISCONNECT_WAIT ((USHORT)0x0001) // used for disconnect
  539. // notification
  540. #define TDI_DISCONNECT_ABORT ((USHORT)0x0002) // immediately terminate
  541. // connection
  542. #define TDI_DISCONNECT_RELEASE ((USHORT)0x0004) // initiate graceful
  543. // disconnect
  544. //
  545. // TdiRequest structure for TdiQueryInformation request.
  546. //
  547. typedef struct _TDI_REQUEST_QUERY_INFORMATION {
  548. TDI_REQUEST Request;
  549. ULONG QueryType; // class of information to be queried.
  550. PTDI_CONNECTION_INFORMATION RequestConnectionInformation;
  551. } TDI_REQUEST_QUERY_INFORMATION, *PTDI_REQUEST_QUERY_INFORMATION;
  552. //
  553. // TdiRequest structure for TdiSetInformation request.
  554. //
  555. typedef struct _TDI_REQUEST_SET_INFORMATION {
  556. TDI_REQUEST Request;
  557. ULONG SetType; // class of information to be set.
  558. PTDI_CONNECTION_INFORMATION RequestConnectionInformation;
  559. } TDI_REQUEST_SET_INFORMATION, *PTDI_REQUEST_SET_INFORMATION;
  560. //
  561. // This is the old name, do not use it.
  562. //
  563. typedef TDI_REQUEST_SET_INFORMATION TDI_REQ_SET_INFORMATION, *PTDI_REQ_SET_INFORMATION;
  564. //
  565. // Convenient universal request type.
  566. //
  567. typedef union _TDI_REQUEST_TYPE {
  568. TDI_REQUEST_ACCEPT TdiAccept;
  569. TDI_REQUEST_CONNECT TdiConnect;
  570. TDI_REQUEST_DISCONNECT TdiDisconnect;
  571. TDI_REQUEST_LISTEN TdiListen;
  572. TDI_REQUEST_QUERY_INFORMATION TdiQueryInformation;
  573. TDI_REQUEST_RECEIVE TdiReceive;
  574. TDI_REQUEST_RECEIVE_DATAGRAM TdiReceiveDatagram;
  575. TDI_REQUEST_SEND TdiSend;
  576. TDI_REQUEST_SEND_DATAGRAM TdiSendDatagram;
  577. TDI_REQUEST_SET_EVENT_HANDLER TdiSetEventHandler;
  578. TDI_REQUEST_SET_INFORMATION TdiSetInformation;
  579. } TDI_REQUEST_TYPE, *PTDI_REQUEST_TYPE;
  580. //
  581. // Query information types
  582. //
  583. //
  584. // Generic query info types, must be supported by all transports.
  585. //
  586. #define TDI_QUERY_BROADCAST_ADDRESS 0x00000001
  587. #define TDI_QUERY_PROVIDER_INFORMATION 0x00000002 // temp, renamed ...
  588. #define TDI_QUERY_PROVIDER_INFO 0x00000002 // ... to this
  589. #define TDI_QUERY_ADDRESS_INFO 0x00000003
  590. #define TDI_QUERY_CONNECTION_INFO 0x00000004
  591. #define TDI_QUERY_PROVIDER_STATISTICS 0x00000005
  592. #define TDI_QUERY_DATAGRAM_INFO 0x00000006
  593. #define TDI_QUERY_DATA_LINK_ADDRESS 0x00000007
  594. #define TDI_QUERY_NETWORK_ADDRESS 0x00000008
  595. #define TDI_QUERY_MAX_DATAGRAM_INFO 0x00000009
  596. //
  597. // netbios specific query information types, must be supported by netbios
  598. // providers. Query adapter status returns the ADAPTER_STATUS struture defined
  599. // in the file NB30.H. Query session status returns the SESSION_HEADER/
  600. // SESSION_BUFFER structures defined in NB30.H. Query find name returns
  601. // the FIND_NAME_HEADER/FIND_NAME_BUFFER structures defined in NB30.H.
  602. //
  603. #define TDI_QUERY_ADAPTER_STATUS 0x00000100
  604. #define TDI_QUERY_SESSION_STATUS 0x00000200
  605. #define TDI_QUERY_FIND_NAME 0x00000300
  606. //
  607. // The following structures are returned by TdiQueryInformation and are read
  608. // by TdiSetInformation. Note that a provider with netbios support will also
  609. // return the adapter status
  610. //
  611. typedef struct _TDI_ENDPOINT_INFO {
  612. ULONG State; // current state of the endpoint.
  613. ULONG Event; // last event at the endpoint.
  614. ULONG TransmittedTsdus; // TSDUs sent from this endpoint.
  615. ULONG ReceivedTsdus; // TSDUs received at this endpoint.
  616. ULONG TransmissionErrors; // TSDUs transmitted in error.
  617. ULONG ReceiveErrors; // TSDUs received in error.
  618. ULONG MinimumLookaheadData; // guaranteed min size of lookahead data.
  619. ULONG MaximumLookaheadData; // maximum size of lookahead data.
  620. ULONG PriorityLevel; // priority class assigned to outgoing data.
  621. ULONG SecurityLevel; // security level assigned to outgoing data.
  622. ULONG SecurityCompartment; // security compartment assigned to outgoing data.
  623. } TDI_ENDPOINT_INFO, *PTDI_ENDPOINT_INFO;
  624. typedef struct _TDI_CONNECTION_INFO {
  625. ULONG State; // current state of the connection.
  626. ULONG Event; // last event on the connection.
  627. ULONG TransmittedTsdus; // TSDUs sent on this connection.
  628. ULONG ReceivedTsdus; // TSDUs received on this connection.
  629. ULONG TransmissionErrors; // TSDUs transmitted in error/this connection.
  630. ULONG ReceiveErrors; // TSDUs received in error/this connection.
  631. LARGE_INTEGER Throughput; // estimated throughput on this connection.
  632. LARGE_INTEGER Delay; // estimated delay on this connection.
  633. ULONG SendBufferSize; // size of buffer for sends - only
  634. // meaningful for internal buffering
  635. // protocols like tcp
  636. ULONG ReceiveBufferSize; // size of buffer for receives - only
  637. // meaningful for internal buffering
  638. // protocols like tcp
  639. BOOLEAN Unreliable; // is this connection "unreliable".
  640. } TDI_CONNECTION_INFO, *PTDI_CONNECTION_INFO;
  641. typedef struct _TDI_ADDRESS_INFO {
  642. ULONG ActivityCount; // outstanding open file objects/this address.
  643. TRANSPORT_ADDRESS Address; // the actual address & its components.
  644. } TDI_ADDRESS_INFO, *PTDI_ADDRESS_INFO;
  645. typedef struct _TDI_DATAGRAM_INFO {
  646. ULONG MaximumDatagramBytes;
  647. ULONG MaximumDatagramCount;
  648. } TDI_DATAGRAM_INFO, *PTDI_DATAGRAM_INFO;
  649. typedef struct _TDI_MAX_DATAGRAM_INFO {
  650. ULONG MaxDatagramSize; // max datagram length in bytes.
  651. } TDI_MAX_DATAGRAM_INFO, *PTDI_MAX_DATAGRAM_INFO;
  652. typedef struct _TDI_PROVIDER_INFO {
  653. ULONG Version; // TDI version: 0xaabb, aa=major, bb=minor
  654. ULONG MaxSendSize; // max size of user send.
  655. ULONG MaxConnectionUserData; // max size of user-specified connect data.
  656. ULONG MaxDatagramSize; // max datagram length in bytes.
  657. ULONG ServiceFlags; // service options, defined below.
  658. ULONG MinimumLookaheadData; // guaranteed min size of lookahead data.
  659. ULONG MaximumLookaheadData; // maximum size of lookahead data.
  660. ULONG NumberOfResources; // how many TDI_RESOURCE_STATS for provider.
  661. LARGE_INTEGER StartTime; // when the provider became active.
  662. } TDI_PROVIDER_INFO, *PTDI_PROVIDER_INFO;
  663. #define TDI_SERVICE_CONNECTION_MODE 0x00000001 // connection mode supported.
  664. #define TDI_SERVICE_ORDERLY_RELEASE 0x00000002 // orderly release supported.
  665. #define TDI_SERVICE_CONNECTIONLESS_MODE 0x00000004 // connectionless mode supported.
  666. #define TDI_SERVICE_ERROR_FREE_DELIVERY 0x00000008 // error free delivery supported.
  667. #define TDI_SERVICE_SECURITY_LEVEL 0x00000010 // security wrapper supported.
  668. #define TDI_SERVICE_BROADCAST_SUPPORTED 0x00000020 // broadcast datagrams supported.
  669. #define TDI_SERVICE_MULTICAST_SUPPORTED 0x00000040 // multicast datagrams supported.
  670. #define TDI_SERVICE_DELAYED_ACCEPTANCE 0x00000080 // use of TDI_ACCEPT_OR_REJECT is supported.
  671. #define TDI_SERVICE_EXPEDITED_DATA 0x00000100 // expedited data supported.
  672. #define TDI_SERVICE_INTERNAL_BUFFERING 0x00000200 // protocol does internal buffering
  673. #define TDI_SERVICE_ROUTE_DIRECTED 0x00000400 // directed packets may go further than MC.
  674. #define TDI_SERVICE_NO_ZERO_LENGTH 0x00000800 // zero-length sends NOT supported
  675. #define TDI_SERVICE_POINT_TO_POINT 0x00001000 // transport is functioning as a RAS gateway
  676. #define TDI_SERVICE_MESSAGE_MODE 0x00002000 // message-mode send supported
  677. #define TDI_SERVICE_HALF_DUPLEX 0x00004000 // data can be received after local disc
  678. #define TDI_SERVICE_DGRAM_CONNECTION 0x00008000 // Pseudo connection for datagrams to handle
  679. // GPC, QOS etc.,
  680. #define TDI_SERVICE_FORCE_ACCESS_CHECK 0x00010000 // kernel mode caller should force access
  681. // check when opening trasnport objects
  682. // if it passes the handle to user mode
  683. #define TDI_SERVICE_SEND_AND_DISCONNECT 0x00020000 // combines send and disconnect processing
  684. #define TDI_SERVICE_DIRECT_ACCEPT 0x00040000 // (deprecated) completes accept-requests directly
  685. #define TDI_SERVICE_ACCEPT_LOCAL_ADDR 0x00080000 // supplies local address
  686. // with accept-completion
  687. typedef struct _TDI_PROVIDER_RESOURCE_STATS {
  688. ULONG ResourceId; // identifies resource in question.
  689. ULONG MaximumResourceUsed; // maximum number in use at once.
  690. ULONG AverageResourceUsed; // average number in use.
  691. ULONG ResourceExhausted; // number of times resource not available.
  692. } TDI_PROVIDER_RESOURCE_STATS, *PTDI_PROVIDER_RESOURCE_STATS;
  693. typedef struct _TDI_PROVIDER_STATISTICS {
  694. ULONG Version; // TDI version: 0xaabb, aa=major, bb=minor
  695. ULONG OpenConnections; // currently active connections.
  696. ULONG ConnectionsAfterNoRetry; // successful connections, no retries.
  697. ULONG ConnectionsAfterRetry; // successful connections after retry.
  698. ULONG LocalDisconnects; // connection disconnected locally.
  699. ULONG RemoteDisconnects; // connection disconnected by remote.
  700. ULONG LinkFailures; // connections dropped, link failure.
  701. ULONG AdapterFailures; // connections dropped, adapter failure.
  702. ULONG SessionTimeouts; // connections dropped, session timeout.
  703. ULONG CancelledConnections; // connect attempts cancelled.
  704. ULONG RemoteResourceFailures; // connections failed, remote resource problems.
  705. ULONG LocalResourceFailures; // connections failed, local resource problems.
  706. ULONG NotFoundFailures; // connections failed, remote not found.
  707. ULONG NoListenFailures; // connections rejected, we had no listens.
  708. ULONG DatagramsSent;
  709. LARGE_INTEGER DatagramBytesSent;
  710. ULONG DatagramsReceived;
  711. LARGE_INTEGER DatagramBytesReceived;
  712. ULONG PacketsSent; // total packets given to NDIS.
  713. ULONG PacketsReceived; // total packets received from NDIS.
  714. ULONG DataFramesSent;
  715. LARGE_INTEGER DataFrameBytesSent;
  716. ULONG DataFramesReceived;
  717. LARGE_INTEGER DataFrameBytesReceived;
  718. ULONG DataFramesResent;
  719. LARGE_INTEGER DataFrameBytesResent;
  720. ULONG DataFramesRejected;
  721. LARGE_INTEGER DataFrameBytesRejected;
  722. ULONG ResponseTimerExpirations; // e.g. T1 for Netbios
  723. ULONG AckTimerExpirations; // e.g. T2 for Netbios
  724. ULONG MaximumSendWindow; // in bytes
  725. ULONG AverageSendWindow; // in bytes
  726. ULONG PiggybackAckQueued; // attempts to wait to piggyback ack.
  727. ULONG PiggybackAckTimeouts; // times that wait timed out.
  728. LARGE_INTEGER WastedPacketSpace; // total amount of "wasted" packet space.
  729. ULONG WastedSpacePackets; // how many packets contributed to that.
  730. ULONG NumberOfResources; // how many TDI_RESOURCE_STATS follow.
  731. TDI_PROVIDER_RESOURCE_STATS ResourceStats[1]; // variable array of them.
  732. } TDI_PROVIDER_STATISTICS, *PTDI_PROVIDER_STATISTICS;
  733. NTSTATUS
  734. TdiOpenNetbiosAddress (
  735. IN OUT PHANDLE FileHandle,
  736. IN PUCHAR Buffer,
  737. IN PVOID DeviceName,
  738. IN PVOID Name
  739. );
  740. #define IOCTL_TDI_MAGIC_BULLET _TDI_CONTROL_CODE( 0x7f, METHOD_NEITHER )
  741. //
  742. // Define these to match the kernel ones for compatibility; eventually
  743. // these will be removed.
  744. //
  745. typedef TDI_REQUEST_ASSOCIATE_ADDRESS TDI_REQUEST_USER_ASSOCIATE, *PTDI_REQUEST_USER_ASSOCIATE;
  746. typedef TDI_REQUEST_CONNECT TDI_REQUEST_USER_CONNECT, *PTDI_REQUEST_USER_CONNECT;
  747. typedef TDI_REQUEST_QUERY_INFORMATION TDI_REQUEST_USER_QUERY_INFO, *PTDI_REQUEST_USER_QUERY_INFO;
  748. //
  749. // The header in the OutputBuffer passed to TdiAction
  750. //
  751. typedef struct _TDI_ACTION_HEADER {
  752. ULONG TransportId;
  753. USHORT ActionCode;
  754. USHORT Reserved;
  755. } TDI_ACTION_HEADER, *PTDI_ACTION_HEADER;
  756. typedef struct _STREAMS_TDI_ACTION {
  757. TDI_ACTION_HEADER Header;
  758. BOOLEAN DatagramOption;
  759. ULONG BufferLength;
  760. CHAR Buffer[1];
  761. } STREAMS_TDI_ACTION, *PSTREAMS_TDI_ACTION;
  762. // These are tags that transports pass to ndis as a first param of NdisAllocatePacketPoolEx
  763. // api. Ndis uses this as pooltag for allocating packet pools for that transport.
  764. #define NDIS_PACKET_POOL_TAG_FOR_NWLNKIPX 'iPDN'
  765. #define NDIS_PACKET_POOL_TAG_FOR_NWLNKSPX 'sPDN'
  766. #define NDIS_PACKET_POOL_TAG_FOR_NWLNKNB 'nPDN'
  767. #define NDIS_PACKET_POOL_TAG_FOR_TCPIP 'tPDN'
  768. #define NDIS_PACKET_POOL_TAG_FOR_NBF 'bPDN'
  769. #define NDIS_PACKET_POOL_TAG_FOR_APPLETALK 'aPDN'
  770. #endif // ndef _TDI_USER_