/* * Ouroboros - Copyright (C) 2016 * * The API to instruct the IRM * * 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. */ #define OUROBOROS_PREFIX "libouroboros-irm" #include #include #include #include #include int irm_create_ipcp(rina_name_t name, char * ipcp_type) { struct irm_msg msg; if (ipcp_type == NULL) return -1; if (!name_is_ok(&name)) { LOG_ERR("Bad name"); return -1; } msg.code = IRM_CREATE_IPCP; msg.name = &name; msg.ipcp_type = ipcp_type; if (send_irmd_msg(&msg)) { LOG_ERR("Failed to send message to daemon"); return -1; } return 0; } int irm_destroy_ipcp(rina_name_t name) { struct irm_msg msg; if (!name_is_ok(&name)) { LOG_ERR("Bad name"); return -1; } msg.code = IRM_DESTROY_IPCP; msg.name = &name; if (send_irmd_msg(&msg)) { LOG_ERR("Failed to send message to daemon"); return -1; } return 0; } int irm_bootstrap_ipcp(rina_name_t name, struct dif_config conf) { struct irm_msg msg; if (!name_is_ok(&name)) { LOG_ERR("Bad name"); return -1; } msg.code = IRM_BOOTSTRAP_IPCP; msg.name = &name; msg.conf = &conf; if (send_irmd_msg(&msg)) { LOG_ERR("Failed to send message to daemon"); return -1; } return 0; } int irm_enroll_ipcp(rina_name_t name, char * dif_name) { struct irm_msg msg; if (!name_is_ok(&name)) { LOG_ERR("Bad name"); return -1; } msg.code = IRM_ENROLL_IPCP; msg.name = &name; msg.dif_name = dif_name; if (send_irmd_msg(&msg)) { LOG_ERR("Failed to send message to daemon"); return -1; } return 0; } int irm_reg_ipcp(rina_name_t name, char ** difs, size_t difs_size) { struct irm_msg msg; if (!name_is_ok(&name)) { LOG_ERR("Bad name"); return -1; } msg.code = IRM_REG_IPCP; msg.name = &name; msg.difs = difs; msg.difs_size = difs_size; if (send_irmd_msg(&msg)) { LOG_ERR("Failed to send message to daemon"); return -1; } return 0; } int irm_unreg_ipcp(rina_name_t name, char ** difs, size_t difs_size) { struct irm_msg msg; if (!name_is_ok(&name)) { LOG_ERR("Bad name"); return -1; } msg.code = IRM_UNREG_IPCP; msg.name = &name; msg.difs = difs; msg.difs_size = difs_size; if (send_irmd_msg(&msg)) { LOG_ERR("Failed to send message to daemon"); return -1; } return 0; }