summaryrefslogtreecommitdiff
path: root/src/irmd/registry.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-07-07 21:52:29 +0200
committerSander Vrijders <[email protected]>2016-07-07 21:52:29 +0200
commit00dba20de7462c07866d321597697456a0ae8555 (patch)
tree36936ba283d5567c4c2533c1e56675290ff5fc67 /src/irmd/registry.c
parentcc377e56c6fd25403fc7ccf5f83c82e3d85a767b (diff)
parent27b36b690a4b048721f0a568ef0aff03bf8e9855 (diff)
downloadouroboros-00dba20de7462c07866d321597697456a0ae8555.tar.gz
ouroboros-00dba20de7462c07866d321597697456a0ae8555.zip
Merged in dstaesse/ouroboros/be-ipcp-priority (pull request #166)
irmd: Prioritize local ipcp for local flows
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)
{