summaryrefslogtreecommitdiff
path: root/src/irmd/registry.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-07-07 19:01:00 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-07-07 20:54:06 +0200
commit27b36b690a4b048721f0a568ef0aff03bf8e9855 (patch)
tree36936ba283d5567c4c2533c1e56675290ff5fc67 /src/irmd/registry.c
parentb3870ef695a256be4a4ed28a991c39aab37bd6f3 (diff)
downloadouroboros-27b36b690a4b048721f0a568ef0aff03bf8e9855.tar.gz
ouroboros-27b36b690a4b048721f0a568ef0aff03bf8e9855.zip
irmd: Prioritize local ipcp for local flows
For locally registered processes, the IRMd will first look for the local, then the normal, then the shim-udp. It will look for a normal, a shim-eth-llc and ultimately a shim-udp for non-local destinations. It does not yet check if a remote destination is actually known in a DIF. Fixes #18.
Diffstat (limited to 'src/irmd/registry.c')
-rw-r--r--src/irmd/registry.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/irmd/registry.c b/src/irmd/registry.c
index c5f81d77..e9927b7e 100644
--- a/src/irmd/registry.c
+++ b/src/irmd/registry.c
@@ -143,6 +143,7 @@ struct reg_entry * reg_entry_init(struct reg_entry * e,
INIT_LIST_HEAD(&e->ap_names);
INIT_LIST_HEAD(&e->auto_ap_info);
INIT_LIST_HEAD(&e->ap_instances);
+ INIT_LIST_HEAD(&e->difs);
e->name = name;
e->flags = flags;
@@ -228,9 +229,65 @@ void reg_entry_destroy(struct reg_entry * e)
free(n);
}
+ list_for_each_safe(pos, n, &e->difs) {
+ struct reg_dif_name * d =
+ list_entry(pos, struct reg_dif_name, next);
+ free(d->dif_name);
+ free(d);
+ }
+
free(e);
}
+bool reg_entry_is_local_in_dif(struct reg_entry * e,
+ char * dif_name)
+{
+ struct list_head * pos = NULL;
+
+ list_for_each(pos, &e->difs) {
+ struct reg_dif_name * d =
+ list_entry(pos, struct reg_dif_name, next);
+
+ if (!strcmp(dif_name, d->dif_name))
+ return true;
+ }
+
+ return false;
+}
+
+int reg_entry_add_local_in_dif(struct reg_entry * e,
+ char * dif_name)
+{
+ if (!reg_entry_is_local_in_dif(e, dif_name)) {
+ struct reg_dif_name * rdn = malloc(sizeof(*rdn));
+ rdn->dif_name = strdup(dif_name);
+ if (rdn->dif_name == NULL)
+ return -1;
+ list_add(&rdn->next, &e->difs);
+ return 0;
+ }
+
+ return 0; /* already registered. Is ok */
+}
+
+void reg_entry_del_local_from_dif(struct reg_entry * e,
+ char * dif_name)
+{
+ struct list_head * pos = NULL;
+ struct list_head * n = NULL;
+
+ list_for_each_safe(pos, n, &e->difs) {
+ struct reg_dif_name * d =
+ list_entry(pos, struct reg_dif_name, next);
+
+ if (!strcmp(dif_name, d->dif_name)) {
+ list_del(&d->next);
+ free(d);
+ }
+ }
+}
+
+
struct reg_ap_name * reg_entry_get_ap_name(struct reg_entry * e,
char * ap_name)
{