ECG_UDP_Out_Endpoint.cpp

Go to the documentation of this file.
00001 // ECG_UDP_Out_Endpoint.cpp,v 1.7 2006/03/14 06:14:25 jtc Exp
00002 
00003 #include "orbsvcs/Event/ECG_UDP_Out_Endpoint.h"
00004 #include "ace/INET_Addr.h"
00005 #include "ace/Sock_Connect.h"
00006 
00007 #if !defined(__ACE_INLINE__)
00008 #include "orbsvcs/Event/ECG_UDP_Out_Endpoint.i"
00009 #endif /* __ACE_INLINE__ */
00010 
00011 ACE_RCSID(Event, ECG_UDP_Out_Endpoint, "ECG_UDP_Out_Endpoint.cpp,v 1.7 2006/03/14 06:14:25 jtc Exp")
00012 
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014 
00015 TAO_ECG_UDP_Out_Endpoint::~TAO_ECG_UDP_Out_Endpoint (void)
00016 {
00017   this->dgram_.close ();
00018 
00019   delete [] this->ifs_;
00020 }
00021 
00022 CORBA::Boolean
00023 TAO_ECG_UDP_Out_Endpoint::is_loopback (const ACE_INET_Addr& from)
00024 {
00025   if (this->port_number_ == 0)
00026     {
00027       // Cache the port number...
00028       ACE_INET_Addr local_addr;
00029       if (this->dgram ().get_local_addr (local_addr) == -1)
00030         return 0;
00031       this->port_number_ = local_addr.get_port_number ();
00032     }
00033 
00034   // Most of the time the port number is enough to determine if the
00035   // message is remote, only when the local port number and the remote
00036   // port number match we have to look at the local ip addresses.
00037   if (from.get_port_number () != this->port_number_)
00038     return 0;
00039 
00040   if (this->ifs_ == 0)
00041     {
00042       ACE::get_ip_interfaces (this->if_count_, this->ifs_);
00043     }
00044 
00045   for (ACE_INET_Addr* i = this->ifs_;
00046        i != this->ifs_ + this->if_count_;
00047        ++i)
00048     {
00049       if ((*i).get_ip_address () == from.get_ip_address ())
00050         return 1;
00051     }
00052   return 0;
00053 }
00054 
00055 TAO_ECG_UDP_Out_Endpoint&
00056 TAO_ECG_UDP_Out_Endpoint::operator= (const TAO_ECG_UDP_Out_Endpoint& rhs)
00057 {
00058   if (this != &rhs)
00059     {
00060       this->request_id_generator_ = rhs.request_id_generator_;
00061       this->dgram_ = rhs.dgram_;
00062       this->port_number_ = rhs.port_number_;
00063       this->if_count_ = rhs.if_count_;
00064 
00065       delete [] this->ifs_;
00066       this->ifs_ = 0;
00067 
00068       if (this->if_count_ != 0)
00069         {
00070           ACE_NEW_RETURN (this->ifs_,
00071                           ACE_INET_Addr [this->if_count_],
00072                           *this);
00073           for(size_t i = 0; i < this->if_count_; ++i)
00074             {
00075               this->ifs_[i] = rhs.ifs_[i];
00076             }
00077         }
00078     }
00079 
00080   return *this;
00081 }
00082 
00083 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:11:11 2006 for TAO_RTEvent by doxygen 1.3.6