ADD_DEFINITIONS(-DINPUT_EVENT_GROUP="${INPUT_EVENT_GROUP}")
ADD_DEFINITIONS(-DDISK_GROUP="${DISK_GROUP}")
ADD_DEFINITIONS(-DTTY_GROUP="${TTY_GROUP}")
+ADD_DEFINITIONS(-DHOST_IPC_SOCKET="/var/run/vasum-ipc.socket")
+#ADD_DEFINITIONS(-DDBUS_CONNECTION)
## Python packages directory ###################################################
IF(NOT DEFINED PYTHON_SITELIB)
${COMMON_FOLDER}/utils/glib-loop.cpp
${COMMON_FOLDER}/utils/glib-loop.hpp
${COMMON_FOLDER}/base-exception.hpp
- ${COMMON_FOLDER}/base-exception.cpp)
+ ${COMMON_FOLDER}/base-exception.cpp
+ ${COMMON_FOLDER}/utils/eventfd.hpp
+ ${COMMON_FOLDER}/utils/eventfd.cpp
+ ${COMMON_FOLDER}/utils/fd-utils.hpp
+ ${COMMON_FOLDER}/utils/fd-utils.cpp
+ ${COMMON_FOLDER}/epoll/*.hpp
+ ${COMMON_FOLDER}/epoll/*.cpp
+ ${COMMON_FOLDER}/ipc/*.hpp
+ ${COMMON_FOLDER}/ipc/*.cpp
+ ${COMMON_FOLDER}/ipc/internals/*.hpp
+ ${COMMON_FOLDER}/ipc/internals/*.cpp)
SET(_LIB_VERSION_ "0.0.1")
SET(_LIB_SOVERSION_ "0")
## Link libraries ##############################################################
-PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0 libSimpleDbus libLogger libConfig)
-INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS})
+FIND_PACKAGE(Boost COMPONENTS system filesystem)
+PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0 libSimpleDbus libLogger libConfig libsystemd-daemon)
+INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${COMMON_FOLDER})
INCLUDE_DIRECTORIES(${SERVER_FOLDER})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_DEPS_LIBRARIES})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_DEPS_LIBRARIES} ${Boost_LIBRARIES})
## Generate the pc file ########################################################
CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+
+/**
+ * @file
+ * @author Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief HostIPCConnection class
+ */
+
+#include <config.hpp>
+#include "host-ipc-connection.hpp"
+#include <api/messages.hpp>
+#include <host-ipc-definitions.hpp>
+
+namespace vasum {
+namespace client {
+
+void HostIPCConnection::createSystem()
+{
+ mConnection.createSystem();
+}
+
+void HostIPCConnection::callGetZoneIds(vasum::api::ZoneIds& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_GET_ZONE_ID_LIST, argOut);
+}
+
+void HostIPCConnection::callGetActiveZoneId(vasum::api::ZoneId& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_GET_ACTIVE_ZONE_ID, argOut);
+}
+
+void HostIPCConnection::callSetActiveZone(const vasum::api::ZoneId& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_SET_ACTIVE_ZONE, argIn);
+}
+
+void HostIPCConnection::callGetZoneInfo(const vasum::api::ZoneId& argIn, vasum::api::ZoneInfoOut& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_GET_ZONE_INFO, argIn, argOut);
+}
+
+void HostIPCConnection::callSetNetdevAttrs(const vasum::api::SetNetDevAttrsIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_SET_NETDEV_ATTRS, argIn);
+}
+
+void HostIPCConnection::callGetNetdevAttrs(const vasum::api::GetNetDevAttrsIn& argIn, vasum::api::GetNetDevAttrs& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_GET_NETDEV_ATTRS, argIn, argOut);
+}
+
+void HostIPCConnection::callGetNetdevList(const vasum::api::ZoneId& argIn, vasum::api::NetDevList& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_GET_NETDEV_LIST, argIn, argOut);
+}
+
+void HostIPCConnection::callCreateNetdevVeth(const vasum::api::CreateNetDevVethIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_CREATE_NETDEV_VETH, argIn);
+}
+
+void HostIPCConnection::callCreateNetdevMacvlan(const vasum::api::CreateNetDevMacvlanIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_CREATE_NETDEV_MACVLAN, argIn);
+}
+
+void HostIPCConnection::callCreateNetdevPhys(const vasum::api::CreateNetDevPhysIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_CREATE_NETDEV_PHYS, argIn);
+}
+
+void HostIPCConnection::callDestroyNetdev(const vasum::api::DestroyNetDevIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_DESTROY_NETDEV, argIn);
+}
+
+void HostIPCConnection::callDeleteNetdevIpAddress(const vasum::api::DeleteNetdevIpAddressIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_DELETE_NETDEV_IP_ADDRESS, argIn);
+}
+
+void HostIPCConnection::callDeclareFile(const vasum::api::DeclareFileIn& argIn, vasum::api::Declaration& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_DECLARE_FILE, argIn, argOut);
+}
+
+void HostIPCConnection::callDeclareMount(const vasum::api::DeclareMountIn& argIn, vasum::api::Declaration& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_DECLARE_MOUNT, argIn, argOut);
+}
+
+void HostIPCConnection::callDeclareLink(const vasum::api::DeclareLinkIn& argIn, vasum::api::Declaration& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_DECLARE_LINK, argIn, argOut);
+}
+
+void HostIPCConnection::callGetDeclarations(const vasum::api::ZoneId& argIn, vasum::api::Declarations& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_GET_DECLARATIONS, argIn, argOut);
+}
+
+void HostIPCConnection::callRemoveDeclaration(const vasum::api::RemoveDeclarationIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_REMOVE_DECLARATION, argIn);
+}
+
+void HostIPCConnection::callCreateZone(const vasum::api::CreateZoneIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_CREATE_ZONE, argIn);
+}
+
+void HostIPCConnection::callDestroyZone(const vasum::api::ZoneId& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_DESTROY_ZONE, argIn);
+}
+
+void HostIPCConnection::callShutdownZone(const vasum::api::ZoneId& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_SHUTDOWN_ZONE, argIn);
+}
+
+void HostIPCConnection::callStartZone(const vasum::api::ZoneId& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_START_ZONE, argIn);
+}
+
+void HostIPCConnection::callLockZone(const vasum::api::ZoneId& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_LOCK_ZONE, argIn);
+}
+
+void HostIPCConnection::callUnlockZone(const vasum::api::ZoneId& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_UNLOCK_ZONE, argIn);
+}
+
+void HostIPCConnection::callGrantDevice(const vasum::api::GrantDeviceIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_GRANT_DEVICE, argIn);
+}
+
+void HostIPCConnection::callRevokeDevice(const vasum::api::RevokeDeviceIn& argIn)
+{
+ mConnection.call(vasum::api::host::METHOD_REVOKE_DEVICE, argIn);
+}
+
+void HostIPCConnection::callGetZoneDbuses(vasum::api::Dbuses& argOut)
+{
+ mConnection.call(vasum::api::host::METHOD_GET_ZONE_DBUSES, argOut);
+}
+
+HostIPCConnection::SubscriptionId
+HostIPCConnection::subscribeZoneDbusState(const ZoneDbusStateCallback& callback)
+{
+ mConnection.subscribe<ZoneDbusStateCallback, vasum::api::DbusState>(
+ vasum::api::host::SIGNAL_ZONE_DBUS_STATE, callback);
+ return vasum::api::host::SIGNAL_ZONE_DBUS_STATE;
+}
+
+void HostIPCConnection::unsubscribe(const SubscriptionId& id)
+{
+ mConnection.unsubscribe(id);
+}
+
+} // namespace client
+} // namespace vasum
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+
+/**
+ * @file
+ * @author Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief HostIPCConnection class
+ */
+
+#ifndef VASUM_CLIENT_HOST_IPC_CONNECTION_HPP
+#define VASUM_CLIENT_HOST_IPC_CONNECTION_HPP
+
+#include "ipc-connection.hpp"
+#include <api/messages.hpp>
+
+namespace vasum {
+namespace client {
+
+/**
+ * HostIPCConnection is used for communication with the vasum's server from host through ipc
+ */
+class HostIPCConnection {
+public:
+ typedef unsigned int SubscriptionId;
+ typedef std::function<void(const vasum::api::DbusState&)> ZoneDbusStateCallback;
+ void createSystem();
+
+ void callGetZoneIds(vasum::api::ZoneIds& argOut);
+ void callGetActiveZoneId(vasum::api::ZoneId& argOut);
+ void callSetActiveZone(const vasum::api::ZoneId& argIn);
+ void callGetZoneInfo(const vasum::api::ZoneId& argIn, vasum::api::ZoneInfoOut& argOut);
+ void callSetNetdevAttrs(const vasum::api::SetNetDevAttrsIn& argIn);
+ void callGetNetdevAttrs(const vasum::api::GetNetDevAttrsIn& argIn, vasum::api::GetNetDevAttrs& argOut);
+ void callGetNetdevList(const vasum::api::ZoneId& argIn, vasum::api::NetDevList& argOut);
+ void callCreateNetdevVeth(const vasum::api::CreateNetDevVethIn& argIn);
+ void callCreateNetdevMacvlan(const vasum::api::CreateNetDevMacvlanIn& argIn);
+ void callCreateNetdevPhys(const vasum::api::CreateNetDevPhysIn& argIn);
+ void callDestroyNetdev(const vasum::api::DestroyNetDevIn& argIn);
+ void callDeleteNetdevIpAddress(const vasum::api::DeleteNetdevIpAddressIn& argIn);
+ void callDeclareFile(const vasum::api::DeclareFileIn& argIn, vasum::api::Declaration& argOut);
+ void callDeclareMount(const vasum::api::DeclareMountIn& argIn, vasum::api::Declaration& argOut);
+ void callDeclareLink(const vasum::api::DeclareLinkIn& argIn, vasum::api::Declaration& argOut);
+ void callGetDeclarations(const vasum::api::ZoneId& argIn, vasum::api::Declarations& argOut);
+ void callRemoveDeclaration(const vasum::api::RemoveDeclarationIn& argIn);
+ void callCreateZone(const vasum::api::CreateZoneIn& argIn);
+ void callDestroyZone(const vasum::api::ZoneId& argIn);
+ void callShutdownZone(const vasum::api::ZoneId& argIn);
+ void callStartZone(const vasum::api::ZoneId& argIn);
+ void callLockZone(const vasum::api::ZoneId& argIn);
+ void callUnlockZone(const vasum::api::ZoneId& argIn);
+ void callGrantDevice(const vasum::api::GrantDeviceIn& argIn);
+ void callRevokeDevice(const vasum::api::RevokeDeviceIn& argIn);
+ void callGetZoneDbuses(vasum::api::Dbuses& argOut);
+ SubscriptionId subscribeZoneDbusState(const ZoneDbusStateCallback& callback);
+ void unsubscribe(const SubscriptionId& id);
+
+private:
+ IPCConnection mConnection;
+};
+
+} // namespace client
+} // namespace vasum
+
+#endif /* VASUM_CLIENT_HOST_IPC_CONNECTION_HPP */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+
+/**
+ * @file
+ * @author Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief IPCConnection class
+ */
+
+#include <config.hpp>
+#include "ipc-connection.hpp"
+
+namespace {
+
+const std::string SOCKET_PATH = HOST_IPC_SOCKET;
+
+} // namespace
+
+vasum::client::IPCConnection::IPCConnection()
+{
+}
+
+vasum::client::IPCConnection::~IPCConnection()
+{
+}
+
+void vasum::client::IPCConnection::createSystem()
+{
+ mClient.reset(new ipc::Client(mDispatcher.getPoll(), SOCKET_PATH));
+ mClient->start();
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+
+/**
+ * @file
+ * @author Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief IPCConnection class
+ */
+
+#ifndef VASUM_CLIENT_IPC_CONNECTION_HPP
+#define VASUM_CLIENT_IPC_CONNECTION_HPP
+
+#include <api/messages.hpp>
+#include <ipc/client.hpp>
+#include <ipc/types.hpp>
+#include <epoll/thread-dispatcher.hpp>
+#include <type_traits>
+#include <memory>
+
+namespace vasum {
+namespace client {
+
+/**
+ * IPCConnection class
+ */
+class IPCConnection {
+public:
+ IPCConnection();
+ virtual ~IPCConnection();
+
+ void createSystem();
+
+ template<typename ArgIn, typename ArgOut>
+ typename std::enable_if<!std::is_integral<ArgOut>::value>::type
+ call(const ipc::MethodID method, const ArgIn& argIn, ArgOut& argOut, unsigned int timeout = 50000) {
+ auto out = mClient->callSync<ArgIn, ArgOut>(method, std::make_shared<ArgIn>(argIn), timeout);
+ argOut = *out;
+ }
+
+ template<typename ArgOut>
+ typename std::enable_if<!std::is_const<ArgOut>::value>::type
+ call(const ipc::MethodID method, ArgOut& argOut, unsigned int timeout = 50000) {
+ vasum::api::Void argIn;
+ call(method, argIn, argOut, timeout);
+ }
+
+ template<typename ArgIn>
+ typename std::enable_if<std::is_const<ArgIn>::value>::type
+ call(const ipc::MethodID method, ArgIn& argIn, unsigned int timeout = 50000) {
+ vasum::api::Void argOut;
+ call(method, argIn, argOut, timeout);
+ }
+
+ template<typename Callback, typename ArgIn>
+ void subscribe(const ipc::MethodID signal, const Callback& callback) {
+ auto callbackWrapper = [callback] (const ipc::PeerID, std::shared_ptr<ArgIn>& data) {
+ callback(*data);
+ };
+ mClient->setSignalHandler<ArgIn>(signal, callbackWrapper);
+ }
+
+ void unsubscribe(const ipc::MethodID signal) {
+ mClient->removeMethod(signal);
+ }
+
+private:
+ epoll::ThreadDispatcher mDispatcher;
+ std::unique_ptr<ipc::Client> mClient;
+};
+
+} // namespace client
+} // namespace vasum
+
+#endif /* VASUM_CLIENT_IPC_CONNECTION_HPP */
#include "utils.hpp"
#include "exception.hpp"
#include "host-dbus-connection.hpp"
+#include "host-ipc-connection.hpp"
#include "zone-dbus-connection.hpp"
#include <zone-dbus-definitions.hpp>
{
}
-VsmStatus Client::coverException(const function<void(void)> worker) noexcept
+VsmStatus Client::coverException(const function<void(void)>& worker) noexcept
{
try {
worker();
return coverException([&] {
shared_ptr<dbus::DbusConnection> connection(dbus::DbusConnection::createSystem().release());
+#ifdef DBUS_CONNECTION
mHostClient.create(connection);
+#else
+ mHostClient.createSystem();
+#endif
mZoneClient.create(connection);
});
}
return coverException([&] {
shared_ptr<dbus::DbusConnection> connection(dbus::DbusConnection::create(address).release());
+#ifdef DBUS_CONNECTION
mHostClient.create(connection);
+#else
+ mHostClient.createSystem();
+#endif
mZoneClient.create(connection);
});
}
#define VASUM_CLIENT_IMPL_HPP
#include "vasum-client.h"
-
+#ifdef DBUS_CONNECTION
#include "host-dbus-connection.hpp"
+#else
+#include "host-ipc-connection.hpp"
+#endif
#include "zone-dbus-connection.hpp"
#include <functional>
*/
static VsmStatus vsm_stop_glib_loop() noexcept;
private:
+#ifdef DBUS_CONNECTION
+ typedef vasum::client::HostDbusConnection HostConnection;
+#else
+ typedef vasum::client::HostIPCConnection HostConnection;
+#endif
+ typedef vasum::client::ZoneDbusConnection ZoneConnection;
struct Status {
Status();
Status(VsmStatus status, const std::string& msg = "");
};
Status mStatus;
- vasum::client::HostDbusConnection mHostClient;
- vasum::client::ZoneDbusConnection mZoneClient;
- VsmStatus coverException(const std::function<void(void)> worker) noexcept;
+ HostConnection mHostClient;
+ ZoneConnection mZoneClient;
+
+ VsmStatus coverException(const std::function<void(void)>& worker) noexcept;
VsmStatus vsm_netdev_get_ip_addr(const char* zone,
const char* netdevId,
int type,
return;
}
- if (pollEvents & EPOLLIN) {
- mProcessor.handleInput(fd);
- return; // because handleInput will handle RDHUP
- }
-
if ((pollEvents & EPOLLHUP) || (pollEvents & EPOLLRDHUP)) {
+ //IN, HUP, RDHUP are set when client is disconnecting but there is 0 bytes to read, so
+ //assume that if IN and HUP or RDHUP are set then input data is garbage.
+ //Assumption is harmless because handleInput processes all message data.
mProcessor.handleLostConnection(fd);
+ return;
+ }
+
+ if (pollEvents & EPOLLIN) {
+ //Process all message data
+ mProcessor.handleInput(fd);
}
}
#include "config.hpp"
-#include "host-connection.hpp"
+#include "host-dbus-connection.hpp"
#include "host-dbus-definitions.hpp"
#include "exception.hpp"
#include "api/dbus-method-result-builder.hpp"
} // namespace
-HostConnection::HostConnection()
+HostDbusConnection::HostDbusConnection()
: mNameAcquired(false)
, mNameLost(false)
{
LOGT("Setting DBUS name");
mDbusConnection->setName(api::host::BUS_NAME,
- std::bind(&HostConnection::onNameAcquired, this),
- std::bind(&HostConnection::onNameLost, this));
+ std::bind(&HostDbusConnection::onNameAcquired, this),
+ std::bind(&HostDbusConnection::onNameLost, this));
if (!waitForName(NAME_ACQUIRED_TIMEOUT)) {
LOGE("Could not acquire dbus name: " << api::host::BUS_NAME);
using namespace std::placeholders;
mDbusConnection->registerObject(api::host::OBJECT_PATH,
api::host::DEFINITION,
- std::bind(&HostConnection::onMessageCall,
+ std::bind(&HostDbusConnection::onMessageCall,
this, _1, _2, _3, _4, _5));
LOGD("Connected");
}
-HostConnection::~HostConnection()
+HostDbusConnection::~HostDbusConnection()
{
}
-bool HostConnection::waitForName(const unsigned int timeoutMs)
+bool HostDbusConnection::waitForName(const unsigned int timeoutMs)
{
std::unique_lock<std::mutex> lock(mNameMutex);
mNameCondition.wait_for(lock,
return mNameAcquired;
}
-void HostConnection::onNameAcquired()
+void HostDbusConnection::onNameAcquired()
{
std::unique_lock<std::mutex> lock(mNameMutex);
mNameAcquired = true;
mNameCondition.notify_one();
}
-void HostConnection::onNameLost()
+void HostDbusConnection::onNameLost()
{
std::unique_lock<std::mutex> lock(mNameMutex);
mNameLost = true;
}
}
-void HostConnection::setProxyCallCallback(const ProxyCallCallback& callback)
+void HostDbusConnection::setProxyCallCallback(const ProxyCallCallback& callback)
{
mProxyCallCallback = callback;
}
-void HostConnection::setGetZoneDbusesCallback(const GetZoneDbusesCallback& callback)
+void HostDbusConnection::setGetZoneDbusesCallback(const GetZoneDbusesCallback& callback)
{
mGetZoneDbusesCallback = callback;
}
-void HostConnection::setGetZoneIdsCallback(const GetZoneIdsCallback& callback)
+void HostDbusConnection::setGetZoneIdsCallback(const GetZoneIdsCallback& callback)
{
mGetZoneIdsCallback = callback;
}
-void HostConnection::setGetActiveZoneIdCallback(const GetActiveZoneIdCallback& callback)
+void HostDbusConnection::setGetActiveZoneIdCallback(const GetActiveZoneIdCallback& callback)
{
mGetActiveZoneIdCallback = callback;
}
-void HostConnection::setGetZoneInfoCallback(const GetZoneInfoCallback& callback)
+void HostDbusConnection::setGetZoneInfoCallback(const GetZoneInfoCallback& callback)
{
mGetZoneInfoCallback = callback;
}
-void HostConnection::setSetNetdevAttrsCallback(const SetNetdevAttrsCallback& callback)
+void HostDbusConnection::setSetNetdevAttrsCallback(const SetNetdevAttrsCallback& callback)
{
mSetNetdevAttrsCallback = callback;
}
-void HostConnection::setGetNetdevAttrsCallback(const GetNetdevAttrsCallback& callback)
+void HostDbusConnection::setGetNetdevAttrsCallback(const GetNetdevAttrsCallback& callback)
{
mGetNetdevAttrsCallback = callback;
}
-void HostConnection::setGetNetdevListCallback(const GetNetdevListCallback& callback)
+void HostDbusConnection::setGetNetdevListCallback(const GetNetdevListCallback& callback)
{
mGetNetdevListCallback = callback;
}
-void HostConnection::setCreateNetdevVethCallback(const CreateNetdevVethCallback& callback)
+void HostDbusConnection::setCreateNetdevVethCallback(const CreateNetdevVethCallback& callback)
{
mCreateNetdevVethCallback = callback;
}
-void HostConnection::setCreateNetdevMacvlanCallback(const CreateNetdevMacvlanCallback& callback)
+void HostDbusConnection::setCreateNetdevMacvlanCallback(const CreateNetdevMacvlanCallback& callback)
{
mCreateNetdevMacvlanCallback = callback;
}
-void HostConnection::setCreateNetdevPhysCallback(const CreateNetdevPhysCallback& callback)
+void HostDbusConnection::setCreateNetdevPhysCallback(const CreateNetdevPhysCallback& callback)
{
mCreateNetdevPhysCallback = callback;
}
-void HostConnection::setDestroyNetdevCallback(const DestroyNetdevCallback& callback)
+void HostDbusConnection::setDestroyNetdevCallback(const DestroyNetdevCallback& callback)
{
mDestroyNetdevCallback = callback;
}
-void HostConnection::setDeleleNetdevIpAddressCallback(const DeleteNetdevIpAddressCallback& callback)
+void HostDbusConnection::setDeleteNetdevIpAddressCallback(const DeleteNetdevIpAddressCallback& callback)
{
mDeleteNetdevIpAddressCallback = callback;
}
-void HostConnection::setDeclareFileCallback(const DeclareFileCallback& callback)
+void HostDbusConnection::setDeclareFileCallback(const DeclareFileCallback& callback)
{
mDeclareFileCallback = callback;
}
-void HostConnection::setDeclareMountCallback(const DeclareMountCallback& callback)
+void HostDbusConnection::setDeclareMountCallback(const DeclareMountCallback& callback)
{
mDeclareMountCallback = callback;
}
-void HostConnection::setDeclareLinkCallback(const DeclareLinkCallback& callback)
+void HostDbusConnection::setDeclareLinkCallback(const DeclareLinkCallback& callback)
{
mDeclareLinkCallback = callback;
}
-void HostConnection::setGetDeclarationsCallback(const GetDeclarationsCallback& callback)
+void HostDbusConnection::setGetDeclarationsCallback(const GetDeclarationsCallback& callback)
{
mGetDeclarationsCallback = callback;
}
-void HostConnection::setRemoveDeclarationCallback(const RemoveDeclarationCallback& callback)
+void HostDbusConnection::setRemoveDeclarationCallback(const RemoveDeclarationCallback& callback)
{
mRemoveDeclarationCallback = callback;
}
-void HostConnection::setSetActiveZoneCallback(const SetActiveZoneCallback& callback)
+void HostDbusConnection::setSetActiveZoneCallback(const SetActiveZoneCallback& callback)
{
mSetActiveZoneCallback = callback;
}
-void HostConnection::setCreateZoneCallback(const CreateZoneCallback& callback)
+void HostDbusConnection::setCreateZoneCallback(const CreateZoneCallback& callback)
{
mCreateZoneCallback = callback;
}
-void HostConnection::setDestroyZoneCallback(const DestroyZoneCallback& callback)
+void HostDbusConnection::setDestroyZoneCallback(const DestroyZoneCallback& callback)
{
mDestroyZoneCallback = callback;
}
-void HostConnection::setShutdownZoneCallback(const ShutdownZoneCallback& callback)
+void HostDbusConnection::setShutdownZoneCallback(const ShutdownZoneCallback& callback)
{
mShutdownZoneCallback = callback;
}
-void HostConnection::setStartZoneCallback(const StartZoneCallback& callback)
+void HostDbusConnection::setStartZoneCallback(const StartZoneCallback& callback)
{
mStartZoneCallback = callback;
}
-void HostConnection::setLockZoneCallback(const LockZoneCallback& callback)
+void HostDbusConnection::setLockZoneCallback(const LockZoneCallback& callback)
{
mLockZoneCallback = callback;
}
-void HostConnection::setUnlockZoneCallback(const UnlockZoneCallback& callback)
+void HostDbusConnection::setUnlockZoneCallback(const UnlockZoneCallback& callback)
{
mUnlockZoneCallback = callback;
}
-void HostConnection::setGrantDeviceCallback(const GrantDeviceCallback& callback)
+void HostDbusConnection::setGrantDeviceCallback(const GrantDeviceCallback& callback)
{
mGrantDeviceCallback = callback;
}
-void HostConnection::setRevokeDeviceCallback(const RevokeDeviceCallback& callback)
+void HostDbusConnection::setRevokeDeviceCallback(const RevokeDeviceCallback& callback)
{
mRevokeDeviceCallback = callback;
}
-void HostConnection::onMessageCall(const std::string& objectPath,
+void HostDbusConnection::onMessageCall(const std::string& objectPath,
const std::string& interface,
const std::string& methodName,
GVariant* parameters,
}
}
-void HostConnection::proxyCallAsync(const std::string& busName,
+void HostDbusConnection::proxyCallAsync(const std::string& busName,
const std::string& objectPath,
const std::string& interface,
const std::string& method,
callback);
}
-void HostConnection::signalZoneDbusState(const std::string& zoneId,
- const std::string& dbusAddress)
+void HostDbusConnection::signalZoneDbusState(const api::DbusState& state)
{
- GVariant* parameters = g_variant_new("(ss)", zoneId.c_str(), dbusAddress.c_str());
+ GVariant* parameters = g_variant_new("(ss)", state.first.c_str(), state.second.c_str());
mDbusConnection->emitSignal(api::host::OBJECT_PATH,
api::host::INTERFACE,
api::host::SIGNAL_ZONE_DBUS_STATE,
*/
-#ifndef SERVER_HOST_CONNECTION_HPP
-#define SERVER_HOST_CONNECTION_HPP
+#ifndef SERVER_HOST_DBUS_CONNECTION_HPP
+#define SERVER_HOST_DBUS_CONNECTION_HPP
#include "dbus/connection.hpp"
#include "api/method-result-builder.hpp"
#include "api/messages.hpp"
+#include <functional>
#include <mutex>
#include <condition_variable>
#include <tuple>
namespace vasum {
-class HostConnection {
+class HostDbusConnection {
public:
- HostConnection();
- ~HostConnection();
+ HostDbusConnection();
+ ~HostDbusConnection();
// ------------- API --------------
/**
* Send signal describing dbus address state change
*/
- void signalZoneDbusState(const std::string& zoneId, const std::string& dbusAddress);
+ void signalZoneDbusState(const api::DbusState& state);
/**
* Register a callback called to get a list of zone ids
/**
* Register a callback called to remove ip address from netdev
*/
- void setDeleleNetdevIpAddressCallback(const DeleteNetdevIpAddressCallback& callback);
+ void setDeleteNetdevIpAddressCallback(const DeleteNetdevIpAddressCallback& callback);
/**
* Register a callback called to declare file
} // namespace vasum
-#endif // SERVER_HOST_CONNECTION_HPP
+#endif // SERVER_HOST_DBUS_CONNECTION_HPP
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+/**
+ * @file
+ * @author Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief HostIPCConnection class
+ */
+
+#include "config.hpp"
+
+#include "host-ipc-connection.hpp"
+#include "host-ipc-definitions.hpp"
+#include "exception.hpp"
+#include "logger/logger.hpp"
+
+namespace vasum {
+
+namespace {
+
+const std::string SOCKET_PATH = HOST_IPC_SOCKET;
+
+} // namespace
+
+
+HostIPCConnection::HostIPCConnection()
+{
+ LOGT("Connecting to host IPC socket");
+ mService.reset(new ipc::Service(mDispatcher.getPoll(), SOCKET_PATH));
+
+ LOGT("Starting IPC");
+ mService->start();
+ LOGD("Connected");
+}
+
+HostIPCConnection::~HostIPCConnection()
+{
+}
+
+void HostIPCConnection::setGetZoneDbusesCallback(const Callback<api::Dbuses>::type& callback)
+{
+ typedef Callback<api::Dbuses> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_GET_ZONE_DBUSES,
+ Callback::getCallbackWrapper(callback));
+
+}
+
+void HostIPCConnection::setGetZoneIdsCallback(const Callback<api::ZoneIds>::type& callback)
+{
+ typedef Callback<api::ZoneIds> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_GET_ZONE_ID_LIST,
+ Callback::getCallbackWrapper(callback));
+
+}
+
+void HostIPCConnection::setGetActiveZoneIdCallback(const Callback<api::ZoneId>::type& callback)
+{
+ typedef Callback<api::ZoneId> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_GET_ACTIVE_ZONE_ID,
+ Callback::getCallbackWrapper(callback));
+
+}
+
+void HostIPCConnection::setGetZoneInfoCallback(const Callback<const api::ZoneId, api::ZoneInfoOut>::type& callback)
+{
+ typedef Callback<const api::ZoneId, api::ZoneInfoOut> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_GET_ZONE_INFO,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setSetNetdevAttrsCallback(const Callback<const api::SetNetDevAttrsIn>::type& callback)
+{
+ typedef Callback<const api::SetNetDevAttrsIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_SET_NETDEV_ATTRS,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setGetNetdevAttrsCallback(const Callback<const api::GetNetDevAttrsIn, api::GetNetDevAttrs>::type& callback)
+{
+ typedef Callback<const api::GetNetDevAttrsIn, api::GetNetDevAttrs> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_GET_NETDEV_ATTRS,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setGetNetdevListCallback(const Callback<const api::ZoneId, api::NetDevList>::type& callback)
+{
+ typedef Callback<const api::ZoneId, api::NetDevList> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_GET_NETDEV_LIST,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setCreateNetdevVethCallback(const Callback<const api::CreateNetDevVethIn>::type& callback)
+{
+ typedef Callback<const api::CreateNetDevVethIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_CREATE_NETDEV_VETH,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setCreateNetdevMacvlanCallback(const Callback<const api::CreateNetDevMacvlanIn>::type& callback)
+{
+ typedef Callback<const api::CreateNetDevMacvlanIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_CREATE_NETDEV_MACVLAN,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setCreateNetdevPhysCallback(const Callback<const api::CreateNetDevPhysIn>::type& callback)
+{
+ typedef Callback<const api::CreateNetDevPhysIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_CREATE_NETDEV_PHYS,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setDestroyNetdevCallback(const Callback<const api::DestroyNetDevIn>::type& callback)
+{
+ typedef Callback<const api::DestroyNetDevIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_DESTROY_NETDEV,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setDeleteNetdevIpAddressCallback(const Callback<const api::DeleteNetdevIpAddressIn>::type& callback)
+{
+ typedef Callback<const api::DeleteNetdevIpAddressIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_DELETE_NETDEV_IP_ADDRESS,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setDeclareFileCallback(const Callback<const api::DeclareFileIn, api::Declaration>::type& callback)
+{
+ typedef Callback<const api::DeclareFileIn, api::Declaration> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_DECLARE_FILE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setDeclareMountCallback(const Callback<const api::DeclareMountIn, api::Declaration>::type& callback)
+{
+ typedef Callback<const api::DeclareMountIn, api::Declaration> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_DECLARE_MOUNT,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setDeclareLinkCallback(const Callback<const api::DeclareLinkIn, api::Declaration>::type& callback)
+{
+ typedef Callback<const api::DeclareLinkIn, api::Declaration> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_DECLARE_LINK,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setGetDeclarationsCallback(const Callback<const api::ZoneId, api::Declarations>::type& callback)
+{
+ typedef Callback<const api::ZoneId, api::Declarations> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_GET_DECLARATIONS,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setRemoveDeclarationCallback(const Callback<const api::RemoveDeclarationIn>::type& callback)
+{
+ typedef Callback<const api::RemoveDeclarationIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_REMOVE_DECLARATION,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setSetActiveZoneCallback(const Callback<const api::ZoneId>::type& callback)
+{
+ typedef Callback<const api::ZoneId> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_SET_ACTIVE_ZONE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setCreateZoneCallback(const Callback<const api::CreateZoneIn>::type& callback)
+{
+ typedef Callback<const api::CreateZoneIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_CREATE_ZONE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setDestroyZoneCallback(const Callback<const api::ZoneId>::type& callback)
+{
+ typedef Callback<const api::ZoneId> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_DESTROY_ZONE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setShutdownZoneCallback(const Callback<const api::ZoneId>::type& callback)
+{
+ typedef Callback<const api::ZoneId> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_SHUTDOWN_ZONE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setStartZoneCallback(const Callback<const api::ZoneId>::type& callback)
+{
+ typedef Callback<const api::ZoneId> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_START_ZONE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setLockZoneCallback(const Callback<const api::ZoneId>::type& callback)
+{
+ typedef Callback<const api::ZoneId> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_LOCK_ZONE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setUnlockZoneCallback(const Callback<const api::ZoneId>::type& callback)
+{
+ typedef Callback<const api::ZoneId> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_UNLOCK_ZONE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setGrantDeviceCallback(const Callback<const api::GrantDeviceIn>::type& callback)
+{
+ typedef Callback<const api::GrantDeviceIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_GRANT_DEVICE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::setRevokeDeviceCallback(const Callback<const api::RevokeDeviceIn>::type& callback)
+{
+ typedef Callback<const api::RevokeDeviceIn> Callback;
+ mService->setMethodHandler<Callback::out, Callback::in>(
+ api::host::METHOD_REVOKE_DEVICE,
+ Callback::getCallbackWrapper(callback));
+}
+
+void HostIPCConnection::signalZoneDbusState(const api::DbusState& dbusState)
+{
+ mService->signal(api::host::SIGNAL_ZONE_DBUS_STATE,
+ std::make_shared<api::DbusState>(dbusState));
+}
+
+} // namespace vasum
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+/**
+ * @file
+ * @author Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief HostIPCConnection class
+ */
+
+
+#ifndef SERVER_HOST_IPC_CONNECTION_HPP
+#define SERVER_HOST_IPC_CONNECTION_HPP
+
+#include "api/messages.hpp"
+#include "api/method-result-builder.hpp"
+#include "api/ipc-method-result-builder.hpp"
+#include "epoll/thread-dispatcher.hpp"
+#include "ipc/service.hpp"
+
+#include <functional>
+
+namespace vasum {
+
+
+
+class HostIPCConnection {
+public:
+ template<typename ArgIn, typename ArgOut = api::Void>
+ class Callback {
+ public:
+ typedef typename std::remove_cv<ArgIn>::type in;
+ typedef ArgOut out;
+ typedef std::function<void(const in&, api::MethodResultBuilder::Pointer)> type;
+
+ static typename ipc::MethodHandler<out, in>::type
+ getCallbackWrapper(const type& callback) {
+ return [callback](const ipc::PeerID,
+ const std::shared_ptr<in>& argIn,
+ ipc::MethodResult::Pointer&& argOut)
+ {
+ auto rb = std::make_shared<api::IPCMethodResultBuilder>(argOut);
+ callback(*argIn, rb);
+ };
+ }
+ };
+
+ template<typename ArgOut>
+ class Callback<ArgOut, typename std::enable_if<!std::is_const<ArgOut>::value, api::Void>::type> {
+ public:
+ typedef api::Void in;
+ typedef ArgOut out;
+ typedef std::function<void(api::MethodResultBuilder::Pointer)> type;
+
+ static typename ipc::MethodHandler<out, in>::type
+ getCallbackWrapper(const type& callback) {
+ return [callback](const ipc::PeerID,
+ const std::shared_ptr<in>& /* argIn */,
+ ipc::MethodResult::Pointer&& argOut)
+ {
+ auto rb = std::make_shared<api::IPCMethodResultBuilder>(argOut);
+ callback(rb);
+ };
+ }
+ };
+
+ HostIPCConnection();
+ ~HostIPCConnection();
+
+ void setGetZoneDbusesCallback(const Callback<api::Dbuses>::type& callback);
+ void setGetZoneIdsCallback(const Callback<api::ZoneIds>::type& callback);
+ void setGetActiveZoneIdCallback(const Callback<api::ZoneId>::type& callback);
+ void setGetZoneInfoCallback(const Callback<const api::ZoneId, api::ZoneInfoOut>::type& callback);
+ void setSetNetdevAttrsCallback(const Callback<const api::SetNetDevAttrsIn>::type& callback);
+ void setGetNetdevAttrsCallback(const Callback<const api::GetNetDevAttrsIn, api::GetNetDevAttrs>::type& callback);
+ void setGetNetdevListCallback(const Callback<const api::ZoneId, api::NetDevList>::type& callback);
+ void setCreateNetdevVethCallback(const Callback<const api::CreateNetDevVethIn>::type& callback);
+ void setCreateNetdevMacvlanCallback(const Callback<const api::CreateNetDevMacvlanIn>::type& callback);
+ void setCreateNetdevPhysCallback(const Callback<const api::CreateNetDevPhysIn>::type& callback);
+ void setDestroyNetdevCallback(const Callback<const api::DestroyNetDevIn>::type& callback);
+ void setDeleteNetdevIpAddressCallback(const Callback<const api::DeleteNetdevIpAddressIn>::type& callback);
+ void setDeclareFileCallback(const Callback<const api::DeclareFileIn, api::Declaration>::type& callback);
+ void setDeclareMountCallback(const Callback<const api::DeclareMountIn, api::Declaration>::type& callback);
+ void setDeclareLinkCallback(const Callback<const api::DeclareLinkIn, api::Declaration>::type& callback);
+ void setGetDeclarationsCallback(const Callback<const api::ZoneId, api::Declarations>::type& callback);
+ void setRemoveDeclarationCallback(const Callback<const api::RemoveDeclarationIn>::type& callback);
+ void setSetActiveZoneCallback(const Callback<const api::ZoneId>::type& callback);
+ void setCreateZoneCallback(const Callback<const api::CreateZoneIn>::type& callback);
+ void setDestroyZoneCallback(const Callback<const api::ZoneId>::type& callback);
+ void setShutdownZoneCallback(const Callback<const api::ZoneId>::type& callback);
+ void setStartZoneCallback(const Callback<const api::ZoneId>::type& callback);
+ void setLockZoneCallback(const Callback<const api::ZoneId>::type& callback);
+ void setUnlockZoneCallback(const Callback<const api::ZoneId>::type& callback);
+ void setGrantDeviceCallback(const Callback<const api::GrantDeviceIn>::type& callback);
+ void setRevokeDeviceCallback(const Callback<const api::RevokeDeviceIn>::type& callback);
+ void signalZoneDbusState(const api::DbusState& dbusState);
+
+private:
+ epoll::ThreadDispatcher mDispatcher;
+ std::unique_ptr<ipc::Service> mService;
+};
+
+} // namespace vasum
+
+#endif // SERVER_HOST_IPC_CONNECTION_HPP
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Mateusz Malicki <m.malicki2@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+/**
+ * @file
+ * @author Mateusz Malicki (m.malicki2@samsung.com)
+ * @brief Host ipc api definitions
+ */
+
+#ifndef SERVER_HOST_IPC_DEFINITIONS_HPP
+#define SERVER_HOST_IPC_DEFINITIONS_HPP
+
+#include "ipc/types.hpp"
+
+namespace vasum {
+namespace api {
+namespace host {
+
+const vasum::ipc::MethodID METHOD_GET_ZONE_DBUSES = 1;
+const vasum::ipc::MethodID METHOD_GET_ZONE_ID_LIST = 2;
+const vasum::ipc::MethodID METHOD_GET_ACTIVE_ZONE_ID = 3;
+const vasum::ipc::MethodID METHOD_GET_ZONE_INFO = 4;
+const vasum::ipc::MethodID METHOD_SET_NETDEV_ATTRS = 5;
+const vasum::ipc::MethodID METHOD_GET_NETDEV_ATTRS = 6;
+const vasum::ipc::MethodID METHOD_GET_NETDEV_LIST = 7;
+const vasum::ipc::MethodID METHOD_CREATE_NETDEV_VETH = 8;
+const vasum::ipc::MethodID METHOD_CREATE_NETDEV_MACVLAN = 9;
+const vasum::ipc::MethodID METHOD_CREATE_NETDEV_PHYS = 10;
+const vasum::ipc::MethodID METHOD_DELETE_NETDEV_IP_ADDRESS = 11;
+const vasum::ipc::MethodID METHOD_DESTROY_NETDEV = 12;
+const vasum::ipc::MethodID METHOD_DECLARE_FILE = 13;
+const vasum::ipc::MethodID METHOD_DECLARE_MOUNT = 14;
+const vasum::ipc::MethodID METHOD_DECLARE_LINK = 15;
+const vasum::ipc::MethodID METHOD_GET_DECLARATIONS = 16;
+const vasum::ipc::MethodID METHOD_REMOVE_DECLARATION = 17;
+const vasum::ipc::MethodID METHOD_SET_ACTIVE_ZONE = 18;
+const vasum::ipc::MethodID METHOD_CREATE_ZONE = 19;
+const vasum::ipc::MethodID METHOD_DESTROY_ZONE = 20;
+const vasum::ipc::MethodID METHOD_SHUTDOWN_ZONE = 21;
+const vasum::ipc::MethodID METHOD_START_ZONE = 22;
+const vasum::ipc::MethodID METHOD_LOCK_ZONE = 23;
+const vasum::ipc::MethodID METHOD_UNLOCK_ZONE = 24;
+const vasum::ipc::MethodID METHOD_GRANT_DEVICE = 25;
+const vasum::ipc::MethodID METHOD_REVOKE_DEVICE = 26;
+
+const vasum::ipc::MethodID SIGNAL_ZONE_DBUS_STATE = 27;
+
+} // namespace host
+} // namespace api
+} // namespace vasum
+
+
+#endif // SERVER_HOST_IPC_DEFINITIONS_HPP
mProxyCallPolicy.reset(new ProxyCallPolicy(mConfig.proxyCallRules));
using namespace std::placeholders;
+#ifdef DBUS_CONNECTION
mHostConnection.setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
this, HOST_ID, _1, _2, _3, _4, _5, _6, _7));
+#endif
mHostConnection.setGetZoneDbusesCallback(bind(&ZonesManager::handleGetZoneDbusesCall,
this, _1));
mHostConnection.setDestroyNetdevCallback(bind(&ZonesManager::handleDestroyNetdevCall,
this, _1, _2));
- mHostConnection.setDeleleNetdevIpAddressCallback(bind(&ZonesManager::handleDeleteNetdevIpAddressCall,
+ mHostConnection.setDeleteNetdevIpAddressCallback(bind(&ZonesManager::handleDeleteNetdevIpAddressCall,
this, _1, _2));
mHostConnection.setDeclareFileCallback(bind(&ZonesManager::handleDeclareFileCall,
};
if (target == HOST_ID) {
+#ifdef DBUS_CONNECTION
mHostConnection.proxyCallAsync(targetBusName,
targetObjectPath,
targetInterface,
targetMethod,
parameters,
asyncResultCallback);
+#else
+ result->setError(api::ERROR_INVALID_ID, "Unsupported proxy call target");
+#endif
return;
}
result->set(dbuses);
}
-void ZonesManager::handleDbusStateChanged(const std::string& zoneId,
+void ZonesManager::handleDbusStateChanged(const std::string& zoneId ,
const std::string& dbusAddress)
{
- mHostConnection.signalZoneDbusState(zoneId, dbusAddress);
+ mHostConnection.signalZoneDbusState({zoneId, dbusAddress});
}
void ZonesManager::handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result)
#include "zone.hpp"
#include "zones-manager-config.hpp"
-#include "host-connection.hpp"
+#ifdef DBUS_CONNECTION
+#include "host-dbus-connection.hpp"
+#else
+#include "host-ipc-connection.hpp"
+#endif
#include "input-monitor.hpp"
#include "proxy-call-policy.hpp"
#include "utils/worker.hpp"
private:
typedef std::recursive_mutex Mutex;
typedef std::unique_lock<Mutex> Lock;
+#ifdef DBUS_CONNECTION
+ typedef HostDbusConnection HostConnection;
+#else
+ typedef HostIPCConnection HostConnection;
+#endif
utils::Worker::Pointer mWorker;
Mutex mMutex; // used to protect mZones