本文整理汇总了C++中ACE_INET_Addr::get_ip_address方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_INET_Addr::get_ip_address方法的具体用法?C++ ACE_INET_Addr::get_ip_address怎么用?C++ ACE_INET_Addr::get_ip_address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_INET_Addr
的用法示例。
在下文中一共展示了ACE_INET_Addr::get_ip_address方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsIPAddrInNetwork
bool IsIPAddrInNetwork(ACE_INET_Addr const& net, ACE_INET_Addr const& addr, ACE_INET_Addr const& subnetMask)
{
uint32 mask = subnetMask.get_ip_address();
if ((net.get_ip_address() & mask) == (addr.get_ip_address() & mask))
return true;
return false;
}
示例2: validate_connection
int CACETrbNetAcceptorImpl::validate_connection(
const TRB_Asynch_Accept::Result& result,
const ACE_INET_Addr& remote,
const ACE_INET_Addr& local)
{
SInetAddress remote1;
SInetAddress local1;
local1.ip = local.get_ip_address();
local1.port = local.get_port_number();
remote1.ip = remote.get_ip_address();
remote1.port = remote.get_port_number();
INetAcceptor* acceptor = getAcceptor();
if (!acceptor)
{
return -1;
}
//to check and block ip
if (!acceptor->onCheckAddress(local1, remote1))
{
return -1;
}
return 0;
}
示例3: DeviceProxy
// static
DeviceProxy *
DeviceProxy::check_hello_and_create( ACE_Message_Block * mb
, const ACE_INET_Addr& from_addr
, Task * task )
{
adportable::protocol::LifeCycleData data;
adportable::protocol::LifeCycleFrame frame;
if ( acewrapper::lifecycle_frame_serializer::unpack( mb, frame, data ) ) {
try {
using namespace adportable::protocol;
LifeCycle_Hello& hello = boost::get< LifeCycle_Hello& >(data);
ACE_INET_Addr addr;
addr.string_to_addr( hello.ipaddr_.c_str() );
if ( addr.get_ip_address() == 0 ) {
addr = from_addr;
addr.set_port_number( hello.portnumber_ );
DeviceProxy * p = new DeviceProxy( addr, task );
p->initialize_dgram();
p->handle_lifecycle_mcast( frame, data );
#if defined _DEBUG
// std::wstring key = adportable::string::convert( acewrapper::string( from_addr ) );
std::wstring text = adportable::string::convert( LifeCycleHelper::to_string( data ) );
task->dispatch_debug( text, p->name() );
#endif
return p; // error should be handled by caller
}
} catch ( std::bad_cast& ) {
}
}
return 0;
}
示例4:
int
ACE_MEM_Addr::same_host (const ACE_INET_Addr &sap)
{
ACE_TRACE ("ACE_MEM_Addr::same_host");
return this->external_.get_ip_address () ==
sap.get_ip_address ();
}
示例5: handle_input
/**
* Receiver::handle_input()
*
* Description:
* Called when input is available
*/
int Receiver::handle_input() {
if (connected_) {
// TODO: Check if really needed! (Try not to read all data from socket)
Miro::Guard guard(mutex_); /* needed for timeout handling */
CORBA::ULong header[HEADER_SIZE / sizeof(CORBA::ULong) + ACE_CDR::MAX_ALIGNMENT];
EventData eventData;
iovec iov[1];
ACE_INET_Addr from;
switch (receiveData(iov, from)) {
case -1:
PRINT_DBG(DBG_INFO, "handleInput: read");
return -1;
case 0:
PRINT_DBG(DBG_INFO, "handleInput: read 0");
return 0;
default:
/* fall through */
break;
}
/* Check if paket was sent locally and if so, drop it */
if (is_loopback(from))
return 0;
//#if DEBUG_LEVEL == DBG_TOOMUCH
struct in_addr ia;
ia.s_addr = htonl(from.get_ip_address());
PRINT("Datagram from " << inet_ntoa(ia) << ":" << from.get_port_number());
//#endif
/* Process packet */
memcpy(header, ((char *)iov[0].iov_base ), sizeof(header));
char *buf = ACE_reinterpret_cast(char *, header);
TAO_InputCDR headerCdr(buf, sizeof(header), (int)buf[0]);
eventData.systemTimestamp = ACE_OS::gettimeofday().msec();
headerCdr.read_boolean(eventData.byteOrder);
headerCdr.read_ulong(eventData.requestId);
headerCdr.read_ulong(eventData.requestSize);
headerCdr.read_ulong(eventData.fragmentSize);
headerCdr.read_ulong(eventData.fragmentOffset);
headerCdr.read_ulong(eventData.fragmentId);
headerCdr.read_ulong(eventData.fragmentCount);
headerCdr.read_ulong(eventData.timestamp);
cout << "test" << endl;
handle_event(eventData, iov);
}
return 0;
}
示例6:
void
TAO_UIPMC_Endpoint::object_addr (const ACE_INET_Addr &addr)
{
this->port_ = addr.get_port_number();
char tmp[INET6_ADDRSTRLEN];
addr.get_host_addr (tmp, sizeof tmp);
this->host_ = CORBA::string_dup (tmp);
this->object_addr_.set (addr);
this->uint_ip_addr (addr.get_ip_address ());
}
示例7:
int
ACE_MEM_Addr::same_host (const ACE_INET_Addr &sap)
{
ACE_TRACE ("ACE_MEM_Addr::same_host");
ACE_UINT32 me = this->external_.get_ip_address ();
ACE_UINT32 you = sap.get_ip_address ();
return me == you;
}
示例8: send
int HDS_UDP_EXPORT_API send(ACE_Message_Block * block , ACE_INET_Addr& ace_addr ,
HDS_UDP_SENDED_DEL_TYPE del_type)
{
SOCKADDR_IN remoteAddr;
remoteAddr.sin_family=AF_INET; //这个值对以后会有影响
remoteAddr.sin_addr.s_addr=htonl(ace_addr.get_ip_address());// ace_remoteAddr.get_ip_address();
remoteAddr.sin_port=htons(ace_addr.get_port_number());//ace_remoteAddr.get_port_number();
int res = kernel_send(block->rd_ptr(),block->length(),0,(sockaddr*)&remoteAddr,sizeof(SOCKADDR_IN));
if(del_type == DELETE_AFTER_SEND)
{
block->release();
}
return res;
}
示例9: make_connect
//************************************
// Method: connect
// FullName: PeerConnector::connect
// Access: public
// Returns: void
// Qualifier: 此方法将remote_addr_作为主键,mb_作为值压入map_中。
// Parameter: ACE_INET_Addr &remote_addr_
// Parameter: ACE_Message_Block *mb_
//************************************
int PeerConnector::make_connect(PeerID peerId, ACE_INET_Addr &remote_addr_,ACE_Message_Block *mb_ )
{
ACE_Guard<ACE_Thread_Mutex> guard(mutex_);
PeerInfoPtr pinfo = new PeerInfo();
pinfo->peerId_ = peerId;
pinfo->address_ = remote_addr_.get_ip_address();
pinfo->mb_ = mb_;
map_.insert(map<ACE_UINT32,PeerInfoPtr>::value_type(pinfo->address_,pinfo));
int iret =connect(remote_addr_);
if(iret != 0)
{
iret = ACE_OS::last_error();
}
return iret;
}
示例10: time
/*virtual*/ int BufferedSocket::open(void* arg)
{
if (Base::open(arg) == -1)
return -1;
ACE_INET_Addr addr;
if (peer().get_remote_addr(addr) == -1)
return -1;
// <anti DDoS> by boxa
uint32 uintAddr = addr.get_ip_address();
if (!uintAddr)
return -1;
time_t currTime = time(NULL);
if (!sIpListStorage.empty())
{
// first del expired records
for (TIpList::iterator itr = sIpListStorage.begin(); itr != sIpListStorage.end();)
{
if (itr->second < currTime)
sIpListStorage.erase(itr++);
else
++itr;
}
// then search current connected ip
TIpList::const_iterator itr = sIpListStorage.find(uintAddr);
if (itr != sIpListStorage.end())
return -1;
}
// add new ip addr into ip list
sIpListStorage[uintAddr] = currTime;
// </anti DDoS>
char address[1024];
addr.get_host_addr(address, 1024);
this->remote_address_ = address;
this->OnAccept();
return 0;
}
示例11: defined
int
ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr (ip_mreq *ret_mreq,
const ACE_INET_Addr &mcast_addr,
const ACE_TCHAR *net_if)
{
ACE_TRACE ("ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr");
ip_mreq lmreq; // Scratch copy.
if (net_if != 0)
{
#if defined (ACE_WIN32) || defined(__INTERIX)
// This port number is not necessary, just convenient
ACE_INET_Addr interface_addr;
if (interface_addr.set (mcast_addr.get_port_number (), net_if) == -1)
return -1;
lmreq.imr_interface.s_addr =
ACE_HTONL (interface_addr.get_ip_address ());
#else
ifreq if_address;
#if defined (ACE_PSOS)
// Look up the interface by number, not name.
if_address.ifr_ifno = ACE_OS::atoi (net_if);
#else
ACE_OS::strcpy (if_address.ifr_name, ACE_TEXT_ALWAYS_CHAR (net_if));
#endif /* defined (ACE_PSOS) */
if (ACE_OS::ioctl (this->get_handle (),
SIOCGIFADDR,
&if_address) == -1)
return -1;
sockaddr_in *socket_address;
socket_address = reinterpret_cast<sockaddr_in*> (&if_address.ifr_addr);
lmreq.imr_interface.s_addr = socket_address->sin_addr.s_addr;
#endif /* ACE_WIN32 || __INTERIX */
}
else
lmreq.imr_interface.s_addr = INADDR_ANY;
lmreq.IMR_MULTIADDR.s_addr = ACE_HTONL (mcast_addr.get_ip_address ());
// Set return info, if requested.
if (ret_mreq)
*ret_mreq = lmreq;
return 0;
}
示例12: addr_str
int
TAO_AV_SCTP_SEQ_Base_Acceptor::acceptor_open (TAO_AV_SCTP_SEQ_Acceptor *acceptor,
ACE_Reactor *reactor,
const ACE_INET_Addr &local_addr,
TAO_FlowSpec_Entry *entry)
{
ORBSVCS_DEBUG ((LM_DEBUG,
"In base acceptor open"));
this->acceptor_ = acceptor;
this->reactor_ = reactor;
this->entry_ = entry;
ACE_Auto_Array_Ptr<ACE_UINT32> local_ip_addr
(new ACE_UINT32[entry->num_local_sec_addrs ()]);
ACE_INET_Addr ip_addr;
char** addrs = entry->get_local_sec_addr ();
for (int i = 0; i < entry->num_local_sec_addrs (); i++)
{
ACE_CString addr_str (addrs[i]);
addr_str += ":";
ip_addr.set (addr_str.c_str ());
local_ip_addr[i] = ip_addr.get_ip_address ();
}
ACE_Multihomed_INET_Addr multi_addr;
multi_addr.set (local_addr.get_port_number (),
local_addr.get_ip_address (),
1,
local_ip_addr.get(),
entry->num_local_sec_addrs ());
char buf[BUFSIZ];
multi_addr.addr_to_string (buf, BUFSIZ);
if (TAO_debug_level > 0)
ORBSVCS_DEBUG ((LM_DEBUG,
"TAO_AV_SCTP_SEQ_Base_Acceptor::open: %s",
buf));
if (this->open (multi_addr,reactor) < 0)
ORBSVCS_ERROR_RETURN ((LM_ERROR,"TAO_AV_SCTP_SEQ_Base_Acceptor::open failed\n"),-1);
return 0;
}
示例13: defined
SimpleAddressServer::SimpleAddressServer (const ACE_INET_Addr& address) {
#if defined (ACE_HAS_IPV6)
if (address.get_type() == PF_INET6)
{
RtecUDPAdmin::UDP_Addr_v6 v6;
sockaddr_in6 *in6 =
reinterpret_cast<sockaddr_in6 *>(address.get_addr());
ACE_OS::memcpy (v6.ipaddr,&in6->sin6_addr,16);
v6.port = address.get_port_number();
this->address_.v6_addr (v6);
return;
}
#endif /* ACE_HAS_IPV6 */
RtecUDPAdmin::UDP_Addr v4;
v4.ipaddr = address.get_ip_address ();
v4.port = address.get_port_number ();
this->address_.v4_addr (v4);
}
示例14: start_sender
int HDS_UDP_EXPORT_API R_Send(
char *block,
unsigned int length,
ACE_INET_Addr & ace_addr,
Connection_ID&con_id,
HDS_UDP_SENDED_DEL_TYPE del_type,
HDS_UDP_Sender_Handler handler,
unsigned long defaultSSTHRESH,
unsigned long maxWindowSize)
{
SOCKADDR_IN remoteAddr;
remoteAddr.sin_family=AF_INET; //这个值对以后会有影响
remoteAddr.sin_addr.s_addr=htonl(ace_addr.get_ip_address());// ace_remoteAddr.get_ip_address();
remoteAddr.sin_port=htons(ace_addr.get_port_number());//ace_remoteAddr.get_port_number();
return connection::start_sender(NULL,block,length,(sockaddr*)&remoteAddr,sizeof(SOCKADDR_IN),
&con_id,del_type,handler,defaultSSTHRESH,maxWindowSize);
}
示例15: defined
bool
ACE_INET_Addr::is_ip_equal (const ACE_INET_Addr &sap) const
{
if (this->get_type () != sap.get_type ()
|| this->get_size () != sap.get_size ())
return false;
#if defined (ACE_HAS_IPV6)
if (this->get_type () == PF_INET6)
{
const unsigned int *addr =
reinterpret_cast<const unsigned int*>(this->ip_addr_pointer());
const unsigned int *saddr =
reinterpret_cast<const unsigned int*>(sap.ip_addr_pointer());
return (addr[0] == saddr[0] &&
addr[1] == saddr[1] &&
addr[2] == saddr[2] &&
addr[3] == saddr[3]);
}
else
#endif /* ACE_HAS_IPV6 */
return this->get_ip_address () == sap.get_ip_address();
}