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.

361 lines
8.6 KiB

  1. //=================================================================
  2. //
  3. // NTDriverIO.cpp --
  4. //
  5. // Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. // Revisions: 07/07/99 a-peterc Created
  8. //
  9. //=================================================================
  10. #include <nt.h>
  11. #include <ntrtl.h>
  12. #include <nturtl.h>
  13. #include <ntobapi.h>
  14. #define _WINNT_ // have what is needed from above
  15. #include "precomp.h"
  16. #include "CNdisApi.h"
  17. #include "ndismisc.h"
  18. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  19. Function: CNdisApi::CNdisApi()
  20. Description: encapsulates the functionallity of NdisHandlePnPEvent()
  21. Arguments:
  22. Returns:
  23. Inputs:
  24. Outputs:
  25. Caveats:
  26. Raid:
  27. History: a-peterc 15-Nov-1998 Created
  28. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  29. CNdisApi::CNdisApi()
  30. {
  31. }
  32. //
  33. CNdisApi::~CNdisApi()
  34. {
  35. }
  36. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  37. Function: UINT CNdisApi::PnpUpdateGateway(
  38. PCWSTR a_pAdapter,
  39. BOOL a_fRouterDiscovery,
  40. BOOL a_fIPEnableRouter
  41. )
  42. Description: PNP notification of gateway changes
  43. Arguments:
  44. Returns: win32 error code
  45. Inputs:
  46. Outputs:
  47. Caveats:
  48. Raid:
  49. History: a-peterc 07-July-1999 Created
  50. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  51. UINT CNdisApi::PnpUpdateGateway(
  52. PCWSTR a_pAdapter
  53. )
  54. {
  55. IP_PNP_RECONFIG_REQUEST IpReconfigRequest;
  56. memset( &IpReconfigRequest, NULL, sizeof( IP_PNP_RECONFIG_REQUEST ) ) ;
  57. // DWORD version
  58. IpReconfigRequest.version = IP_PNP_RECONFIG_VERSION;
  59. IpReconfigRequest.gatewayListUpdate = TRUE ;
  60. IpReconfigRequest.InterfaceMetricUpdate = TRUE ;
  61. IpReconfigRequest.Flags = IP_PNP_FLAG_GATEWAY_LIST_UPDATE |
  62. IP_PNP_FLAG_INTERFACE_METRIC_UPDATE ;
  63. IpReconfigRequest.gatewayListUpdate = TRUE ;
  64. IpReconfigRequest.InterfaceMetricUpdate = TRUE ;
  65. CHString t_chsAdapterDevice(L"\\Device\\") ;
  66. t_chsAdapterDevice += a_pAdapter ;
  67. UNICODE_STRING t_strAdapter ;
  68. RtlInitUnicodeString( &t_strAdapter, t_chsAdapterDevice ) ;
  69. UNICODE_STRING t_strTcpIp ;
  70. RtlInitUnicodeString( &t_strTcpIp, L"Tcpip" ) ;
  71. UNICODE_STRING t_strBinding ;
  72. RtlInitUnicodeString( &t_strBinding, L"" ) ;
  73. t_strBinding.MaximumLength = 0;
  74. UINT t_iRet = NdisHandlePnPEvent(
  75. NDIS,
  76. RECONFIGURE,
  77. &t_strAdapter,
  78. &t_strTcpIp,
  79. &t_strBinding,
  80. &IpReconfigRequest,
  81. sizeof( IP_PNP_RECONFIG_REQUEST )
  82. ) ;
  83. if( !t_iRet )
  84. {
  85. t_iRet = GetLastError();
  86. }
  87. return t_iRet;
  88. }
  89. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  90. Function: UINT CNdisApi::PnpUpdateNbtAdapter( PCWSTR a_pAdapter )
  91. Description: PNP notification of NetBios adapter level changes
  92. Arguments:
  93. Returns: win32 error code
  94. Inputs:
  95. Outputs:
  96. Caveats:
  97. Raid:
  98. History: a-peterc 07-July-1999 Created
  99. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  100. UINT CNdisApi::PnpUpdateNbtAdapter( PCWSTR a_pAdapter )
  101. {
  102. CHString t_chsAdapterDevice(L"\\Device\\") ;
  103. t_chsAdapterDevice += a_pAdapter ;
  104. UNICODE_STRING t_strAdapter ;
  105. RtlInitUnicodeString( &t_strAdapter, t_chsAdapterDevice ) ;
  106. UNICODE_STRING t_strNetBT ;
  107. RtlInitUnicodeString( &t_strNetBT, L"NetBT" ) ;
  108. UNICODE_STRING t_strBinding ;
  109. RtlInitUnicodeString( &t_strBinding, L"" ) ;
  110. t_strBinding.MaximumLength = 0;
  111. // per adapter notification
  112. UINT t_iRet = NdisHandlePnPEvent(
  113. TDI,
  114. RECONFIGURE,
  115. &t_strAdapter,
  116. &t_strNetBT,
  117. &t_strBinding,
  118. NULL,
  119. 0
  120. ) ;
  121. if( !t_iRet )
  122. {
  123. t_iRet = GetLastError();
  124. }
  125. return t_iRet;
  126. }
  127. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  128. Function: UINT CNdisApi::PnpUpdateNbtGlobal(
  129. BOOL a_fLmhostsFileSet,
  130. BOOL a_fEnableLmHosts
  131. )
  132. Description: PNP notification of NetBios global level changes
  133. Arguments:
  134. Returns: win32 error code
  135. Inputs:
  136. Outputs:
  137. Caveats:
  138. Raid:
  139. History: a-peterc 07-July-1999 Created
  140. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  141. UINT CNdisApi::PnpUpdateNbtGlobal(
  142. BOOL a_fLmhostsFileSet,
  143. BOOL a_fEnableLmHosts
  144. )
  145. {
  146. NETBT_PNP_RECONFIG_REQUEST t_NetbtReconfigRequest;
  147. memset( &t_NetbtReconfigRequest, NULL, sizeof( NETBT_PNP_RECONFIG_REQUEST ) ) ;
  148. // DWORD version
  149. t_NetbtReconfigRequest.version = 1;
  150. t_NetbtReconfigRequest.enumDnsOption = WinsThenDns;
  151. t_NetbtReconfigRequest.fScopeIdUpdated = FALSE;
  152. t_NetbtReconfigRequest.fLmhostsEnabled = a_fEnableLmHosts == 0 ? 0 : 1;
  153. t_NetbtReconfigRequest.fLmhostsFileSet = a_fLmhostsFileSet == 0 ? 0 : 1;
  154. UNICODE_STRING t_strAdapter ;
  155. RtlInitUnicodeString( &t_strAdapter, L"" ) ;
  156. UNICODE_STRING t_strNetBT ;
  157. RtlInitUnicodeString( &t_strNetBT, L"NetBT" ) ;
  158. UNICODE_STRING t_strBinding ;
  159. RtlInitUnicodeString( &t_strBinding, L"" ) ;
  160. t_strBinding.MaximumLength = 0;
  161. // global notification
  162. UINT t_iRet = NdisHandlePnPEvent(
  163. TDI,
  164. RECONFIGURE,
  165. &t_strAdapter,
  166. &t_strNetBT,
  167. &t_strBinding,
  168. &t_NetbtReconfigRequest,
  169. sizeof( NETBT_PNP_RECONFIG_REQUEST )
  170. ) ;
  171. if( !t_iRet )
  172. {
  173. t_iRet = GetLastError();
  174. }
  175. return t_iRet;
  176. }
  177. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  178. Function: UINT CNdisApi::PnpUpdateIpxGlobal()
  179. Description: PNP notification of IPX global level changes
  180. Arguments:
  181. Returns: win32 error code
  182. Inputs:
  183. Outputs:
  184. Caveats:
  185. Raid:
  186. History: a-peterc 07-July-1999 Created
  187. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  188. UINT CNdisApi::PnpUpdateIpxGlobal()
  189. {
  190. RECONFIG t_IpxConfig ;
  191. memset( &t_IpxConfig, NULL, sizeof( RECONFIG ) ) ;
  192. // DWORD version
  193. t_IpxConfig.ulVersion = IPX_RECONFIG_VERSION;
  194. t_IpxConfig.InternalNetworkNumber = TRUE;
  195. UNICODE_STRING t_strAdapter ;
  196. RtlInitUnicodeString( &t_strAdapter, L"" ) ;
  197. UNICODE_STRING t_strIPX ;
  198. RtlInitUnicodeString( &t_strIPX, L"NwlnkIpx" ) ;
  199. UNICODE_STRING t_strBinding ;
  200. RtlInitUnicodeString( &t_strBinding, L"" ) ;
  201. t_strBinding.MaximumLength = 0;
  202. // global notification
  203. UINT t_iRet = NdisHandlePnPEvent(
  204. NDIS,
  205. RECONFIGURE,
  206. &t_strAdapter,
  207. &t_strIPX,
  208. &t_strBinding,
  209. &t_IpxConfig,
  210. sizeof( RECONFIG )
  211. ) ;
  212. if( !t_iRet )
  213. {
  214. t_iRet = GetLastError();
  215. }
  216. return t_iRet;
  217. }
  218. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  219. Function: UINT CNdisApi::PnpUpdateIpxAdapter( PCWSTR a_pAdapter, BOOL a_fAuto )
  220. Description: PNP notification of IPX adapter level changes
  221. Arguments:
  222. Returns: win32 error code
  223. Inputs:
  224. Outputs:
  225. Caveats:
  226. Raid:
  227. History: a-peterc 07-July-1999 Created
  228. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  229. UINT CNdisApi::PnpUpdateIpxAdapter( PCWSTR a_pAdapter, BOOL a_fAuto )
  230. {
  231. RECONFIG t_IpxConfig ;
  232. memset( &t_IpxConfig, NULL, sizeof( RECONFIG ) ) ;
  233. // DWORD version
  234. t_IpxConfig.ulVersion = IPX_RECONFIG_VERSION;
  235. t_IpxConfig.InternalNetworkNumber = FALSE ;
  236. t_IpxConfig.AdapterParameters[ a_fAuto ? RECONFIG_AUTO_DETECT : RECONFIG_MANUAL ] = TRUE;
  237. // set all frame types
  238. memset( &t_IpxConfig.AdapterParameters[ RECONFIG_PREFERENCE_1 ],
  239. TRUE,
  240. sizeof(BOOLEAN) * 8) ;
  241. CHString t_chsAdapterDevice(L"\\Device\\") ;
  242. t_chsAdapterDevice += a_pAdapter ;
  243. UNICODE_STRING t_strAdapter ;
  244. RtlInitUnicodeString( &t_strAdapter, t_chsAdapterDevice ) ;
  245. UNICODE_STRING t_strIPX ;
  246. RtlInitUnicodeString( &t_strIPX, L"NwlnkIpx" ) ;
  247. UNICODE_STRING t_strBinding ;
  248. RtlInitUnicodeString( &t_strBinding, L"" ) ;
  249. t_strBinding.MaximumLength = 0;
  250. // global notification
  251. UINT t_iRet = NdisHandlePnPEvent(
  252. NDIS,
  253. RECONFIGURE,
  254. &t_strAdapter,
  255. &t_strIPX,
  256. &t_strBinding,
  257. &t_IpxConfig,
  258. sizeof( RECONFIG )
  259. ) ;
  260. if( !t_iRet )
  261. {
  262. t_iRet = GetLastError();
  263. }
  264. return t_iRet;
  265. }