OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Private Attributes | List of all members
OpenDDS::RTPS::Spdp::SendStun Class Reference
Inheritance diagram for OpenDDS::RTPS::Spdp::SendStun:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::RTPS::Spdp::SendStun:
Collaboration graph
[legend]

Public Member Functions

 SendStun (const DCPS::RcHandle< SpdpTransport > &tport, const ACE_INET_Addr &address, const STUN::Message &message)
 
void execute ()
 
- Public Member Functions inherited from OpenDDS::DCPS::Job
virtual ~Job ()
 
- Public Member Functions inherited from OpenDDS::DCPS::RcObject
virtual ~RcObject ()
 
virtual void _add_ref ()
 
virtual void _remove_ref ()
 
long ref_count () const
 
WeakObject_get_weak_object () const
 

Private Attributes

DCPS::WeakRcHandle< SpdpTransporttport_
 
ACE_INET_Addr address_
 
STUN::Message message_
 

Additional Inherited Members

- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 

Detailed Description

Definition at line 559 of file Spdp.h.

Constructor & Destructor Documentation

◆ SendStun()

OpenDDS::RTPS::Spdp::SendStun::SendStun ( const DCPS::RcHandle< SpdpTransport > &  tport,
const ACE_INET_Addr address,
const STUN::Message message 
)
inline

Definition at line 561 of file Spdp.h.

564  : tport_(tport)
565  , address_(address)
566  , message_(message)
567  {}
ACE_INET_Addr address_
Definition: Spdp.h:571
STUN::Message message_
Definition: Spdp.h:572
DCPS::WeakRcHandle< SpdpTransport > tport_
Definition: Spdp.h:570

Member Function Documentation

◆ execute()

void OpenDDS::RTPS::Spdp::SendStun::execute ( void  )
virtual

Implements OpenDDS::DCPS::Job.

Definition at line 3302 of file Spdp.cpp.

References ACE_ERROR, ACE_GUARD, ACE_TEXT(), OpenDDS::DCPS::DCPS_debug_level, OpenDDS::STUN::encoding(), ENETUNREACH, if(), LM_WARNING, OpenDDS::DCPS::MCK_STUN, OpenDDS::DCPS::RcHandle< T >::reset(), ACE_SOCK_Dgram::send(), socket(), and OpenDDS::RTPS::Spdp::tport_.

3303 {
3304  DCPS::RcHandle<SpdpTransport> tport = tport_.lock();
3305  if (!tport) return;
3306 
3307  DCPS::RcHandle<Spdp> outer = tport->outer_.lock();
3308  if (!outer) return;
3309 
3310  ACE_GUARD(ACE_Thread_Mutex, g, outer->lock_);
3311  tport->wbuff_.reset();
3312  Serializer serializer(&tport->wbuff_, STUN::encoding);
3313  const_cast<STUN::Message&>(message_).block = &tport->wbuff_;
3314  serializer << message_;
3315 
3316 #ifdef OPENDDS_TESTING_FEATURES
3317  if (outer->sedp_->transport_inst()->should_drop(tport->wbuff_.length())) {
3318  return;
3319  }
3320 #endif
3321 
3322  const ACE_SOCK_Dgram& socket = tport->choose_send_socket(address_);
3323  const ssize_t res = socket.send(tport->wbuff_.rd_ptr(), tport->wbuff_.length(), address_);
3324  if (res < 0) {
3325  if (outer->sedp_->transport_inst()->count_messages()) {
3326  // Have the lock.
3327  const DCPS::InternalMessageCountKey key(DCPS::NetworkAddress(address_), DCPS::MCK_STUN, address_ == outer->config_->spdp_stun_server_address());
3328  tport->transport_statistics_.message_count[key].send_fail(tport->wbuff_.length());
3329  }
3330  const int err = errno;
3331  if (err != ENETUNREACH || !tport->network_is_unreachable_) {
3332  errno = err;
3333  if (DCPS::DCPS_debug_level > 0) {
3334  ACE_ERROR((LM_WARNING,
3335  ACE_TEXT("(%P|%t) WARNING: Spdp::SendStun::execute() - ")
3336  ACE_TEXT("destination %C failed send: %m\n"), DCPS::LogAddr(address_).c_str()));
3337  }
3338  }
3339  if (err == ENETUNREACH) {
3340  tport->network_is_unreachable_ = true;
3341  }
3342  } else {
3343  if (outer->sedp_->transport_inst()->count_messages()) {
3344  // Have the lock.
3345  const DCPS::InternalMessageCountKey key(DCPS::NetworkAddress(address_), DCPS::MCK_STUN, address_ == outer->config_->spdp_stun_server_address());
3346  tport->transport_statistics_.message_count[key].send(tport->wbuff_.length());
3347  }
3348  tport->network_is_unreachable_ = false;
3349  }
3350 }
#define ACE_ERROR(X)
#define ACE_GUARD(MUTEX, OBJ, LOCK)
if(!(yy_init))
sequence< octet > key
int ssize_t
const MessageCountKind MCK_STUN
ACE_HANDLE socket(int protocol_family, int type, int proto)
ACE_INET_Addr address_
Definition: Spdp.h:571
ACE_TEXT("TCP_Factory")
STUN::Message message_
Definition: Spdp.h:572
DCPS::WeakRcHandle< SpdpTransport > tport_
Definition: Spdp.h:570
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_thread_mutex_t lock_
const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_BIG)
ssize_t send(const void *buf, size_t n, const ACE_Addr &addr, int flags=0) const

Member Data Documentation

◆ address_

ACE_INET_Addr OpenDDS::RTPS::Spdp::SendStun::address_
private

Definition at line 571 of file Spdp.h.

◆ message_

STUN::Message OpenDDS::RTPS::Spdp::SendStun::message_
private

Definition at line 572 of file Spdp.h.

◆ tport_

DCPS::WeakRcHandle<SpdpTransport> OpenDDS::RTPS::Spdp::SendStun::tport_
private

Definition at line 570 of file Spdp.h.


The documentation for this class was generated from the following files: