[36277] | 1 | /* $Id: VBoxNetCfg-win.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
[36536] | 3 | * Network Configuration API for Windows platforms.
|
---|
[36277] | 4 | */
|
---|
[36536] | 5 |
|
---|
[36277] | 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2011-2023 Oracle and/or its affiliates.
|
---|
[36277] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
[37479] | 11 | *
|
---|
[96407] | 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
[37479] | 25 | * The contents of this file may alternatively be used under the terms
|
---|
| 26 | * of the Common Development and Distribution License Version 1.0
|
---|
[96407] | 27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
| 28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
[37479] | 29 | * CDDL are applicable instead of those of the GPL.
|
---|
| 30 | *
|
---|
| 31 | * You may elect to license modified versions of this file under the
|
---|
| 32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
[96407] | 33 | *
|
---|
| 34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
[36277] | 35 | */
|
---|
| 36 |
|
---|
[76558] | 37 | #ifndef VBOX_INCLUDED_VBoxNetCfg_win_h
|
---|
| 38 | #define VBOX_INCLUDED_VBoxNetCfg_win_h
|
---|
[76507] | 39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 40 | # pragma once
|
---|
| 41 | #endif
|
---|
[36536] | 42 |
|
---|
[58794] | 43 | /*
|
---|
| 44 | * Defining VBOXNETCFG_DELAYEDRENAME postpones renaming of host-only adapter
|
---|
| 45 | * connection during adapter creation after it has been assigned with an
|
---|
| 46 | * IP address. This hopefully prevents collisions that may happen when we
|
---|
| 47 | * attempt to rename a connection too early, while its configuration is
|
---|
| 48 | * still being 'committed' by the network setup engine.
|
---|
| 49 | */
|
---|
[58874] | 50 | #define VBOXNETCFG_DELAYEDRENAME
|
---|
[58794] | 51 |
|
---|
[62680] | 52 | #include <iprt/win/winsock2.h>
|
---|
| 53 | #include <iprt/win/windows.h>
|
---|
[36277] | 54 | #include <Netcfgn.h>
|
---|
[62688] | 55 | #include <iprt/win/Setupapi.h>
|
---|
[36536] | 56 | #include <VBox/cdefs.h>
|
---|
[68670] | 57 | #include <iprt/types.h>
|
---|
[36277] | 58 |
|
---|
| 59 | /** @defgroup grp_vboxnetcfgwin The Windows Network Configration Library
|
---|
| 60 | * @{ */
|
---|
| 61 |
|
---|
| 62 | /** @def VBOXNETCFGWIN_DECL
|
---|
| 63 | * The usual declaration wrapper.
|
---|
| 64 | */
|
---|
| 65 | #if 0
|
---|
| 66 | /* enable this in case we include this in a dll*/
|
---|
| 67 | # ifdef IN_VBOXDDU
|
---|
[36536] | 68 | # define VBOXNETCFGWIN_DECL(a_Type) DECLEXPORT(a_Type)
|
---|
[36277] | 69 | # else
|
---|
[36536] | 70 | # define VBOXNETCFGWIN_DECL(a_Type) DECLIMPORT(a_Type)
|
---|
[36277] | 71 | # endif
|
---|
| 72 | #else
|
---|
| 73 | /*enable this in case we include this in a static lib*/
|
---|
[36536] | 74 | # define VBOXNETCFGWIN_DECL(a_Type) a_Type VBOXCALL
|
---|
[36277] | 75 | #endif
|
---|
| 76 |
|
---|
| 77 | RT_C_DECLS_BEGIN
|
---|
| 78 |
|
---|
| 79 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinQueryINetCfg(OUT INetCfg **ppNetCfg,
|
---|
| 80 | IN BOOL fGetWriteLock,
|
---|
| 81 | IN LPCWSTR pszwClientDescription,
|
---|
| 82 | IN DWORD cmsTimeout,
|
---|
| 83 | OUT LPWSTR *ppszwClientDescription);
|
---|
| 84 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinReleaseINetCfg(IN INetCfg *pNetCfg, IN BOOL fHasWriteLock);
|
---|
[36536] | 85 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGetComponentByGuid(IN INetCfg *pNc, IN const GUID *pguidClass,
|
---|
| 86 | IN const GUID * pComponentGuid, OUT INetCfgComponent **ppncc);
|
---|
[36277] | 87 |
|
---|
[96572] | 88 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetFltInstall(IN INetCfg *pNc, IN LPCWSTR const *pwszInfFullPaths, IN UINT cInfFullPaths);
|
---|
[36277] | 89 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetFltUninstall(IN INetCfg *pNc);
|
---|
[96572] | 90 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetLwfInstall(IN INetCfg *pNc, IN LPCWSTR const pwszInfFullPath);
|
---|
[51480] | 91 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetLwfUninstall(IN INetCfg *pNc);
|
---|
[36277] | 92 |
|
---|
[53090] | 93 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetAdpUninstall(IN INetCfg *pNc, IN LPCWSTR pwszId);
|
---|
[96572] | 94 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetAdpInstall(IN INetCfg *pNc,IN LPCWSTR const pwszInfFullPath);
|
---|
[52824] | 95 |
|
---|
[58794] | 96 | #ifndef VBOXNETCFG_DELAYEDRENAME
|
---|
[96572] | 97 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface(IN LPCWSTR pwszInfPath, IN bool fIsInfPathFile,
|
---|
| 98 | IN BSTR pBstrDesiredName,
|
---|
| 99 | OUT GUID *pGuid, OUT BSTR *pBstrName, OUT BSTR *pErrMsg);
|
---|
[58794] | 100 | #else /* VBOXNETCFG_DELAYEDRENAME */
|
---|
[96572] | 101 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface(IN LPCWSTR pwszInfPath, IN bool fIsInfPathFile,
|
---|
| 102 | IN BSTR pBstrDesiredName,
|
---|
| 103 | OUT GUID *pGuid, OUT BSTR *pBstrId, OUT BSTR *pErrMsg);
|
---|
[58794] | 104 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRenameHostOnlyConnection(IN const GUID *pGuid, IN LPCWSTR pszId, OUT BSTR *pDevName);
|
---|
| 105 | #endif /* VBOXNETCFG_DELAYEDRENAME */
|
---|
[96572] | 106 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinUpdateHostOnlyNetworkInterface(LPCWSTR pcsxwInf, BOOL *pfRebootRequired, LPCWSTR pcsxwId);
|
---|
[36536] | 107 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRemoveHostOnlyNetworkInterface(IN const GUID *pGUID, OUT BSTR *pErrMsg);
|
---|
[36277] | 108 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRemoveAllNetDevicesOfId(IN LPCWSTR lpszPnPId);
|
---|
| 109 |
|
---|
[96572] | 110 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGenHostonlyConnectionName(IN PCWSTR pwszDevName, OUT WCHAR *pwszBuf,
|
---|
| 111 | IN ULONG cwcBuf, OUT PULONG pcwcNeeded);
|
---|
| 112 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRenameConnection(IN LPWSTR pwszGuid, IN PCWSTR pwszNewName);
|
---|
| 113 |
|
---|
| 114 | typedef enum VBOXNECTFGWINPROPCHANGE_TYPE_T
|
---|
[40993] | 115 | {
|
---|
| 116 | VBOXNECTFGWINPROPCHANGE_TYPE_UNDEFINED = 0,
|
---|
| 117 | VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE,
|
---|
| 118 | VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE
|
---|
[96572] | 119 | } VBOXNECTFGWINPROPCHANGE_TYPE_T;
|
---|
[40993] | 120 |
|
---|
[96572] | 121 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinPropChangeAllNetDevicesOfId(IN LPCWSTR lpszPnPId, VBOXNECTFGWINPROPCHANGE_TYPE_T enmPcType);
|
---|
[40993] | 122 |
|
---|
[36277] | 123 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGenHostOnlyNetworkNetworkIp(OUT PULONG pNetIp, OUT PULONG pNetMask);
|
---|
| 124 |
|
---|
[36536] | 125 | typedef struct ADAPTER_SETTINGS
|
---|
[36277] | 126 | {
|
---|
| 127 | ULONG ip;
|
---|
| 128 | ULONG mask;
|
---|
| 129 | BOOL bDhcp;
|
---|
[36536] | 130 | } ADAPTER_SETTINGS, *PADAPTER_SETTINGS; /**< I'm not prefixed */
|
---|
[36277] | 131 |
|
---|
| 132 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinEnableStaticIpConfig(IN const GUID *pGuid, IN ULONG ip, IN ULONG mask);
|
---|
| 133 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGetAdapterSettings(IN const GUID * pGuid, OUT PADAPTER_SETTINGS pSettings);
|
---|
| 134 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinEnableDynamicIpConfig(IN const GUID *pGuid);
|
---|
| 135 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinDhcpRediscover(IN const GUID *pGuid);
|
---|
| 136 |
|
---|
| 137 |
|
---|
[85121] | 138 | typedef DECLCALLBACKTYPE(void, FNVBOXNETCFGLOGGER,(const char *pszString));
|
---|
| 139 | typedef FNVBOXNETCFGLOGGER *PFNVBOXNETCFGLOGGER;
|
---|
| 140 | VBOXNETCFGWIN_DECL(void) VBoxNetCfgWinSetLogging(IN PFNVBOXNETCFGLOGGER pfnLogger);
|
---|
[36277] | 141 |
|
---|
| 142 | RT_C_DECLS_END
|
---|
| 143 |
|
---|
| 144 | /** @} */
|
---|
| 145 |
|
---|
[76585] | 146 | #endif /* !VBOX_INCLUDED_VBoxNetCfg_win_h */
|
---|
[36536] | 147 |
|
---|