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

Side by Side Diff: net/quic/quic_socket_address_coder.cc

Issue 1932363003: Remove net::IPAddressNumber. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « net/net.gypi ('k') | net/socket/transport_client_socket_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/quic/quic_socket_address_coder.h" 5 #include "net/quic/quic_socket_address_coder.h"
6 6
7 #include "net/base/ip_address.h" 7 #include "net/base/ip_address.h"
8 #include "net/base/sys_addrinfo.h" 8 #include "net/base/sys_addrinfo.h"
9 9
10 using std::string; 10 using std::string;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 if (length < sizeof(address_family)) { 53 if (length < sizeof(address_family)) {
54 return false; 54 return false;
55 } 55 }
56 memcpy(&address_family, data, sizeof(address_family)); 56 memcpy(&address_family, data, sizeof(address_family));
57 data += sizeof(address_family); 57 data += sizeof(address_family);
58 length -= sizeof(address_family); 58 length -= sizeof(address_family);
59 59
60 size_t ip_length; 60 size_t ip_length;
61 switch (address_family) { 61 switch (address_family) {
62 case kIPv4: 62 case kIPv4:
63 ip_length = kIPv4AddressSize; 63 ip_length = IPAddress::kIPv4AddressSize;
64 break; 64 break;
65 case kIPv6: 65 case kIPv6:
66 ip_length = kIPv6AddressSize; 66 ip_length = IPAddress::kIPv6AddressSize;
67 break; 67 break;
68 default: 68 default:
69 return false; 69 return false;
70 } 70 }
71 if (length < ip_length) { 71 if (length < ip_length) {
72 return false; 72 return false;
73 } 73 }
74 std::vector<uint8_t> ip(ip_length); 74 std::vector<uint8_t> ip(ip_length);
75 memcpy(&ip[0], data, ip_length); 75 memcpy(&ip[0], data, ip_length);
76 data += ip_length; 76 data += ip_length;
77 length -= ip_length; 77 length -= ip_length;
78 78
79 uint16_t port; 79 uint16_t port;
80 if (length != sizeof(port)) { 80 if (length != sizeof(port)) {
81 return false; 81 return false;
82 } 82 }
83 memcpy(&port, data, length); 83 memcpy(&port, data, length);
84 84
85 address_ = IPEndPoint(IPAddress(ip), port); 85 address_ = IPEndPoint(IPAddress(ip), port);
86 return true; 86 return true;
87 } 87 }
88 88
89 } // namespace net 89 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/socket/transport_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698