summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/irmd/main.c96
-rw-r--r--src/lib/CMakeLists.txt2
-rw-r--r--src/lib/instance_name.c (renamed from src/lib/rina_name.c)155
-rw-r--r--src/lib/ipcp.c10
-rw-r--r--src/lib/irm.c71
-rw-r--r--src/tools/echo/echo_client.c1
-rw-r--r--src/tools/echo/echo_server.c1
-rw-r--r--src/tools/irm/irm.c2
-rw-r--r--src/tools/irm/irm_bootstrap_ipcp.c11
-rw-r--r--src/tools/irm/irm_create_ipcp.c12
-rw-r--r--src/tools/irm/irm_destroy_ipcp.c11
-rw-r--r--src/tools/irm/irm_enroll_ipcp.c11
-rw-r--r--src/tools/irm/irm_register_ipcp.c11
-rw-r--r--src/tools/irm/irm_unregister_ipcp.c11
-rw-r--r--src/tools/irm/irm_utils.h4
15 files changed, 192 insertions, 217 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index e4b6cebd..547286e8 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -29,7 +29,7 @@
#include <ouroboros/ipcp.h>
#include <ouroboros/da.h>
#include <ouroboros/list.h>
-#include <ouroboros/rina_name.h>
+#include <ouroboros/instance_name.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -37,17 +37,17 @@
#include <errno.h>
struct name_to_pid_entry {
- struct list_head next;
- pid_t pid;
- rina_name_t * name;
+ struct list_head next;
+ pid_t pid;
+ instance_name_t * api;
};
struct irm {
struct list_head name_to_pid;
};
-static pid_t find_pid_by_name(struct irm * instance,
- rina_name_t * name)
+static pid_t find_pid_by_name(struct irm * instance,
+ instance_name_t * api)
{
struct list_head * pos;
@@ -55,23 +55,23 @@ static pid_t find_pid_by_name(struct irm * instance,
struct name_to_pid_entry * tmp =
list_entry(pos, struct name_to_pid_entry, next);
- LOG_DBG("name is %s", name->ap_name);
+ LOG_DBG("name is %s", api->name);
- if (name_is_equal(name, tmp->name))
+ if (instance_name_cmp(api, tmp->api) == 0)
return tmp->pid;
}
return 0;
}
-static void create_ipcp(struct irm * instance,
- rina_name_t name,
- char * ipcp_type)
+static void create_ipcp(struct irm * instance,
+ instance_name_t * api,
+ char * ipcp_type)
{
pid_t pid;
struct name_to_pid_entry * tmp;
- pid = ipcp_create(name, ipcp_type);
+ pid = ipcp_create(api, ipcp_type);
if (pid == -1) {
LOG_ERR("Failed to create IPCP");
return;
@@ -84,8 +84,8 @@ static void create_ipcp(struct irm * instance,
INIT_LIST_HEAD(&tmp->next);
tmp->pid = pid;
- tmp->name = name_dup(&name);
- if (tmp->name == NULL) {
+ tmp->api = instance_name_dup(api);
+ if (tmp->api == NULL) {
free(tmp);
return;
}
@@ -95,14 +95,14 @@ static void create_ipcp(struct irm * instance,
list_add(&tmp->next, &instance->name_to_pid);
}
-static void destroy_ipcp(struct irm * instance,
- rina_name_t name)
+static void destroy_ipcp(struct irm * instance,
+ instance_name_t * api)
{
pid_t pid = 0;
struct list_head * pos;
struct list_head * n;
- pid = find_pid_by_name(instance, &name);
+ pid = find_pid_by_name(instance, api);
if (pid == 0) {
LOG_ERR("No such IPCP");
return;
@@ -117,18 +117,18 @@ static void destroy_ipcp(struct irm * instance,
struct name_to_pid_entry * tmp =
list_entry(pos, struct name_to_pid_entry, next);
- if (name_is_equal(&name, tmp->name))
+ if (instance_name_cmp(api, tmp->api) == 0)
list_del(&tmp->next);
}
}
-static void bootstrap_ipcp(struct irm * instance,
- rina_name_t name,
+static void bootstrap_ipcp(struct irm * instance,
+ instance_name_t * api,
struct dif_config * conf)
{
pid_t pid = 0;
- pid = find_pid_by_name(instance, &name);
+ pid = find_pid_by_name(instance, api);
if (pid == 0) {
LOG_ERR("No such IPCP");
return;
@@ -138,16 +138,16 @@ static void bootstrap_ipcp(struct irm * instance,
LOG_ERR("Could not bootstrap IPCP");
}
-static void enroll_ipcp(struct irm * instance,
- rina_name_t name,
- char * dif_name)
+static void enroll_ipcp(struct irm * instance,
+ instance_name_t * api,
+ char * dif_name)
{
- pid_t pid = 0;
- char * member;
+ pid_t pid = 0;
+ char * member;
char ** n_1_difs = NULL;
ssize_t n_1_difs_size = 0;
- pid = find_pid_by_name(instance, &name);
+ pid = find_pid_by_name(instance, api);
if (pid == 0) {
LOG_ERR("No such IPCP");
return;
@@ -166,14 +166,14 @@ static void enroll_ipcp(struct irm * instance,
LOG_ERR("Could not enroll IPCP");
}
-static void reg_ipcp(struct irm * instance,
- rina_name_t name,
- char ** difs,
- size_t difs_size)
+static void reg_ipcp(struct irm * instance,
+ instance_name_t * api,
+ char ** difs,
+ size_t difs_size)
{
pid_t pid = 0;
- pid = find_pid_by_name(instance, &name);
+ pid = find_pid_by_name(instance, api);
if (pid == 0) {
LOG_ERR("No such IPCP");
return;
@@ -183,14 +183,14 @@ static void reg_ipcp(struct irm * instance,
LOG_ERR("Could not register IPCP to N-1 DIF(s)");
}
-static void unreg_ipcp(struct irm * instance,
- rina_name_t name,
- char ** difs,
- size_t difs_size)
+static void unreg_ipcp(struct irm * instance,
+ instance_name_t * api,
+ char ** difs,
+ size_t difs_size)
{
pid_t pid = 0;
- pid = find_pid_by_name(instance, &name);
+ pid = find_pid_by_name(instance, api);
if (pid == 0) {
LOG_ERR("No such IPCP");
return;
@@ -204,8 +204,8 @@ static void unreg_ipcp(struct irm * instance,
int main()
{
struct irm * instance = NULL;
- int sockfd;
- uint8_t buf[IRM_MSG_BUF_SIZE];
+ int sockfd;
+ uint8_t buf[IRM_MSG_BUF_SIZE];
instance = malloc(sizeof(*instance));
if (instance == NULL)
@@ -221,7 +221,7 @@ int main()
int cli_sockfd;
irm_msg_t * msg;
ssize_t count;
- rina_name_t name;
+ instance_name_t api;
cli_sockfd = accept(sockfd, 0, 0);
if (cli_sockfd < 0) {
@@ -235,31 +235,31 @@ int main()
if (msg == NULL)
continue;
- name.ap_name = msg->ap_name;
- name.api_id = msg->api_id;
+ api.name = msg->ap_name;
+ api.id = msg->api_id;
switch (msg->code) {
case IRM_MSG_CODE__IRM_CREATE_IPCP:
- create_ipcp(instance, name, msg->ipcp_type);
+ create_ipcp(instance, &api, msg->ipcp_type);
break;
case IRM_MSG_CODE__IRM_DESTROY_IPCP:
- destroy_ipcp(instance, name);
+ destroy_ipcp(instance, &api);
break;
case IRM_MSG_CODE__IRM_BOOTSTRAP_IPCP:
- bootstrap_ipcp(instance, name, NULL);
+ bootstrap_ipcp(instance, &api, NULL);
break;
case IRM_MSG_CODE__IRM_ENROLL_IPCP:
if (msg->n_dif_name != 1)
continue;
- enroll_ipcp(instance, name, msg->dif_name[0]);
+ enroll_ipcp(instance, &api, msg->dif_name[0]);
break;
case IRM_MSG_CODE__IRM_REG_IPCP:
- reg_ipcp(instance, name,
+ reg_ipcp(instance, &api,
msg->dif_name,
msg->n_dif_name);
break;
case IRM_MSG_CODE__IRM_UNREG_IPCP:
- unreg_ipcp(instance, name,
+ unreg_ipcp(instance, &api,
msg->dif_name,
msg->n_dif_name);
break;
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 37222e58..1f7b0f55 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -27,10 +27,10 @@ set(SOURCE_FILES
dev.c
du_buff.c
flow.c
+ instance_name.c
ipcp.c
irm.c
list.c
- rina_name.c
shm_du_map.c
sockets.c
utils.c
diff --git a/src/lib/rina_name.c b/src/lib/instance_name.c
index 2dcfbb08..0f666211 100644
--- a/src/lib/rina_name.c
+++ b/src/lib/instance_name.c
@@ -19,11 +19,11 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#define OUROBOROS_PREFIX "name-utils"
+#define OUROBOROS_PREFIX "instance-name"
#include <ouroboros/logs.h>
#include <ouroboros/common.h>
-#include <ouroboros/rina_name.h>
+#include <ouroboros/instance_name.h>
#include <ouroboros/utils.h>
#include <string.h>
@@ -31,6 +31,8 @@
#include <malloc.h>
#include <stdlib.h>
+#define instance_name_is_equal(a, b) (instance_name_cmp(a, b) == 0)
+
static char * strdup(const char * src)
{
int len = 0;
@@ -50,153 +52,144 @@ static char * strdup(const char * src)
return dst;
}
-rina_name_t * name_create()
+instance_name_t * instance_name_create()
{
- rina_name_t * tmp;
+ instance_name_t * tmp;
- tmp = malloc(sizeof(rina_name_t));
+ tmp = malloc(sizeof *tmp);
- tmp->ap_name = NULL;
- tmp->api_id = 0;
+ tmp->name = NULL;
+ tmp->id = 0;
return tmp;
}
-rina_name_t * name_init_from(rina_name_t * dst,
- const char * ap_name,
- unsigned int api_id)
+instance_name_t * instance_name_init_from(instance_name_t * dst,
+ const char * name,
+ uint16_t id)
{
if (dst == NULL)
return NULL;
/* Clean up the destination, leftovers might be there ... */
- name_fini(dst);
+ instance_name_fini(dst);
- dst->ap_name = strdup(ap_name);
- dst->api_id = api_id;
+ dst->name = strdup(name);
+ dst->id = id;
- if (dst->ap_name == NULL) {
- name_fini(dst);
+ if (dst->name == NULL) {
+ instance_name_fini(dst);
return NULL;
}
return dst;
}
-rina_name_t * name_init_with(rina_name_t * dst,
- char * ap_name,
- unsigned int api_id)
+instance_name_t * instance_name_init_with(instance_name_t * dst,
+ char * name,
+ uint16_t id)
{
if (dst == NULL)
return NULL;
/* Clean up the destination, leftovers might be there ... */
- name_fini(dst);
+ instance_name_fini(dst);
- dst->ap_name = ap_name;
- dst->api_id = api_id;
+ dst->name = name;
+ dst->id = id;
return dst;
}
-void name_fini(rina_name_t * n)
+void instance_name_fini(instance_name_t * n)
{
- if (n == NULL)
+ if (n == NULL || n->name == NULL)
return;
- if (n->ap_name != NULL) {
- free(n->ap_name);
- n->ap_name = NULL;
- }
+ free(n->name);
+ n->name = NULL;
}
-void name_destroy(rina_name_t * ptr)
+void instance_name_destroy(instance_name_t * ptr)
{
if (ptr == NULL)
return;
- name_fini(ptr);
+ instance_name_fini(ptr);
free(ptr);
}
-int name_cpy(const rina_name_t * src,
- rina_name_t * dst)
+int instance_name_cpy(instance_name_t * dst,
+ const instance_name_t * src)
{
- rina_name_t * res;
+ instance_name_t * res;
if (src == NULL || dst == NULL)
return -1;
- res = name_init_from(dst,
- src->ap_name,
- src->api_id);
+ res = instance_name_init_from(dst, src->name, src->id);
if (res == NULL)
return -1;
return 0;
}
-rina_name_t * name_dup(const rina_name_t * src)
+instance_name_t * instance_name_dup(const instance_name_t * src)
{
- rina_name_t * tmp;
+ instance_name_t * tmp;
if (src == NULL)
return NULL;
- tmp = name_create();
+ tmp = instance_name_create();
if (tmp == NULL)
return NULL;
- if (name_cpy(src, tmp)) {
- name_destroy(tmp);
+ if (instance_name_cpy(tmp, src)) {
+ instance_name_destroy(tmp);
return NULL;
}
return tmp;
}
-#define NAME_CMP_FIELD(X, Y, FIELD) \
- ((X->FIELD != NULL && Y->FIELD != NULL) ? \
- strcmp(X->FIELD, Y->FIELD) : \
- ((X->FIELD == NULL && Y->FIELD == NULL) ? 0 : -1))
-
-bool name_is_ok(const rina_name_t * n)
-{ return (n != NULL &&
- n->ap_name != NULL &&
- strlen(n->ap_name)); }
+bool instance_name_is_valid(const instance_name_t * n)
+{
+ return (n != NULL && n->name != NULL && strlen(n->name));
+}
-bool name_cmp(uint8_t flags,
- const rina_name_t * a,
- const rina_name_t * b)
+int instance_name_cmp(const instance_name_t * a,
+ const instance_name_t * b)
{
- if (a == b)
- return true;
- if (a == NULL || b == NULL)
- return false;
+ int ret = 0;
+
+ if (a == NULL || b == NULL) {
+ LOG_DBGF("Won't compare NULL.");
+ return -2;
+ }
- if (!(flags & NAME_CMP_ALL))
- LOG_DBG("No flags, name comparison will be meaningless ...");
+ if (a == b)
+ return 0;
- if (flags & NAME_CMP_APN)
- if (NAME_CMP_FIELD(a, b, ap_name))
- return false;
+ ret = strcmp(a->name, b->name);
- if (flags & NAME_CMP_API)
- if (a->api_id != b->api_id)
- return false;
+ if (!ret) {
+ if (a->id == b-> id)
+ return 0;
+ else
+ return a->id < b->id ? -1 : 1;
+ }
- return true;
+ return ret;
}
-bool name_is_equal(const rina_name_t * a,
- const rina_name_t * b)
-{ return name_cmp(NAME_CMP_ALL, a, b); }
+
#define DELIMITER "/"
-char * name_to_string(const rina_name_t * n)
+char * instance_name_to_string(const instance_name_t * n)
{
char * tmp;
size_t size;
@@ -206,14 +199,14 @@ char * name_to_string(const rina_name_t * n)
if (n == NULL)
return NULL;
- size = 0;
+ size = 0;
- size += (n->ap_name != NULL ?
- strlen(n->ap_name) : none_len);
+ size += (n->name != NULL ?
+ strlen(n->name) : none_len);
size += strlen(DELIMITER);
- size += (n->api_id == 0 ?
- 1 : n_digits(n->api_id));
+ size += (n->id == 0 ?
+ 1 : n_digits(n->id));
size += strlen(DELIMITER);
tmp = malloc(size);
@@ -221,8 +214,8 @@ char * name_to_string(const rina_name_t * n)
return NULL;
if (sprintf(tmp, "%s%s%d",
- (n->ap_name != NULL ? n->ap_name : none),
- DELIMITER, n->api_id)
+ (n->name != NULL ? n->name : none),
+ DELIMITER, n->id)
!= size - 1) {
free(tmp);
return NULL;
@@ -231,9 +224,9 @@ char * name_to_string(const rina_name_t * n)
return tmp;
}
-rina_name_t * string_to_name(const char * s)
+instance_name_t * string_to_instance_name(const char * s)
{
- rina_name_t * name;
+ instance_name_t * name;
char * tmp1 = NULL;
char * tmp_ap = NULL;
@@ -254,15 +247,15 @@ rina_name_t * string_to_name(const char * s)
if (tmp_s_api != NULL)
tmp_api = (unsigned int) strtol(tmp_s_api, &tmp2, 10);
- name = name_create();
+ name = instance_name_create();
if (name == NULL) {
if (tmp1 != NULL)
free(tmp1);
return NULL;
}
- if (!name_init_from(name, tmp_ap, tmp_api)) {
- name_destroy(name);
+ if (!instance_name_init_from(name, tmp_ap, tmp_api)) {
+ instance_name_destroy(name);
if (tmp1 != NULL)
free(tmp1);
return NULL;
diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c
index 445160f0..60d5879e 100644
--- a/src/lib/ipcp.c
+++ b/src/lib/ipcp.c
@@ -85,8 +85,8 @@ static int send_ipcp_msg(pid_t pid,
return 0;
}
-pid_t ipcp_create(rina_name_t name,
- char * ipcp_type)
+pid_t ipcp_create(instance_name_t * api,
+ char * ipcp_type)
{
pid_t pid = 0;
char * api_id = NULL;
@@ -107,12 +107,12 @@ pid_t ipcp_create(rina_name_t name,
return pid;
}
- api_id = malloc(n_digits(name.api_id) + 1);
+ api_id = malloc(n_digits(api->id) + 1);
if (!api_id) {
LOG_ERR("Failed to malloc");
exit(EXIT_FAILURE);
}
- sprintf(api_id, "%d", name.api_id);
+ sprintf(api_id, "%d", api->id);
len += strlen(INSTALL_DIR);
len += strlen(ipcp_dir);
@@ -129,7 +129,7 @@ pid_t ipcp_create(rina_name_t name,
strcat(full_name, ipcp_dir);
char * argv[] = {full_name,
- name.ap_name, api_id,
+ api->name, api_id,
ipcp_type, 0};
char * envp[] = {0};
diff --git a/src/lib/irm.c b/src/lib/irm.c
index 92d8b3a5..644e1113 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -26,22 +26,22 @@
#include <ouroboros/common.h>
#include <ouroboros/logs.h>
#include <ouroboros/sockets.h>
+#include <ouroboros/instance_name.h>
#include <stdlib.h>
-int irm_create_ipcp(char * ap_name,
- int api_id,
- char * ipcp_type)
+int irm_create_ipcp(instance_name_t * api,
+ char * ipcp_type)
{
irm_msg_t msg = IRM_MSG__INIT;
- if (ipcp_type == NULL || ap_name == NULL)
+ if (api == NULL || ipcp_type == NULL || api->name == NULL)
return -EINVAL;
msg.code = IRM_MSG_CODE__IRM_CREATE_IPCP;
- msg.ap_name = ap_name;
+ msg.ap_name = api->name;
msg.has_api_id = true;
- msg.api_id = api_id;
+ msg.api_id = api->id;
msg.ipcp_type = ipcp_type;
if (send_irm_msg(&msg)) {
@@ -52,19 +52,17 @@ int irm_create_ipcp(char * ap_name,
return 0;
}
-int irm_destroy_ipcp(char * ap_name,
- int api_id)
+int irm_destroy_ipcp(instance_name_t * api)
{
irm_msg_t msg = IRM_MSG__INIT;
- if (ap_name == NULL) {
+ if (api == NULL || api->name == NULL)
return -EINVAL;
- }
msg.code = IRM_MSG_CODE__IRM_DESTROY_IPCP;
- msg.ap_name = ap_name;
+ msg.ap_name = api->name;
msg.has_api_id = true;
- msg.api_id = api_id;
+ msg.api_id = api->id;
if (send_irm_msg(&msg)) {
LOG_ERR("Failed to send message to daemon");
@@ -74,20 +72,18 @@ int irm_destroy_ipcp(char * ap_name,
return 0;
}
-int irm_bootstrap_ipcp(char * ap_name,
- int api_id,
+int irm_bootstrap_ipcp(instance_name_t * api,
struct dif_config * conf)
{
irm_msg_t msg = IRM_MSG__INIT;
- if (ap_name == NULL || conf == NULL) {
+ if (api == NULL || api->name == NULL || conf == NULL)
return -EINVAL;
- }
msg.code = IRM_MSG_CODE__IRM_BOOTSTRAP_IPCP;
- msg.ap_name = ap_name;
+ msg.ap_name = api->name;
msg.has_api_id = true;
- msg.api_id = api_id;
+ msg.api_id = api->id;
if (send_irm_msg(&msg)) {
LOG_ERR("Failed to send message to daemon");
@@ -97,20 +93,18 @@ int irm_bootstrap_ipcp(char * ap_name,
return 0;
}
-int irm_enroll_ipcp(char * ap_name,
- int api_id,
- char * dif_name)
+int irm_enroll_ipcp(instance_name_t * api,
+ char * dif_name)
{
irm_msg_t msg = IRM_MSG__INIT;
- if (ap_name == NULL || dif_name == NULL) {
+ if (api == NULL || api->name == NULL || dif_name == NULL)
return -EINVAL;
- }
msg.code = IRM_MSG_CODE__IRM_ENROLL_IPCP;
- msg.ap_name = ap_name;
+ msg.ap_name = api->name;
msg.has_api_id = true;
- msg.api_id = api_id;
+ msg.api_id = api->id;
msg.n_dif_name = 1;
msg.dif_name = malloc(sizeof(*(msg.dif_name)));
if (msg.dif_name == NULL) {
@@ -130,14 +124,13 @@ int irm_enroll_ipcp(char * ap_name,
return 0;
}
-int irm_reg_ipcp(char * ap_name,
- int api_id,
- char ** difs,
- size_t difs_size)
+int irm_reg_ipcp(instance_name_t * api,
+ char ** difs,
+ size_t difs_size)
{
irm_msg_t msg = IRM_MSG__INIT;
- if (ap_name == NULL ||
+ if (api->name == NULL ||
difs == NULL ||
difs_size == 0 ||
difs[0] == NULL) {
@@ -145,9 +138,9 @@ int irm_reg_ipcp(char * ap_name,
}
msg.code = IRM_MSG_CODE__IRM_REG_IPCP;
- msg.ap_name = ap_name;
+ msg.ap_name = api->name;
msg.has_api_id = true;
- msg.api_id = api_id;
+ msg.api_id = api->id;
msg.dif_name = difs;
msg.n_dif_name = difs_size;
@@ -159,14 +152,14 @@ int irm_reg_ipcp(char * ap_name,
return 0;
}
-int irm_unreg_ipcp(char * ap_name,
- int api_id,
- char ** difs,
- size_t difs_size)
+int irm_unreg_ipcp(const instance_name_t * api,
+ char ** difs,
+ size_t difs_size)
{
irm_msg_t msg = IRM_MSG__INIT;
- if (ap_name == NULL ||
+ if (api == NULL ||
+ api->name == NULL ||
difs == NULL ||
difs_size == 0 ||
difs[0] == NULL) {
@@ -174,9 +167,9 @@ int irm_unreg_ipcp(char * ap_name,
}
msg.code = IRM_MSG_CODE__IRM_UNREG_IPCP;
- msg.ap_name = ap_name;
+ msg.ap_name = api->name;
msg.has_api_id = true;
- msg.api_id = api_id;
+ msg.api_id = api->id;
msg.dif_name = difs;
msg.n_dif_name = difs_size;
diff --git a/src/tools/echo/echo_client.c b/src/tools/echo/echo_client.c
index 196296f2..8d3fc322 100644
--- a/src/tools/echo/echo_client.c
+++ b/src/tools/echo/echo_client.c
@@ -23,7 +23,6 @@
#define CLIENT_AP_NAME "echo-client"
#include <ouroboros/dev.h>
-#include <ouroboros/rina_name.h>
int client_main()
{
diff --git a/src/tools/echo/echo_server.c b/src/tools/echo/echo_server.c
index 289f537a..b1547d8c 100644
--- a/src/tools/echo/echo_server.c
+++ b/src/tools/echo/echo_server.c
@@ -26,7 +26,6 @@
#include <stdlib.h>
#include <ouroboros/dev.h>
-#include <ouroboros/rina_name.h>
#define DIF_NAME "*"
diff --git a/src/tools/irm/irm.c b/src/tools/irm/irm.c
index 895d52c2..d05e083e 100644
--- a/src/tools/irm/irm.c
+++ b/src/tools/irm/irm.c
@@ -21,7 +21,7 @@
*/
#include <ouroboros/common.h>
-#include <ouroboros/rina_name.h>
+#include <ouroboros/instance_name.h>
#include <ouroboros/irm.h>
#include <stdio.h>
#include <string.h>
diff --git a/src/tools/irm/irm_bootstrap_ipcp.c b/src/tools/irm/irm_bootstrap_ipcp.c
index 0843083d..c7b82c4a 100644
--- a/src/tools/irm/irm_bootstrap_ipcp.c
+++ b/src/tools/irm/irm_bootstrap_ipcp.c
@@ -39,17 +39,16 @@ static void usage()
int do_bootstrap_ipcp(int argc, char ** argv)
{
- char * ap_name = NULL;
- int api_id = 0;
+ instance_name_t api = {NULL, 0};
struct dif_config conf;
conf.qosspecs = NULL;
while (argc > 0) {
if (matches(*argv, "ap") == 0) {
- ap_name = *(argv + 1);
+ api.name = *(argv + 1);
} else if (matches(*argv, "api") == 0) {
- api_id = atoi(*(argv + 1));
+ api.id = atoi(*(argv + 1));
} else {
printf("\"%s\" is unknown, try \"irm "
"destroy_ipcp\".\n", *argv);
@@ -61,10 +60,10 @@ int do_bootstrap_ipcp(int argc, char ** argv)
argv += 2;
}
- if (ap_name == NULL) {
+ if (api.name == NULL) {
usage();
return -1;
}
- return irm_bootstrap_ipcp(ap_name, api_id, &conf);
+ return irm_bootstrap_ipcp(&api, &conf);
}
diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_create_ipcp.c
index 3262bd5c..73d20dce 100644
--- a/src/tools/irm/irm_create_ipcp.c
+++ b/src/tools/irm/irm_create_ipcp.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <ouroboros/irm.h>
#include <ouroboros/common.h>
+#include <ouroboros/instance_name.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -41,16 +42,15 @@ static void usage()
int do_create_ipcp(int argc, char ** argv)
{
char * ipcp_type = NULL;
- char * ap_name = NULL;
- int api_id = 0;
+ instance_name_t api = {NULL, 0};
while (argc > 0) {
if (matches(*argv, "type") == 0) {
ipcp_type = *(argv + 1);
} else if (matches(*argv, "ap") == 0) {
- ap_name = *(argv + 1);
+ api.name = *(argv + 1);
} else if (matches(*argv, "api") == 0) {
- api_id = atoi(*(argv + 1));
+ api.id = atoi(*(argv + 1));
} else {
printf("\"%s\" is unknown, try \"irm "
"create_ipcp\".\n", *argv);
@@ -61,10 +61,10 @@ int do_create_ipcp(int argc, char ** argv)
argv += 2;
}
- if (ipcp_type == NULL || ap_name == NULL) {
+ if (ipcp_type == NULL || api.name == NULL) {
usage();
return -1;
}
- return irm_create_ipcp(ap_name, api_id, ipcp_type);
+ return irm_create_ipcp(&api, ipcp_type);
}
diff --git a/src/tools/irm/irm_destroy_ipcp.c b/src/tools/irm/irm_destroy_ipcp.c
index fbbeb5bd..fe6ef57e 100644
--- a/src/tools/irm/irm_destroy_ipcp.c
+++ b/src/tools/irm/irm_destroy_ipcp.c
@@ -37,14 +37,13 @@ static void usage()
int do_destroy_ipcp(int argc, char ** argv)
{
- char * ap_name = NULL;
- int api_id = 0;
+ instance_name_t api = {NULL, 0};
while (argc > 0) {
if (matches(*argv, "ap") == 0) {
- ap_name = *(argv + 1);
+ api.name = *(argv + 1);
} else if (matches(*argv, "api") == 0) {
- api_id = atoi(*(argv + 1));
+ api.id = atoi(*(argv + 1));
} else {
printf("\"%s\" is unknown, try \"irm "
"destroy_ipcp\".\n", *argv);
@@ -55,10 +54,10 @@ int do_destroy_ipcp(int argc, char ** argv)
argv += 2;
}
- if (ap_name == NULL) {
+ if (api.name == NULL) {
usage();
return -1;
}
- return irm_destroy_ipcp(ap_name, api_id);
+ return irm_destroy_ipcp(&api);
}
diff --git a/src/tools/irm/irm_enroll_ipcp.c b/src/tools/irm/irm_enroll_ipcp.c
index 70798821..5c9572bf 100644
--- a/src/tools/irm/irm_enroll_ipcp.c
+++ b/src/tools/irm/irm_enroll_ipcp.c
@@ -38,15 +38,14 @@ static void usage()
int do_enroll_ipcp(int argc, char ** argv)
{
- char * ap_name = NULL;
- int api_id = 0;
+ instance_name_t api = {NULL, 0};
char * dif_name = NULL;
while (argc > 0) {
if (matches(*argv, "ap") == 0) {
- ap_name = *(argv + 1);
+ api.name = *(argv + 1);
} else if (matches(*argv, "api") == 0) {
- api_id = atoi(*(argv + 1));
+ api.id = atoi(*(argv + 1));
} else if (matches(*argv, "dif") == 0) {
dif_name = *(argv + 1);
} else {
@@ -59,10 +58,10 @@ int do_enroll_ipcp(int argc, char ** argv)
argv += 2;
}
- if (dif_name == NULL || ap_name == NULL) {
+ if (dif_name == NULL || api.name == NULL) {
usage();
return -1;
}
- return irm_enroll_ipcp(ap_name, api_id, dif_name);
+ return irm_enroll_ipcp(&api, dif_name);
}
diff --git a/src/tools/irm/irm_register_ipcp.c b/src/tools/irm/irm_register_ipcp.c
index b8808ecd..f0c1ccff 100644
--- a/src/tools/irm/irm_register_ipcp.c
+++ b/src/tools/irm/irm_register_ipcp.c
@@ -47,14 +47,13 @@ int do_register_ipcp(int argc, char ** argv)
{
char * difs[MAX_DIFS];
size_t difs_size = 0;
- char * ap_name = NULL;
- int api_id = 0;
+ instance_name_t api = {NULL, 0};
while (argc > 0) {
if (matches(*argv, "ap") == 0) {
- ap_name = *(argv + 1);
+ api.name = *(argv + 1);
} else if (matches(*argv, "api") == 0) {
- api_id = atoi(*(argv + 1));
+ api.id = atoi(*(argv + 1));
} else if (matches(*argv, "dif") == 0) {
difs[difs_size++] = *(argv + 1);
if (difs_size > MAX_DIFS) {
@@ -71,10 +70,10 @@ int do_register_ipcp(int argc, char ** argv)
argv += 2;
}
- if (difs_size == 0 || ap_name == NULL) {
+ if (difs_size == 0 || api.name == NULL) {
usage();
return -1;
}
- return irm_reg_ipcp(ap_name, api_id, difs, difs_size);
+ return irm_reg_ipcp(&api, difs, difs_size);
}
diff --git a/src/tools/irm/irm_unregister_ipcp.c b/src/tools/irm/irm_unregister_ipcp.c
index 1321c263..3fd6f148 100644
--- a/src/tools/irm/irm_unregister_ipcp.c
+++ b/src/tools/irm/irm_unregister_ipcp.c
@@ -45,17 +45,16 @@ static void usage()
int do_unregister_ipcp(int argc, char ** argv)
{
- char * ap_name = NULL;
- int api_id = 0;
+ instance_name_t api = {NULL, 0};
char * difs[MAX_DIFS];
size_t difs_size = 0;
while (argc > 0) {
if (matches(*argv, "ap") == 0) {
- ap_name = *(argv + 1);
+ api.name = *(argv + 1);
} else if (matches(*argv, "api") == 0) {
- api_id = atoi(*(argv + 1));
+ api.id = atoi(*(argv + 1));
} else if (matches(*argv, "dif") == 0) {
difs[difs_size++] = *(argv + 1);
if (difs_size > MAX_DIFS) {
@@ -72,10 +71,10 @@ int do_unregister_ipcp(int argc, char ** argv)
argv += 2;
}
- if (difs_size == 0 || ap_name == NULL) {
+ if (difs_size == 0 || api.name == NULL) {
usage();
return -1;
}
- return irm_unreg_ipcp(ap_name, api_id, difs, difs_size);
+ return irm_unreg_ipcp(&api, difs, difs_size);
}
diff --git a/src/tools/irm/irm_utils.h b/src/tools/irm/irm_utils.h
index 3d328d95..da2259c6 100644
--- a/src/tools/irm/irm_utils.h
+++ b/src/tools/irm/irm_utils.h
@@ -20,8 +20,4 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <ouroboros/rina_name.h>
-
-#include <stdbool.h>
-
int matches(const char * cmd, const char * pattern);