OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 explicit IPAddress(const in_addr& ip4) : family_(AF_INET) { | 56 explicit IPAddress(const in_addr& ip4) : family_(AF_INET) { |
57 memset(&u_, 0, sizeof(u_)); | 57 memset(&u_, 0, sizeof(u_)); |
58 u_.ip4 = ip4; | 58 u_.ip4 = ip4; |
59 } | 59 } |
60 | 60 |
61 explicit IPAddress(const in6_addr& ip6) : family_(AF_INET6) { | 61 explicit IPAddress(const in6_addr& ip6) : family_(AF_INET6) { |
62 u_.ip6 = ip6; | 62 u_.ip6 = ip6; |
63 } | 63 } |
64 | 64 |
65 explicit IPAddress(uint32 ip_in_host_byte_order) : family_(AF_INET) { | 65 explicit IPAddress(uint32_t ip_in_host_byte_order) : family_(AF_INET) { |
66 memset(&u_, 0, sizeof(u_)); | 66 memset(&u_, 0, sizeof(u_)); |
67 u_.ip4.s_addr = HostToNetwork32(ip_in_host_byte_order); | 67 u_.ip4.s_addr = HostToNetwork32(ip_in_host_byte_order); |
68 } | 68 } |
69 | 69 |
70 IPAddress(const IPAddress& other) : family_(other.family_) { | 70 IPAddress(const IPAddress& other) : family_(other.family_) { |
71 ::memcpy(&u_, &other.u_, sizeof(u_)); | 71 ::memcpy(&u_, &other.u_, sizeof(u_)); |
72 } | 72 } |
73 | 73 |
74 virtual ~IPAddress() {} | 74 virtual ~IPAddress() {} |
75 | 75 |
(...skipping 24 matching lines...) Expand all Loading... |
100 | 100 |
101 // Returns an unmapped address from a possibly-mapped address. | 101 // Returns an unmapped address from a possibly-mapped address. |
102 // Returns the same address if this isn't a mapped address. | 102 // Returns the same address if this isn't a mapped address. |
103 IPAddress Normalized() const; | 103 IPAddress Normalized() const; |
104 | 104 |
105 // Returns this address as an IPv6 address. | 105 // Returns this address as an IPv6 address. |
106 // Maps v4 addresses (as ::ffff:a.b.c.d), returns v6 addresses unchanged. | 106 // Maps v4 addresses (as ::ffff:a.b.c.d), returns v6 addresses unchanged. |
107 IPAddress AsIPv6Address() const; | 107 IPAddress AsIPv6Address() const; |
108 | 108 |
109 // For socketaddress' benefit. Returns the IP in host byte order. | 109 // For socketaddress' benefit. Returns the IP in host byte order. |
110 uint32 v4AddressAsHostOrderInteger() const; | 110 uint32_t v4AddressAsHostOrderInteger() const; |
111 | 111 |
112 // Whether this is an unspecified IP address. | 112 // Whether this is an unspecified IP address. |
113 bool IsNil() const; | 113 bool IsNil() const; |
114 | 114 |
115 static void set_strip_sensitive(bool enable); | 115 static void set_strip_sensitive(bool enable); |
116 | 116 |
117 private: | 117 private: |
118 int family_; | 118 int family_; |
119 union { | 119 union { |
120 in_addr ip4; | 120 in_addr ip4; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 IPAddress GetLoopbackIP(int family); | 182 IPAddress GetLoopbackIP(int family); |
183 | 183 |
184 // Returns the number of contiguously set bits, counting from the MSB in network | 184 // Returns the number of contiguously set bits, counting from the MSB in network |
185 // byte order, in this IPAddress. Bits after the first 0 encountered are not | 185 // byte order, in this IPAddress. Bits after the first 0 encountered are not |
186 // counted. | 186 // counted. |
187 int CountIPMaskBits(IPAddress mask); | 187 int CountIPMaskBits(IPAddress mask); |
188 | 188 |
189 } // namespace rtc | 189 } // namespace rtc |
190 | 190 |
191 #endif // WEBRTC_BASE_IPADDRESS_H_ | 191 #endif // WEBRTC_BASE_IPADDRESS_H_ |
OLD | NEW |