-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add several network-related interface proxies.
- Loading branch information
Showing
8 changed files
with
1,168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* 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(IBandwidthControl) | ||
|
||
uint32_t VBox::IBandwidthControl::numGroups() const | ||
{ | ||
COM_ULong result; | ||
COM_GetValue(get_IFC(), NumGroups, result); | ||
return static_cast<uint32_t>(result); | ||
} | ||
|
||
void VBox::IBandwidthControl::createBandwidthGroup(const std::u16string &name, | ||
BandwidthGroupType type, int64_t maxBytesPerSec) | ||
{ | ||
COM_StringProxy pName(name); | ||
auto cType = static_cast<COM_Enum(::BandwidthGroupType)>(type); | ||
|
||
auto rc = get_IFC()->CreateBandwidthGroup(pName.m_text, cType, maxBytesPerSec); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
|
||
void VBox::IBandwidthControl::deleteBandwidthGroup(const std::u16string &name) | ||
{ | ||
COM_StringProxy pName(name); | ||
|
||
auto rc = get_IFC()->DeleteBandwidthGroup(pName.m_text); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
|
||
VBox::COMPtr<VBox::IBandwidthGroup> VBox::IBandwidthControl::getBandwidthGroup( | ||
const std::u16string &name) const | ||
{ | ||
::IBandwidthGroup *cResult = nullptr; | ||
COM_StringProxy pName(name); | ||
|
||
auto rc = get_IFC()->GetBandwidthGroup(pName.m_text, &cResult); | ||
COM_ERROR_CHECK(rc); | ||
|
||
return COMPtr<IBandwidthGroup>::wrap(cResult); | ||
} | ||
|
||
std::vector<VBox::COMPtr<VBox::IBandwidthGroup>> | ||
VBox::IBandwidthControl::getAllBandwidthGroups() const | ||
{ | ||
COM_ArrayProxy<::IBandwidthGroup *> pResult; | ||
|
||
auto rc = get_IFC()->GetAllBandwidthGroups(COM_ArrayParameterRef(pResult)); | ||
COM_ERROR_CHECK(rc); | ||
|
||
std::vector<COMPtr<IBandwidthGroup>> result; | ||
pResult.toVector(result); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* 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(IBandwidthGroup) | ||
|
||
std::u16string VBox::IBandwidthGroup::name() const | ||
{ | ||
std::u16string result; | ||
COM_GetString(get_IFC(), Name, result); | ||
return result; | ||
} | ||
|
||
VBox::BandwidthGroupType VBox::IBandwidthGroup::type() const | ||
{ | ||
COM_Enum(::BandwidthGroupType) result; | ||
COM_GetValue(get_IFC(), Type, result); | ||
return static_cast<BandwidthGroupType>(result); | ||
} | ||
|
||
uint32_t VBox::IBandwidthGroup::reference() const | ||
{ | ||
COM_ULong result; | ||
COM_GetValue(get_IFC(), Reference, result); | ||
return static_cast<uint32_t>(result); | ||
} | ||
|
||
int64_t VBox::IBandwidthGroup::maxBytesPerSec() const | ||
{ | ||
COM_Long64 result; | ||
COM_GetValue(get_IFC(), MaxBytesPerSec, result); | ||
return static_cast<int64_t>(result); | ||
} | ||
|
||
void VBox::IBandwidthGroup::set_maxBytesPerSec(int64_t value) | ||
{ | ||
COM_SetValue(get_IFC(), MaxBytesPerSec, value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
/* 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(IDHCPServer) | ||
|
||
VBox::COMPtr<VBox::IEventSource> VBox::IDHCPServer::eventSource() const | ||
{ | ||
COMPtr<IEventSource> result; | ||
COM_GetValue_Wrap(get_IFC(), EventSource, result); | ||
return result; | ||
} | ||
|
||
bool VBox::IDHCPServer::enabled() const | ||
{ | ||
COM_Bool result; | ||
COM_GetValue(get_IFC(), Enabled, result); | ||
return static_cast<bool>(result); | ||
} | ||
|
||
void VBox::IDHCPServer::set_enabled(bool value) | ||
{ | ||
COM_SetValue(get_IFC(), Enabled, value); | ||
} | ||
|
||
std::u16string VBox::IDHCPServer::IPAddress() const | ||
{ | ||
std::u16string result; | ||
COM_GetString(get_IFC(), IPAddress, result); | ||
return result; | ||
} | ||
|
||
std::u16string VBox::IDHCPServer::networkMask() const | ||
{ | ||
std::u16string result; | ||
COM_GetString(get_IFC(), NetworkMask, result); | ||
return result; | ||
} | ||
|
||
std::u16string VBox::IDHCPServer::networkName() const | ||
{ | ||
std::u16string result; | ||
COM_GetString(get_IFC(), NetworkName, result); | ||
return result; | ||
} | ||
|
||
std::u16string VBox::IDHCPServer::lowerIP() const | ||
{ | ||
std::u16string result; | ||
COM_GetString(get_IFC(), LowerIP, result); | ||
return result; | ||
} | ||
|
||
std::u16string VBox::IDHCPServer::upperIP() const | ||
{ | ||
std::u16string result; | ||
COM_GetString(get_IFC(), UpperIP, result); | ||
return result; | ||
} | ||
|
||
std::vector<std::u16string> VBox::IDHCPServer::globalOptions() const | ||
{ | ||
std::vector<std::u16string> result; | ||
COM_GetStringArray(get_IFC(), GlobalOptions, result); | ||
return result; | ||
} | ||
|
||
std::vector<std::u16string> VBox::IDHCPServer::vmConfigs() const | ||
{ | ||
std::vector<std::u16string> result; | ||
COM_GetStringArray(get_IFC(), VmConfigs, result); | ||
return result; | ||
} | ||
|
||
void VBox::IDHCPServer::addGlobalOption(DhcpOpt option, | ||
const std::u16string &value) | ||
{ | ||
auto cOption = static_cast<COM_Enum(::DhcpOpt)>(option); | ||
COM_StringProxy pValue(value); | ||
|
||
auto rc = get_IFC()->AddGlobalOption(cOption, pValue.m_text); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
|
||
#if VirtualBoxSDK_VERSION >= VBox_MAKE_VERSION(6, 0, 0) | ||
void VBox::IDHCPServer::removeGlobalOption(DhcpOpt option) | ||
{ | ||
auto cOption = static_cast<COM_Enum(::DhcpOpt)>(option); | ||
|
||
auto rc = get_IFC()->RemoveGlobalOption(cOption); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
|
||
void VBox::IDHCPServer::removeGlobalOptions() | ||
{ | ||
auto rc = get_IFC()->RemoveGlobalOptions(); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
#endif | ||
|
||
void VBox::IDHCPServer::addVmSlotOption(const std::u16string &vmname, | ||
int32_t slot, DhcpOpt option, const std::u16string &value) | ||
{ | ||
COM_StringProxy pVmname(vmname); | ||
auto cOption = static_cast<COM_Enum(::DhcpOpt)>(option); | ||
COM_StringProxy pValue(value); | ||
|
||
auto rc = get_IFC()->AddVmSlotOption(pVmname.m_text, slot, cOption, pValue.m_text); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
|
||
#if VirtualBoxSDK_VERSION >= VBox_MAKE_VERSION(6, 0, 0) | ||
void VBox::IDHCPServer::removeVmSlotOption(const std::u16string& vmname, | ||
int32_t slot, DhcpOpt option) | ||
{ | ||
COM_StringProxy pVmname(vmname); | ||
auto cOption = static_cast<COM_Enum(::DhcpOpt)>(option); | ||
|
||
auto rc = get_IFC()->RemoveVmSlotOption(pVmname.m_text, slot, cOption); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
#endif | ||
|
||
void VBox::IDHCPServer::removeVmSlotOptions(const std::u16string &vmname, | ||
int32_t slot) | ||
{ | ||
COM_StringProxy pVmname(vmname); | ||
|
||
auto rc = get_IFC()->RemoveVmSlotOptions(pVmname.m_text, slot); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
|
||
std::vector<std::u16string> VBox::IDHCPServer::getVmSlotOptions( | ||
const std::u16string &vmname, int32_t slot) | ||
{ | ||
COM_StringArrayProxy pResult; | ||
COM_StringProxy pVmname(vmname); | ||
|
||
auto rc = get_IFC()->GetVmSlotOptions(pVmname.m_text, slot, | ||
COM_ArrayParameterRef(pResult)); | ||
COM_ERROR_CHECK(rc); | ||
|
||
std::vector<std::u16string> result; | ||
pResult.toVector(result); | ||
return result; | ||
} | ||
|
||
std::vector<std::u16string> VBox::IDHCPServer::getMacOptions( | ||
const std::u16string &mac) | ||
{ | ||
COM_StringArrayProxy pResult; | ||
COM_StringProxy pMac(mac); | ||
|
||
auto rc = get_IFC()->GetMacOptions(pMac.m_text, COM_ArrayParameterRef(pResult)); | ||
COM_ERROR_CHECK(rc); | ||
|
||
std::vector<std::u16string> result; | ||
pResult.toVector(result); | ||
return result; | ||
} | ||
|
||
void VBox::IDHCPServer::setConfiguration(const std::u16string &IPAddress, | ||
const std::u16string &networkMask, const std::u16string &FromIPAddress, | ||
const std::u16string &ToIPAddress) | ||
{ | ||
COM_StringProxy pIPAddress(IPAddress); | ||
COM_StringProxy pNetworkMask(networkMask); | ||
COM_StringProxy pFromIPAddress(FromIPAddress); | ||
COM_StringProxy pToIPAddress(ToIPAddress); | ||
|
||
auto rc = get_IFC()->SetConfiguration(pIPAddress.m_text, pNetworkMask.m_text, | ||
pFromIPAddress.m_text, pToIPAddress.m_text); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
|
||
void VBox::IDHCPServer::start(const std::u16string &networkName, | ||
const std::u16string &trunkName, const std::u16string &trunkType) | ||
{ | ||
COM_StringProxy pNetworkName(networkName); | ||
COM_StringProxy pTrunkName(trunkName); | ||
COM_StringProxy pTrunkType(trunkType); | ||
|
||
auto rc = get_IFC()->Start(pNetworkName.m_text, pTrunkName.m_text, | ||
pTrunkType.m_text); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
|
||
void VBox::IDHCPServer::stop() | ||
{ | ||
auto rc = get_IFC()->Stop(); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
|
||
#if VirtualBoxSDK_VERSION >= VBox_MAKE_VERSION(6, 0, 0) | ||
void VBox::IDHCPServer::restart() | ||
{ | ||
auto rc = get_IFC()->Restart(); | ||
COM_ERROR_CHECK(rc); | ||
} | ||
#endif |
Oops, something went wrong.