From 2c868981b1cf6d32e6dec66af40d04bb33caa5f5 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 21 Dec 2023 23:46:19 +0800 Subject: [PATCH] Fix ospf length endianness conversion, suggested by @yangsong21 --- Homework/ospf/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Homework/ospf/main.cpp b/Homework/ospf/main.cpp index d5a495d..69508d9 100644 --- a/Homework/ospf/main.cpp +++ b/Homework/ospf/main.cpp @@ -1414,7 +1414,7 @@ int main(int argc, char *argv[]) { // neighbor state transitions to ExStart." if (neighbor_found && neighbor->state == NeighborInit) { int num_neighbors = - (ntohl(ospf_hdr->length) - sizeof(struct ospf_hello)) / + (ntohs(ospf_hdr->length) - sizeof(struct ospf_hello)) / sizeof(uint32_t); // TODO(8 行) // 修改这个检查,完成 Hello 的协商判断:当发现对方发送的 OSPF Hello