Skip to content

Commit 78e382c

Browse files
committed
Refactor network code to use 'network' namespace
Replaces usage of the 'net' namespace and related includes with the 'network' namespace and updated include paths throughout the codebase. This unifies network-related function calls and types, improving code clarity and maintainability.
1 parent bf418dd commit 78e382c

File tree

120 files changed

+769
-957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+769
-957
lines changed

lib-artnet/include/artnetnode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class ArtNetNode
240240
void HandleShowFile(const artnet::ArtDmx* artdmx)
241241
{
242242
current_millis_ = hal::Millis();
243-
ip_address_from_ = net::GetPrimaryIp();
243+
ip_address_from_ = network::GetPrimaryIp();
244244
receive_buffer_ = reinterpret_cast<uint8_t*>(const_cast<artnet::ArtDmx*>(artdmx));
245245
HandleDmx();
246246
}
@@ -282,7 +282,7 @@ class ArtNetNode
282282
{
283283
assert(timecode != nullptr);
284284
memcpy(&art_time_code_.Frames, timecode, sizeof(struct artnet::TimeCode));
285-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&art_time_code_), sizeof(struct artnet::ArtTimeCode), node_.ip_timecode, artnet::kUdpPort);
285+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&art_time_code_), sizeof(struct artnet::ArtTimeCode), node_.ip_timecode, artnet::kUdpPort);
286286
}
287287

288288
void SetArtTimeCodeCallbackFunction(ArtTimeCodeCallbackFunctionPtr art_time_code_callback_function_ptr)

lib-artnet/include/artnetnode_inline_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ inline void ArtNetNode::SendDiag([[maybe_unused]] const artnet::PriorityCodes kP
408408

409409
const uint16_t kSize = sizeof(struct artnet::ArtDiagData) - sizeof(diag_data_.data) + diag_data_.LengthLo;
410410

411-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&diag_data_), kSize, state_.art.diag_ip, artnet::kUdpPort);
411+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&diag_data_), kSize, state_.art.diag_ip, artnet::kUdpPort);
412412
#endif
413413
}
414414

lib-artnet/src/controller/artnetcontroller.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ArtNetController::ArtNetController()
8282
art_poll_reply_.Style = static_cast<uint8_t>(StyleCode::kServer);
8383
network::iface::CopyMacAddressTo(art_poll_reply_.MAC);
8484
art_poll_reply_.bind_index = 1;
85-
ip.u32 = net::GetPrimaryIp();
85+
ip.u32 = network::GetPrimaryIp();
8686
memcpy(art_poll_reply_.IPAddress, ip.u8, sizeof(art_poll_reply_.IPAddress));
8787
#if (ARTNET_VERSION >= 4)
8888
memcpy(art_poll_reply_.BindIp, ip.u8, sizeof(art_poll_reply_.BindIp));
@@ -244,10 +244,10 @@ void ArtNetController::Start()
244244
DEBUG_ENTRY();
245245

246246
assert(handle_ == -1);
247-
handle_ = net::udp::Begin(artnet::kUdpPort, StaticCallbackFunction);
247+
handle_ = network::udp::Begin(artnet::kUdpPort, StaticCallbackFunction);
248248
assert(handle_ != -1);
249249

250-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&m_ArtNetPoll), sizeof(struct ArtPoll), net::GetBroadcastIp(), artnet::kUdpPort);
250+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&m_ArtNetPoll), sizeof(struct ArtPoll), network::GetBroadcastIp(), artnet::kUdpPort);
251251

252252
state_.status = artnet::Status::kOn;
253253

@@ -260,7 +260,7 @@ void ArtNetController::Stop()
260260

261261
// FIXME ArtNetController::Stop
262262
//
263-
// net::udp::End(artnet::UDP_PORT);
263+
// network::udp::End(artnet::UDP_PORT);
264264
// handle_ = -1;
265265
//
266266
// state_.status = artnet::Status::OFF;
@@ -330,7 +330,7 @@ void ArtNetController::HandleDmxOut(uint16_t nUniverse, const uint8_t* pDmxData,
330330
{
331331
for (uint32_t index = 0; index < count; index++)
332332
{
333-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtDmx), sizeof(struct ArtDmx), IpAddresses->pIpAddresses[index], artnet::kUdpPort);
333+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtDmx), sizeof(struct ArtDmx), IpAddresses->pIpAddresses[index], artnet::kUdpPort);
334334
}
335335

336336
m_bDmxHandled = true;
@@ -341,7 +341,7 @@ void ArtNetController::HandleDmxOut(uint16_t nUniverse, const uint8_t* pDmxData,
341341

342342
if (!m_bUnicast || (count > 40) || !m_bForceBroadcast)
343343
{
344-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtDmx), sizeof(struct ArtDmx), net::GetBroadcastIp(), artnet::kUdpPort);
344+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtDmx), sizeof(struct ArtDmx), network::GetBroadcastIp(), artnet::kUdpPort);
345345

346346
m_bDmxHandled = true;
347347
}
@@ -354,7 +354,7 @@ void ArtNetController::HandleSync()
354354
if (m_bSynchronization && m_bDmxHandled)
355355
{
356356
m_bDmxHandled = false;
357-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtSync), sizeof(struct ArtSync), net::GetBroadcastIp(), artnet::kUdpPort);
357+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtSync), sizeof(struct ArtSync), network::GetBroadcastIp(), artnet::kUdpPort);
358358
}
359359
}
360360

@@ -397,7 +397,7 @@ void ArtNetController::HandleBlackout()
397397

398398
for (uint32_t index = 0; index < count; index++)
399399
{
400-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtDmx), sizeof(struct ArtDmx), kIpAddresses->pIpAddresses[index],
400+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtDmx), sizeof(struct ArtDmx), kIpAddresses->pIpAddresses[index],
401401
artnet::kUdpPort);
402402
}
403403

@@ -415,7 +415,7 @@ void ArtNetController::HandleBlackout()
415415
m_pArtDmx->Sequence = 1;
416416
}
417417

418-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtDmx), sizeof(struct ArtDmx), net::GetBroadcastIp(), artnet::kUdpPort);
418+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(m_pArtDmx), sizeof(struct ArtDmx), network::GetBroadcastIp(), artnet::kUdpPort);
419419
}
420420
}
421421

@@ -436,7 +436,7 @@ void ArtNetController::ProcessPoll()
436436

437437
if (__builtin_expect((kCurrentMillis - m_nLastPollMillis > POLL_INTERVAL_MILLIS), 0))
438438
{
439-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&m_ArtNetPoll), sizeof(struct ArtPoll), net::GetBroadcastIp(), artnet::kUdpPort);
439+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&m_ArtNetPoll), sizeof(struct ArtPoll), network::GetBroadcastIp(), artnet::kUdpPort);
440440
m_nLastPollMillis = kCurrentMillis;
441441

442442
#ifndef NDEBUG
@@ -461,7 +461,7 @@ void ArtNetController::HandlePoll(const uint8_t* buffer, uint32_t from_ip)
461461
snprintf(reinterpret_cast<char*>(art_poll_reply->NodeReport), artnet::kReportLength, "#%04x [%u]", static_cast<int>(state_.reportcode),
462462
static_cast<unsigned>(state_.art.poll_reply_count++));
463463

464-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&art_poll_reply), sizeof(artnet::ArtPollReply), from_ip, artnet::kUdpPort);
464+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&art_poll_reply), sizeof(artnet::ArtPollReply), from_ip, artnet::kUdpPort);
465465

466466
DEBUG_EXIT();
467467
}
@@ -471,7 +471,7 @@ void ArtNetController::HandlePollReply(const uint8_t* buffer, uint32_t from_ip)
471471
DEBUG_ENTRY();
472472
DEBUG_PRINTF(IPSTR, IP2STR(from_ip));
473473

474-
if (from_ip != net::GetPrimaryIp())
474+
if (from_ip != network::GetPrimaryIp())
475475
{
476476
Add(reinterpret_cast<const artnet::ArtPollReply*>(buffer));
477477

lib-artnet/src/controller/artnetpolltable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "artnetpolltable.h"
3737
#include "hal.h"
3838
#include "hal_millis.h"
39-
#include "net/ip4_address.h"
39+
#include "ip4/ip4_address.h"
4040
#include "firmware/debug/debug_debug.h"
4141

4242
union uip

lib-artnet/src/controller/json_get_polltable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "artnetcontroller.h"
3131
#include "artnet.h"
32-
#include "net/ip4_address.h"
32+
#include "ip4/ip4_address.h"
3333

3434
namespace remoteconfig::artnet::controller
3535
{

lib-artnet/src/json/artnetparams.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "json/artnetparamsconst.h"
3535
#include "dmxnode_utils.h"
3636
#include "json/json_parser.h"
37-
#include "net/ip4_helpers.h"
37+
#include "ip4/ip4_helpers.h"
3838
#include "dmxnode.h"
3939
#include "configstore.h"
4040
#include "configurationstore.h"
@@ -75,7 +75,7 @@ void ArtNetParams::SetDestinationIpPort(const char* key, uint32_t key_len, const
7575

7676
if (val_len == 0)
7777
{
78-
store_dmxnode_.destination_ip[kIndex] = net::GetBroadcastIp();
78+
store_dmxnode_.destination_ip[kIndex] = network::GetBroadcastIp();
7979
}
8080
else
8181
{

lib-artnet/src/json/json_config_artnet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "json/artnetparams.h"
3131
#include "json/artnetparamsconst.h"
3232
#include "json/json_helpers.h"
33-
#include "net/ip4_helpers.h"
33+
#include "ip4/ip4_helpers.h"
3434

3535
namespace json::config
3636
{

lib-artnet/src/node/artnetnode.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ArtNetNode::ArtNetNode()
9898
SetLongName(nullptr); // Set default long name
9999

100100
memset(&node_, 0, sizeof(struct artnetnode::Node));
101-
node_.ip_timecode = net::GetBroadcastIp();
101+
node_.ip_timecode = network::GetBroadcastIp();
102102

103103
for (auto& port : node_.port)
104104
{
@@ -117,7 +117,7 @@ ArtNetNode::ArtNetNode()
117117
output_port_[port_index].source_b.physical = 0x100;
118118
output_port_[port_index].good_output_b = artnet::GoodOutputB::kRdmDisabled | artnet::GoodOutputB::kDiscoveryNotRunning;
119119
memset(&input_port_[port_index], 0, sizeof(struct artnetnode::InputPort));
120-
input_port_[port_index].destination_ip = net::GetBroadcastIp();
120+
input_port_[port_index].destination_ip = network::GetBroadcastIp();
121121
}
122122

123123
#if defined(ARTNET_HAVE_DMXIN)
@@ -183,7 +183,7 @@ void ArtNetNode::Start()
183183
art_poll_reply_.Status3 |= artnet::Status3::kOutputSwitch;
184184
#endif
185185

186-
handle_ = net::udp::Begin(artnet::kUdpPort, StaticCallbackFunction);
186+
handle_ = network::udp::Begin(artnet::kUdpPort, StaticCallbackFunction);
187187
assert(handle_ != -1);
188188

189189
#if defined(ARTNET_HAVE_DMXIN)
@@ -364,12 +364,12 @@ void ArtNetNode::SetLocalMerging()
364364
{
365365
if (!node_.port[output_port_index].local_merge)
366366
{
367-
output_port_[output_port_index].source_a.ip = net::IPADDR_LOOPBACK;
367+
output_port_[output_port_index].source_a.ip = network::IPADDR_LOOPBACK;
368368
DEBUG_PUTS("Local merge Source A");
369369
}
370370
else
371371
{
372-
output_port_[output_port_index].source_b.ip = net::IPADDR_LOOPBACK;
372+
output_port_[output_port_index].source_b.ip = network::IPADDR_LOOPBACK;
373373
DEBUG_PUTS("Local merge Source B");
374374
}
375375

@@ -738,7 +738,7 @@ void ArtNetNode::Print()
738738
printf(" Port %-2u %-4u", static_cast<unsigned int>(port_index), static_cast<unsigned int>(kUniverse));
739739
if (node_.port[port_index].protocol == artnet::PortProtocol::kArtnet)
740740
{
741-
const auto kDestinationIp = (input_port_[port_index].destination_ip == 0 ? net::GetBroadcastIp() : input_port_[port_index].destination_ip);
741+
const auto kDestinationIp = (input_port_[port_index].destination_ip == 0 ? network::GetBroadcastIp() : input_port_[port_index].destination_ip);
742742
printf(" -> " IPSTR, IP2STR(kDestinationIp));
743743
}
744744
#if (ARTNET_VERSION >= 4)

lib-artnet/src/node/artnetnodehandleipprog.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,25 @@ void ArtNetNode::HandleIpProg()
6262

6363
if ((kCommand & kCommandSetToDefault) == kCommandSetToDefault)
6464
{
65-
net::SetPrimaryIp(0);
65+
network::SetPrimaryIp(0);
6666
}
6767

6868
if ((kCommand & kCommandProgramIpaddress) == kCommandProgramIpaddress)
6969
{
7070
memcpy(ip.u8, &kPArtIpProg->prog_ip_hi, artnet::kIpSize);
71-
net::SetPrimaryIp(ip.u32);
71+
network::SetPrimaryIp(ip.u32);
7272
}
7373

7474
if ((kCommand & kCommandProgramSubnetmask) == kCommandProgramSubnetmask)
7575
{
7676
memcpy(ip.u8, &kPArtIpProg->prog_sm_hi, artnet::kIpSize);
77-
net::SetNetmask(ip.u32);
77+
network::SetNetmask(ip.u32);
7878
}
7979

8080
if ((kCommand & kCommandProgramGateway) == kCommandProgramGateway)
8181
{
8282
memcpy(ip.u8, &kPArtIpProg->prog_gw_hi, artnet::kIpSize);
83-
net::SetGatewayIp(ip.u32);
83+
network::SetGatewayIp(ip.u32);
8484
}
8585

8686
if ( network::iface::IsDhcpUsed())
@@ -96,22 +96,22 @@ void ArtNetNode::HandleIpProg()
9696

9797
auto is_changed = (kIsDhcp != network::iface::IsDhcpUsed());
9898

99-
ip.u32 = net::GetPrimaryIp();
99+
ip.u32 = network::GetPrimaryIp();
100100
is_changed |= (memcmp(&kPArtIpProg->prog_ip_hi, ip.u8, artnet::kIpSize) != 0);
101101
memcpy(&reply->prog_ip_hi, ip.u8, artnet::kIpSize);
102102

103-
ip.u32 = net::GetNetmask();
103+
ip.u32 = network::GetNetmask();
104104
is_changed |= (memcmp(&kPArtIpProg->prog_sm_hi, ip.u8, artnet::kIpSize) != 0);
105105
memcpy(&reply->prog_sm_hi, ip.u8, artnet::kIpSize);
106106

107-
ip.u32 = net::GetGatewayIp();
107+
ip.u32 = network::GetGatewayIp();
108108
is_changed |= (memcmp(&kPArtIpProg->prog_gw_hi, ip.u8, artnet::kIpSize) != 0);
109109
memcpy(&reply->prog_gw_hi, ip.u8, artnet::kIpSize);
110110

111111
reply->spare7 = 0;
112112
reply->spare8 = 0;
113113

114-
net::udp::Send(handle_, receive_buffer_, sizeof(struct artnet::ArtIpProgReply), ip_address_from_, artnet::kUdpPort);
114+
network::udp::Send(handle_, receive_buffer_, sizeof(struct artnet::ArtIpProgReply), ip_address_from_, artnet::kUdpPort);
115115

116116
if (is_changed)
117117
{

lib-artnet/src/node/artnetnodehandlepoll.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void ArtNetNode::ProcessPollReply(uint32_t port_index, [[maybe_unused]] uint32_t
193193

194194
void ArtNetNode::SendPollReply(uint32_t port_index, uint32_t destination_ip, artnet::ArtPollQueue* queue)
195195
{
196-
ip.u32 = net::GetPrimaryIp();
196+
ip.u32 = network::GetPrimaryIp();
197197
memcpy(art_poll_reply_.IPAddress, ip.u8, sizeof(art_poll_reply_.IPAddress));
198198
#if (ARTNET_VERSION >= 4)
199199
memcpy(art_poll_reply_.BindIp, ip.u8, sizeof(art_poll_reply_.BindIp));
@@ -242,7 +242,7 @@ void ArtNetNode::SendPollReply(uint32_t port_index, uint32_t destination_ip, art
242242
}
243243

244244
CreateNodeReport(art_poll_reply_.NodeReport, state_.report_code, state_.art.poll_reply_count);
245-
net::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&art_poll_reply_), sizeof(artnet::ArtPollReply), destination_ip, artnet::kUdpPort);
245+
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&art_poll_reply_), sizeof(artnet::ArtPollReply), destination_ip, artnet::kUdpPort);
246246
}
247247

248248
state_.is_changed = false;
@@ -266,7 +266,7 @@ void ArtNetNode::HandlePoll()
266266
else if (!state_.is_multiple_controllers_req_diag && (state_.art.poll_ip != ip_address_from_))
267267
{
268268
// If there are multiple controllers requesting diagnostics, diagnostics shall be broadcast.
269-
state_.art.diag_ip = net::GetBroadcastIp();
269+
state_.art.diag_ip = network::GetBroadcastIp();
270270
state_.is_multiple_controllers_req_diag = true;
271271
}
272272

@@ -287,7 +287,7 @@ void ArtNetNode::HandlePoll()
287287
}
288288
else
289289
{
290-
state_.art.diag_ip = net::GetBroadcastIp();
290+
state_.art.diag_ip = network::GetBroadcastIp();
291291
}
292292
}
293293
else

0 commit comments

Comments
 (0)