Skip to content

Commit 9ca39f4

Browse files
refactor: improve code quality and add packet processing tests
- Convert iovec C-arrays to std::array<iovec, N> (4 sites in NUClearNet.cpp, 1 in header) - Replace for(;;){break} in read_socket with while loop - Split process_packet switch/case into if-else chain dispatching to per-type methods: process_announce_packet, process_leave_packet, process_connect_packet, process_data_packet, process_ack_packet - Make per-type methods public for testability - Add comprehensive behavioral tests (ProcessPacket.cpp) covering: validate_header edge cases, packet dispatch, connect handshake, data delivery/rejection/dedup/reassembly, ACK handling, send paths
1 parent 89e3c38 commit 9ca39f4

4 files changed

Lines changed: 685 additions & 204 deletions

File tree

src/nuclearnet/Fragmentation.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ namespace network {
4646
public:
4747
/// Result of a completed reassembly
4848
struct AssembledPacket {
49-
uint16_t packet_id;
50-
uint64_t hash;
51-
uint8_t flags;
49+
uint16_t packet_id{0};
50+
uint64_t hash{0};
51+
uint8_t flags{0};
5252
std::vector<uint8_t> payload;
5353
};
5454

0 commit comments

Comments
 (0)