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.

473 lines
16 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. local.h
  5. Abstract:
  6. This module contains various declarations for implementation
  7. specific "stuff".
  8. Author:
  9. Manny Weiser (mannyw) 21-Oct-1992
  10. Environment:
  11. User Mode - Win32
  12. Revision History:
  13. Madan Appiah (madana) 21-Oct-1993
  14. --*/
  15. #ifndef _LOCAL_
  16. #define _LOCAL_
  17. //
  18. // dhcp.c will #include this file with GLOBAL_DATA_ALLOCATE defined.
  19. // That will cause each of these variables to be allocated.
  20. //
  21. #ifdef GLOBAL_DATA_ALLOCATE
  22. #define EXTERN
  23. #else
  24. #define EXTERN extern
  25. #endif
  26. #define DAY_LONG_SLEEP 24*60*60 // in secs.
  27. #define INVALID_INTERFACE_CONTEXT 0xFFFF
  28. #define DHCP_NEW_IPADDRESS_EVENT_NAME TEXT("DHCPNEWIPADDRESS"
  29. //
  30. // Registry keys and values we're interested in.
  31. //
  32. #define DHCP_SERVICES_KEY TEXT("System\\CurrentControlSet\\Services")
  33. #define DHCP_ADAPTERS_KEY TEXT("System\\CurrentControlSet\\Services\\TCPIP\\Linkage")
  34. #define DHCP_ADAPTERS_VALUE TEXT("Bind")
  35. #define DHCP_ADAPTERS_VALUE_TYPE REG_MULTI_SZ
  36. #define DHCP_ADAPTERS_DEVICE_STRING TEXT("\\Device\\")
  37. #define DHCP_TCPIP_DEVICE_STRING TEXT("\\Device\\TCPIP_")
  38. #if defined(_PNP_POWER_)
  39. #define DHCP_NETBT_DEVICE_STRING TEXT("NetBT_TCPIP_")
  40. #else
  41. #define DHCP_NETBT_DEVICE_STRING TEXT("NetBT_")
  42. #endif _PNP_POWER_
  43. #define DHCP_CLIENT_ENABLE_DYNDNS_VALUE TEXT("EnableDynDNS")
  44. #define DHCP_CLIENT_ENABLE_DYNDNS_VALUE_TYPE REG_DWORD
  45. #ifdef DYNDNS_DNS_OVERRIDE_ENABLED
  46. #define DHCP_CLIENT_DYNDNS_DNS_OVERRIDE_VALUE TEXT("DynDNSServer")
  47. #define DHCP_CLIENT_DYNDNS_DNS_OVERRIDE_VALUE_TYPE REG_DWORD
  48. #endif
  49. #define DHCP_CLIENT_PARAMETER_KEY TEXT("System\\CurrentControlSet\\Services\\Dhcp\\Parameters")
  50. #if DBG
  51. #define DHCP_DEBUG_FLAG_VALUE TEXT("DebugFlag")
  52. #define DHCP_DEBUG_FLAG_VALUE_TYPE REG_DWORD
  53. #endif
  54. #define DHCP_CLIENT_OPTION_KEY TEXT("System\\CurrentControlSet\\Services\\Dhcp\\Parameters\\Options")
  55. #define DHCP_CLIENT_GLOBAL_CLASSES_KEY TEXT("System\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Classes")
  56. #define DHCP_CLIENT_CLASS_VALUE TEXT("DhcpMachineClass")
  57. #if defined(_PNP_POWER_)
  58. #define DHCP_ADAPTER_PARAMETERS_KEY TEXT("\\TCPIP\\Parameters\\Interfaces")
  59. #else
  60. #define DHCP_ADAPTER_PARAMETERS_KEY TEXT("\\Parameters\\TCPIP")
  61. #endif _PNP_POWER_
  62. #define DHCP_DEFAULT_GATEWAY_PARAMETER TEXT("DefaultGateway")
  63. #define DHCP_DONT_ADD_DEFAULT_GATEWAY_FLAG TEXT("DontAddDefaultGateway")
  64. #define DHCP_DONT_PING_GATEWAY_FLAG TEXT("DontPingGateway")
  65. #define DHCP_USE_MHASYNCDNS_FLAG TEXT("UseMHAsyncDns")
  66. #define DHCP_USE_INFORM_FLAG TEXT("UseInform")
  67. #define DHCP_INFORM_SEPARATION_INTERVAL TEXT("DhcpInformInterval")
  68. #define DHCP_TCPIP_PARAMETERS_KEY DHCP_SERVICES_KEY TEXT("\\TCPIP\\Parameters")
  69. #define DHCP_TCPIP_ADAPTER_PARAMETERS_KEY NULL
  70. #define DHCP_NAME_SERVER_VALUE TEXT("NameServer")
  71. #define DHCP_IPADDRESS_VALUE TEXT("IPAddress")
  72. #define DHCP_HOSTNAME_VALUE TEXT("Hostname")
  73. #define DHCP_DOMAINNAME_VALUE TEXT("Domain")
  74. #define DHCP_STATIC_DOMAIN_VALUE_A "Domain"
  75. #ifdef __DHCP_CLIENT_OPTIONS_API_ENABLED__
  76. #define DHCP_CLIENT_OPTION_SIZE TEXT("OptionSize")
  77. #define DHCP_CLIENT_OPTION_SIZE_TYPE REG_DWORD
  78. #define DHCP_CLIENT_OPTION_VALUE TEXT("OptionValue")
  79. #define DHCP_CLIENT_OPTION_VALUE_TYPE REG_BINARY
  80. #endif
  81. #define REGISTRY_CONNECT L'\\'
  82. #define REGISTRY_CONNECT_STRING TEXT("\\")
  83. #define DHCP_CLIENT_OPTION_REG_LOCATION TEXT("RegLocation")
  84. #define DHCP_CLIENT_OPTION_REG_LOCATION_TYPE REG_SZ
  85. #define DHCP_CLIENT_OPTION_REG_KEY_TYPE TEXT("KeyType")
  86. #define DHCP_CLIENT_OPTION_REG_KEY_TYPE_TYPE REG_DWORD
  87. #define DHCP_CLASS_LOCATION_VALUE TEXT("DhcpClientClassLocation")
  88. #define DHCP_CLASS_LOCATION_TYPE REG_MULTI_SZ
  89. #define DEFAULT_USER_CLASS_LOCATION TEXT("Tcpip\\Parameters\\Interfaces\\?\\DhcpClassIdBin")
  90. #define DEFAULT_USER_CLASS_LOC_FULL DHCP_SERVICES_KEY REGISTRY_CONNECT_STRING DEFAULT_USER_CLASS_LOCATION
  91. #define DEFAULT_USER_CLASS_UI_LOCATION TEXT("Tcpip\\Parameters\\Interfaces\\?\\DhcpClassId")
  92. #define DEFAULT_USER_CLASS_UI_LOC_FULL DHCP_SERVICES_KEY REGISTRY_CONNECT_STRING DEFAULT_USER_CLASS_UI_LOCATION
  93. // ******** Don;t chagne regloc for below.. it also affects DHCP_REGISTER_OPTION_LOC below
  94. #define DEFAULT_REGISTER_OPT_LOC TEXT("Tcpip\\Parameters\\Interfaces\\?\\DhcpRequestOptions")
  95. #define DHCP_OPTION_LIST_VALUE TEXT("DhcpOptionLocationList")
  96. #define DHCP_OPTION_LIST_TYPE REG_MULTI_SZ
  97. #define NETBIOSLESS_OPT TEXT("DhcpNetbiosLessOption\0")
  98. #define DEFAULT_DHCP_KEYS_LIST_VALUE (L"1\0" L"15\0" L"3\0" L"44\0" L"46\0" L"47\0" L"6\0" NETBIOSLESS_OPT)
  99. #define DHCP_OPTION_OPTIONID_VALUE TEXT("OptionId")
  100. #define DHCP_OPTION_OPTIONID_TYPE REG_DWORD
  101. #define DHCP_OPTION_ISVENDOR_VALUE TEXT("VendorType")
  102. #define DHCP_OPTION_ISVENDOR_TYPE REG_DWORD
  103. #define DHCP_OPTION_SAVE_TYPE_VALUE TEXT("KeyType")
  104. #define DHCP_OPTION_SAVE_TYPE_TYPE REG_DWORD
  105. #define DHCP_OPTION_CLASSID_VALUE TEXT("ClassId")
  106. #define DHCP_OPTION_CLASSID_TYPE REG_BINARY
  107. #define DHCP_OPTION_SAVE_LOCATION_VALUE TEXT("RegLocation")
  108. #define DHCP_OPTION_SAVE_LOCATION_TYPE REG_MULTI_SZ
  109. #define DHCP_OPTION_SEND_LOCATION_VALUE TEXT("RegSendLocation")
  110. #define DHCP_OPTION_SEND_LOCATION_TYPE REG_MULTI_SZ
  111. #define DHCP_ENABLE_STRING TEXT("EnableDhcp")
  112. #define DHCP_ENABLE_STRING_TYPE REG_DWORD
  113. #define DHCP_IP_ADDRESS_STRING TEXT("DhcpIPAddress")
  114. #define DHCP_IP_ADDRESS_STRING_TYPE REG_SZ
  115. #define DHCP_SUBNET_MASK_STRING TEXT("DhcpSubnetMask")
  116. #define DHCP_SUBNET_MASK_STRING_TYPE REG_SZ
  117. #define DHCP_SERVER TEXT("DhcpServer")
  118. #define DHCP_SERVER_TYPE REG_SZ
  119. #define DHCP_LEASE TEXT("Lease")
  120. #define DHCP_LEASE_TYPE REG_DWORD
  121. #define DHCP_LEASE_OBTAINED_TIME TEXT("LeaseObtainedTime")
  122. #define DHCP_LEASE_OBTAINED_TIME_TYPE REG_DWORD
  123. #define DHCP_LEASE_T1_TIME TEXT("T1")
  124. #define DHCP_LEASE_T1_TIME_TYPE REG_DWORD
  125. #define DHCP_LEASE_T2_TIME TEXT("T2")
  126. #define DHCP_LEASE_T2_TIME_TYPE REG_DWORD
  127. #define DHCP_LEASE_TERMINATED_TIME TEXT("LeaseTerminatesTime")
  128. #define DHCP_LEASE_TERMINATED_TIME_TYPE REG_DWORD
  129. #define DHCP_IP_INTERFACE_CONTEXT TEXT("IpInterfaceContext")
  130. #define DHCP_IP_INTERFACE_CONTEXT_TYPE REG_DWORD
  131. #define DHCP_IP_INTERFACE_CONTEXT_MAX TEXT("IpInterfaceContextMax")
  132. #define DHCP_IP_INTERFACE_CONTEXT_MAX_TYPE REG_DWORD
  133. #if defined(_PNP_POWER_)
  134. #define DHCP_NTE_CONTEXT_LIST TEXT("NTEContextList")
  135. #define DHCP_NTE_CONTEXT_LIST_TYPE REG_MULTI_SZ
  136. #endif _PNP_POWER_
  137. #define DHCP_CLIENT_IDENTIFIER_FORMAT TEXT("DhcpClientIdentifierType")
  138. #define DHCP_CLIENT_IDENTIFIER_FORMAT_TYPE REG_DWORD
  139. #define DHCP_CLIENT_IDENTIFIER_VALUE TEXT("DhcpClientIdentifier")
  140. #define DHCP_DYNDNS_UPDATE_REQUIRED TEXT("DNSUpdateRequired")
  141. #define DHCP_DYNDNS_UPDATE_REQUIRED_TYPE REG_DWORD
  142. #define DHCP_IPAUTOCONFIGURATION_ENABLED TEXT("IPAutoconfigurationEnabled")
  143. #define DHCP_IPAUTOCONFIGURATION_ENABLED_TYPE REG_DWORD
  144. #define DHCP_IPAUTOCONFIGURATION_ADDRESS TEXT("IPAutoconfigurationAddress")
  145. #define DHCP_IPAUTOCONFIGURATION_ADDRESS_TYPE REG_SZ
  146. #define DHCP_IPAUTOCONFIGURATION_SUBNET TEXT("IPAutoconfigurationSubnet")
  147. #define DHCP_IPAUTOCONFIGURATION_SUBNET_TYPE REG_SZ
  148. #define DHCP_IPAUTOCONFIGURATION_MASK TEXT("IPAutoconfigurationMask")
  149. #define DHCP_IPAUTOCONFIGURATION_MASK_TYPE REG_SZ
  150. #define DHCP_IPAUTOCONFIGURATION_SEED TEXT("IPAutoconfigurationSeed")
  151. #define DHCP_IPAUTOCONFIGURATION_SEED_TYPE REG_DWORD
  152. #define DHCP_OPTION_EXPIRATION_DATE TEXT("ExpirationTime")
  153. #define DHCP_OPTION_EXPIRATION_DATE_TYPE REG_BINARY
  154. #define DHCP_MACHINE_TYPE TEXT("MachineType")
  155. #define DHCP_MACHINE_TYPE_TYPE REG_DWORD
  156. #define DHCP_AUTONET_RETRIES_VALUE TEXT("AutonetRetries")
  157. #define DHCP_AUTONET_RETRIES_VALUE_TYPE REG_DWORD
  158. #define DHCP_ADDRESS_TYPE_VALUE TEXT("AddressType")
  159. #define DHCP_ADDRESS_TYPE_TYPE REG_DWORD
  160. #if DBG
  161. #define DHCP_LEASE_OBTAINED_CTIME TEXT("LeaseObtainedCTime"
  162. #define DHCP_LEASE_OBTAINED_CTIME_TYPE REG_SZ
  163. #define DHCP_LEASE_T1_CTIME TEXT("T1CTime")
  164. #define DHCP_LEASE_T1_CTIME_TYPE REG_SZ
  165. #define DHCP_LEASE_T2_CTIME TEXT("T2CTime")
  166. #define DHCP_LEASE_T2_CTIME_TYPE REG_SZ
  167. #define DHCP_LEASE_TERMINATED_CTIME TEXT("LeaseTerminatesCTime")
  168. #define DHCP_LEASE_TERMINATED_CTIME_TYPE REG_SZ
  169. #define DHCP_OPTION_EXPIRATION_CDATE TEXT("ExpirationCTime")
  170. #define DHCP_OPTION_EXPIRATION_CDATE_TYPE REG_SZ
  171. #endif
  172. // options api specials
  173. #define DHCPAPI_VALID_VALUE TEXT("Valid")
  174. #define DHCPAPI_VALID_VALUE_TYPE REG_DWORD
  175. #define DHCPAPI_AVAIL_VALUE TEXT("AvailableOptions")
  176. #define DHCPAPI_AVAIL_VALUE_TYPE REG_BINARY
  177. #define DHCPAPI_REQUESTED_VALUE TEXT("RequestedOptions")
  178. #define DHCPAPI_REQUESTED_VALUE_TYPE REG_BINARY
  179. #define DHCPAPI_RAW_OPTIONS_VALUE TEXT("RawOptionsValue")
  180. #define DHCPAPI_RAW_OPTIONS_VALUE_TYPE REG_BINARY
  181. #define DHCPAPI_RAW_LENGTH_VALUE TEXT("RawOptionsLength")
  182. #define DHCPAPI_RAW_LENGTH_VALUE_TYPE REG_DWORD
  183. #define DHCPAPI_GATEWAY_VALUE TEXT("LastGateWay")
  184. #define DHCPAPI_GATEWAY_VALUE_TYPE REG_DWORD
  185. // this tag is used to locate dns updates requests on the renewal list
  186. #define DHCP_DNS_UPDATE_CONTEXT_TAG TEXT("DNSUpdateRetry")
  187. // This semaphore cannot have backward slashes in it.
  188. #define DHCP_REQUEST_OPTIONS_API_SEMAPHORE TEXT("DhcpRequestOptionsAPI")
  189. // the client vendor name (DhcpGlobalClientClassInfo) value is this..
  190. #define DHCP_DEFAULT_CLIENT_CLASS_INFO "MSFT 5.0"
  191. // the location for storing options for DhcpRegisterOptions API.
  192. // ****** Don't change the foll value -- it also changes DEFAULT_REGISTER_OPT_LOC above
  193. //
  194. #define DHCP_REGISTER_OPTIONS_LOC DHCP_TCPIP_PARAMETERS_KEY L"\\Interfaces\\?\\DhcpRequestOptions"
  195. //
  196. // size of the largest adapter name in unicode.
  197. //
  198. #define ADAPTER_STRING_SIZE 512
  199. //
  200. // windows version info.
  201. //
  202. #define HOST_COMMENT_LENGTH 128
  203. #define WINDOWS_32S "Win32s on Windows 3.1"
  204. #define WINDOWS_NT "Windows NT"
  205. #define DHCP_NAMESERVER_BACKUP TEXT("Backup")
  206. #define DHCP_NAMESERVER_BACKUP_LIST TEXT("BackupList")
  207. //
  208. // Adapter Key - replacement character.
  209. //
  210. #define OPTION_REPLACE_CHAR L'\?'
  211. //
  212. // registry access key.
  213. //
  214. #define DHCP_CLIENT_KEY_ACCESS (KEY_QUERY_VALUE | \
  215. KEY_SET_VALUE | \
  216. KEY_CREATE_SUB_KEY | \
  217. KEY_ENUMERATE_SUB_KEYS)
  218. //
  219. // Dhcp registry class.
  220. //
  221. #define DHCP_CLASS TEXT("DhcpClientClass")
  222. #define DHCP_CLASS_SIZE sizeof(DHCP_CLASS)
  223. //
  224. // Option ID key length.
  225. //
  226. #define DHCP_OPTION_KEY_LEN 32
  227. //
  228. // The name of the DHCP service DLL
  229. //
  230. #define DHCP_SERVICE_DLL TEXT("dhcpcsvc.dll")
  231. //
  232. // command values for SetDefaultGateway function.
  233. #define DEFAULT_GATEWAY_ADD 0
  234. #define DEFAULT_GATEWAY_DELETE 1
  235. //
  236. // A block NT specific context information, appended the the DHCP work
  237. // context block.
  238. //
  239. typedef struct _LOCAL_CONTEXT_INFO {
  240. DWORD IpInterfaceContext;
  241. DWORD IpInterfaceInstance; // needed for BringUpInterface
  242. LPWSTR AdapterName;
  243. #if !defined(_PNP_POWER_)
  244. LPWSTR DeviceName;
  245. #endif _PNP_POWER_
  246. LPWSTR NetBTDeviceName;
  247. LPWSTR RegistryKey;
  248. SOCKET Socket;
  249. BOOL DefaultGatewaysSet;
  250. } LOCAL_CONTEXT_INFO, *PLOCAL_CONTEXT_INFO;
  251. //
  252. // Other service specific options info struct.
  253. //
  254. typedef struct _SERVICE_SPECIFIC_DHCP_OPTION {
  255. DHCP_OPTION_ID OptionId;
  256. LPWSTR RegKey; // alloted memory.
  257. LPWSTR ValueName; // embedded in the RegKey memory.
  258. DWORD ValueType;
  259. DWORD OptionLength;
  260. #ifdef __DHCP_CLIENT_OPTIONS_API_ENABLED__
  261. time_t ExpirationDate; // this value is used to decide when to stop
  262. // requested unneeded options.
  263. #endif
  264. LPBYTE RawOptionValue;
  265. } SERVICE_SPECIFIC_DHCP_OPTION, *LPSERVICE_SPECIFIC_DHCP_OPTION;
  266. //
  267. // Key query Info.
  268. //
  269. typedef struct _DHCP_KEY_QUERY_INFO {
  270. WCHAR Class[DHCP_CLASS_SIZE];
  271. DWORD ClassSize;
  272. DWORD NumSubKeys;
  273. DWORD MaxSubKeyLen;
  274. DWORD MaxClassLen;
  275. DWORD NumValues;
  276. DWORD MaxValueNameLen;
  277. DWORD MaxValueLen;
  278. DWORD SecurityDescriptorLen;
  279. FILETIME LastWriteTime;
  280. } DHCP_KEY_QUERY_INFO, *LPDHCP_KEY_QUERY_INFO;
  281. //
  282. // Global variables.
  283. //
  284. //
  285. // client specific option list.
  286. //
  287. EXTERN HINSTANCE DhcpGlobalMessageFileHandle;
  288. EXTERN DWORD DhcpGlobalOptionCount;
  289. EXTERN LPSERVICE_SPECIFIC_DHCP_OPTION DhcpGlobalOptionInfo;
  290. EXTERN LPBYTE DhcpGlobalOptionList;
  291. //
  292. // Service variables
  293. //
  294. EXTERN SERVICE_STATUS DhcpGlobalServiceStatus;
  295. EXTERN SERVICE_STATUS_HANDLE DhcpGlobalServiceStatusHandle;
  296. //
  297. // To signal to stop the service.
  298. //
  299. EXTERN HANDLE DhcpGlobalTerminateEvent;
  300. //
  301. // multi home flag.
  302. //
  303. EXTERN BOOL DhcpGlobalMultiHomedHost;
  304. //
  305. // Client APIs over name pipe variables.
  306. //
  307. EXTERN HANDLE DhcpGlobalClientApiPipe;
  308. EXTERN HANDLE DhcpGlobalClientApiPipeEvent;
  309. EXTERN OVERLAPPED DhcpGlobalClientApiOverLapBuffer;
  310. //
  311. // Message Popup Thread handle.
  312. //
  313. EXTERN HANDLE DhcpGlobalMsgPopupThreadHandle;
  314. EXTERN BOOL DhcpGlobalDisplayPopup;
  315. EXTERN CRITICAL_SECTION DhcpGlobalPopupCritSect;
  316. #define LOCK_POPUP() EnterCriticalSection(&DhcpGlobalPopupCritSect)
  317. #define UNLOCK_POPUP() LeaveCriticalSection(&DhcpGlobalPopupCritSect)
  318. //
  319. // winsock variables.
  320. //
  321. EXTERN WSADATA DhcpGlobalWsaData;
  322. EXTERN BOOL DhcpGlobalWinSockInitialized;
  323. EXTERN BOOL DhcpGlobalGatewaysSet;
  324. EXTERN BOOL DhcpGlobalIsService;
  325. //
  326. // a named event that notifies the ip address changes to
  327. // external apps.
  328. //
  329. EXTERN HANDLE DhcpGlobalNewIpAddressNotifyEvent;
  330. EXTERN UINT DhcpGlobalIPEventSeqNo;
  331. #endif // _LOCAL_