Skip to content

Commit

Permalink
return string empty if not found address
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmorato committed Jun 27, 2024
1 parent e1f57ed commit 124dfa1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
20 changes: 11 additions & 9 deletions Native/OpenDDSWrapper/MulticastInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ void MulticastInst_SetPortOffset(::OpenDDS::DCPS::MulticastInst *mi, CORBA::USho

char *MulticastInst_GetGroupAddress(::OpenDDS::DCPS::MulticastInst *mi) {
const char* addr_str = ::OpenDDS::DCPS::LogAddr(mi->group_address_.get()).c_str();

if (addr_str == NULL) {
return CORBA::string_dup("");
}
return CORBA::string_dup(addr_str);
}

void MulticastInst_SetGroupAddress(::OpenDDS::DCPS::MulticastInst *mi, char *value) {
const ::OpenDDS::DCPS::NetworkAddress * addr_obj = new ::OpenDDS::DCPS::NetworkAddress(value);
mi->group_address(*addr_obj);
const ::OpenDDS::DCPS::NetworkAddress addr_obj(value);
mi->group_address(addr_obj);
}

char *MulticastInst_GetLocalAddress(::OpenDDS::DCPS::MulticastInst *mi) {
Expand All @@ -77,7 +79,7 @@ void MulticastInst_SetLocalAddress(::OpenDDS::DCPS::MulticastInst *mi, char *val
}

CORBA::Double MulticastInst_GetSynBackoff(::OpenDDS::DCPS::MulticastInst *mi) {
return mi->syn_backoff_;
return mi->syn_backoff_.get();
}

void MulticastInst_SetSynBackoff(::OpenDDS::DCPS::MulticastInst *mi, CORBA::Double value) {
Expand All @@ -101,7 +103,7 @@ void MulticastInst_SetSynTimeout(::OpenDDS::DCPS::MulticastInst *mi, TimeValueWr
}

size_t MulticastInst_GetNakDepth(::OpenDDS::DCPS::MulticastInst *mi) {
return mi->nak_depth_;
return mi->nak_depth_.get();
}

void MulticastInst_SetNakDepth(::OpenDDS::DCPS::MulticastInst *mi, size_t value) {
Expand All @@ -117,15 +119,15 @@ void MulticastInst_SetNakInterval(::OpenDDS::DCPS::MulticastInst *mi, TimeValueW
}

size_t MulticastInst_GetNakDelayIntervals(::OpenDDS::DCPS::MulticastInst *mi) {
return mi->nak_delay_intervals_;
return mi->nak_delay_intervals_.get();
}

void MulticastInst_SetNakDelayIntervals(::OpenDDS::DCPS::MulticastInst *mi, size_t value) {
mi->nak_delay_intervals_ = value;
}

size_t MulticastInst_GetNakMax(::OpenDDS::DCPS::MulticastInst *mi) {
return mi->nak_max_;
return mi->nak_max_.get();
}

void MulticastInst_SetNakMax(::OpenDDS::DCPS::MulticastInst *mi, size_t value) {
Expand All @@ -141,15 +143,15 @@ void MulticastInst_SetNakTimeout(::OpenDDS::DCPS::MulticastInst *mi, TimeValueWr
}

CORBA::Octet MulticastInst_GetTtl(::OpenDDS::DCPS::MulticastInst *mi) {
return mi->ttl_;
return mi->ttl_.get();
}

void MulticastInst_SetTtl(::OpenDDS::DCPS::MulticastInst *mi, CORBA::Octet value) {
mi->ttl_ = value;
}

size_t MulticastInst_GetRcvBufferSize(::OpenDDS::DCPS::MulticastInst *mi) {
return mi->rcv_buffer_size_;
return mi->rcv_buffer_size_.get();
}

void MulticastInst_SetRcvBufferSize(::OpenDDS::DCPS::MulticastInst *mi, size_t value) {
Expand Down
9 changes: 4 additions & 5 deletions Native/OpenDDSWrapper/RtpsDiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ ::OpenDDS::RTPS::RtpsDiscovery *RtpsDiscovery_new(const char *key) {
}

TimeValueWrapper RtpsDiscovery_GetResendPeriod(::OpenDDS::RTPS::RtpsDiscovery *d) {
::OpenDDS::DCPS::TimeDuration td = d->resend_period();
return td;
return d->resend_period();
}

void RtpsDiscovery_SetResendPeriod(::OpenDDS::RTPS::RtpsDiscovery *d, TimeValueWrapper value) {
Expand Down Expand Up @@ -102,7 +101,7 @@ char *RtpsDiscovery_GetSedpLocalAddress(::OpenDDS::RTPS::RtpsDiscovery *d) {
}

void RtpsDiscovery_SetSedpLocalAddress(::OpenDDS::RTPS::RtpsDiscovery *d, char *value) {
const ::OpenDDS::DCPS::NetworkAddress addr = static_cast<const ::OpenDDS::DCPS::NetworkAddress>(value);
const ::OpenDDS::DCPS::NetworkAddress addr(value);
d->sedp_local_address(addr);
}

Expand All @@ -116,7 +115,7 @@ char *RtpsDiscovery_GetSpdpLocalAddress(::OpenDDS::RTPS::RtpsDiscovery *d) {
}

void RtpsDiscovery_SetSpdpLocalAddress(::OpenDDS::RTPS::RtpsDiscovery *d, char *value) {
const ::OpenDDS::DCPS::NetworkAddress addr = static_cast<const ::OpenDDS::DCPS::NetworkAddress>(value);
const ::OpenDDS::DCPS::NetworkAddress addr(value);
d->spdp_local_address(addr);
}

Expand Down Expand Up @@ -146,7 +145,7 @@ char *RtpsDiscovery_GetDefaultMulticastGroup(::OpenDDS::RTPS::RtpsDiscovery *d,
}

void RtpsDiscovery_SetDefaultMulticastGroup(::OpenDDS::RTPS::RtpsDiscovery *d, char *value) {
const ::OpenDDS::DCPS::NetworkAddress addr = static_cast<const ::OpenDDS::DCPS::NetworkAddress>(value);
const ::OpenDDS::DCPS::NetworkAddress addr(value);
d->default_multicast_group(addr);
}

Expand Down
11 changes: 8 additions & 3 deletions Native/OpenDDSWrapper/RtpsUdpInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,15 @@ void RtpsUdpInst_SetTtl(::OpenDDS::DCPS::RtpsUdpInst *ri, CORBA::Octet value) {

char *RtpsUdpInst_GetMulticastGroupAddress(::OpenDDS::DCPS::RtpsUdpInst *ri, int domain_id) {
const char* addr_str = ::OpenDDS::DCPS::LogAddr(ri->multicast_group_address(domain_id)).c_str();
if (addr_str == NULL) {
return CORBA::string_dup("");
}

return CORBA::string_dup(addr_str);
}

void RtpsUdpInst_SetMulticastGroupAddress(::OpenDDS::DCPS::RtpsUdpInst *ri, char *value) {
const OpenDDS::DCPS::NetworkAddress addr = static_cast<const OpenDDS::DCPS::NetworkAddress>(value);
const OpenDDS::DCPS::NetworkAddress addr(value);
ri->multicast_group_address(addr);
}

Expand All @@ -97,12 +100,14 @@ void RtpsUdpInst_SetMulticastInterface(::OpenDDS::DCPS::RtpsUdpInst *ri, char *v

char *RtpsUdpInst_GetLocalAddress(::OpenDDS::DCPS::RtpsUdpInst *ri) {
const char* addr_str = ::OpenDDS::DCPS::LogAddr(ri->local_address()).c_str();

if (addr_str == NULL) {
return CORBA::string_dup("");
}
return CORBA::string_dup(addr_str);
}

void RtpsUdpInst_SetLocalAddress(::OpenDDS::DCPS::RtpsUdpInst *ri, char *value) {
const OpenDDS::DCPS::NetworkAddress addr = static_cast<const OpenDDS::DCPS::NetworkAddress>(value);
const OpenDDS::DCPS::NetworkAddress addr(value);
ri->local_address(addr);
}

Expand Down
12 changes: 11 additions & 1 deletion Tests/OpenDDSharp.UnitTest/MulticastInstTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,17 @@ public void TestNonDefaultValues()
Assert.IsNotNull(mi.SynTimeout);
Assert.AreEqual(10, mi.SynTimeout.Seconds);
Assert.AreEqual(500000, mi.SynTimeout.MicroSeconds);
Assert.IsTrue(mi.AsyncSend);

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Assert.IsTrue(mi.AsyncSend);
}
else
{
// AsyncSend is not supported on Unix platforms and should always be false.
Assert.IsFalse(mi.AsyncSend);
}

Assert.AreEqual(2, mi.Ttl);
Assert.AreEqual(64U, mi.DatalinkControlChunks);
Assert.AreEqual(20000, mi.DatalinkReleaseDelay);
Expand Down

0 comments on commit 124dfa1

Please sign in to comment.