Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: net/base/ip_address.cc

Issue 1676023002: Make IPAddress::FromIPLiteral a member function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/ip_address.h" 5 #include "net/base/ip_address.h"
6 6
7 #include "net/base/ip_address_number.h" 7 #include "net/base/ip_address_number.h"
8 #include "url/gurl.h" 8 #include "url/gurl.h"
9 #include "url/url_canon_ip.h" 9 #include "url/url_canon_ip.h"
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 bool IPAddress::IsIPv4MappedIPv6() const { 50 bool IPAddress::IsIPv4MappedIPv6() const {
51 return net::IsIPv4Mapped(ip_address_); 51 return net::IsIPv4Mapped(ip_address_);
52 } 52 }
53 53
54 std::string IPAddress::ToString() const { 54 std::string IPAddress::ToString() const {
55 return IPAddressToString(ip_address_); 55 return IPAddressToString(ip_address_);
56 } 56 }
57 57
58 // static 58 bool IPAddress::AssignFromIPLiteral(const base::StringPiece& ip_literal) {
59 bool IPAddress::FromIPLiteral(const base::StringPiece& ip_literal,
60 IPAddress* ip_address) {
61 std::vector<uint8_t> number; 59 std::vector<uint8_t> number;
62 if (!ParseIPLiteralToNumber(ip_literal, &number)) 60 if (!ParseIPLiteralToNumber(ip_literal, &number))
63 return false; 61 return false;
64 62
65 std::swap(number, ip_address->ip_address_); 63 std::swap(number, ip_address_);
66 return true; 64 return true;
67 } 65 }
68 66
69 bool IPAddress::operator==(const IPAddress& that) const { 67 bool IPAddress::operator==(const IPAddress& that) const {
70 return ip_address_ == that.ip_address_; 68 return ip_address_ == that.ip_address_;
71 } 69 }
72 70
73 bool IPAddress::operator!=(const IPAddress& that) const { 71 bool IPAddress::operator!=(const IPAddress& that) const {
74 return ip_address_ != that.ip_address_; 72 return ip_address_ != that.ip_address_;
75 } 73 }
(...skipping 17 matching lines...) Expand all
93 91
94 IPAddress ConvertIPv4ToIPv4MappedIPv6(const IPAddress& address) { 92 IPAddress ConvertIPv4ToIPv4MappedIPv6(const IPAddress& address) {
95 return IPAddress(ConvertIPv4NumberToIPv6Number(address.bytes())); 93 return IPAddress(ConvertIPv4NumberToIPv6Number(address.bytes()));
96 } 94 }
97 95
98 IPAddress ConvertIPv4MappedIPv6ToIPv4(const IPAddress& address) { 96 IPAddress ConvertIPv4MappedIPv6ToIPv4(const IPAddress& address) {
99 return IPAddress(ConvertIPv4MappedToIPv4(address.bytes())); 97 return IPAddress(ConvertIPv4MappedToIPv4(address.bytes()));
100 } 98 }
101 99
102 } // namespace net 100 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698