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.

899 lines
30 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: R O U T E R . C P P
  7. //
  8. // Contents: Implementation of functions used to setup the router.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 13 Oct 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include <fltdefs.h> // must include for iprtinfo.h
  18. #include <ipinfoid.h>
  19. #include <iprtinfo.h>
  20. #include <iprtrmib.h>
  21. #include <ipxrtdef.h>
  22. #include <mprerror.h>
  23. #include <tdi.h> // must include for isnkrnl.h
  24. #include <isnkrnl.h>
  25. #include <rtinfo.h>
  26. #include <routprot.h>
  27. #include "router.h"
  28. #define PAD8(_p) (((ULONG_PTR)(_p) + ALIGN_SHIFT) & ALIGN_MASK)
  29. //+---------------------------------------------------------------------------
  30. //
  31. // Function: MakeIpInterfaceInfo
  32. //
  33. // Purpose: Create the router interface block for IP.
  34. //
  35. // Arguments:
  36. // pszwAdapterName [in] The adapter name
  37. // dwPacketType [in] The packet type
  38. // ppBuff [out] Pointer to the returned info.
  39. // Free with delete.
  40. //
  41. // Returns: nothing
  42. //
  43. // Author: shaunco 28 Jul 1997
  44. //
  45. // Notes:
  46. //
  47. void MakeIpInterfaceInfo (
  48. PCWSTR pszwAdapterName,
  49. DWORD dwPacketType,
  50. LPBYTE* ppBuff)
  51. {
  52. UNREFERENCED_PARAMETER (pszwAdapterName);
  53. UNREFERENCED_PARAMETER (dwPacketType);
  54. Assert (ppBuff);
  55. const int c_cTocEntries = 3;
  56. // Alocate for minimal global Information.
  57. //
  58. DWORD dwSize = sizeof( RTR_INFO_BLOCK_HEADER )
  59. // header contains one TOC_ENTRY already
  60. + ((c_cTocEntries - 1) * sizeof( RTR_TOC_ENTRY ))
  61. + sizeof( INTERFACE_STATUS_INFO )
  62. + sizeof( RTR_DISC_INFO )
  63. + (c_cTocEntries * ALIGN_SIZE);
  64. PRTR_INFO_BLOCK_HEADER pIBH = (PRTR_INFO_BLOCK_HEADER) MemAlloc(dwSize);
  65. if (!pIBH)
  66. {
  67. *ppBuff = NULL;
  68. return;
  69. }
  70. ZeroMemory (pIBH, dwSize);
  71. *ppBuff = (LPBYTE) pIBH;
  72. // Initialize infobase fields.
  73. //
  74. pIBH->Version = RTR_INFO_BLOCK_VERSION;
  75. pIBH->Size = dwSize;
  76. pIBH->TocEntriesCount = c_cTocEntries;
  77. LPBYTE pbDataPtr = (LPBYTE) &( pIBH-> TocEntry[ pIBH->TocEntriesCount ] );
  78. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  79. PRTR_TOC_ENTRY pTocEntry = pIBH->TocEntry;
  80. // Create empty route info block
  81. //
  82. pTocEntry->InfoType = IP_ROUTE_INFO;
  83. pTocEntry->InfoSize = sizeof( MIB_IPFORWARDROW );
  84. pTocEntry->Count = 0;
  85. pTocEntry->Offset = pbDataPtr - (LPBYTE)pIBH;
  86. pbDataPtr += pTocEntry->Count * pTocEntry->InfoSize;
  87. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  88. pTocEntry++;
  89. // Create interface status block.
  90. //
  91. pTocEntry->InfoType = IP_INTERFACE_STATUS_INFO;
  92. pTocEntry->InfoSize = sizeof( INTERFACE_STATUS_INFO );
  93. pTocEntry->Count = 1;
  94. pTocEntry->Offset = pbDataPtr - (LPBYTE)pIBH;
  95. PINTERFACE_STATUS_INFO pifStat = (PINTERFACE_STATUS_INFO)pbDataPtr;
  96. pifStat->dwAdminStatus = MIB_IF_ADMIN_STATUS_UP;
  97. pbDataPtr += pTocEntry->Count * pTocEntry->InfoSize;
  98. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  99. pTocEntry++;
  100. // Create Router Disc. Info.
  101. //
  102. pTocEntry->InfoType = IP_ROUTER_DISC_INFO;
  103. pTocEntry->InfoSize = sizeof( RTR_DISC_INFO );
  104. pTocEntry->Count = 1;
  105. pTocEntry->Offset = pbDataPtr - (LPBYTE)pIBH;
  106. PRTR_DISC_INFO pRtrDisc = (PRTR_DISC_INFO)pbDataPtr;
  107. pRtrDisc->bAdvertise = FALSE;
  108. pRtrDisc->wMaxAdvtInterval = DEFAULT_MAX_ADVT_INTERVAL;
  109. pRtrDisc->wMinAdvtInterval = DEFAULT_MIN_ADVT_INTERVAL_RATIO * DEFAULT_MAX_ADVT_INTERVAL;
  110. pRtrDisc->wAdvtLifetime = DEFAULT_ADVT_LIFETIME_RATIO * DEFAULT_MAX_ADVT_INTERVAL;
  111. pRtrDisc->lPrefLevel = DEFAULT_PREF_LEVEL;
  112. }
  113. //+---------------------------------------------------------------------------
  114. //
  115. // Function: MakeIpTransportInfo
  116. //
  117. // Purpose: Create the router transport blocks for IP. Free with delete.
  118. //
  119. // Arguments:
  120. // ppBuffGlobal [out] Pointer to the returned global block.
  121. // ppBuffClient [out] Pointer to the returned client block.
  122. //
  123. // Returns: nothing
  124. //
  125. // Author: shaunco 28 Jul 1997
  126. //
  127. // Notes:
  128. //
  129. void MakeIpTransportInfo (LPBYTE* ppBuffGlobal, LPBYTE* ppBuffClient)
  130. {
  131. Assert (ppBuffGlobal);
  132. Assert (ppBuffClient);
  133. *ppBuffClient = NULL;
  134. const int c_cTocEntries = 2;
  135. const int c_cProtocols = 7;
  136. // Alocate for minimal global Information.
  137. //
  138. DWORD dwSize = sizeof( RTR_INFO_BLOCK_HEADER )
  139. // header contains one TOC_ENTRY already
  140. + ((c_cTocEntries - 1) * sizeof( RTR_TOC_ENTRY ))
  141. + sizeof(GLOBAL_INFO)
  142. + SIZEOF_PRIORITY_INFO(c_cProtocols)
  143. + (c_cTocEntries * ALIGN_SIZE);
  144. PRTR_INFO_BLOCK_HEADER pIBH = (PRTR_INFO_BLOCK_HEADER) MemAlloc(dwSize);
  145. if (!pIBH)
  146. {
  147. *ppBuffGlobal = NULL;
  148. return;
  149. }
  150. ZeroMemory (pIBH, dwSize);
  151. *ppBuffGlobal = (LPBYTE) pIBH;
  152. // Initialize infobase fields.
  153. //
  154. pIBH->Version = RTR_INFO_BLOCK_VERSION;
  155. pIBH->Size = dwSize;
  156. pIBH->TocEntriesCount = c_cTocEntries;
  157. LPBYTE pbDataPtr = (LPBYTE) &( pIBH->TocEntry[ pIBH->TocEntriesCount ] );
  158. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  159. PRTR_TOC_ENTRY pTocEntry = pIBH->TocEntry;
  160. // Make IP router manager global info.
  161. //
  162. pTocEntry->InfoType = IP_GLOBAL_INFO;
  163. pTocEntry->InfoSize = sizeof(GLOBAL_INFO);
  164. pTocEntry->Count = 1;
  165. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  166. PGLOBAL_INFO pGlbInfo = (PGLOBAL_INFO) pbDataPtr;
  167. pGlbInfo->bFilteringOn = FALSE;
  168. pGlbInfo->dwLoggingLevel = IPRTR_LOGGING_ERROR;
  169. pbDataPtr += pTocEntry->Count * pTocEntry-> InfoSize;
  170. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  171. pTocEntry++;
  172. // Make IP router manager priority info.
  173. //
  174. pTocEntry->InfoType = IP_PROT_PRIORITY_INFO;
  175. pTocEntry->InfoSize = SIZEOF_PRIORITY_INFO(c_cProtocols);
  176. pTocEntry->Count = 1;
  177. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  178. PPRIORITY_INFO pPriorInfo = (PPRIORITY_INFO) pbDataPtr;
  179. pPriorInfo->dwNumProtocols = c_cProtocols;
  180. pPriorInfo->ppmProtocolMetric[ 0 ].dwProtocolId = PROTO_IP_LOCAL;
  181. pPriorInfo->ppmProtocolMetric[ 0 ].dwMetric = 1;
  182. pPriorInfo->ppmProtocolMetric[ 1 ].dwProtocolId = PROTO_IP_NETMGMT;
  183. pPriorInfo->ppmProtocolMetric[ 1 ].dwMetric = 10;
  184. pPriorInfo->ppmProtocolMetric[ 2 ].dwProtocolId = PROTO_IP_NT_STATIC;
  185. pPriorInfo->ppmProtocolMetric[ 2 ].dwMetric = 3;
  186. pPriorInfo->ppmProtocolMetric[ 3 ].dwProtocolId = PROTO_IP_NT_STATIC_NON_DOD;
  187. pPriorInfo->ppmProtocolMetric[ 3 ].dwMetric = 5;
  188. pPriorInfo->ppmProtocolMetric[ 4 ].dwProtocolId = PROTO_IP_NT_AUTOSTATIC;
  189. pPriorInfo->ppmProtocolMetric[ 4 ].dwMetric = 7;
  190. pPriorInfo->ppmProtocolMetric[ 5 ].dwProtocolId = PROTO_IP_OSPF;
  191. pPriorInfo->ppmProtocolMetric[ 5 ].dwMetric = 110;
  192. pPriorInfo->ppmProtocolMetric[ 6 ].dwProtocolId = PROTO_IP_RIP;
  193. pPriorInfo->ppmProtocolMetric[ 6 ].dwMetric = 120;
  194. }
  195. //+---------------------------------------------------------------------------
  196. //
  197. // Function: MakeIpxInterfaceInfo
  198. //
  199. // Purpose: Create the router interface block for IPX.
  200. //
  201. // Arguments:
  202. // pszwAdapterName [in] The adapter name
  203. // dwPacketType [in] The packet type
  204. // ppBuff [out] Pointer to the returned info.
  205. // Free with delete.
  206. //
  207. // Returns: nothing
  208. //
  209. // Author: shaunco 28 Jul 1997
  210. //
  211. // Notes:
  212. //
  213. void MakeIpxInterfaceInfo (
  214. PCWSTR pszwAdapterName,
  215. DWORD dwPacketType,
  216. LPBYTE* ppBuff)
  217. {
  218. Assert (ppBuff);
  219. const BOOL fDialInInterface = (NULL == pszwAdapterName);
  220. const int c_cTocEntries = 5;
  221. // Alocate for minimal global Information.
  222. //
  223. DWORD dwSize = sizeof( RTR_INFO_BLOCK_HEADER )
  224. // header contains one TOC_ENTRY already
  225. + ((c_cTocEntries - 1) * sizeof( RTR_TOC_ENTRY ))
  226. + sizeof(IPX_IF_INFO)
  227. + sizeof(IPX_ADAPTER_INFO)
  228. + sizeof(IPXWAN_IF_INFO)
  229. + sizeof(RIP_IF_CONFIG)
  230. + sizeof(SAP_IF_CONFIG)
  231. + (c_cTocEntries * ALIGN_SIZE);
  232. PRTR_INFO_BLOCK_HEADER pIBH = (PRTR_INFO_BLOCK_HEADER) MemAlloc(dwSize);
  233. if (!pIBH)
  234. {
  235. *ppBuff = NULL;
  236. return;
  237. }
  238. ZeroMemory (pIBH, dwSize);
  239. *ppBuff = (LPBYTE) pIBH;
  240. // Initialize infobase fields.
  241. //
  242. pIBH->Version = RTR_INFO_BLOCK_VERSION;
  243. pIBH->Size = dwSize;
  244. pIBH->TocEntriesCount = c_cTocEntries;
  245. LPBYTE pbDataPtr = (LPBYTE) &( pIBH->TocEntry[ pIBH->TocEntriesCount ] );
  246. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  247. PRTR_TOC_ENTRY pTocEntry = pIBH->TocEntry;
  248. // Make IPX router manager interface info.
  249. //
  250. pTocEntry->InfoType = IPX_INTERFACE_INFO_TYPE;
  251. pTocEntry->InfoSize = sizeof(IPX_IF_INFO);
  252. pTocEntry->Count = 1;
  253. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  254. PIPX_IF_INFO pIfInfo = (PIPX_IF_INFO) pbDataPtr;
  255. pIfInfo->AdminState = ADMIN_STATE_ENABLED;
  256. pIfInfo->NetbiosAccept = ADMIN_STATE_ENABLED;
  257. pIfInfo->NetbiosDeliver = (fDialInInterface) ? ADMIN_STATE_DISABLED
  258. : ADMIN_STATE_ENABLED;
  259. pbDataPtr += pTocEntry->Count * pTocEntry->InfoSize;
  260. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  261. pTocEntry++;
  262. // Make adapter info.
  263. //
  264. pTocEntry->InfoType = IPX_ADAPTER_INFO_TYPE;
  265. pTocEntry->InfoSize = sizeof(IPX_ADAPTER_INFO);
  266. pTocEntry->Count = 1;
  267. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  268. PIPX_ADAPTER_INFO pAdInfo = (PIPX_ADAPTER_INFO) pbDataPtr;
  269. if (ISN_FRAME_TYPE_AUTO == dwPacketType)
  270. {
  271. dwPacketType = AUTO_DETECT_PACKET_TYPE;
  272. }
  273. pAdInfo->PacketType = dwPacketType;
  274. if (pszwAdapterName)
  275. {
  276. AssertSz (lstrlen (pszwAdapterName) < celems (pAdInfo->AdapterName),
  277. "Bindname too big for pAdInfo->AdapterName buffer.");
  278. lstrcpyW (pAdInfo->AdapterName, pszwAdapterName);
  279. }
  280. else
  281. {
  282. AssertSz (0 == pAdInfo->AdapterName[0],
  283. "Who removed the ZeroMemory call above?");
  284. }
  285. pbDataPtr += pTocEntry->Count * pTocEntry->InfoSize;
  286. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  287. pTocEntry++;
  288. // Make wan info.
  289. //
  290. pTocEntry->InfoType = IPXWAN_INTERFACE_INFO_TYPE;
  291. pTocEntry->InfoSize = sizeof(IPXWAN_IF_INFO);
  292. pTocEntry->Count = 1;
  293. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  294. PIPXWAN_IF_INFO pWanInfo = (PIPXWAN_IF_INFO) pbDataPtr;
  295. pWanInfo->AdminState = ADMIN_STATE_DISABLED;
  296. pbDataPtr += pTocEntry->Count * pTocEntry->InfoSize;
  297. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  298. pTocEntry++;
  299. // Make RIP interface info.
  300. //
  301. pTocEntry->InfoType = IPX_PROTOCOL_RIP;
  302. pTocEntry->InfoSize = sizeof(RIP_IF_CONFIG);
  303. pTocEntry->Count = 1;
  304. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  305. PRIP_IF_CONFIG pRipInfo = (PRIP_IF_CONFIG) pbDataPtr;
  306. pRipInfo->RipIfInfo.AdminState = ADMIN_STATE_ENABLED;
  307. pRipInfo->RipIfInfo.UpdateMode = (fDialInInterface)
  308. ? IPX_NO_UPDATE
  309. : IPX_STANDARD_UPDATE;
  310. pRipInfo->RipIfInfo.PacketType = IPX_STANDARD_PACKET_TYPE;
  311. pRipInfo->RipIfInfo.Supply = ADMIN_STATE_ENABLED;
  312. pRipInfo->RipIfInfo.Listen = ADMIN_STATE_ENABLED;
  313. pRipInfo->RipIfInfo.PeriodicUpdateInterval = 60;
  314. pRipInfo->RipIfInfo.AgeIntervalMultiplier = 3;
  315. pRipInfo->RipIfFilters.SupplyFilterAction = IPX_ROUTE_FILTER_DENY;
  316. pRipInfo->RipIfFilters.SupplyFilterCount = 0;
  317. pRipInfo->RipIfFilters.ListenFilterAction = IPX_ROUTE_FILTER_DENY;
  318. pRipInfo->RipIfFilters.ListenFilterCount = 0;
  319. pbDataPtr += pTocEntry->Count * pTocEntry->InfoSize;
  320. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  321. pTocEntry++;
  322. // Make SAP interface info.
  323. //
  324. pTocEntry->InfoType = IPX_PROTOCOL_SAP;
  325. pTocEntry->InfoSize = sizeof(SAP_IF_CONFIG);
  326. pTocEntry->Count = 1;
  327. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  328. PSAP_IF_CONFIG pSapInfo = (PSAP_IF_CONFIG) pbDataPtr;
  329. pSapInfo->SapIfInfo.AdminState = ADMIN_STATE_ENABLED;
  330. pSapInfo->SapIfInfo.UpdateMode = (fDialInInterface)
  331. ? IPX_NO_UPDATE
  332. : IPX_STANDARD_UPDATE;
  333. pSapInfo->SapIfInfo.PacketType = IPX_STANDARD_PACKET_TYPE;
  334. pSapInfo->SapIfInfo.Supply = ADMIN_STATE_ENABLED;
  335. pSapInfo->SapIfInfo.Listen = ADMIN_STATE_ENABLED;
  336. pSapInfo->SapIfInfo.GetNearestServerReply = ADMIN_STATE_ENABLED;
  337. pSapInfo->SapIfInfo.PeriodicUpdateInterval = 60;
  338. pSapInfo->SapIfInfo.AgeIntervalMultiplier = 3;
  339. pSapInfo->SapIfFilters.SupplyFilterAction = IPX_SERVICE_FILTER_DENY;
  340. pSapInfo->SapIfFilters.SupplyFilterCount = 0;
  341. pSapInfo->SapIfFilters.ListenFilterAction = IPX_SERVICE_FILTER_DENY;
  342. pSapInfo->SapIfFilters.ListenFilterCount = 0;
  343. }
  344. //+---------------------------------------------------------------------------
  345. //
  346. // Function: MakeIpxTransportInfo
  347. //
  348. // Purpose: Create the router transport blocks for IPX. Free with delete.
  349. //
  350. // Arguments:
  351. // ppBuffGlobal [out] Pointer to the returned global block.
  352. // ppBuffClient [out] Pointer to the returned client block.
  353. //
  354. // Returns: nothing
  355. //
  356. // Author: shaunco 28 Jul 1997
  357. //
  358. // Notes:
  359. //
  360. void MakeIpxTransportInfo (LPBYTE* ppBuffGlobal, LPBYTE* ppBuffClient)
  361. {
  362. Assert (ppBuffGlobal);
  363. Assert (ppBuffClient);
  364. MakeIpxInterfaceInfo (NULL, ISN_FRAME_TYPE_AUTO, ppBuffClient);
  365. const int c_cTocEntries = 3;
  366. // Alocate for minimal global Information.
  367. //
  368. DWORD dwSize = sizeof( RTR_INFO_BLOCK_HEADER )
  369. // header contains one TOC_ENTRY already
  370. + ((c_cTocEntries - 1) * sizeof( RTR_TOC_ENTRY ))
  371. + sizeof(IPX_GLOBAL_INFO)
  372. + sizeof(RIP_GLOBAL_INFO)
  373. + sizeof(SAP_GLOBAL_INFO)
  374. + (c_cTocEntries * ALIGN_SIZE);
  375. PRTR_INFO_BLOCK_HEADER pIBH = (PRTR_INFO_BLOCK_HEADER) MemAlloc(dwSize);
  376. if (!pIBH)
  377. {
  378. *ppBuffGlobal = NULL;
  379. return;
  380. }
  381. ZeroMemory (pIBH, dwSize);
  382. *ppBuffGlobal = (LPBYTE) pIBH;
  383. // Initialize infobase fields.
  384. //
  385. pIBH->Version = RTR_INFO_BLOCK_VERSION;
  386. pIBH->Size = dwSize;
  387. pIBH->TocEntriesCount = c_cTocEntries;
  388. LPBYTE pbDataPtr = (LPBYTE) &( pIBH->TocEntry[ pIBH->TocEntriesCount ] );
  389. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  390. PRTR_TOC_ENTRY pTocEntry = pIBH->TocEntry;
  391. // Make IPX router manager global info.
  392. //
  393. pTocEntry->InfoType = IPX_GLOBAL_INFO_TYPE;
  394. pTocEntry->InfoSize = sizeof(IPX_GLOBAL_INFO);
  395. pTocEntry->Count = 1;
  396. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  397. PIPX_GLOBAL_INFO pGlbInfo = (PIPX_GLOBAL_INFO) pbDataPtr;
  398. pGlbInfo->RoutingTableHashSize = IPX_MEDIUM_ROUTING_TABLE_HASH_SIZE;
  399. pGlbInfo->EventLogMask = EVENTLOG_ERROR_TYPE;
  400. pbDataPtr += pTocEntry->Count * pTocEntry->InfoSize;
  401. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  402. pTocEntry++;
  403. // Make RIP global info.
  404. //
  405. pTocEntry->InfoType = IPX_PROTOCOL_RIP;
  406. pTocEntry->InfoSize = sizeof(RIP_GLOBAL_INFO);
  407. pTocEntry->Count = 1;
  408. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  409. PRIP_GLOBAL_INFO pRipInfo = (PRIP_GLOBAL_INFO) pbDataPtr;
  410. pRipInfo->EventLogMask = EVENTLOG_ERROR_TYPE;
  411. pbDataPtr += pTocEntry->Count * pTocEntry->InfoSize;
  412. pbDataPtr = (LPBYTE)PAD8(pbDataPtr);
  413. pTocEntry++;
  414. // Make SAP global info.
  415. //
  416. pTocEntry->InfoType = IPX_PROTOCOL_SAP;
  417. pTocEntry->InfoSize = sizeof(SAP_GLOBAL_INFO);
  418. pTocEntry->Count = 1;
  419. pTocEntry->Offset = pbDataPtr - (PBYTE)pIBH;
  420. PSAP_GLOBAL_INFO pSapInfo = (PSAP_GLOBAL_INFO) pbDataPtr;
  421. pSapInfo->EventLogMask = EVENTLOG_ERROR_TYPE;
  422. }
  423. //+---------------------------------------------------------------------------
  424. //
  425. // mprapi.h wrappers to return HRESULTs and obey rules of COM in regard
  426. // to output parameters.
  427. //
  428. HRESULT
  429. HrMprAdminServerConnect(
  430. IN PWSTR lpwsServerName OPTIONAL,
  431. OUT MPR_SERVER_HANDLE * phMprServer
  432. )
  433. {
  434. HRESULT hr = S_OK;
  435. DWORD dw = MprAdminServerConnect (lpwsServerName, phMprServer);
  436. if (dw)
  437. {
  438. hr = HRESULT_FROM_WIN32 (dw);
  439. *phMprServer = NULL;
  440. }
  441. TraceHr (ttidError, FAL, hr,
  442. (HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE) == hr) ||
  443. (HRESULT_FROM_WIN32(RPC_S_UNKNOWN_IF) == hr),
  444. "HrMprAdminServerConnect");
  445. return hr;
  446. }
  447. HRESULT
  448. HrMprAdminInterfaceCreate(
  449. IN MPR_SERVER_HANDLE hMprServer,
  450. IN DWORD dwLevel,
  451. IN LPBYTE lpbBuffer,
  452. OUT HANDLE * phInterface
  453. )
  454. {
  455. HRESULT hr = S_OK;
  456. DWORD dw = MprAdminInterfaceCreate (hMprServer,
  457. dwLevel, lpbBuffer, phInterface);
  458. if (dw)
  459. {
  460. hr = HRESULT_FROM_WIN32 (dw);
  461. *phInterface = NULL;
  462. }
  463. TraceHr (ttidError, FAL, hr, FALSE, "HrMprAdminInterfaceCreate");
  464. return hr;
  465. }
  466. HRESULT
  467. HrMprAdminInterfaceEnum(
  468. IN MPR_SERVER_HANDLE hMprServer,
  469. IN DWORD dwLevel,
  470. OUT LPBYTE * lplpbBuffer,
  471. IN DWORD dwPrefMaxLen,
  472. OUT LPDWORD lpdwEntriesRead,
  473. OUT LPDWORD lpdwTotalEntries,
  474. IN LPDWORD lpdwResumeHandle OPTIONAL
  475. )
  476. {
  477. HRESULT hr = S_OK;
  478. DWORD dw = MprAdminInterfaceEnum (hMprServer, dwLevel, lplpbBuffer,
  479. dwPrefMaxLen, lpdwEntriesRead,
  480. lpdwTotalEntries, lpdwResumeHandle);
  481. if (dw)
  482. {
  483. hr = HRESULT_FROM_WIN32 (dw);
  484. *lpdwEntriesRead = 0;
  485. *lpdwTotalEntries = 0;
  486. }
  487. TraceHr (ttidError, FAL, hr,
  488. (HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS) == hr) ||
  489. (HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE) == hr) ||
  490. (HRESULT_FROM_WIN32(RPC_S_INVALID_BINDING) == hr) ||
  491. (HRESULT_FROM_WIN32(RPC_S_UNKNOWN_IF) == hr),
  492. "HrMprAdminInterfaceEnum");
  493. return hr;
  494. }
  495. HRESULT
  496. HrMprAdminInterfaceGetHandle(
  497. IN MPR_SERVER_HANDLE hMprServer,
  498. IN PWSTR lpwsInterfaceName,
  499. OUT HANDLE * phInterface,
  500. IN BOOL fIncludeClientInterfaces
  501. )
  502. {
  503. HRESULT hr = S_OK;
  504. DWORD dw = MprAdminInterfaceGetHandle (hMprServer, lpwsInterfaceName,
  505. phInterface, fIncludeClientInterfaces);
  506. if (dw)
  507. {
  508. hr = HRESULT_FROM_WIN32 (dw);
  509. *phInterface = NULL;
  510. }
  511. TraceHr (ttidError, FAL, hr,
  512. (HRESULT_FROM_WIN32(ERROR_NO_SUCH_INTERFACE) == hr) ||
  513. (HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE) == hr) ||
  514. (HRESULT_FROM_WIN32(RPC_S_INVALID_BINDING) == hr) ||
  515. (HRESULT_FROM_WIN32(RPC_S_UNKNOWN_IF) == hr),
  516. "HrMprAdminInterfaceGetHandle");
  517. return hr;
  518. }
  519. HRESULT
  520. HrMprAdminInterfaceTransportAdd(
  521. IN MPR_SERVER_HANDLE hMprServer,
  522. IN HANDLE hInterface,
  523. IN DWORD dwTransportId,
  524. IN LPBYTE pInterfaceInfo,
  525. IN DWORD dwInterfaceInfoSize
  526. )
  527. {
  528. HRESULT hr = S_OK;
  529. DWORD dw = MprAdminInterfaceTransportAdd (hMprServer, hInterface,
  530. dwTransportId, pInterfaceInfo, dwInterfaceInfoSize);
  531. if (dw)
  532. {
  533. hr = HRESULT_FROM_WIN32 (dw);
  534. }
  535. TraceHr (ttidError, FAL, hr,
  536. HRESULT_FROM_WIN32(ERROR_INTERFACE_ALREADY_EXISTS) == hr,
  537. "HrMprAdminInterfaceTransportAdd");
  538. return hr;
  539. }
  540. HRESULT
  541. HrMprAdminTransportCreate(
  542. IN HANDLE hMprAdmin,
  543. IN DWORD dwTransportId,
  544. IN PWSTR lpwsTransportName OPTIONAL,
  545. IN LPBYTE pGlobalInfo,
  546. IN DWORD dwGlobalInfoSize,
  547. IN LPBYTE pClientInterfaceInfo OPTIONAL,
  548. IN DWORD dwClientInterfaceInfoSize OPTIONAL,
  549. IN PWSTR lpwsDLLPath
  550. )
  551. {
  552. HRESULT hr = S_OK;
  553. DWORD dw = MprAdminTransportCreate (hMprAdmin, dwTransportId,
  554. lpwsTransportName, pGlobalInfo, dwGlobalInfoSize,
  555. pClientInterfaceInfo, dwClientInterfaceInfoSize,
  556. lpwsDLLPath);
  557. if (dw)
  558. {
  559. hr = HRESULT_FROM_WIN32 (dw);
  560. }
  561. TraceHr (ttidError, FAL, hr, FALSE, "HrMprAdminTransportCreate");
  562. return hr;
  563. }
  564. HRESULT
  565. HrMprConfigServerConnect(
  566. IN PWSTR lpwsServerName,
  567. OUT HANDLE* phMprConfig
  568. )
  569. {
  570. HRESULT hr = S_OK;
  571. DWORD dw = MprConfigServerConnect (lpwsServerName, phMprConfig);
  572. if (dw)
  573. {
  574. hr = HRESULT_FROM_WIN32 (dw);
  575. *phMprConfig = NULL;
  576. }
  577. TraceHr (ttidError, FAL, hr, FALSE, "HrMprConfigServerConnect");
  578. return hr;
  579. }
  580. HRESULT
  581. HrMprConfigInterfaceCreate(
  582. IN HANDLE hMprConfig,
  583. IN DWORD dwLevel,
  584. IN LPBYTE lpbBuffer,
  585. OUT HANDLE* phRouterInterface
  586. )
  587. {
  588. HRESULT hr = S_OK;
  589. DWORD dw = MprConfigInterfaceCreate (hMprConfig, dwLevel, lpbBuffer,
  590. phRouterInterface);
  591. if (dw)
  592. {
  593. hr = HRESULT_FROM_WIN32 (dw);
  594. *phRouterInterface = NULL;
  595. }
  596. TraceHr (ttidError, FAL, hr, FALSE, "HrMprConfigInterfaceCreate");
  597. return hr;
  598. }
  599. HRESULT
  600. HrMprConfigInterfaceEnum(
  601. IN HANDLE hMprConfig,
  602. IN DWORD dwLevel,
  603. IN OUT LPBYTE* lplpBuffer,
  604. IN DWORD dwPrefMaxLen,
  605. OUT LPDWORD lpdwEntriesRead,
  606. OUT LPDWORD lpdwTotalEntries,
  607. IN OUT LPDWORD lpdwResumeHandle OPTIONAL
  608. )
  609. {
  610. HRESULT hr = S_OK;
  611. DWORD dw = MprConfigInterfaceEnum (hMprConfig, dwLevel, lplpBuffer,
  612. dwPrefMaxLen, lpdwEntriesRead,
  613. lpdwTotalEntries, lpdwResumeHandle);
  614. if (dw)
  615. {
  616. hr = HRESULT_FROM_WIN32 (dw);
  617. *lpdwEntriesRead = 0;
  618. *lpdwTotalEntries = 0;
  619. }
  620. TraceHr (ttidError, FAL, hr,
  621. HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS) == hr,
  622. "HrMprConfigInterfaceEnum");
  623. return hr;
  624. }
  625. HRESULT
  626. HrMprConfigInterfaceTransportEnum(
  627. IN HANDLE hMprConfig,
  628. IN HANDLE hRouterInterface,
  629. IN DWORD dwLevel,
  630. IN OUT LPBYTE* lplpBuffer, // MPR_IFTRANSPORT_0
  631. IN DWORD dwPrefMaxLen,
  632. OUT LPDWORD lpdwEntriesRead,
  633. OUT LPDWORD lpdwTotalEntries,
  634. IN OUT LPDWORD lpdwResumeHandle OPTIONAL
  635. )
  636. {
  637. HRESULT hr = S_OK;
  638. DWORD dw = MprConfigInterfaceTransportEnum (hMprConfig, hRouterInterface,
  639. dwLevel, lplpBuffer,
  640. dwPrefMaxLen, lpdwEntriesRead,
  641. lpdwTotalEntries, lpdwResumeHandle);
  642. if (dw)
  643. {
  644. hr = HRESULT_FROM_WIN32 (dw);
  645. *lpdwEntriesRead = 0;
  646. *lpdwTotalEntries = 0;
  647. }
  648. TraceHr (ttidError, FAL, hr,
  649. HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS) == hr,
  650. "HrMprConfigInterfaceTransportEnum");
  651. return hr;
  652. }
  653. HRESULT
  654. HrMprConfigInterfaceGetHandle(
  655. IN HANDLE hMprConfig,
  656. IN PWSTR lpwsInterfaceName,
  657. OUT HANDLE* phRouterInterface
  658. )
  659. {
  660. HRESULT hr = S_OK;
  661. DWORD dw = MprConfigInterfaceGetHandle (hMprConfig, lpwsInterfaceName,
  662. phRouterInterface);
  663. if (dw)
  664. {
  665. hr = HRESULT_FROM_WIN32 (dw);
  666. *phRouterInterface = NULL;
  667. }
  668. TraceHr (ttidError, FAL, hr,
  669. HRESULT_FROM_WIN32(ERROR_NO_SUCH_INTERFACE) == hr,
  670. "HrMprConfigInterfaceGetHandle");
  671. return hr;
  672. }
  673. HRESULT
  674. HrMprConfigInterfaceTransportAdd(
  675. IN HANDLE hMprConfig,
  676. IN HANDLE hRouterInterface,
  677. IN DWORD dwTransportId,
  678. IN PWSTR lpwsTransportName OPTIONAL,
  679. IN LPBYTE pInterfaceInfo,
  680. IN DWORD dwInterfaceInfoSize,
  681. OUT HANDLE* phRouterIfTransport
  682. )
  683. {
  684. HRESULT hr = S_OK;
  685. DWORD dw = MprConfigInterfaceTransportAdd (hMprConfig, hRouterInterface,
  686. dwTransportId, lpwsTransportName,
  687. pInterfaceInfo, dwInterfaceInfoSize,
  688. phRouterIfTransport);
  689. if (dw)
  690. {
  691. hr = HRESULT_FROM_WIN32 (dw);
  692. *phRouterIfTransport = NULL;
  693. }
  694. TraceHr (ttidError, FAL, hr, FALSE, "HrMprConfigInterfaceTransportAdd");
  695. return hr;
  696. }
  697. HRESULT
  698. HrMprConfigInterfaceTransportGetHandle(
  699. IN HANDLE hMprConfig,
  700. IN HANDLE hRouterInterface,
  701. IN DWORD dwTransportId,
  702. OUT HANDLE* phRouterIfTransport
  703. )
  704. {
  705. HRESULT hr = S_OK;
  706. DWORD dw = MprConfigInterfaceTransportGetHandle (hMprConfig,
  707. hRouterInterface,
  708. dwTransportId,
  709. phRouterIfTransport);
  710. if (dw)
  711. {
  712. hr = HRESULT_FROM_WIN32 (dw);
  713. *phRouterIfTransport = NULL;
  714. }
  715. TraceHr (ttidError, FAL, hr,
  716. HRESULT_FROM_WIN32(ERROR_NO_SUCH_INTERFACE) == hr,
  717. "HrMprConfigInterfaceTransportGetHandle");
  718. return hr;
  719. }
  720. HRESULT
  721. HrMprConfigTransportCreate(
  722. IN HANDLE hMprConfig,
  723. IN DWORD dwTransportId,
  724. IN PWSTR lpwsTransportName OPTIONAL,
  725. IN LPBYTE pGlobalInfo,
  726. IN DWORD dwGlobalInfoSize,
  727. IN LPBYTE pClientInterfaceInfo OPTIONAL,
  728. IN DWORD dwClientInterfaceInfoSize OPTIONAL,
  729. IN PWSTR lpwsDLLPath,
  730. OUT HANDLE* phRouterTransport
  731. )
  732. {
  733. HRESULT hr = S_OK;
  734. DWORD dw = MprConfigTransportCreate (hMprConfig, dwTransportId,
  735. lpwsTransportName, pGlobalInfo, dwGlobalInfoSize,
  736. pClientInterfaceInfo, dwClientInterfaceInfoSize,
  737. lpwsDLLPath, phRouterTransport);
  738. if (dw)
  739. {
  740. hr = HRESULT_FROM_WIN32 (dw);
  741. *phRouterTransport = NULL;
  742. }
  743. TraceHr (ttidError, FAL, hr, FALSE, "HrMprConfigTransportCreate");
  744. return hr;
  745. }
  746. HRESULT
  747. HrMprConfigTransportDelete(
  748. IN HANDLE hMprConfig,
  749. IN HANDLE hRouterTransport)
  750. {
  751. HRESULT hr = S_OK;
  752. DWORD dw = MprConfigTransportDelete (hMprConfig, hRouterTransport);
  753. if (dw)
  754. {
  755. hr = HRESULT_FROM_WIN32 (dw);
  756. }
  757. TraceHr (ttidError, FAL, hr, FALSE, "HrMprConfigTransportDelete");
  758. return hr;
  759. }
  760. HRESULT
  761. HrMprConfigTransportGetHandle(
  762. IN HANDLE hMprConfig,
  763. IN DWORD dwTransportId,
  764. OUT HANDLE* phRouterTransport
  765. )
  766. {
  767. HRESULT hr = S_OK;
  768. DWORD dw = MprConfigTransportGetHandle (hMprConfig, dwTransportId,
  769. phRouterTransport);
  770. if (dw)
  771. {
  772. hr = HRESULT_FROM_WIN32 (dw);
  773. *phRouterTransport = NULL;
  774. }
  775. TraceHr (ttidError, FAL, hr,
  776. HRESULT_FROM_WIN32 (ERROR_UNKNOWN_PROTOCOL_ID) == hr,
  777. "HrMprConfigTransportGetHandle");
  778. return hr;
  779. }
  780. HRESULT
  781. HrMprConfigTransportGetInfo(
  782. IN HANDLE hMprConfig,
  783. IN HANDLE hRouterTransport,
  784. IN OUT LPBYTE* ppGlobalInfo OPTIONAL,
  785. OUT LPDWORD lpdwGlobalInfoSize OPTIONAL,
  786. IN OUT LPBYTE* ppClientInterfaceInfo OPTIONAL,
  787. OUT LPDWORD lpdwClientInterfaceInfoSize OPTIONAL,
  788. IN OUT PWSTR* lplpwsDLLPath OPTIONAL
  789. )
  790. {
  791. HRESULT hr = S_OK;
  792. DWORD dw = MprConfigTransportGetInfo (hMprConfig, hRouterTransport,
  793. ppGlobalInfo, lpdwGlobalInfoSize,
  794. ppClientInterfaceInfo,
  795. lpdwClientInterfaceInfoSize,
  796. lplpwsDLLPath);
  797. if (dw)
  798. {
  799. hr = HRESULT_FROM_WIN32 (dw);
  800. }
  801. TraceHr (ttidError, FAL, hr, FALSE, "HrMprConfigTransportGetInfo");
  802. return hr;
  803. }