1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/* -*- C++ -*- */
// $Id$
// INET_Addr.i
// Default dtor.
ACE_INLINE
ACE_INET_Addr::~ACE_INET_Addr (void)
{
}
// Return the port number, converting it into host byte order...
ACE_INLINE u_short
ACE_INET_Addr::get_port_number (void) const
{
ACE_TRACE ("ACE_INET_Addr::get_port_number");
#if defined (ACE_HAS_IPV6)
#if defined (ACE_USES_IPV4_IPV6_MIGRATION)
if(ACE_INET_Addr::protocol_family() == PF_INET)
return ntohs (this->inet_addr4_.sin_port);
else
#endif
return ntohs (this->inet_addr6_.sin6_port);
#else
return ntohs (this->inet_addr6_.sin_port);
#endif
}
// Return the address.
ACE_INLINE void *
ACE_INET_Addr::get_addr (void) const
{
ACE_TRACE ("ACE_INET_Addr::get_addr");
#if defined (ACE_HAS_IPV6)
#if defined (ACE_USES_IPV4_IPV6_MIGRATION)
if(ACE_INET_Addr::protocol_family() == PF_INET)
return (void*)&this->inet_addr4_;
else
#endif
return (void*)&this->inet_addr6_;
#else
return (void *) &this->inet_addr4_;
#endif
}
ACE_INLINE u_long
ACE_INET_Addr::hash (void) const
{
#if defined (ACE_HAS_IPV6)
const unsigned int *addr = (const unsigned int*)this->addr_pointer();
return addr[0] + addr[1] + addr[2] + addr[3] + this->get_port_number();
#else
return this->get_ip_address () + this->get_port_number ();
#endif
}
ACE_INLINE int
ACE_INET_Addr::operator < (const ACE_INET_Addr &rhs) const
{
return this->get_ip_address () < rhs.get_ip_address ()
|| (this->get_ip_address () == rhs.get_ip_address ()
&& this->get_port_number () < rhs.get_port_number ());
}
#if defined (ACE_HAS_WCHAR)
ACE_INLINE int
ACE_INET_Addr::set (u_short port_number,
const wchar_t host_name[],
int encode)
{
return this->set (port_number,
ACE_Wide_To_Ascii (host_name).char_rep (),
encode);
}
ACE_INLINE int
ACE_INET_Addr::set (const wchar_t port_name[],
const wchar_t host_name[],
const wchar_t protocol[])
{
return this->set (ACE_Wide_To_Ascii (port_name).char_rep (),
ACE_Wide_To_Ascii (host_name).char_rep (),
ACE_Wide_To_Ascii (protocol).char_rep ());
}
ACE_INLINE int
ACE_INET_Addr::set (const wchar_t port_name[],
ACE_UINT32 ip_addr,
const wchar_t protocol[])
{
return this->set (ACE_Wide_To_Ascii (port_name).char_rep (),
ip_addr,
ACE_Wide_To_Ascii (protocol).char_rep ());
}
ACE_INLINE int
ACE_INET_Addr::set (const wchar_t addr[])
{
return this->set (ACE_Wide_To_Ascii (addr).char_rep ());
}
#endif /* ACE_HAS_WCHAR */
|