1 | /* $Id: VBoxNetCfg-win.h 96572 2022-09-01 20:36:22Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Network Configuration API for Windows platforms.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
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 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
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
|
---|
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.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef VBOX_INCLUDED_VBoxNetCfg_win_h
|
---|
38 | #define VBOX_INCLUDED_VBoxNetCfg_win_h
|
---|
39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
40 | # pragma once
|
---|
41 | #endif
|
---|
42 |
|
---|
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 | */
|
---|
50 | #define VBOXNETCFG_DELAYEDRENAME
|
---|
51 |
|
---|
52 | #include <iprt/win/winsock2.h>
|
---|
53 | #include <iprt/win/windows.h>
|
---|
54 | #include <Netcfgn.h>
|
---|
55 | #include <iprt/win/Setupapi.h>
|
---|
56 | #include <VBox/cdefs.h>
|
---|
57 | #include <iprt/types.h>
|
---|
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
|
---|
68 | # define VBOXNETCFGWIN_DECL(a_Type) DECLEXPORT(a_Type)
|
---|
69 | # else
|
---|
70 | # define VBOXNETCFGWIN_DECL(a_Type) DECLIMPORT(a_Type)
|
---|
71 | # endif
|
---|
72 | #else
|
---|
73 | /*enable this in case we include this in a static lib*/
|
---|
74 | # define VBOXNETCFGWIN_DECL(a_Type) a_Type VBOXCALL
|
---|
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);
|
---|
85 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGetComponentByGuid(IN INetCfg *pNc, IN const GUID *pguidClass,
|
---|
86 | IN const GUID * pComponentGuid, OUT INetCfgComponent **ppncc);
|
---|
87 |
|
---|
88 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetFltInstall(IN INetCfg *pNc, IN LPCWSTR const *pwszInfFullPaths, IN UINT cInfFullPaths);
|
---|
89 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetFltUninstall(IN INetCfg *pNc);
|
---|
90 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetLwfInstall(IN INetCfg *pNc, IN LPCWSTR const pwszInfFullPath);
|
---|
91 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetLwfUninstall(IN INetCfg *pNc);
|
---|
92 |
|
---|
93 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetAdpUninstall(IN INetCfg *pNc, IN LPCWSTR pwszId);
|
---|
94 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetAdpInstall(IN INetCfg *pNc,IN LPCWSTR const pwszInfFullPath);
|
---|
95 |
|
---|
96 | #ifndef VBOXNETCFG_DELAYEDRENAME
|
---|
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);
|
---|
100 | #else /* VBOXNETCFG_DELAYEDRENAME */
|
---|
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);
|
---|
104 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRenameHostOnlyConnection(IN const GUID *pGuid, IN LPCWSTR pszId, OUT BSTR *pDevName);
|
---|
105 | #endif /* VBOXNETCFG_DELAYEDRENAME */
|
---|
106 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinUpdateHostOnlyNetworkInterface(LPCWSTR pcsxwInf, BOOL *pfRebootRequired, LPCWSTR pcsxwId);
|
---|
107 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRemoveHostOnlyNetworkInterface(IN const GUID *pGUID, OUT BSTR *pErrMsg);
|
---|
108 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRemoveAllNetDevicesOfId(IN LPCWSTR lpszPnPId);
|
---|
109 |
|
---|
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
|
---|
115 | {
|
---|
116 | VBOXNECTFGWINPROPCHANGE_TYPE_UNDEFINED = 0,
|
---|
117 | VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE,
|
---|
118 | VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE
|
---|
119 | } VBOXNECTFGWINPROPCHANGE_TYPE_T;
|
---|
120 |
|
---|
121 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinPropChangeAllNetDevicesOfId(IN LPCWSTR lpszPnPId, VBOXNECTFGWINPROPCHANGE_TYPE_T enmPcType);
|
---|
122 |
|
---|
123 | VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGenHostOnlyNetworkNetworkIp(OUT PULONG pNetIp, OUT PULONG pNetMask);
|
---|
124 |
|
---|
125 | typedef struct ADAPTER_SETTINGS
|
---|
126 | {
|
---|
127 | ULONG ip;
|
---|
128 | ULONG mask;
|
---|
129 | BOOL bDhcp;
|
---|
130 | } ADAPTER_SETTINGS, *PADAPTER_SETTINGS; /**< I'm not prefixed */
|
---|
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 |
|
---|
138 | typedef DECLCALLBACKTYPE(void, FNVBOXNETCFGLOGGER,(const char *pszString));
|
---|
139 | typedef FNVBOXNETCFGLOGGER *PFNVBOXNETCFGLOGGER;
|
---|
140 | VBOXNETCFGWIN_DECL(void) VBoxNetCfgWinSetLogging(IN PFNVBOXNETCFGLOGGER pfnLogger);
|
---|
141 |
|
---|
142 | RT_C_DECLS_END
|
---|
143 |
|
---|
144 | /** @} */
|
---|
145 |
|
---|
146 | #endif /* !VBOX_INCLUDED_VBoxNetCfg_win_h */
|
---|
147 |
|
---|