diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-23 15:35:19 +0000 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-03-23 15:35:19 +0000 |
commit | b350f91968b05e61a362d21d55cf183af28da77a (patch) | |
tree | f4a656bb04365d27ef1ac1ae5850fbdc1de59c7d /src/ipcpd/normal/routing.c | |
parent | 22ec3addff9fd786fdd6917c5fd5800beab49d0c (diff) | |
parent | bb30c4f0488d5d444fd316d716f59c824a01540f (diff) | |
download | ouroboros-b350f91968b05e61a362d21d55cf183af28da77a.tar.gz ouroboros-b350f91968b05e61a362d21d55cf183af28da77a.zip |
Merged in sandervrijders/ouroboros/be-dijkstra (pull request #416)
ipcpd: normal: Add routing table calculation
Diffstat (limited to 'src/ipcpd/normal/routing.c')
-rw-r--r-- | src/ipcpd/normal/routing.c | 42 |
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); } |