summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/routing.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2017-03-23 15:51:42 +0100
committerSander Vrijders <[email protected]>2017-03-23 16:32:12 +0100
commitbb30c4f0488d5d444fd316d716f59c824a01540f (patch)
treef4a656bb04365d27ef1ac1ae5850fbdc1de59c7d /src/ipcpd/normal/routing.c
parent22ec3addff9fd786fdd6917c5fd5800beab49d0c (diff)
downloadouroboros-bb30c4f0488d5d444fd316d716f59c824a01540f.tar.gz
ouroboros-bb30c4f0488d5d444fd316d716f59c824a01540f.zip
ipcpd: normal: Add routing table calculation
This adds routing table calculation to the graph component. The routing instances can then periodically ask the graph component for the routing table, and update their PFFs accordingly.
Diffstat (limited to 'src/ipcpd/normal/routing.c')
-rw-r--r--src/ipcpd/normal/routing.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/ipcpd/normal/routing.c b/src/ipcpd/normal/routing.c
index 70999951..3a72bf36 100644
--- a/src/ipcpd/normal/routing.c
+++ b/src/ipcpd/normal/routing.c
@@ -44,15 +44,11 @@
typedef Fso fso_t;
#define BUF_SIZE 256
-
-struct routing_table_entry {
- struct list_head next;
- uint64_t dst;
- uint64_t nhop;
-};
+#define RECALC_TIME 4
struct routing_i {
struct pff * pff;
+ pthread_t calculator;
};
struct {
@@ -66,6 +62,34 @@ struct {
pthread_t rib_listener;
} routing;
+static void * calculate_pff(void * o)
+{
+ struct routing_table ** table;
+ ssize_t i;
+ int j;
+
+ (void) o;
+
+ while (true) {
+ i = graph_routing_table(routing.graph, ipcpi.dt_addr, &table);
+ if (table != NULL) {
+ /*
+ * FIXME: Calculate address to fd here
+ * and fill in PFF
+ */
+ }
+
+ for (j = 0; j < i; j++) {
+ free(table[j]);
+ }
+ free(table);
+
+ sleep(RECALC_TIME);
+ }
+
+ return (void *) 0;
+}
+
struct routing_i * routing_i_create(struct pff * pff)
{
struct routing_i * tmp;
@@ -78,6 +102,8 @@ struct routing_i * routing_i_create(struct pff * pff)
tmp->pff = pff;
+ pthread_create(&tmp->calculator, NULL, calculate_pff, NULL);
+
return tmp;
}
@@ -85,6 +111,10 @@ void routing_i_destroy(struct routing_i * instance)
{
assert(instance);
+ pthread_cancel(instance->calculator);
+
+ pthread_join(instance->calculator, NULL);
+
free(instance);
}