diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/irmd/main.c | 79 | ||||
-rw-r--r-- | src/lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/lib/da.c | 33 | ||||
-rw-r--r-- | src/lib/ipcp.c | 63 | ||||
-rw-r--r-- | src/lib/irm.c | 2 |
5 files changed, 151 insertions, 28 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index 262b737c..f744ee7f 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -26,53 +26,79 @@ #include <ouroboros/common.h> #include <ouroboros/sockets.h> #include <ouroboros/irm.h> +#include <ouroboros/ipcp.h> +#include <ouroboros/da.h> + #include <sys/socket.h> #include <sys/un.h> #include <stdlib.h> #include <errno.h> -static void create_ipcp(rina_name_t * name, +struct irm { + +}; + +static void create_ipcp(rina_name_t name, char * ipcp_type) { - LOG_DBG("AP name is %s", name->ap_name); - LOG_DBG("AP instance id is %d", name->api_id); - LOG_DBG("AE name is %s", name->ae_name); - LOG_DBG("AE instance id is %d", name->aei_id); + struct ipcp * instance = NULL; - LOG_DBG("IPCP type is %s", ipcp_type); - - LOG_MISSING; + instance = ipcp_create(name, ipcp_type); + if (instance == NULL) + LOG_ERR("Failed to create IPCP"); } -static void destroy_ipcp(rina_name_t * name) +static void destroy_ipcp(rina_name_t name) { - LOG_MISSING; + struct ipcp * instance = NULL; + + if (ipcp_destroy(instance)) + LOG_ERR("Could not destroy IPCP"); } -static void bootstrap_ipcp(rina_name_t * name, - struct dif_config * conf) +static void bootstrap_ipcp(rina_name_t name, + struct dif_config conf) { - LOG_MISSING; + struct ipcp * instance = NULL; + + if (ipcp_bootstrap(instance, conf)) + LOG_ERR("Could not bootstrap IPCP"); } -static void enroll_ipcp(rina_name_t * name, +static void enroll_ipcp(rina_name_t name, char * dif_name) { - LOG_MISSING; + struct ipcp * instance = NULL; + rina_name_t * member; + + member = da_resolve_daf(dif_name); + if (member == NULL) { + LOG_ERR("Could not find a member of that DIF"); + return; + } + + if (ipcp_enroll(instance, dif_name, *member)) + LOG_ERR("Could not enroll IPCP"); } -static void reg_ipcp(rina_name_t * name, +static void reg_ipcp(rina_name_t name, char ** difs, size_t difs_size) { - LOG_MISSING; + struct ipcp * instance = NULL; + + if (ipcp_reg(instance, difs, difs_size)) + LOG_ERR("Could not register IPCP to N-1 DIF(s)"); } -static void unreg_ipcp(rina_name_t * name, +static void unreg_ipcp(rina_name_t name, char ** difs, size_t difs_size) { - LOG_MISSING; + struct ipcp * instance = NULL; + + if (ipcp_unreg(instance, difs, difs_size)) + LOG_ERR("Could not unregister IPCP from N-1 DIF(s)"); } int main() @@ -104,29 +130,28 @@ int main() if (msg == NULL) continue; - LOG_DBG("Got message code %d", msg->code); switch (msg->code) { case IRM_CREATE_IPCP: - create_ipcp(msg->name, msg->ipcp_type); + create_ipcp(*(msg->name), msg->ipcp_type); break; case IRM_DESTROY_IPCP: - destroy_ipcp(msg->name); + destroy_ipcp(*(msg->name)); break; case IRM_BOOTSTRAP_IPCP: - bootstrap_ipcp(msg->name, - msg->conf); + bootstrap_ipcp(*(msg->name), + *(msg->conf)); break; case IRM_ENROLL_IPCP: - enroll_ipcp(msg->name, + enroll_ipcp(*(msg->name), msg->dif_name); break; case IRM_REG_IPCP: - reg_ipcp(msg->name, + reg_ipcp(*(msg->name), msg->difs, msg->difs_size); break; case IRM_UNREG_IPCP: - unreg_ipcp(msg->name, + unreg_ipcp(*(msg->name), msg->difs, msg->difs_size); break; diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 5dad9153..349f8d73 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -8,7 +8,9 @@ set(SOURCE_FILES # Add source files here bitmap.c cdap.c + da.c du_buff.c + ipcp.c irm.c sockets.c ) diff --git a/src/lib/da.c b/src/lib/da.c new file mode 100644 index 00000000..e9888d9e --- /dev/null +++ b/src/lib/da.c @@ -0,0 +1,33 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * The API to instruct the DIF Allocator + * + * Sander Vrijders <[email protected]> + * + * 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. + */ + +#include <ouroboros/da.h> + +rina_name_t * da_resolve_daf(char * daf_name) +{ + return NULL; +} + +char ** da_resolve_dap(rina_name_t * name) +{ + return NULL; +} diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c new file mode 100644 index 00000000..718b5f3e --- /dev/null +++ b/src/lib/ipcp.c @@ -0,0 +1,63 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * The API to instruct IPCPs + * + * Sander Vrijders <[email protected]> + * + * 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. + */ + +#include <ouroboros/ipcp.h> + +struct ipcp {}; + +struct ipcp * ipcp_create(rina_name_t name, + char * ipcp_type) +{ + return NULL; +} + +int ipcp_destroy(struct ipcp * instance) +{ + return -1; +} + +int ipcp_reg(struct ipcp * instance, + char ** difs, + size_t difs_size) +{ + return -1; +} + +int ipcp_unreg(struct ipcp * instance, + char ** difs, + size_t difs_size) +{ + return -1; +} + +int ipcp_bootstrap(struct ipcp * instance, + struct dif_config conf) +{ + return -1; +} + +int ipcp_enroll(struct ipcp * instance, + char * dif_name, + rina_name_t member) +{ + return -1; +} diff --git a/src/lib/irm.c b/src/lib/irm.c index 519b4eb8..493cb71d 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -40,7 +40,7 @@ static int send_irm_msg(struct irm_msg * msg) buf = serialize_irm_msg(msg); if (buf == NULL) { close(sockfd); - return -1; + return -1; } if (write(sockfd, buf->data, buf->size) == -1) { |