From bd7a8ea8a1adbd6763aea857e72623929b7ad7a4 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 15 Mar 2016 15:43:17 +0100 Subject: irmd, lib: Create and destroy IPC Processes This adds the functionality to create and destroy IPCPs. Upon creation a new process is forked and execve'd. Upon destruction the IPCP is destroyed by killing it with SIGTERM. --- include/ouroboros/CMakeLists.txt | 7 ++++++- include/ouroboros/config.h.in | 31 +++++++++++++++++++++++++++++++ include/ouroboros/ipcp.h | 16 +++++++++------- include/ouroboros/utils.h | 27 +++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 include/ouroboros/config.h.in create mode 100644 include/ouroboros/utils.h (limited to 'include') diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt index e862de8c..167cf0e2 100644 --- a/include/ouroboros/CMakeLists.txt +++ b/include/ouroboros/CMakeLists.txt @@ -1,3 +1,7 @@ +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/config.h") + set(HEADER_FILES bitmap.h cdap.h @@ -11,7 +15,8 @@ set(HEADER_FILES logs.h rina_name.h sockets.h + utils.h ) -install(FILES ${HEADER_FILES} +install(FILES ${HEADER_FILES} "${CMAKE_CURRENT_BINARY_DIR}/config.h" DESTINATION include/ouroboros) diff --git a/include/ouroboros/config.h.in b/include/ouroboros/config.h.in new file mode 100644 index 00000000..0f5c2131 --- /dev/null +++ b/include/ouroboros/config.h.in @@ -0,0 +1,31 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * Configuration information + * + * Sander Vrijders + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef OUROBOROS_CONFIG +#define OUROBOROS_CONFIG + +#define PROJECT_NAME "@CMAKE_PROJECT_NAME@" +#define PROJECT_VERSION "@PACKAGE_VERSION@" +#define INSTALL_DIR "@CMAKE_INSTALL_PREFIX@" +#define BUILD_TYPE "@CMAKE_BUILD_TYPE@" + +#endif diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h index 39e9c909..5e3e7f8c 100644 --- a/include/ouroboros/ipcp.h +++ b/include/ouroboros/ipcp.h @@ -23,26 +23,28 @@ #ifndef OUROBOROS_IPCP_H #define OUROBOROS_IPCP_H +#include + #include "common.h" #include "rina_name.h" struct ipcp; /* Returns the process id */ -int ipcp_create(rina_name_t name, - char * ipcp_type); -int ipcp_destroy(int pid); +pid_t ipcp_create(rina_name_t name, + char * ipcp_type); +int ipcp_destroy(pid_t pid); -int ipcp_reg(int pid, +int ipcp_reg(pid_t pid, char ** difs, size_t difs_size); -int ipcp_unreg(int pid, +int ipcp_unreg(pid_t pid, char ** difs, size_t difs_size); -int ipcp_bootstrap(int pid, +int ipcp_bootstrap(pid_t pid, struct dif_config conf); -int ipcp_enroll(int pid, +int ipcp_enroll(pid_t pid, char * dif_name, rina_name_t member, char ** n_1_difs, diff --git a/include/ouroboros/utils.h b/include/ouroboros/utils.h new file mode 100644 index 00000000..0e50c039 --- /dev/null +++ b/include/ouroboros/utils.h @@ -0,0 +1,27 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * Handy utilities + * + * Sander Vrijders + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Returns the number of characters a uint would + * need when represented as a string + */ +int n_digits(unsigned i); -- cgit v1.2.3