aboutsummaryrefslogtreecommitdiff
path: root/Semestr 4/sieci/pracownia2/router
diff options
context:
space:
mode:
Diffstat (limited to 'Semestr 4/sieci/pracownia2/router')
-rw-r--r--Semestr 4/sieci/pracownia2/router/config.h2
-rw-r--r--Semestr 4/sieci/pracownia2/router/makefile37
-rw-r--r--Semestr 4/sieci/pracownia2/router/network_addr.h11
-rw-r--r--Semestr 4/sieci/pracownia2/router/vector.h1
4 files changed, 14 insertions, 37 deletions
diff --git a/Semestr 4/sieci/pracownia2/router/config.h b/Semestr 4/sieci/pracownia2/router/config.h
index 3537c03..abf7d23 100644
--- a/Semestr 4/sieci/pracownia2/router/config.h
+++ b/Semestr 4/sieci/pracownia2/router/config.h
@@ -2,7 +2,7 @@
#define CONFIG_H
#define SERVER_PORT 54321
-#define TURN_LEN_S 5
+#define TURN_LEN_S 20
#define TURN_LEN_MS (1000 * TURN_LEN_S)
#define TURN_LEN_US (1000000 * TURN_LEN_S)
diff --git a/Semestr 4/sieci/pracownia2/router/makefile b/Semestr 4/sieci/pracownia2/router/makefile
index be41840..7d8aaef 100644
--- a/Semestr 4/sieci/pracownia2/router/makefile
+++ b/Semestr 4/sieci/pracownia2/router/makefile
@@ -1,30 +1,19 @@
-CC := gcc
-CFLAGS := -Og -std=gnu17 -Wall -Wall -fsanitize=address -fsanitize=undefined
-TARGET := router
+CC := gcc
+CFLAGS := -Og -std=gnu17 -Wall -Wall -fsanitize=address -fsanitize=undefined
+TARGET := router
+DEPS := config.h
-all: $(TARGET)
-test: test
-
-utils.o: utils.c
- $(CC) $(CFLAGS) -c utils.c
-
-network_addr.o: network_addr.c
- $(CC) $(CFLAGS) -c network_addr.c
+ODIR := obj
+_OBJ := router.o utils.o linked_list.o network_addr.o dist_vector.o
+OBJ := $(patsubst %,$(ODIR)/%,$(_OBJ))
-router.o: router.c
- $(CC) $(CFLAGS) -c $(TARGET).c
-
-linked_list.o: linked_list.c
- $(CC) $(CFLAGS) -c linked_list.c
-
-router: utils.o network_addr.o linked_list.o router.o
- $(CC) $(CFLAGS) -o $(TARGET) $(TARGET).o network_addr.o utils.o linked_list.o
+all: $(TARGET)
-test.o: test.c
- $(CC) $(CFLAGS) -c test.c
+$(ODIR)/%.o: %.c $(DEPS)
+ $(CC) $(CFLAGS) -c -o $@ $<
-test: linked_list.o test.o
- $(CC) $(CFLAGS) -o test test.o linked_list.o
+$(TARGET): $(OBJ)
+ $(CC) -o $@ $^ $(CFLAGS)
clean:
rm -rf $(TARGET)
@@ -33,4 +22,4 @@ clean:
distclean:
rm -rf $(TARGET)
rm -rf test
- rm -rf *.o
+ rm -rf $(ODIR)/*.o
diff --git a/Semestr 4/sieci/pracownia2/router/network_addr.h b/Semestr 4/sieci/pracownia2/router/network_addr.h
index 777406a..2067e05 100644
--- a/Semestr 4/sieci/pracownia2/router/network_addr.h
+++ b/Semestr 4/sieci/pracownia2/router/network_addr.h
@@ -16,17 +16,6 @@ struct network_addr {
typedef struct network_addr router_addr;
-/* Item of the distance vector.
- * If <<reachable>> is set to 0, then it means that the network is reachable.
- * If <<reachable>> has positive value, then it indicates that the network was
- * unreachable for <<reachable>> turns.
- */
-struct vector_item {
- struct network_addr network;
- struct in_addr via_ip;
- uint8_t reachable;
-};
-
/* Returns broadcast address of a given network. */
struct in_addr get_broadcast_address(struct network_addr na);
diff --git a/Semestr 4/sieci/pracownia2/router/vector.h b/Semestr 4/sieci/pracownia2/router/vector.h
deleted file mode 100644
index 4cd0039..0000000
--- a/Semestr 4/sieci/pracownia2/router/vector.h
+++ /dev/null
@@ -1 +0,0 @@
-#ifndef \ No newline at end of file