-
Notifications
You must be signed in to change notification settings - Fork 6
/
hostnetworkinterface.cpp
160 lines (137 loc) · 4.49 KB
/
hostnetworkinterface.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* This file is part of libvbox
* Copyright (C) 2019 Michael Hansen
*
* libvbox is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* libvbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with libvbox; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "libvbox_p.h"
COM_WRAP_IFC(IHostNetworkInterface)
std::u16string VBox::IHostNetworkInterface::name() const
{
std::u16string result;
COM_GetString(get_IFC(), Name, result);
return result;
}
std::u16string VBox::IHostNetworkInterface::shortName() const
{
std::u16string result;
COM_GetString(get_IFC(), ShortName, result);
return result;
}
std::u16string VBox::IHostNetworkInterface::id() const
{
std::u16string result;
COM_GetString(get_IFC(), Id, result);
return result;
}
std::u16string VBox::IHostNetworkInterface::networkName() const
{
std::u16string result;
COM_GetString(get_IFC(), NetworkName, result);
return result;
}
bool VBox::IHostNetworkInterface::DHCPEnabled() const
{
COM_Bool result;
COM_GetValue(get_IFC(), DHCPEnabled, result);
return static_cast<bool>(result);
}
std::u16string VBox::IHostNetworkInterface::IPAddress() const
{
std::u16string result;
COM_GetString(get_IFC(), IPAddress, result);
return result;
}
std::u16string VBox::IHostNetworkInterface::networkMask() const
{
std::u16string result;
COM_GetString(get_IFC(), NetworkMask, result);
return result;
}
bool VBox::IHostNetworkInterface::IPV6Supported() const
{
COM_Bool result;
COM_GetValue(get_IFC(), IPV6Supported, result);
return static_cast<bool>(result);
}
std::u16string VBox::IHostNetworkInterface::IPV6Address() const
{
std::u16string result;
COM_GetString(get_IFC(), IPV6Address, result);
return result;
}
uint32_t VBox::IHostNetworkInterface::IPV6NetworkMaskPrefixLength() const
{
COM_ULong result;
COM_GetValue(get_IFC(), IPV6NetworkMaskPrefixLength, result);
return static_cast<uint32_t>(result);
}
std::u16string VBox::IHostNetworkInterface::hardwareAddress() const
{
std::u16string result;
COM_GetString(get_IFC(), HardwareAddress, result);
return result;
}
VBox::HostNetworkInterfaceMediumType VBox::IHostNetworkInterface::mediumType() const
{
COM_Enum(::HostNetworkInterfaceMediumType) result;
COM_GetValue(get_IFC(), MediumType, result);
return static_cast<HostNetworkInterfaceMediumType>(result);
}
VBox::HostNetworkInterfaceStatus VBox::IHostNetworkInterface::status() const
{
COM_Enum(::HostNetworkInterfaceStatus) result;
COM_GetValue(get_IFC(), Status, result);
return static_cast<HostNetworkInterfaceStatus>(result);
}
VBox::HostNetworkInterfaceType VBox::IHostNetworkInterface::interfaceType() const
{
COM_Enum(::HostNetworkInterfaceType) result;
COM_GetValue(get_IFC(), InterfaceType, result);
return static_cast<HostNetworkInterfaceType>(result);
}
#if VirtualBoxSDK_VERSION >= VBox_MAKE_VERSION(5, 2, 0)
bool VBox::IHostNetworkInterface::wireless() const
{
COM_Bool result;
COM_GetValue(get_IFC(), Wireless, result);
return static_cast<bool>(result);
}
#endif
void VBox::IHostNetworkInterface::enableStaticIPConfig(
const std::u16string &IPAddress, const std::u16string &networkMask)
{
COM_StringProxy pIPAddress(IPAddress);
COM_StringProxy pNetworkMask(networkMask);
auto rc = get_IFC()->EnableStaticIPConfig(pIPAddress.m_text, pNetworkMask.m_text);
COM_ERROR_CHECK(rc);
}
void VBox::IHostNetworkInterface::enableStaticIPConfigV6(
const std::u16string &IPV6Address, uint32_t IPV6NetworkMaskPrefixLength)
{
COM_StringProxy pIPV6Address(IPV6Address);
auto rc = get_IFC()->EnableStaticIPConfigV6(pIPV6Address.m_text,
IPV6NetworkMaskPrefixLength);
COM_ERROR_CHECK(rc);
}
void VBox::IHostNetworkInterface::enableDynamicIPConfig()
{
auto rc = get_IFC()->EnableDynamicIPConfig();
COM_ERROR_CHECK(rc);
}
void VBox::IHostNetworkInterface::DHCPRediscover()
{
auto rc = get_IFC()->DHCPRediscover();
COM_ERROR_CHECK(rc);
}