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
16 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. union {
  202. TDI_ADDRESS_IP Address;
  203. TDI_ADDRESS_IP6 AddressIp6;
  204. };
  205. } AddressIP;
  206. } NBT_ADDRESS_PAIR, *PNBT_ADDRESS_PAIR;
  207. typedef struct _NBT_ADDRESS_PAIR_INFO {
  208. ULONG ActivityCount; // outstanding open file objects/this address.
  209. NBT_ADDRESS_PAIR AddressPair; // the actual address & its components.
  210. } NBT_ADDRESS_PAIR_INFO, *PNBT_ADDRESS_PAIR_INFO;
  211. #define WINS_INTERFACE_NAME "WinsInterface"
  212. //
  213. // This is the format of the remote address structure on the front of
  214. // datagram rcvs passed up to WINS
  215. //
  216. typedef struct
  217. {
  218. SHORT Family;
  219. USHORT Port;
  220. ULONG IpAddress;
  221. ULONG LengthOfBuffer;
  222. } tREM_ADDRESS;
  223. #define MAX_NAME 650 // arbitrary!
  224. typedef struct _NETBT_ADAPTER_INDEX_MAP
  225. {
  226. ULONG Index;
  227. #if defined(VXD) || defined(CHICAGO_PRODUCT)
  228. ULONG LanaNumber;
  229. #else
  230. WCHAR Name[MAX_NAME];
  231. #endif
  232. }NETBT_ADAPTER_INDEX_MAP, *PNETBT_ADAPTER_INDEX_MAP;
  233. typedef struct _NETBT_INTERFACE_INFO
  234. {
  235. LONG NumAdapters;
  236. NETBT_ADAPTER_INDEX_MAP Adapter[1];
  237. } NETBT_INTERFACE_INFO,*PNETBT_INTERFACE_INFO;
  238. //
  239. // Bind request type as requested by Rdr/Srv
  240. //
  241. enum eNbtBindRequestor
  242. {
  243. SMB_SERVER,
  244. SMB_CLIENT
  245. };
  246. #if !defined(VXD) && !defined(CHICAGO_PRODUCT)
  247. typedef struct _NETBT_SMB_BIND_REQUEST
  248. {
  249. ULONG RequestType; // Set as SMB_SERVER_BINDING_.... from above
  250. ULONG PnPOpCode;
  251. PUNICODE_STRING pDeviceName;
  252. PWSTR MultiSZBindList;
  253. }NETBT_SMB_BIND_REQUEST, *PNETBT_SMB_BIND_REQUEST;
  254. #endif // !VXD && !CHICAGO_PRODUCT
  255. //
  256. // Wins and Netbt share the transaction id space, where WINS uses the lower
  257. // half
  258. //
  259. #define WINS_MAXIMUM_TRANSACTION_ID 0x7FFF
  260. // this is equivalent to AF_INET - WINS depends on this to determine kind of
  261. // address the source node has.
  262. //
  263. #define NBT_UNIX 1
  264. #define NBT_INET 2
  265. #define WINS_EXPORT TEXT("Export")
  266. #define NETBT_LINKAGE_KEY TEXT("system\\currentcontrolset\\services\\netbt\\linkage")
  267. typedef struct _tWINS_SET_INFO
  268. {
  269. ULONG IpAddress;
  270. }tWINS_SET_INFO;
  271. // defines for CHICAGO_PRODUCT
  272. #if defined(VXD) || defined(CHICAGO_PRODUCT)
  273. #define NBT_VERIFY_VXD_IOCTL 0x33333333
  274. typedef struct {
  275. ULONG Signature;
  276. ULONG LanaNumber;
  277. CHAR UserData[1];
  278. } tNBT_IOCTL_HEADER;
  279. #define IOCTL_NETBT_PURGE_CACHE 101
  280. #define IOCTL_NETBT_GET_BCAST_NAMES 102
  281. #define IOCTL_NETBT_GET_CONNECTIONS 103
  282. #define IOCTL_NETBT_GET_LOCAL_NAMES 104
  283. #define IOCTL_NETBT_GET_REMOTE_NAMES 105
  284. #define IOCTL_NETBT_REREAD_REGISTRY 106
  285. #define IOCTL_NETBT_NEW_IPADDRESS 107
  286. #define IOCTL_NETBT_DNS_NAME_RESOLVE 108
  287. #define IOCTL_NETBT_FIND_NAME 109
  288. #define IOCTL_NETBT_GET_WINS_ADDR 110
  289. #define IOCTL_NETBT_WINS_SEND 111
  290. #define IOCTL_NETBT_WINS_RCV 112
  291. #define IOCTL_NETBT_GET_IP_ADDRS 113
  292. #define IOCTL_NETBT_GET_IP_SUBNET 114
  293. #define IOCTL_NETBT_ADAPTER_STATUS 115
  294. #define IOCTL_NETBT_IPCONFIG_INFO 116
  295. #define IOCTL_NETBT_NAME_RELEASE_REFRESH 117
  296. #define IOCTL_NETBT_ADD_TO_REMOTE_TABLE 118
  297. #define IOCTL_NETBT_GET_INTERFACE_INFO 119
  298. #define IOCTL_NETBT_SET_TCP_CONNECTION_INFO 120
  299. #define IOCTL_NETBT_REMOVE_FROM_REMOTE_TABLE 121
  300. #define IOCTL_NETBT_LAST_IOCTL 200
  301. #else
  302. // defines for NT
  303. //
  304. // NtDeviceIoControlFile IoControlCode values for this device.
  305. //
  306. #define _NETBT_CTRL_CODE(function, method, access) \
  307. CTL_CODE(FILE_DEVICE_TRANSPORT, function, method, access)
  308. #define IOCTL_NETBT_PURGE_CACHE _NETBT_CTRL_CODE( 30, METHOD_BUFFERED, \
  309. FILE_ANY_ACCESS)
  310. #define IOCTL_NETBT_GET_BCAST_NAMES _NETBT_CTRL_CODE( 31, METHOD_OUT_DIRECT,\
  311. FILE_ANY_ACCESS)
  312. #define IOCTL_NETBT_GET_CONNECTIONS _NETBT_CTRL_CODE( 32, METHOD_OUT_DIRECT, \
  313. FILE_ANY_ACCESS)
  314. #define IOCTL_NETBT_GET_REMOTE_NAMES _NETBT_CTRL_CODE( 33, METHOD_OUT_DIRECT, \
  315. FILE_ANY_ACCESS)
  316. #define IOCTL_NETBT_REREAD_REGISTRY _NETBT_CTRL_CODE( 34, METHOD_BUFFERED, \
  317. FILE_ANY_ACCESS)
  318. #define IOCTL_NETBT_NEW_IPADDRESS _NETBT_CTRL_CODE( 35, METHOD_BUFFERED, \
  319. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  320. #define IOCTL_NETBT_DNS_NAME_RESOLVE _NETBT_CTRL_CODE( 36, METHOD_OUT_DIRECT,\
  321. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  322. #define IOCTL_NETBT_FIND_NAME _NETBT_CTRL_CODE( 37, METHOD_OUT_DIRECT, \
  323. FILE_ANY_ACCESS)
  324. #define IOCTL_NETBT_GET_WINS_ADDR _NETBT_CTRL_CODE( 38, METHOD_OUT_DIRECT, \
  325. FILE_ANY_ACCESS)
  326. #define IOCTL_NETBT_WINS_SEND _NETBT_CTRL_CODE( 39, METHOD_OUT_DIRECT, \
  327. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  328. #define IOCTL_NETBT_WINS_RCV _NETBT_CTRL_CODE( 40, METHOD_OUT_DIRECT, \
  329. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  330. #define IOCTL_NETBT_GET_IP_ADDRS _NETBT_CTRL_CODE( 41, METHOD_OUT_DIRECT, \
  331. FILE_ANY_ACCESS)
  332. #define IOCTL_NETBT_GET_IP_SUBNET _NETBT_CTRL_CODE( 42, METHOD_OUT_DIRECT, \
  333. FILE_ANY_ACCESS)
  334. #define IOCTL_NETBT_ADAPTER_STATUS _NETBT_CTRL_CODE( 43, METHOD_OUT_DIRECT, \
  335. FILE_ANY_ACCESS)
  336. #define IOCTL_NETBT_CHECK_IP_ADDR _NETBT_CTRL_CODE( 44, METHOD_OUT_DIRECT, \
  337. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  338. #define IOCTL_NETBT_ADD_INTERFACE _NETBT_CTRL_CODE( 45, METHOD_BUFFERED,\
  339. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  340. #define IOCTL_NETBT_DELETE_INTERFACE _NETBT_CTRL_CODE( 46, METHOD_BUFFERED,\
  341. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  342. #define IOCTL_NETBT_QUERY_INTERFACE_INSTANCE _NETBT_CTRL_CODE( 47, METHOD_BUFFERED,\
  343. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  344. #define IOCTL_NETBT_SET_WINS_ADDRESS _NETBT_CTRL_CODE( 48, METHOD_BUFFERED,\
  345. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  346. #define IOCTL_NETBT_ENABLE_EXTENDED_ADDR _NETBT_CTRL_CODE( 49, METHOD_BUFFERED,\
  347. FILE_ANY_ACCESS)
  348. #define IOCTL_NETBT_DISABLE_EXTENDED_ADDR _NETBT_CTRL_CODE( 50, METHOD_BUFFERED,\
  349. FILE_ANY_ACCESS)
  350. #define IOCTL_NETBT_NAME_RELEASE_REFRESH _NETBT_CTRL_CODE( 51, METHOD_BUFFERED,\
  351. FILE_ANY_ACCESS)
  352. #define IOCTL_NETBT_ADD_TO_REMOTE_TABLE _NETBT_CTRL_CODE( 52, METHOD_BUFFERED, \
  353. FILE_ANY_ACCESS)
  354. #define IOCTL_NETBT_GET_INTERFACE_INFO _NETBT_CTRL_CODE( 53, METHOD_OUT_DIRECT, \
  355. FILE_ANY_ACCESS)
  356. #define IOCTL_NETBT_SET_TCP_CONNECTION_INFO _NETBT_CTRL_CODE( 54, METHOD_BUFFERED, \
  357. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  358. #define IOCTL_NETBT_SET_SMBDEVICE_BIND_INFO _NETBT_CTRL_CODE( 55, METHOD_BUFFERED, \
  359. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  360. #define IOCTL_NETBT_REMOVE_FROM_REMOTE_TABLE _NETBT_CTRL_CODE( 56, METHOD_BUFFERED, \
  361. FILE_ANY_ACCESS)
  362. #define IOCTL_NETBT_WINS_SET_INFO _NETBT_CTRL_CODE( 57, METHOD_BUFFERED, \
  363. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  364. #define IOCTL_NETBT_ENABLE_DISABLE_NETBIOS_SMB _NETBT_CTRL_CODE( 58, METHOD_BUFFERED, \
  365. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  366. //
  367. // This ioctl should be last since Driver.c uses this to decide the range of
  368. // ioctls to pass to DispatchIoctls
  369. //
  370. #define IOCTL_NETBT_LAST_IOCTL _NETBT_CTRL_CODE( 59, METHOD_OUT_DIRECT, \
  371. FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  372. #define NETBT_DISABLE_NETBIOS_SMB 0
  373. #define NETBT_ENABLE_NETBIOS_SMB 1
  374. #define NETBT_RESTORE_NETBIOS_SMB 2
  375. //
  376. // Used in IOCTL_NETBT_ADD_INTERFACE and IOCTL_NETBT_DELETE_INTERFACE
  377. //
  378. typedef struct _netbt_add_del_if {
  379. NTSTATUS Status;
  380. ULONG InstanceNumber; // instance number of this device
  381. ULONG Length; // length of the buffer
  382. WCHAR IfName[1]; // actual data
  383. } NETBT_ADD_DEL_IF, *PNETBT_ADD_DEL_IF;
  384. //
  385. // Used in IOCTL_NETBT_SET_WINS_ADDRESS
  386. //
  387. typedef struct _netbt_set_wins_addr {
  388. ULONG PrimaryWinsAddr;
  389. ULONG SecondaryWinsAddr;
  390. NTSTATUS Status;
  391. } NETBT_SET_WINS_ADDR, *PNETBT_SET_WINS_ADDR;
  392. #endif // VXD || CHICAGO_PRODUCT
  393. #endif // ifndef _NBTIOCTL_