From 27b36b690a4b048721f0a568ef0aff03bf8e9855 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 7 Jul 2016 19:01:00 +0200 Subject: 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. --- src/irmd/registry.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'src/irmd/registry.c') 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) { -- cgit v1.2.3