From 9247a4c0998de14ef5993822cac75b4a6327ee1e Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Mon, 19 Apr 2021 18:05:41 +0200 Subject: Router working finally --- Semestr 4/sieci/pracownia2/router/dist_vector.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'Semestr 4/sieci/pracownia2/router/dist_vector.h') diff --git a/Semestr 4/sieci/pracownia2/router/dist_vector.h b/Semestr 4/sieci/pracownia2/router/dist_vector.h index cd1a995..14159b4 100644 --- a/Semestr 4/sieci/pracownia2/router/dist_vector.h +++ b/Semestr 4/sieci/pracownia2/router/dist_vector.h @@ -3,6 +3,7 @@ #include "linked_list.h" #include "network_addr.h" +#include "config.h" /* Item of the distance vector. * If <> is set to 0, then it means that the network is reachable. @@ -11,14 +12,25 @@ */ struct vector_item { struct network_addr network; - router_addr via_ip; + struct in_addr via_ip; + uint16_t distance; uint8_t reachable; + bool is_connected_directly; }; -/* Returns true if given distance vector item is connected directly, false otherwise */ +/* Initis distance vector with given neighbours array. */ +void init_dv(list_t *dv, int n_cnt, struct network_addr *neighbours); + +/* Returns true if given distance vector item is connected directly, false otherwise. */ bool is_connected_directly(struct vector_item item); /* Updates the distance vector. */ -void update_distance_vector(list_t *distance_vector, struct vector_item new_item); +void update_dv_new_item(list_t *distance_vector, struct vector_item new_item); + +/* Updates reachabilities. */ +void update_dv_reachability(list_t *distance_vector); + +/* Print distance vector. */ +void print_dv(list_t *distance_vector); #endif \ No newline at end of file -- cgit v1.2.3