diff --git a/src/route_lib.c b/src/route_lib.c index e3efb758..0e7b7e10 100644 --- a/src/route_lib.c +++ b/src/route_lib.c @@ -167,7 +167,8 @@ bool route_insert(struct ROUTE_TABLE *table, struct NODEINFO_Q *node) { // === Проверка пересечений === for (size_t i = 0; i < count; i++) { uint32_t network; - memcpy(&network, subnets[i].addr, 4); // addr уже в network byte order (big-endian) + memcpy(&network, subnets[i].addr, 4); + network = ntohl(network); uint8_t prefix = subnets[i].prefix_length; if (check_route_overlap_in_table(network, prefix, @@ -195,6 +196,7 @@ bool route_insert(struct ROUTE_TABLE *table, struct NODEINFO_Q *node) { for (size_t i = 0; i < count; i++) { uint32_t network; memcpy(&network, subnets[i].addr, 4); + network = ntohl(network); uint8_t prefix_length = subnets[i].prefix_length; int pos = binary_search_insert_pos(table->entries, table->count, network, prefix_length); diff --git a/src/route_lib.h b/src/route_lib.h index 3c276874..f3a8fd71 100644 --- a/src/route_lib.h +++ b/src/route_lib.h @@ -110,4 +110,6 @@ void route_table_print(const struct ROUTE_TABLE *table); */ int parse_subnet(const char *subnet_str, uint32_t *network, uint8_t *prefix_length); +bool route_add_local_subnet(struct ROUTE_TABLE *table, uint32_t network, uint8_t prefix_length); + #endif // ROUTE_LIB_H