ECG_UDP_Out_Endpoint.cpp

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

Generated on Tue Feb 2 17:44:06 2010 for TAO_RTEvent by  doxygen 1.4.7