Skip to content

Commit 045e3be

Browse files
fix: complete Clang-Tidy fixes and move default multicast IP to cpp
Add missing includes across nuclearnet sources, apply empty announce_address default in reset(), and relocate the multicast literal out of headers for Sonar. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent df0116e commit 045e3be

6 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/nuclearnet/NUClearNet.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ namespace network {
5050

5151
namespace {
5252

53+
/// Default organization-local multicast address for peer discovery (RFC 2365)
54+
const char* default_announce_address() {
55+
return "239.226.152.162"; // NOSONAR
56+
}
57+
5358
iovec make_iovec(void* base, std::size_t len) {
5459
#ifdef _WIN32
5560
iovec iov{};
@@ -135,6 +140,9 @@ namespace {
135140

136141
config = new_config;
137142
node_name = new_config.name;
143+
if (config.announce_address.empty()) {
144+
config.announce_address = default_announce_address();
145+
}
138146

139147
// Update module configurations
140148
discovery = std::make_unique<Discovery>(new_config.peer_timeout);

src/nuclearnet/NUClearNet.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include "PacketDeduplicator.hpp"
4242
#include "Reliability.hpp"
4343
#include "Routing.hpp"
44-
#include "wire_protocol.hpp"
4544

4645
namespace NUClear {
4746
namespace network {
@@ -52,8 +51,8 @@ namespace network {
5251
struct NetworkConfig {
5352
/// This node's name on the network
5453
std::string name;
55-
/// The multicast/broadcast/unicast address to announce on
56-
std::string announce_address = default_announce_address();
54+
/// The multicast/broadcast/unicast address to announce on (empty = default organization-local multicast)
55+
std::string announce_address;
5756
/// The port to use for announce discovery
5857
in_port_t announce_port = 7447;
5958
/// Address to bind to (empty = all interfaces)

src/nuclearnet/RTTEstimator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "RTTEstimator.hpp"
2525

2626
#include <algorithm>
27+
#include <chrono>
2728
#include <cmath>
2829

2930
namespace NUClear {

src/nuclearnet/Reliability.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
#include "Reliability.hpp"
2626

2727
#include <algorithm>
28+
#include <chrono>
29+
#include <cstdint>
2830
#include <cstring>
31+
#include <mutex>
32+
#include <vector>
2933

3034
#include "wire_protocol.hpp"
3135

src/nuclearnet/Routing.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222

2323
#include "Routing.hpp"
2424

25+
#include <cstdint>
26+
#include <mutex>
27+
#include <utility>
28+
#include <vector>
29+
2530
namespace NUClear {
2631
namespace network {
2732

src/nuclearnet/wire_protocol.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ namespace network {
4141
/// Protocol version for NUClearNet v2
4242
constexpr uint8_t PROTOCOL_VERSION = 0x03;
4343

44-
/// Default organization-local multicast address for peer discovery (RFC 2365)
45-
inline const char* default_announce_address() {
46-
return "239.226.152.162"; // NOSONAR
47-
}
48-
4944
/// Packet type identifiers
5045
enum PacketType : uint8_t {
5146
ANNOUNCE = 1,

0 commit comments

Comments
 (0)