Lines Matching full:addr

97 bool AreEqual(const IPAddress& addr, const IPAddress& addr2) {  in AreEqual()  argument
98 if ((IPIsAny(addr) != IPIsAny(addr2)) || in AreEqual()
99 (IPIsLoopback(addr) != IPIsLoopback(addr2)) || in AreEqual()
100 (IPIsPrivate(addr) != IPIsPrivate(addr2)) || in AreEqual()
101 (HashIP(addr) != HashIP(addr2)) || (addr.Size() != addr2.Size()) || in AreEqual()
102 (addr.family() != addr2.family()) || in AreEqual()
103 (addr.ToString() != addr2.ToString())) { in AreEqual()
107 v4addr = addr.ipv4_address(); in AreEqual()
113 v6addr = addr.ipv6_address(); in AreEqual()
122 IPAddress addr(0); // Intentionally make it v4. in BrokenIPStringFails() local
123 if (IPFromString(kIPv4BrokenString1, &addr)) { in BrokenIPStringFails()
126 return addr.family() == AF_UNSPEC; in BrokenIPStringFails()
130 IPAddress addr; in CheckMaskCount() local
131 return IPFromString(mask, &addr) && in CheckMaskCount()
132 (expected_length == CountIPMaskBits(addr)); in CheckMaskCount()
138 IPAddress addr; in TryInvalidMaskCount() local
139 if (!IPFromString(mask, &addr)) { in TryInvalidMaskCount()
142 CountIPMaskBits(addr); in TryInvalidMaskCount()
149 IPAddress addr, expected; in CheckTruncateIP() local
150 IPFromString(initial, &addr); in CheckTruncateIP()
152 IPAddress truncated = TruncateIP(addr, truncate_length); in CheckTruncateIP()
157 IPAddress addr; in TEST() local
158 EXPECT_FALSE(IPIsAny(addr)); in TEST()
159 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
160 EXPECT_FALSE(IPIsPrivate(addr)); in TEST()
162 EXPECT_EQ(0U, addr.Size()); in TEST()
163 EXPECT_EQ(AF_UNSPEC, addr.family()); in TEST()
164 EXPECT_EQ("", addr.ToString()); in TEST()
172 IPAddress addr(v4addr); in TEST() local
173 EXPECT_TRUE(IPIsAny(addr)); in TEST()
174 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
175 EXPECT_FALSE(IPIsPrivate(addr)); in TEST()
176 EXPECT_EQ(kIPv4AddrSize, addr.Size()); in TEST()
177 EXPECT_EQ(kIPv4AnyAddrString, addr.ToString()); in TEST()
181 addr = IPAddress(v4addr); in TEST()
182 EXPECT_FALSE(IPIsAny(addr)); in TEST()
183 EXPECT_TRUE(IPIsLoopback(addr)); in TEST()
184 EXPECT_FALSE(IPIsSharedNetwork(addr)); in TEST()
185 EXPECT_TRUE(IPIsPrivate(addr)); in TEST()
186 EXPECT_EQ(kIPv4AddrSize, addr.Size()); in TEST()
187 EXPECT_EQ(kIPv4LoopbackAddrString, addr.ToString()); in TEST()
191 addr = IPAddress(v4addr); in TEST()
192 EXPECT_FALSE(IPIsAny(addr)); in TEST()
193 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
194 EXPECT_FALSE(IPIsSharedNetwork(addr)); in TEST()
195 EXPECT_TRUE(IPIsPrivate(addr)); in TEST()
196 EXPECT_EQ(kIPv4AddrSize, addr.Size()); in TEST()
197 EXPECT_EQ(kIPv4RFC1918AddrString, addr.ToString()); in TEST()
201 addr = IPAddress(v4addr); in TEST()
202 EXPECT_FALSE(IPIsAny(addr)); in TEST()
203 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
204 EXPECT_TRUE(IPIsPrivate(addr)); in TEST()
205 EXPECT_TRUE(IPIsSharedNetwork(addr)); in TEST()
206 EXPECT_EQ(kIPv4AddrSize, addr.Size()); in TEST()
207 EXPECT_EQ(kIPv4RFC6598AddrString, addr.ToString()); in TEST()
211 addr = IPAddress(v4addr); in TEST()
212 EXPECT_FALSE(IPIsAny(addr)); in TEST()
213 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
214 EXPECT_FALSE(IPIsPrivate(addr)); in TEST()
215 EXPECT_EQ(kIPv4AddrSize, addr.Size()); in TEST()
216 EXPECT_EQ(kIPv4PublicAddrString, addr.ToString()); in TEST()
221 IPAddress addr(in6addr_any); in TEST() local
222 EXPECT_TRUE(IPIsAny(addr)); in TEST()
223 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
224 EXPECT_FALSE(IPIsPrivate(addr)); in TEST()
225 EXPECT_EQ(kIPv6AddrSize, addr.Size()); in TEST()
226 EXPECT_EQ(kIPv6AnyAddrString, addr.ToString()); in TEST()
229 addr = IPAddress(in6addr_loopback); in TEST()
230 EXPECT_FALSE(IPIsAny(addr)); in TEST()
231 EXPECT_TRUE(IPIsLoopback(addr)); in TEST()
232 EXPECT_FALSE(IPIsSharedNetwork(addr)); in TEST()
233 EXPECT_TRUE(IPIsPrivate(addr)); in TEST()
234 EXPECT_EQ(kIPv6AddrSize, addr.Size()); in TEST()
235 EXPECT_EQ(kIPv6LoopbackAddrString, addr.ToString()); in TEST()
238 addr = IPAddress(kIPv6LinkLocalAddr); in TEST()
239 EXPECT_FALSE(IPIsAny(addr)); in TEST()
240 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
241 EXPECT_FALSE(IPIsSharedNetwork(addr)); in TEST()
242 EXPECT_TRUE(IPIsPrivate(addr)); in TEST()
243 EXPECT_EQ(kIPv6AddrSize, addr.Size()); in TEST()
244 EXPECT_EQ(kIPv6LinkLocalAddrString, addr.ToString()); in TEST()
247 addr = IPAddress(kIPv6PublicAddr); in TEST()
248 EXPECT_FALSE(IPIsAny(addr)); in TEST()
249 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
250 EXPECT_FALSE(IPIsPrivate(addr)); in TEST()
251 EXPECT_EQ(kIPv6AddrSize, addr.Size()); in TEST()
252 EXPECT_EQ(kIPv6PublicAddrString, addr.ToString()); in TEST()
257 IPAddress addr(0); in TEST() local
258 EXPECT_TRUE(IPIsAny(addr)); in TEST()
259 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
260 EXPECT_FALSE(IPIsPrivate(addr)); in TEST()
261 EXPECT_EQ(kIPv4AddrSize, addr.Size()); in TEST()
262 EXPECT_EQ(kIPv4AnyAddrString, addr.ToString()); in TEST()
265 addr = IPAddress(INADDR_LOOPBACK); in TEST()
266 EXPECT_FALSE(IPIsAny(addr)); in TEST()
267 EXPECT_TRUE(IPIsLoopback(addr)); in TEST()
268 EXPECT_FALSE(IPIsSharedNetwork(addr)); in TEST()
269 EXPECT_TRUE(IPIsPrivate(addr)); in TEST()
270 EXPECT_EQ(kIPv4AddrSize, addr.Size()); in TEST()
271 EXPECT_EQ(kIPv4LoopbackAddrString, addr.ToString()); in TEST()
274 addr = IPAddress(kIPv4RFC1918Addr); in TEST()
275 EXPECT_FALSE(IPIsAny(addr)); in TEST()
276 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
277 EXPECT_FALSE(IPIsSharedNetwork(addr)); in TEST()
278 EXPECT_TRUE(IPIsPrivate(addr)); in TEST()
279 EXPECT_EQ(kIPv4AddrSize, addr.Size()); in TEST()
280 EXPECT_EQ(kIPv4RFC1918AddrString, addr.ToString()); in TEST()
283 addr = IPAddress(kIPv4PublicAddr); in TEST()
284 EXPECT_FALSE(IPIsAny(addr)); in TEST()
285 EXPECT_FALSE(IPIsLoopback(addr)); in TEST()
286 EXPECT_FALSE(IPIsPrivate(addr)); in TEST()
287 EXPECT_EQ(kIPv4AddrSize, addr.Size()); in TEST()
288 EXPECT_EQ(kIPv4PublicAddrString, addr.ToString()); in TEST()
294 IPAddress addr(v4addr); in TEST() local
295 IPAddress addr2(addr); in TEST()
297 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
299 addr = IPAddress(INADDR_ANY); in TEST()
300 addr2 = IPAddress(addr); in TEST()
301 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
303 addr = IPAddress(INADDR_LOOPBACK); in TEST()
304 addr2 = IPAddress(addr); in TEST()
305 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
307 addr = IPAddress(kIPv4PublicAddr); in TEST()
308 addr2 = IPAddress(addr); in TEST()
309 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
311 addr = IPAddress(kIPv4RFC1918Addr); in TEST()
312 addr2 = IPAddress(addr); in TEST()
313 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
315 addr = IPAddress(in6addr_any); in TEST()
316 addr2 = IPAddress(addr); in TEST()
317 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
319 addr = IPAddress(in6addr_loopback); in TEST()
320 addr2 = IPAddress(addr); in TEST()
321 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
323 addr = IPAddress(kIPv6LinkLocalAddr); in TEST()
324 addr2 = IPAddress(addr); in TEST()
325 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
327 addr = IPAddress(kIPv6PublicAddr); in TEST()
328 addr2 = IPAddress(addr); in TEST()
329 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
337 IPAddress addr(v4addr); in TEST() local
341 EXPECT_TRUE(addr == addr); in TEST()
344 EXPECT_TRUE(addr == addr3); in TEST()
345 EXPECT_TRUE(addr3 == addr); in TEST()
346 EXPECT_FALSE(addr2 == addr); in TEST()
348 EXPECT_FALSE(addr == addr2); in TEST()
366 EXPECT_FALSE(addr == addr4); in TEST()
367 EXPECT_FALSE(addr == addr5); in TEST()
368 EXPECT_FALSE(addr == addr6); in TEST()
369 EXPECT_FALSE(addr4 == addr); in TEST()
370 EXPECT_FALSE(addr5 == addr); in TEST()
371 EXPECT_FALSE(addr6 == addr); in TEST()
449 IPAddress addr; in TEST() local
453 EXPECT_TRUE(IPFromString(kIPv4AnyAddrString, &addr)); in TEST()
454 EXPECT_EQ(addr.ToString(), kIPv4AnyAddrString); in TEST()
455 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
458 EXPECT_TRUE(IPFromString(kIPv4LoopbackAddrString, &addr)); in TEST()
459 EXPECT_EQ(addr.ToString(), kIPv4LoopbackAddrString); in TEST()
460 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
463 EXPECT_TRUE(IPFromString(kIPv4RFC1918AddrString, &addr)); in TEST()
464 EXPECT_EQ(addr.ToString(), kIPv4RFC1918AddrString); in TEST()
465 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
468 EXPECT_TRUE(IPFromString(kIPv4PublicAddrString, &addr)); in TEST()
469 EXPECT_EQ(addr.ToString(), kIPv4PublicAddrString); in TEST()
470 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
473 EXPECT_TRUE(IPFromString(kIPv6AnyAddrString, &addr)); in TEST()
474 EXPECT_EQ(addr.ToString(), kIPv6AnyAddrString); in TEST()
475 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
478 EXPECT_TRUE(IPFromString(kIPv6LoopbackAddrString, &addr)); in TEST()
479 EXPECT_EQ(addr.ToString(), kIPv6LoopbackAddrString); in TEST()
480 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
483 EXPECT_TRUE(IPFromString(kIPv6LinkLocalAddrString, &addr)); in TEST()
484 EXPECT_EQ(addr.ToString(), kIPv6LinkLocalAddrString); in TEST()
485 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
488 EXPECT_TRUE(IPFromString(kIPv6PublicAddrString, &addr)); in TEST()
489 EXPECT_EQ(addr.ToString(), kIPv6PublicAddrString); in TEST()
490 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
493 EXPECT_TRUE(IPFromString(kIPv4MappedV4StyleAddrString, &addr)); in TEST()
494 EXPECT_TRUE(AreEqual(addr, addr2)); in TEST()
496 // Broken cases, should set addr to AF_UNSPEC. in TEST()
531 IPAddress addr; in TEST() local
532 EXPECT_TRUE(IPFromAddrInfo(&test_info, &addr)); in TEST()
533 EXPECT_EQ(expected, addr); in TEST()
539 EXPECT_TRUE(IPFromAddrInfo(&test_info, &addr)); in TEST()
540 EXPECT_EQ(expected, addr); in TEST()
543 EXPECT_FALSE(IPFromAddrInfo(&test_info, &addr)); in TEST()
546 EXPECT_FALSE(IPFromAddrInfo(&next_info, &addr)); in TEST()
565 IPAddress addr; in TEST() local
568 EXPECT_TRUE(IPFromString(kIPv6AnyAddrString, &addr)); in TEST()
569 EXPECT_FALSE(addr.IsNil()); in TEST()
571 EXPECT_TRUE(IPFromString(kIPv4AnyAddrString, &addr)); in TEST()
572 EXPECT_FALSE(addr.IsNil()); in TEST()
619 IPAddress addr; in TEST() local
621 EXPECT_TRUE(IPFromString(kIPv6AnyAddrString, &addr)); in TEST()
622 EXPECT_TRUE(IPIsAny(addr)); in TEST()
624 EXPECT_TRUE(IPFromString(kIPv4AnyAddrString, &addr)); in TEST()
625 EXPECT_TRUE(IPIsAny(addr)); in TEST()
631 IPAddress addr; in TEST() local
632 EXPECT_TRUE(IPFromString(kIPv6EuiAddrString, &addr)); in TEST()
633 EXPECT_TRUE(IPIsMacBased(addr)); in TEST()
635 EXPECT_TRUE(IPFromString(kIPv6TemporaryAddrString, &addr)); in TEST()
636 EXPECT_FALSE(IPIsMacBased(addr)); in TEST()
638 EXPECT_TRUE(IPFromString(kIPv6LinkLocalAddrString, &addr)); in TEST()
639 EXPECT_TRUE(IPIsMacBased(addr)); in TEST()
641 EXPECT_TRUE(IPFromString(kIPv6AnyAddrString, &addr)); in TEST()
642 EXPECT_FALSE(IPIsMacBased(addr)); in TEST()
644 EXPECT_TRUE(IPFromString(kIPv6LoopbackAddrString, &addr)); in TEST()
645 EXPECT_FALSE(IPIsMacBased(addr)); in TEST()
650 IPAddress addr; in TEST() local
651 EXPECT_TRUE(IPFromString(kIPv4MappedV4StyleAddrString, &addr)); in TEST()
653 addr = addr.Normalized(); in TEST()
654 EXPECT_EQ(addr2, addr); in TEST()
657 addr = IPAddress(kIPv4MappedPublicAddr); in TEST()
659 addr = addr.Normalized(); in TEST()
660 EXPECT_EQ(addr, addr2); in TEST()
663 addr = IPAddress(kIPv6PublicAddr); in TEST()
665 addr = addr.Normalized(); in TEST()
666 EXPECT_EQ(addr, addr2); in TEST()
669 EXPECT_TRUE(IPFromString("fe80::ffff:0102:0304", &addr)); in TEST()
670 addr2 = addr; in TEST()
671 addr = addr.Normalized(); in TEST()
672 EXPECT_EQ(addr, addr2); in TEST()
673 EXPECT_TRUE(IPFromString("::0102:0304", &addr)); in TEST()
674 addr2 = addr; in TEST()
675 addr = addr.Normalized(); in TEST()
676 EXPECT_EQ(addr, addr2); in TEST()
679 EXPECT_TRUE(IPFromString("::192.168.7.1", &addr)); in TEST()
680 addr2 = addr; in TEST()
681 addr = addr.Normalized(); in TEST()
682 EXPECT_EQ(addr, addr2); in TEST()
685 addr = IPAddress(htonl(kIPv4PublicAddr)); in TEST()
687 addr = addr.Normalized(); in TEST()
688 EXPECT_EQ(addr, addr2); in TEST()
692 IPAddress addr(kIPv4PublicAddr); in TEST() local
694 addr = addr.AsIPv6Address(); in TEST()
695 EXPECT_EQ(addr, addr2); in TEST()
697 addr = IPAddress(kIPv4MappedPublicAddr); in TEST()
699 addr = addr.AsIPv6Address(); in TEST()
700 EXPECT_EQ(addr, addr2); in TEST()
702 addr = IPAddress(kIPv6PublicAddr); in TEST()
704 addr = addr.AsIPv6Address(); in TEST()
705 EXPECT_EQ(addr, addr2); in TEST()
953 in6_addr addr; in TEST() local
958 addr = addr1.ipv6_address(); in TEST()
959 EXPECT_TRUE(IN6_ARE_ADDR_EQUAL(&addr, &kIPv6PublicAddr)); in TEST()
964 addr = addr2.ipv6_address(); in TEST()
965 EXPECT_TRUE(IN6_ARE_ADDR_EQUAL(&addr, &kIPv6PublicAddr)); in TEST()
970 addr = addr3.ipv6_address(); in TEST()
971 EXPECT_TRUE(IN6_ARE_ADDR_EQUAL(&addr, &kIPv6PublicAddr)); in TEST()