SET(LOGGER_FOLDER ${PROJECT_SOURCE_DIR}/libs/logger)
SET(DBUS_FOLDER ${PROJECT_SOURCE_DIR}/libs/dbus)
SET(CONFIG_FOLDER ${PROJECT_SOURCE_DIR}/libs/config)
+SET(IPC_FOLDER ${PROJECT_SOURCE_DIR}/libs/ipc)
SET(CLIENT_FOLDER ${PROJECT_SOURCE_DIR}/client)
SET(SERVER_FOLDER ${PROJECT_SOURCE_DIR}/server)
SET(ZONE_SUPPORT_FOLDER ${PROJECT_SOURCE_DIR}/zone-support)
ADD_SUBDIRECTORY(${LOGGER_FOLDER})
ADD_SUBDIRECTORY(${DBUS_FOLDER})
ADD_SUBDIRECTORY(${CONFIG_FOLDER})
+ADD_SUBDIRECTORY(${IPC_FOLDER})
ADD_SUBDIRECTORY(${CLIENT_FOLDER})
ADD_SUBDIRECTORY(${SERVER_FOLDER})
ADD_SUBDIRECTORY(${ZONE_SUPPORT_FOLDER})
INCLUDE_DIRECTORIES(${CLIENT_FOLDER})
INCLUDE_DIRECTORIES(${COMMON_FOLDER})
-TARGET_LINK_LIBRARIES(${CLI_CODENAME} ${PROJECT_NAME}-client ${LIB_DEPS_LIBRARIES})
+TARGET_LINK_LIBRARIES(${CLI_CODENAME} ${PROJECT_NAME}-client ${LIB_DEPS_LIBRARIES} Ipc)
CONFIGURE_FILE(support/vasum-cli-completion.sh.in
${CMAKE_BINARY_DIR}/vasum-cli-completion.sh
MESSAGE(STATUS "Generating makefile for the Client...")
FILE(GLOB project_SRCS *.cpp *.hpp *.h)
-FILE(GLOB common_SRCS ${COMMON_FOLDER}/ipc/epoll/*.hpp ${COMMON_FOLDER}/ipc/epoll/*.cpp
- ${COMMON_FOLDER}/ipc/*.hpp ${COMMON_FOLDER}/ipc/*.cpp
- ${COMMON_FOLDER}/ipc/internals/*.hpp ${COMMON_FOLDER}/ipc/internals/*.cpp
- ${COMMON_FOLDER}/utils/*.hpp ${COMMON_FOLDER}/utils/*.cpp
+FILE(GLOB common_SRCS ${COMMON_FOLDER}/utils/*.hpp ${COMMON_FOLDER}/utils/*.cpp
${COMMON_FOLDER}/*.hpp ${COMMON_FOLDER}/*.cpp)
SET(_LIB_VERSION_ "${VERSION}")
INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${COMMON_FOLDER})
INCLUDE_DIRECTORIES(${LIBS_FOLDER})
+INCLUDE_DIRECTORIES(${IPC_FOLDER})
INCLUDE_DIRECTORIES(${SERVER_FOLDER})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_DEPS_LIBRARIES} ${Boost_LIBRARIES}
- Config SimpleDbus)
+ Config SimpleDbus Ipc)
## Generate the pc file ########################################################
CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
#include "utils/exception.hpp"
#include "utils/make-clean.hpp"
#include "utils/environment.hpp"
+#include "base-exception.hpp"
#include <logger/logger.hpp>
#include <cassert>
#include <cstring>
#include <cstdint>
-using namespace vasum;
-
namespace utils {
EventFD::EventFD()
#ifndef COMMON_UTILS_EXCEPTION_HPP
#define COMMON_UTILS_EXCEPTION_HPP
-#include "base-exception.hpp"
-
+#include <stdexcept>
namespace utils {
/**
* Base class for exceptions in utils
*/
-struct UtilsException: public vasum::VasumException {
+struct UtilsException: public std::runtime_error {
- UtilsException(const std::string& error) : vasum::VasumException(error) {}
+ UtilsException(const std::string& error) : std::runtime_error(error) {}
};
/**
namespace fs = boost::filesystem;
namespace chr = std::chrono;
-using namespace vasum;
-
namespace utils {
namespace {
#include <unistd.h>
#include <stdexcept>
-using namespace vasum;
-
namespace utils {
namespace fs = boost::filesystem;
-using namespace vasum;
-
namespace utils {
--- /dev/null
+# Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# 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 CMakeLists.txt
+# @author Mateusz Malicki (m.malicki2@samsung.com)
+#
+
+PROJECT(Ipc)
+
+MESSAGE(STATUS "")
+MESSAGE(STATUS "Generating makefile for the libIpc...")
+
+FILE(GLOB HEADERS *.hpp)
+FILE(GLOB HEADERS_INTERNALS internals/*.hpp)
+FILE(GLOB HEADERS_EPOLL epoll/*.hpp)
+FILE(GLOB HEADERS_UTILS ${COMMON_FOLDER}/utils/fd-utils.hpp
+ ${COMMON_FOLDER}/utils/eventfd.hpp
+ ${COMMON_FOLDER}/utils/exception.hpp
+ ${COMMON_FOLDER}/utils/callback-guard.hpp)
+FILE(GLOB SRCS *.cpp)
+FILE(GLOB SRCS_INTERNALS internals/*.cpp)
+FILE(GLOB SRCS_EPOLL epoll/*.cpp)
+FILE(GLOB SRCS_UTILS ${COMMON_FOLDER}/utils/fd-utils.cpp
+ ${COMMON_FOLDER}/utils/eventfd.cpp
+ ${COMMON_FOLDER}/utils/exception.cpp
+ ${COMMON_FOLDER}/utils/callback-guard.cpp)
+
+SET(_LIB_VERSION_ "${VERSION}")
+SET(_LIB_SOVERSION_ "0")
+SET(PC_FILE "lib${PROJECT_NAME}.pc")
+
+## Setup target ################################################################
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} ${SRCS_INTERNALS} ${SRCS_UTILS} ${SRCS_EPOLL})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
+ SOVERSION ${_LIB_SOVERSION_}
+ VERSION ${_LIB_VERSION_}
+ )
+
+## Link libraries ##############################################################
+INCLUDE_DIRECTORIES(${LIBS_FOLDER})
+INCLUDE_DIRECTORIES(${COMMON_FOLDER})
+INCLUDE_DIRECTORIES(SYSTEM ${DBUS_DEPS_INCLUDE_DIRS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} Logger Config)
+
+## Generate the pc file ########################################################
+CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE} @ONLY)
+
+## Install #####################################################################
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE}
+ DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+INSTALL(TARGETS ${PROJECT_NAME}
+ DESTINATION ${LIB_INSTALL_DIR}
+ COMPONENT RuntimeLibraries)
+
+INSTALL(FILES ${HEADERS}
+ DESTINATION ${INCLUDE_INSTALL_DIR}/vasum-tools/ipc)
+
+INSTALL(FILES ${HEADERS_INTERNALS}
+ DESTINATION ${INCLUDE_INSTALL_DIR}/vasum-tools/ipc/internals)
+
+INSTALL(FILES ${HEADERS_EPOLL}
+ DESTINATION ${INCLUDE_INSTALL_DIR}/vasum-tools/ipc/epoll)
+
+INSTALL(FILES ${HEADERS_UTILS}
+ DESTINATION ${INCLUDE_INSTALL_DIR}/vasum-tools/ipc/utils)
#include <string.h>
#include <assert.h>
-using namespace vasum;
using namespace utils;
namespace ipc {
#ifndef COMMON_IPC_EXCEPTION_HPP
#define COMMON_IPC_EXCEPTION_HPP
-#include "base-exception.hpp"
+#include <stdexcept>
namespace ipc {
/**
* Base class for exceptions in IPC
*/
-struct IPCException: public vasum::VasumException {
+struct IPCException: public std::runtime_error {
IPCException(const std::string& message)
- : VasumException(message) {}
+ : std::runtime_error(message) {}
};
struct IPCParsingException: public IPCException {
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+
+Name: libIpc
+Description: IPC library
+Version: @_LIB_VERSION_@
+Libs: -L${libdir} -lIpc
+Cflags: -I${includedir}/vasum-tools -I${includedir}/vasum-tools/ipc
+
%{_includedir}/vasum-tools/config
%{_libdir}/pkgconfig/libConfig.pc
+## libIpc Package #######################################################
+%package -n libIpc
+Summary: IPC library
+Group: Security/Other
+Requires: libConfig
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description -n libIpc
+The package provides libIpc library.
+%post -n libIpc -p /sbin/ldconfig
+
+%postun -n libIpc -p /sbin/ldconfig
+
+%files -n libIpc
+%defattr(644,root,root,755)
+%{_libdir}/libIpc.so.0
+%attr(755,root,root) %{_libdir}/libIpc.so.%{version}
+
+%package -n libIpc-devel
+Summary: Development IPC library
+Group: Development/Libraries
+Requires: libIpc = %{epoch}:%{version}-%{release}
+Requires: pkgconfig(libLogger)
+Requires: pkgconfig(libConfig)
+
+%description -n libIpc-devel
+The package provides libIpc development tools and libs.
+
+%files -n libIpc-devel
+%defattr(644,root,root,755)
+%{_libdir}/libIpc.so
+%{_includedir}/vasum-tools/ipc
+%{_libdir}/pkgconfig/libIpc.pc
)
TARGET_LINK_LIBRARIES(${SERVER_CODENAME} ${SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES}
- Logger Config SimpleDbus)
+ Logger Config SimpleDbus Ipc)
## Subdirectories ##############################################################
ADD_SUBDIRECTORY(configs)
//XXX:get(iter).sendNotification(caller, application, message);
}
result->setVoid();
- } catch (const VasumException&) {
+ } catch (const std::runtime_error&) {
LOGE("Notification from " << caller << " hasn't been sent");
result->setError(api::ERROR_INTERNAL, "Notification hasn't been sent");
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << data.id);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE("Can't set attributes: " << ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << data.first);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE("Can't set attributes: " << ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE("Can't set attributes: " << ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << data.id);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE("Can't create veth: " << ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << data.id);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE("Can't create macvlan: " << ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << data.first);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE("Can't create netdev: " << ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << data.first);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE("Can't create netdev: " << ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << data.zone);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE("Can't delete address: " << ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE(ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
} catch (const InvalidZoneIdException&) {
LOGE("No zone with id=" << data.first);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& ex) {
+ } catch (const std::runtime_error& ex) {
LOGE(ex.what());
result->setError(api::ERROR_INTERNAL, ex.what());
}
try {
LOGI("Generating config from " << zoneTemplatePath);
generateNewConfig(id, zoneTemplatePath);
- } catch (VasumException& e) {
+ } catch (std::runtime_error& e) {
LOGE("Generate config failed: " << e.what());
utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr));
throw e;
LOGT("Creating new zone");
try {
insertZone(id, zoneTemplatePath);
- } catch (VasumException& e) {
+ } catch (std::runtime_error& e) {
LOGE("Creating new zone failed: " << e.what());
utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr));
throw e;
result->setVoid();
} catch (const InvalidZoneIdException& e) {
result->setError(api::ERROR_INVALID_ID, "Existing or invalid zone id");
- } catch (const VasumException& e) {
+ } catch (const std::runtime_error& e) {
result->setError(api::ERROR_INTERNAL, "Failed to create zone");
}
}
} catch (const InvalidZoneIdException&) {
LOGE("Failed to destroy zone - no such zone id: " << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
- } catch (const VasumException& e) {
+ } catch (const std::runtime_error& e) {
LOGE("Error during zone destruction: " << e.what());
result->setError(api::ERROR_INTERNAL, "Failed to destroy zone");
return;
)
TARGET_LINK_LIBRARIES(${UT_SERVER_CODENAME} ${UT_SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES}
- Logger Config SimpleDbus)
+ Logger Config SimpleDbus Ipc)
TARGET_LINK_LIBRARIES(${SOCKET_TEST_CODENAME} ${UT_SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES}
- Logger Config SimpleDbus)
+ Logger Config SimpleDbus Ipc)
## Subdirectories ##############################################################
SET(VSM_TEST_CONFIG_INSTALL_DIR ${VSM_CONFIG_INSTALL_DIR}/tests)
#include "ipc/epoll/glib-dispatcher.hpp"
#include "ipc/epoll/thread-dispatcher.hpp"
-using namespace vasum;
using namespace utils;
using namespace ipc;
using namespace ipc::epoll;
#include <utility>
#include <future>
-using namespace vasum;
using namespace ipc;
using namespace epoll;
using namespace utils;