summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-03-28 14:43:16 +0200
committerSander Vrijders <[email protected]>2016-03-28 14:43:16 +0200
commita14d696bdbc72754e8019fa9579d5a338cc85a05 (patch)
tree2533a574e03a9954b9eeaf7750219d3175ce8b99 /src/lib
parentd37add0f20c93432c0b4c12866810c124a7a18ec (diff)
downloadouroboros-a14d696bdbc72754e8019fa9579d5a338cc85a05.tar.gz
ouroboros-a14d696bdbc72754e8019fa9579d5a338cc85a05.zip
lib: Update irm.h API
Removes rina_name_t from that API. Passing ap_name and api_id as params instead. The IRM tool has been updated accordingly. Some errors in the build related to protobuf-c have also been resolved.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/.gitignore1
-rw-r--r--src/lib/CMakeLists.txt11
-rw-r--r--src/lib/irm.c141
-rw-r--r--src/lib/sockets.c7
4 files changed, 98 insertions, 62 deletions
diff --git a/src/lib/.gitignore b/src/lib/.gitignore
new file mode 100644
index 00000000..8704469b
--- /dev/null
+++ b/src/lib/.gitignore
@@ -0,0 +1 @@
+*.pb-c.[ch] \ No newline at end of file
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index e05dce8b..0427e236 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -34,10 +34,13 @@ set(SOURCE_FILES
shm_du_map.c
sockets.c
utils.c
-)
+ )
-add_library(ouroboros SHARED ${SOURCE_FILES} ${PROTO_SRCS} ${PROTO_HDRS})
-target_link_libraries(ouroboros rt pthread ${PROTOBUF_LIBRARIES})
+install(FILES ${PROTO_HDRS}
+ DESTINATION include/ouroboros)
+
+add_library(ouroboros SHARED ${SOURCE_FILES} ${PROTO_SRCS})
+target_link_libraries(ouroboros rt pthread ${PROTOBUF_C_LIBRARY})
include(MacroAddCompileFlags)
if (CMAKE_BUILD_TYPE MATCHES Debug)
@@ -46,4 +49,6 @@ endif (CMAKE_BUILD_TYPE MATCHES Debug)
install(TARGETS ouroboros LIBRARY DESTINATION lib)
+target_include_directories(ouroboros PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
+
add_subdirectory(tests)
diff --git a/src/lib/irm.c b/src/lib/irm.c
index 9fd13d52..92d8b3a5 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -26,26 +26,25 @@
#include <ouroboros/common.h>
#include <ouroboros/logs.h>
#include <ouroboros/sockets.h>
+
#include <stdlib.h>
-int irm_create_ipcp(rina_name_t name,
+int irm_create_ipcp(char * ap_name,
+ int api_id,
char * ipcp_type)
{
- struct irm_msg msg;
+ irm_msg_t msg = IRM_MSG__INIT;
- if (ipcp_type == NULL)
- return -1;
+ if (ipcp_type == NULL || ap_name == NULL)
+ return -EINVAL;
- if (!name_is_ok(&name)) {
- LOG_ERR("Bad name");
- return -1;
- }
-
- msg.code = IRM_CREATE_IPCP;
- msg.name = &name;
+ msg.code = IRM_MSG_CODE__IRM_CREATE_IPCP;
+ msg.ap_name = ap_name;
+ msg.has_api_id = true;
+ msg.api_id = api_id;
msg.ipcp_type = ipcp_type;
- if (send_irmd_msg(&msg)) {
+ if (send_irm_msg(&msg)) {
LOG_ERR("Failed to send message to daemon");
return -1;
}
@@ -53,19 +52,21 @@ int irm_create_ipcp(rina_name_t name,
return 0;
}
-int irm_destroy_ipcp(rina_name_t name)
+int irm_destroy_ipcp(char * ap_name,
+ int api_id)
{
- struct irm_msg msg;
+ irm_msg_t msg = IRM_MSG__INIT;
- if (!name_is_ok(&name)) {
- LOG_ERR("Bad name");
- return -1;
+ if (ap_name == NULL) {
+ return -EINVAL;
}
- msg.code = IRM_DESTROY_IPCP;
- msg.name = &name;
+ msg.code = IRM_MSG_CODE__IRM_DESTROY_IPCP;
+ msg.ap_name = ap_name;
+ msg.has_api_id = true;
+ msg.api_id = api_id;
- if (send_irmd_msg(&msg)) {
+ if (send_irm_msg(&msg)) {
LOG_ERR("Failed to send message to daemon");
return -1;
}
@@ -73,21 +74,22 @@ int irm_destroy_ipcp(rina_name_t name)
return 0;
}
-int irm_bootstrap_ipcp(rina_name_t name,
- struct dif_config conf)
+int irm_bootstrap_ipcp(char * ap_name,
+ int api_id,
+ struct dif_config * conf)
{
- struct irm_msg msg;
+ irm_msg_t msg = IRM_MSG__INIT;
- if (!name_is_ok(&name)) {
- LOG_ERR("Bad name");
- return -1;
+ if (ap_name == NULL || conf == NULL) {
+ return -EINVAL;
}
- msg.code = IRM_BOOTSTRAP_IPCP;
- msg.name = &name;
- msg.conf = &conf;
+ msg.code = IRM_MSG_CODE__IRM_BOOTSTRAP_IPCP;
+ msg.ap_name = ap_name;
+ msg.has_api_id = true;
+ msg.api_id = api_id;
- if (send_irmd_msg(&msg)) {
+ if (send_irm_msg(&msg)) {
LOG_ERR("Failed to send message to daemon");
return -1;
}
@@ -95,45 +97,61 @@ int irm_bootstrap_ipcp(rina_name_t name,
return 0;
}
-int irm_enroll_ipcp(rina_name_t name,
+int irm_enroll_ipcp(char * ap_name,
+ int api_id,
char * dif_name)
{
- struct irm_msg msg;
+ irm_msg_t msg = IRM_MSG__INIT;
- if (!name_is_ok(&name)) {
- LOG_ERR("Bad name");
- return -1;
+ if (ap_name == NULL || dif_name == NULL) {
+ return -EINVAL;
}
- msg.code = IRM_ENROLL_IPCP;
- msg.name = &name;
- msg.dif_name = dif_name;
+ msg.code = IRM_MSG_CODE__IRM_ENROLL_IPCP;
+ msg.ap_name = ap_name;
+ msg.has_api_id = true;
+ msg.api_id = api_id;
+ msg.n_dif_name = 1;
+ msg.dif_name = malloc(sizeof(*(msg.dif_name)));
+ if (msg.dif_name == NULL) {
+ LOG_ERR("Failed to malloc");
+ return -1;
+ }
+ msg.dif_name[0] = dif_name;
- if (send_irmd_msg(&msg)) {
+ if (send_irm_msg(&msg)) {
LOG_ERR("Failed to send message to daemon");
+ free(msg.dif_name);
return -1;
}
+ free(msg.dif_name);
+
return 0;
}
-int irm_reg_ipcp(rina_name_t name,
+int irm_reg_ipcp(char * ap_name,
+ int api_id,
char ** difs,
size_t difs_size)
{
- struct irm_msg msg;
+ irm_msg_t msg = IRM_MSG__INIT;
- if (!name_is_ok(&name)) {
- LOG_ERR("Bad name");
- return -1;
+ if (ap_name == NULL ||
+ difs == NULL ||
+ difs_size == 0 ||
+ difs[0] == NULL) {
+ return -EINVAL;
}
- msg.code = IRM_REG_IPCP;
- msg.name = &name;
- msg.difs = difs;
- msg.difs_size = difs_size;
+ msg.code = IRM_MSG_CODE__IRM_REG_IPCP;
+ msg.ap_name = ap_name;
+ msg.has_api_id = true;
+ msg.api_id = api_id;
+ msg.dif_name = difs;
+ msg.n_dif_name = difs_size;
- if (send_irmd_msg(&msg)) {
+ if (send_irm_msg(&msg)) {
LOG_ERR("Failed to send message to daemon");
return -1;
}
@@ -141,23 +159,28 @@ int irm_reg_ipcp(rina_name_t name,
return 0;
}
-int irm_unreg_ipcp(rina_name_t name,
+int irm_unreg_ipcp(char * ap_name,
+ int api_id,
char ** difs,
size_t difs_size)
{
- struct irm_msg msg;
+ irm_msg_t msg = IRM_MSG__INIT;
- if (!name_is_ok(&name)) {
- LOG_ERR("Bad name");
- return -1;
+ if (ap_name == NULL ||
+ difs == NULL ||
+ difs_size == 0 ||
+ difs[0] == NULL) {
+ return -EINVAL;
}
- msg.code = IRM_UNREG_IPCP;
- msg.name = &name;
- msg.difs = difs;
- msg.difs_size = difs_size;
+ msg.code = IRM_MSG_CODE__IRM_UNREG_IPCP;
+ msg.ap_name = ap_name;
+ msg.has_api_id = true;
+ msg.api_id = api_id;
+ msg.dif_name = difs;
+ msg.n_dif_name = difs_size;
- if (send_irmd_msg(&msg)) {
+ if (send_irm_msg(&msg)) {
LOG_ERR("Failed to send message to daemon");
return -1;
}
diff --git a/src/lib/sockets.c b/src/lib/sockets.c
index b157b628..b98f6bbc 100644
--- a/src/lib/sockets.c
+++ b/src/lib/sockets.c
@@ -166,6 +166,13 @@ struct irm_msg * send_recv_irmd_msg(struct irm_msg * msg)
return recv_msg;
}
+
+int send_irm_msg(irm_msg_t * msg)
+{
+
+ return -1;
+}
+
char * ipcp_sock_path(pid_t pid)
{
char * full_name = NULL;