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.

457 lines
15 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. nbtioctl.h
  5. Abstract:
  6. This header file defines constants for issuing IOCTLS to Netbt
  7. Author:
  8. JSTEW November 16, 1993
  9. Revision History:
  10. --*/
  11. #include <tdi.h>
  12. #ifndef _NBTIOCTL_
  13. #define _NBTIOCTL_
  14. #define NETBIOS_NAMESIZE 16
  15. #define MAX_IPADDRS_PER_HOST 26
  16. //
  17. // The following definitions are from Dns.c
  18. //
  19. #define DNS_NAME_BUFFER_LENGTH (256)
  20. #define DNS_MAX_NAME_LENGTH (255)
  21. //
  22. // Netbt supports this number of adapters
  23. //
  24. #if defined(VXD) || defined(CHICAGO_PRODUCT)
  25. #define NBT_MAXIMUM_BINDINGS 32 // we allow up to 32 net cards in CHICAGO
  26. #else
  27. #define NBT_MAXIMUM_BINDINGS 64 // we allow up to 64 net cards in NT
  28. #endif // VXD || CHICAGO_PRODUCT
  29. //
  30. // This structure is passed down to netbt on a IOCTL_NETBT_ADAPTER_STATUS
  31. // call. If the Ipaddress is set to anything other than zero netbt will
  32. // assume it is an ip address and use it rather than try a name resolution
  33. // on the netbios name passed in.
  34. //
  35. typedef struct
  36. {
  37. ULONG IpAddress;
  38. TA_NETBIOS_ADDRESS NetbiosAddress;
  39. } tIPANDNAMEINFO;
  40. //
  41. // Adapter Status response buffer format for a query of the remote hash
  42. // table. It is the same as the adapter status format except it includes
  43. // the ip address of each name too. This is used in NBtQueryAdapterStatus
  44. // when responding to nbtstat queries.
  45. //
  46. typedef struct
  47. {
  48. UCHAR name[NETBIOS_NAMESIZE];
  49. UCHAR name_num;
  50. UCHAR name_flags;
  51. UCHAR padding;
  52. #ifndef CHICAGO_PRODUCT
  53. ULONG IpAddress; // ip address of remote host
  54. ULONG Ttl; // remaining time in cache
  55. #else
  56. UCHAR IpAddress[4];
  57. UCHAR Ttl[4];
  58. #endif // !CHICAGO_PRODUCT
  59. } tREMOTE_CACHE;
  60. // We log the how names are registered and queried
  61. //
  62. #define NAME_QUERY_SUCCESS 0
  63. #define NAME_REGISTRATION_SUCCESS 1
  64. #define NAME_QUERY_FAILURE 2
  65. #define SIZE_RESOLVD_BY_BCAST_CACHE 8
  66. typedef struct
  67. {
  68. UCHAR Name[NETBIOS_NAMESIZE];
  69. } tNAME;
  70. typedef struct
  71. {
  72. ULONG Stats[4];
  73. ULONG Index;
  74. tNAME NamesReslvdByBcast[SIZE_RESOLVD_BY_BCAST_CACHE];
  75. } tNAMESTATS_INFO;
  76. typedef struct
  77. {
  78. USHORT LanaNumber;
  79. ULONG IpAddress;
  80. ULONG NameServerAddress; // primary WINS server
  81. ULONG BackupServer; // backup WINS server
  82. ULONG lDnsServerAddress; // primary DNS server
  83. ULONG lDnsBackupServer; // backup DNS server
  84. } tIPCONFIG_PER_LANA;
  85. //
  86. // structure returned when ipconfig queries vnbt for parameters being used
  87. //
  88. typedef struct
  89. {
  90. USHORT NumLanas;
  91. tIPCONFIG_PER_LANA LanaInfo[8];
  92. USHORT NodeType;
  93. USHORT ScopeLength;
  94. CHAR szScope[1];
  95. } tIPCONFIG_INFO;
  96. //
  97. // These two structures are used to return the connection list to
  98. // NbtStat
  99. //
  100. typedef struct
  101. {
  102. #ifdef CHICAGO_PRODUCT
  103. UCHAR State[4];
  104. UCHAR SrcIpAddr[4];
  105. CHAR LocalName[NETBIOS_NAMESIZE];
  106. CHAR RemoteName[NETBIOS_NAMESIZE];
  107. UCHAR BytesRcvd[4];
  108. UCHAR BytesSent[4];
  109. #else
  110. ULONG State;
  111. ULONG SrcIpAddr;
  112. CHAR LocalName[NETBIOS_NAMESIZE];
  113. CHAR RemoteName[NETBIOS_NAMESIZE];
  114. LARGE_INTEGER BytesRcvd;
  115. LARGE_INTEGER BytesSent;
  116. #endif // CHICAGO_PRODUCT
  117. UCHAR Originator; // True if originated on this node
  118. } tCONNECTIONS;
  119. typedef struct
  120. {
  121. ULONG ConnectionCount;
  122. tCONNECTIONS ConnList[1];
  123. } tCONNECTION_LIST;
  124. typedef struct
  125. {
  126. ULONG IpAddress;
  127. ULONG Resolved;
  128. UCHAR Name[16];
  129. } tIPADDR_BUFFER;
  130. // this is the format of the buffer passed to Netbt when it either posts
  131. // a buffer for subsequent DNS name resolutions, or it replies to a name
  132. // resolution request. For a posted buffer, Name starts with a null, otherwise
  133. // name is the name that was resolved. Resolved is set to true if the name
  134. // resolved.
  135. //
  136. typedef struct
  137. {
  138. union {
  139. WCHAR pwName[DNS_NAME_BUFFER_LENGTH]; // Support for UNICODE
  140. CHAR pName[DNS_NAME_BUFFER_LENGTH]; // Support for UNICODE
  141. };
  142. ULONG NameLen; // how big is the name
  143. ULONG bUnicode;
  144. ULONG Resolved;
  145. ULONG IpAddrsList[MAX_IPADDRS_PER_HOST+1];
  146. } tIPADDR_BUFFER_DNS;
  147. //
  148. // this is the format of the buffer passed to Nbt by DHCP when DHCP
  149. // changes the Ip Address
  150. //
  151. typedef struct
  152. {
  153. ULONG IpAddress;
  154. ULONG SubnetMask;
  155. } tNEW_IP_ADDRESS;
  156. //
  157. // this is the format of the buffer passed to Nbt by the RDR when
  158. // it wants to know the Wins IP addresses for a given network adapter
  159. // card.
  160. //
  161. typedef struct
  162. {
  163. ULONG PrimaryWinsServer;
  164. ULONG BackupWinsServer;
  165. } tWINS_ADDRESSES;
  166. typedef ULONG tIPADDRESS;
  167. #define MAX_NUM_OTHER_NAME_SERVERS 10 // # of Backup Name Server entries to keep in cache
  168. typedef struct
  169. {
  170. union
  171. {
  172. tIPADDRESS AllNameServers[2+MAX_NUM_OTHER_NAME_SERVERS];
  173. struct
  174. {
  175. tIPADDRESS NameServerAddress;
  176. tIPADDRESS BackupServer;
  177. tIPADDRESS Others[MAX_NUM_OTHER_NAME_SERVERS];
  178. };
  179. };
  180. USHORT NumOtherServers;
  181. USHORT LastResponsive;
  182. ULONG NodeType;
  183. BOOLEAN NetbiosEnabled;
  184. }tWINS_NODE_INFO;
  185. //
  186. // This structure is returned by Nbt when a TdiQueryInformation()
  187. // call asks for TDI_QUERY_ADDRESS_INFO on a connection. This is
  188. // the same as a TRANSPORT_ADDRESS struct from "tdi.h" containing
  189. // two address, a NetBIOS address followed by an IP address.
  190. //
  191. typedef struct _NBT_ADDRESS_PAIR {
  192. LONG TAAddressCount; // this will always == 2
  193. struct {
  194. USHORT AddressLength; // length in bytes of this address == 18
  195. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_NETBIOS
  196. TDI_ADDRESS_NETBIOS Address;
  197. } AddressNetBIOS;
  198. struct {
  199. USHORT AddressLength; // length in bytes of this address == 14
  200. USHORT AddressType; // this will == TDI_ADDRESS_TYPE_IP
  201. TDI_ADDRESS_IP Address;
  202. } AddressIP;
  203. } NBT_ADDRESS_PAIR, *PNBT_ADDRESS_PAIR;
  204. typedef struct _NBT_ADDRESS_PAIR_INFO {
  205. ULONG ActivityCount; // outstanding open file objects/this address.
  206. NBT_ADDRESS_PAIR AddressPair; // the actual address & its components.
  207. } NBT_ADDRESS_PAIR_INFO, *PNBT_ADDRESS_PAIR_INFO;
  208. #define WINS_INTERFACE_NAME "WinsInterface"
  209. //
  210. // This is the format of the remote address structure on the front of
  211. // datagram rcvs passed up to WINS
  212. //
  213. typedef struct
  214. {
  215. SHORT Family;
  216. USHORT Port;
  217. ULONG IpAddress;
  218. ULONG LengthOfBuffer;
  219. } tREM_ADDRESS;
  220. #define MAX_NAME 650 // arbitrary!
  221. typedef struct _NETBT_ADAPTER_INDEX_MAP
  222. {
  223. ULONG Index;
  224. #if defined(VXD) || defined(CHICAGO_PRODUCT)
  225. ULONG LanaNumber;
  226. #else
  227. WCHAR Name[MAX_NAME];
  228. #endif
  229. }NETBT_ADAPTER_INDEX_MAP, *PNETBT_ADAPTER_INDEX_MAP;
  230. typedef struct _NETBT_INTERFACE_INFO
  231. {
  232. LONG NumAdapters;
  233. NETBT_ADAPTER_INDEX_MAP Adapter[1];
  234. } NETBT_INTERFACE_INFO,*PNETBT_INTERFACE_INFO;
  235. //
  236. // Bind request type as requested by Rdr/Srv
  237. //
  238. enum eNbtBindRequestor
  239. {
  240. SMB_SERVER,
  241. SMB_CLIENT
  242. };
  243. #if !defined(VXD) && !defined(CHICAGO_PRODUCT)
  244. typedef struct _NETBT_SMB_BIND_REQUEST
  245. {
  246. ULONG RequestType; // Set as SMB_SERVER_BINDING_.... from above
  247. ULONG PnPOpCode;
  248. PUNICODE_STRING pDeviceName;
  249. PWSTR MultiSZBindList;
  250. }NETBT_SMB_BIND_REQUEST, *PNETBT_SMB_BIND_REQUEST;
  251. #endif // !VXD && !CHICAGO_PRODUCT
  252. //
  253. // Wins and Netbt share the transaction id space, where WINS uses the lower
  254. // half
  255. //
  256. #define WINS_MAXIMUM_TRANSACTION_ID 0x7FFF
  257. // this is equivalent to AF_INET - WINS depends on this to determine kind of
  258. // address the source node has.
  259. //
  260. #define NBT_UNIX 1
  261. #define NBT_INET 2
  262. #define WINS_EXPORT TEXT("Export")
  263. #define NETBT_LINKAGE_KEY TEXT("system\\currentcontrolset\\services\\netbt\\linkage")
  264. typedef struct _tWINS_SET_INFO
  265. {
  266. ULONG IpAddress;
  267. }tWINS_SET_INFO;
  268. // defines for CHICAGO_PRODUCT
  269. #if defined(VXD) || defined(CHICAGO_PRODUCT)
  270. #define NBT_VERIFY_VXD_IOCTL 0x33333333
  271. typedef struct {
  272. ULONG Signature;
  273. ULONG LanaNumber;
  274. CHAR UserData[1];
  275. } tNBT_IOCTL_HEADER;
  276. #define IOCTL_NETBT_PURGE_CACHE 101
  277. #define IOCTL_NETBT_GET_BCAST_NAMES 102
  278. #define IOCTL_NETBT_GET_CONNECTIONS 103
  279. #define IOCTL_NETBT_GET_LOCAL_NAMES 104
  280. #define IOCTL_NETBT_GET_REMOTE_NAMES 105
  281. #define IOCTL_NETBT_REREAD_REGISTRY 106
  282. #define IOCTL_NETBT_NEW_IPADDRESS 107
  283. #define IOCTL_NETBT_DNS_NAME_RESOLVE 108
  284. #define IOCTL_NETBT_FIND_NAME 109
  285. #define IOCTL_NETBT_GET_WINS_ADDR 110
  286. #define IOCTL_NETBT_WINS_SEND 111
  287. #define IOCTL_NETBT_WINS_RCV 112
  288. #define IOCTL_NETBT_GET_IP_ADDRS 113
  289. #define IOCTL_NETBT_GET_IP_SUBNET 114
  290. #define IOCTL_NETBT_ADAPTER_STATUS 115
  291. #define IOCTL_NETBT_IPCONFIG_INFO 116
  292. #define IOCTL_NETBT_NAME_RELEASE_REFRESH 117
  293. #define IOCTL_NETBT_ADD_TO_REMOTE_TABLE 118
  294. #define IOCTL_NETBT_GET_INTERFACE_INFO 119
  295. #define IOCTL_NETBT_SET_TCP_CONNECTION_INFO 120
  296. #define IOCTL_NETBT_REMOVE_FROM_REMOTE_TABLE 121
  297. #define IOCTL_NETBT_LAST_IOCTL 200
  298. #else
  299. // defines for NT
  300. //
  301. // NtDeviceIoControlFile IoControlCode values for this device.
  302. //
  303. #define _NETBT_CTRL_CODE(function, method, access) \
  304. CTL_CODE(FILE_DEVICE_TRANSPORT, function, method, access)
  305. #define IOCTL_NETBT_PURGE_CACHE _NETBT_CTRL_CODE( 30, METHOD_BUFFERED, \
  306. FILE_ANY_ACCESS)
  307. #define IOCTL_NETBT_GET_BCAST_NAMES _NETBT_CTRL_CODE( 31, METHOD_OUT_DIRECT,\
  308. FILE_ANY_ACCESS)
  309. #define IOCTL_NETBT_GET_CONNECTIONS _NETBT_CTRL_CODE( 32, METHOD_OUT_DIRECT, \
  310. FILE_ANY_ACCESS)
  311. #define IOCTL_NETBT_GET_REMOTE_NAMES _NETBT_CTRL_CODE( 33, METHOD_OUT_DIRECT, \
  312. FILE_ANY_ACCESS)
  313. #define IOCTL_NETBT_REREAD_REGISTRY _NETBT_CTRL_CODE( 34, METHOD_BUFFERED, \
  314. FILE_ANY_ACCESS)
  315. #define IOCTL_NETBT_NEW_IPADDRESS _NETBT_CTRL_CODE( 35, METHOD_BUFFERED, \
  316. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  317. #define IOCTL_NETBT_DNS_NAME_RESOLVE _NETBT_CTRL_CODE( 36, METHOD_OUT_DIRECT,\
  318. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  319. #define IOCTL_NETBT_FIND_NAME _NETBT_CTRL_CODE( 37, METHOD_OUT_DIRECT, \
  320. FILE_ANY_ACCESS)
  321. #define IOCTL_NETBT_GET_WINS_ADDR _NETBT_CTRL_CODE( 38, METHOD_OUT_DIRECT, \
  322. FILE_ANY_ACCESS)
  323. #define IOCTL_NETBT_WINS_SEND _NETBT_CTRL_CODE( 39, METHOD_OUT_DIRECT, \
  324. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  325. #define IOCTL_NETBT_WINS_RCV _NETBT_CTRL_CODE( 40, METHOD_OUT_DIRECT, \
  326. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  327. #define IOCTL_NETBT_GET_IP_ADDRS _NETBT_CTRL_CODE( 41, METHOD_OUT_DIRECT, \
  328. FILE_ANY_ACCESS)
  329. #define IOCTL_NETBT_GET_IP_SUBNET _NETBT_CTRL_CODE( 42, METHOD_OUT_DIRECT, \
  330. FILE_ANY_ACCESS)
  331. #define IOCTL_NETBT_ADAPTER_STATUS _NETBT_CTRL_CODE( 43, METHOD_OUT_DIRECT, \
  332. FILE_ANY_ACCESS)
  333. #define IOCTL_NETBT_CHECK_IP_ADDR _NETBT_CTRL_CODE( 44, METHOD_OUT_DIRECT, \
  334. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  335. #define IOCTL_NETBT_ADD_INTERFACE _NETBT_CTRL_CODE( 45, METHOD_BUFFERED,\
  336. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  337. #define IOCTL_NETBT_DELETE_INTERFACE _NETBT_CTRL_CODE( 46, METHOD_BUFFERED,\
  338. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  339. #define IOCTL_NETBT_QUERY_INTERFACE_INSTANCE _NETBT_CTRL_CODE( 47, METHOD_BUFFERED,\
  340. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  341. #define IOCTL_NETBT_SET_WINS_ADDRESS _NETBT_CTRL_CODE( 48, METHOD_BUFFERED,\
  342. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  343. #define IOCTL_NETBT_ENABLE_EXTENDED_ADDR _NETBT_CTRL_CODE( 49, METHOD_BUFFERED,\
  344. FILE_ANY_ACCESS)
  345. #define IOCTL_NETBT_DISABLE_EXTENDED_ADDR _NETBT_CTRL_CODE( 50, METHOD_BUFFERED,\
  346. FILE_ANY_ACCESS)
  347. #define IOCTL_NETBT_NAME_RELEASE_REFRESH _NETBT_CTRL_CODE( 51, METHOD_BUFFERED,\
  348. FILE_ANY_ACCESS)
  349. #define IOCTL_NETBT_ADD_TO_REMOTE_TABLE _NETBT_CTRL_CODE( 52, METHOD_BUFFERED, \
  350. FILE_ANY_ACCESS)
  351. #define IOCTL_NETBT_GET_INTERFACE_INFO _NETBT_CTRL_CODE( 53, METHOD_OUT_DIRECT, \
  352. FILE_ANY_ACCESS)
  353. #define IOCTL_NETBT_SET_TCP_CONNECTION_INFO _NETBT_CTRL_CODE( 54, METHOD_BUFFERED, \
  354. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  355. #define IOCTL_NETBT_SET_SMBDEVICE_BIND_INFO _NETBT_CTRL_CODE( 55, METHOD_BUFFERED, \
  356. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  357. #define IOCTL_NETBT_REMOVE_FROM_REMOTE_TABLE _NETBT_CTRL_CODE( 56, METHOD_BUFFERED, \
  358. FILE_ANY_ACCESS)
  359. #define IOCTL_NETBT_WINS_SET_INFO _NETBT_CTRL_CODE( 57, METHOD_BUFFERED, \
  360. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  361. //
  362. // This ioctl should be last since Driver.c uses this to decide the range of
  363. // ioctls to pass to DispatchIoctls
  364. //
  365. #define IOCTL_NETBT_LAST_IOCTL _NETBT_CTRL_CODE( 58, METHOD_OUT_DIRECT, \
  366. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  367. //
  368. // Used in IOCTL_NETBT_ADD_INTERFACE and IOCTL_NETBT_DELETE_INTERFACE
  369. //
  370. typedef struct _netbt_add_del_if {
  371. NTSTATUS Status;
  372. ULONG InstanceNumber; // instance number of this device
  373. ULONG Length; // length of the buffer
  374. WCHAR IfName[1]; // actual data
  375. } NETBT_ADD_DEL_IF, *PNETBT_ADD_DEL_IF;
  376. //
  377. // Used in IOCTL_NETBT_SET_WINS_ADDRESS
  378. //
  379. typedef struct _netbt_set_wins_addr {
  380. ULONG PrimaryWinsAddr;
  381. ULONG SecondaryWinsAddr;
  382. NTSTATUS Status;
  383. } NETBT_SET_WINS_ADDR, *PNETBT_SET_WINS_ADDR;
  384. #endif // VXD || CHICAGO_PRODUCT
  385. #endif // ifndef _NBTIOCTL_