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.

201 lines
5.7 KiB

  1. // This contains all the functions that are currently directly called inside the class managers from netman
  2. // In order to move the class managers out later, these functions should stop being used.
  3. #include "pch.h"
  4. #pragma hdrstop
  5. #define NO_CM_SEPERATE_NAMESPACES
  6. #include "nmbase.h"
  7. #include "cmdirect.h"
  8. // Don't try moving these function to an inline in cmdirect.h. It won't work - it requires
  9. // access to CDialupConnection in the root namespace, which is not defined unless
  10. // NO_CM_SEPERATE_NAMESPACES is defined.
  11. namespace CMDIRECT
  12. {
  13. namespace DIALUP
  14. {
  15. HRESULT CreateWanConnectionManagerEnumConnectionInstance(
  16. NETCONMGR_ENUM_FLAGS Flags,
  17. REFIID riid,
  18. VOID** ppv)
  19. {
  20. return CWanConnectionManagerEnumConnection::CreateInstance(
  21. Flags,
  22. riid,
  23. ppv);
  24. }
  25. HRESULT CreateInstanceFromDetails(
  26. const RASENUMENTRYDETAILS* pEntryDetails,
  27. REFIID riid,
  28. VOID** ppv)
  29. {
  30. return CDialupConnection::CreateInstanceFromDetails (
  31. pEntryDetails,
  32. riid,
  33. ppv);
  34. }
  35. }
  36. namespace INBOUND
  37. {
  38. HRESULT CreateInstance (
  39. IN BOOL fIsConfigConnection,
  40. IN HRASSRVCONN hRasSrvConn,
  41. IN PCWSTR pszwName,
  42. IN PCWSTR pszwDeviceName,
  43. IN DWORD dwType,
  44. IN const GUID* pguidId,
  45. IN REFIID riid,
  46. OUT VOID** ppv)
  47. {
  48. return CInboundConnection::CreateInstance(fIsConfigConnection, hRasSrvConn, pszwName, pszwDeviceName, dwType, pguidId, riid, ppv);
  49. }
  50. }
  51. }
  52. #include "nmbase.h"
  53. #include "conman.h"
  54. #include "cmutil.h"
  55. #include "ncras.h"
  56. #include "diag.h"
  57. #include "cmdirect.h"
  58. // These functions are exported from class managers
  59. EXTERN_C
  60. VOID
  61. WINAPI
  62. NetManDiagFromCommandArgs (IN const DIAG_OPTIONS * pOptions)
  63. {
  64. Assert (pOptions);
  65. Assert (pOptions->pDiagCtx);
  66. g_pDiagCtx = pOptions->pDiagCtx;
  67. INetConnectionManager * pConMan;
  68. CMDIRECT(LANCON, HrInitializeConMan)(&pConMan);
  69. switch (pOptions->Command)
  70. {
  71. case CMD_SHOW_LAN_CONNECTIONS:
  72. CMDIRECT(LANCON, CmdShowLanConnections)(pOptions, pConMan);
  73. break;
  74. case CMD_SHOW_ALL_DEVICES:
  75. CMDIRECT(LANCON, CmdShowAllDevices)(pOptions, pConMan);
  76. break;
  77. case CMD_SHOW_LAN_DETAILS:
  78. CMDIRECT(LANCON, CmdShowLanDetails)(pOptions, pConMan);
  79. break;
  80. case CMD_LAN_CHANGE_STATE:
  81. CMDIRECT(LANCON, CmdLanChangeState)(pOptions, pConMan);
  82. break;
  83. default:
  84. break;
  85. }
  86. CMDIRECT(LANCON, HrUninitializeConMan(pConMan));
  87. g_pDiagCtx = NULL;
  88. }
  89. #include "raserror.h"
  90. //+---------------------------------------------------------------------------
  91. //
  92. // Function: HrRasConnectionNameFromGuid
  93. //
  94. // Purpose: Exported API used by iphlpapi et. al. to get the connection
  95. // of a RAS connection given its GUID.
  96. //
  97. // Arguments:
  98. // guid [in] The guid id representing the connection.
  99. // pszwName [out] Pointer to a buffer to store the name.
  100. // pcchMax [inout] On input, the length, in characters, of the buffer
  101. // including the null terminator. On output, the
  102. // length of the string including the null terminator
  103. // (if it was written) or the length of the buffer
  104. // required.
  105. //
  106. // Returns: HRESULT_FROM_WIN32(ERROR_NOT_FOUND) if the entry was not found.
  107. // HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
  108. // S_OK
  109. //
  110. // Author: shaunco 23 Sep 1998
  111. //
  112. // Notes:
  113. //
  114. EXTERN_C
  115. HRESULT
  116. WINAPI
  117. HrRasConnectionNameFromGuid (
  118. IN REFGUID guid,
  119. OUT PWSTR pszwName,
  120. IN OUT DWORD* pcchMax)
  121. {
  122. Assert (pszwName);
  123. Assert (pcchMax);
  124. // Initialize the output parameter.
  125. //
  126. *pszwName = NULL;
  127. // We now need to enumerate all entries in this phonebook and
  128. // find our details record with the matching guidId.
  129. //
  130. RASENUMENTRYDETAILS* aRasEntryDetails;
  131. DWORD cRasEntryDetails;
  132. HRESULT hr;
  133. hr = HrRasEnumAllEntriesWithDetails (
  134. NULL,
  135. &aRasEntryDetails,
  136. &cRasEntryDetails);
  137. if (SUCCEEDED(hr))
  138. {
  139. RASENUMENTRYDETAILS* pDetails;
  140. // Assume we don't find the entry.
  141. //
  142. hr = HRESULT_FROM_WIN32 (ERROR_NOT_FOUND);
  143. for (DWORD i = 0; i < cRasEntryDetails; i++)
  144. {
  145. pDetails = &aRasEntryDetails[i];
  146. if (pDetails->guidId == guid)
  147. {
  148. // Only copy the string if the caller has enough room in
  149. // the output buffer.
  150. //
  151. hr = HRESULT_FROM_WIN32 (ERROR_INSUFFICIENT_BUFFER);
  152. DWORD cchRequired = wcslen(pDetails->szEntryName) + 1;
  153. if (cchRequired <= *pcchMax)
  154. {
  155. lstrcpynW (pszwName, pDetails->szEntryName, *pcchMax);
  156. hr = S_OK;
  157. }
  158. *pcchMax = cchRequired;
  159. break;
  160. }
  161. }
  162. MemFree (aRasEntryDetails);
  163. }
  164. else if (HRESULT_FROM_WIN32(ERROR_CANNOT_OPEN_PHONEBOOK) == hr)
  165. {
  166. hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
  167. }
  168. TraceError ("HrRasConnectionNameFromGuid", hr);
  169. return hr;
  170. }