summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/ribmgr.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-03-21 16:21:49 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2017-03-21 16:21:49 +0100
commitfef50c3db0e02f0052f1759d508045c44fc4146e (patch)
treefc73859827a5dfebf5022fad37e826d98ba4046f /src/ipcpd/normal/ribmgr.c
parent4b257b249ea91d1ee7e2341c563bac561911e8a6 (diff)
parentd4e80d41197b75d2c351659c7e8d4546270e677d (diff)
downloadouroboros-fef50c3db0e02f0052f1759d508045c44fc4146e.tar.gz
ouroboros-fef50c3db0e02f0052f1759d508045c44fc4146e.zip
Merge branch 'be' of bitbucket.org:ouroboros-rina/ouroboros into be
Diffstat (limited to 'src/ipcpd/normal/ribmgr.c')
-rw-r--r--src/ipcpd/normal/ribmgr.c96
1 files changed, 69 insertions, 27 deletions
diff --git a/src/ipcpd/normal/ribmgr.c b/src/ipcpd/normal/ribmgr.c
index f254bd50..ec465c6b 100644
--- a/src/ipcpd/normal/ribmgr.c
+++ b/src/ipcpd/normal/ribmgr.c
@@ -3,8 +3,8 @@
*
* RIB manager of the IPC Process
*
- * Dimitri Staessens <dimitri.staessens@intec.ugent.be>
- * Sander Vrijders <sander.vrijders@intec.ugent.be>
+ * Dimitri Staessens <dimitri.staessens@ugent.be>
+ * Sander Vrijders <sander.vrijders@ugent.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -45,35 +45,70 @@
#include <assert.h>
struct {
- flow_set_t * fs;
- fqueue_t * fq;
- struct gam * gam;
+ flow_set_t * fs;
+ fqueue_t * fq;
+
+ struct gam * gam;
+ struct nbs * nbs;
+ struct ae * ae;
+
+ struct nb_notifier nb_notifier;
} ribmgr;
+static int ribmgr_neighbor_event(enum nb_event event,
+ struct conn conn)
+{
+ /* We are only interested in neighbors being added and removed. */
+ switch (event) {
+ case NEIGHBOR_ADDED:
+ flow_set_add(ribmgr.fs, conn.flow_info.fd);
+ break;
+ case NEIGHBOR_REMOVED:
+ flow_set_del(ribmgr.fs, conn.flow_info.fd);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
int ribmgr_init(void)
{
- enum pol_cacep pc;
- enum pol_gam pg;
+ enum pol_gam pg;
+ struct conn_info info;
- if (rib_read(BOOT_PATH "/rm/gam/type", &pg, sizeof(pg))
- != sizeof(pg)) {
- log_err("Failed to read policy for ribmgr gam.");
+ strcpy(info.ae_name, MGMT_AE);
+ strcpy(info.protocol, CDAP_PROTO);
+ info.pref_version = 1;
+ info.pref_syntax = PROTO_GPB;
+
+ ribmgr.nbs = nbs_create();
+ if (ribmgr.nbs == NULL) {
+ log_err("Failed to create neighbors.");
return -1;
}
- if (rib_read(BOOT_PATH "/rm/gam/cacep", &pc, sizeof(pc))
- != sizeof(pc)) {
- log_err("Failed to read CACEP policy for ribmgr gam.");
+ ribmgr.ae = connmgr_ae_create(info);
+ if (ribmgr.ae == NULL) {
+ log_err("Failed to create AE struct.");
+ nbs_destroy(ribmgr.nbs);
return -1;
}
- /* FIXME: Implement cacep policies */
- (void) pc;
+ if (rib_read(BOOT_PATH "/rm/gam/type", &pg, sizeof(pg))
+ != sizeof(pg)) {
+ log_err("Failed to read policy for ribmgr gam.");
+ connmgr_ae_destroy(ribmgr.ae);
+ nbs_destroy(ribmgr.nbs);
+ return -1;
+ }
- ribmgr.gam = gam_create(pg, MGMT_AE);
+ ribmgr.gam = gam_create(pg, ribmgr.nbs, ribmgr.ae);
if (ribmgr.gam == NULL) {
log_err("Failed to create gam.");
+ connmgr_ae_destroy(ribmgr.ae);
+ nbs_destroy(ribmgr.nbs);
return -1;
}
@@ -81,6 +116,8 @@ int ribmgr_init(void)
if (ribmgr.fs == NULL) {
log_err("Failed to create flow set.");
gam_destroy(ribmgr.gam);
+ connmgr_ae_destroy(ribmgr.ae);
+ nbs_destroy(ribmgr.nbs);
return -1;
}
@@ -89,6 +126,19 @@ int ribmgr_init(void)
log_err("Failed to create fq.");
flow_set_destroy(ribmgr.fs);
gam_destroy(ribmgr.gam);
+ connmgr_ae_destroy(ribmgr.ae);
+ nbs_destroy(ribmgr.nbs);
+ return -1;
+ }
+
+ ribmgr.nb_notifier.notify_call = ribmgr_neighbor_event;
+ if (nbs_reg_notifier(ribmgr.nbs, &ribmgr.nb_notifier)) {
+ log_err("Failed to register notifier.");
+ fqueue_destroy(ribmgr.fq);
+ flow_set_destroy(ribmgr.fs);
+ gam_destroy(ribmgr.gam);
+ connmgr_ae_destroy(ribmgr.ae);
+ nbs_destroy(ribmgr.nbs);
return -1;
}
@@ -97,20 +147,12 @@ int ribmgr_init(void)
void ribmgr_fini(void)
{
+ nbs_unreg_notifier(ribmgr.nbs, &ribmgr.nb_notifier);
flow_set_destroy(ribmgr.fs);
fqueue_destroy(ribmgr.fq);
gam_destroy(ribmgr.gam);
-}
-
-int ribmgr_flow_arr(int fd,
- qosspec_t qs)
-{
- assert(ribmgr.gam);
-
- if (gam_flow_arr(ribmgr.gam, fd, qs))
- return -1;
-
- return 0;
+ connmgr_ae_destroy(ribmgr.ae);
+ nbs_destroy(ribmgr.nbs);
}
int ribmgr_disseminate(char * path,