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

Side by Side Diff: chrome/browser/printing/cloud_print/privet_traffic_detector.cc

Issue 1565303002: Change IPEndpoint::address() to return a net::IPAddress (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase for ChromeOS Created 4 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/printing/cloud_print/privet_traffic_detector.h" 5 #include "chrome/browser/printing/cloud_print/privet_traffic_detector.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 133 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
134 socket_.reset(new net::UDPServerSocket(NULL, net::NetLog::Source())); 134 socket_.reset(new net::UDPServerSocket(NULL, net::NetLog::Source()));
135 net::IPEndPoint multicast_addr = net::GetMDnsIPEndPoint(address_family_); 135 net::IPEndPoint multicast_addr = net::GetMDnsIPEndPoint(address_family_);
136 net::IPAddressNumber address_any(multicast_addr.address().size()); 136 net::IPAddressNumber address_any(multicast_addr.address().size());
137 net::IPEndPoint bind_endpoint(address_any, multicast_addr.port()); 137 net::IPEndPoint bind_endpoint(address_any, multicast_addr.port());
138 socket_->AllowAddressReuse(); 138 socket_->AllowAddressReuse();
139 int rv = socket_->Listen(bind_endpoint); 139 int rv = socket_->Listen(bind_endpoint);
140 if (rv < net::OK) 140 if (rv < net::OK)
141 return rv; 141 return rv;
142 socket_->SetMulticastLoopbackMode(false); 142 socket_->SetMulticastLoopbackMode(false);
143 return socket_->JoinGroup(multicast_addr.address()); 143 return socket_->JoinGroup(multicast_addr.address().bytes());
144 } 144 }
145 145
146 bool PrivetTrafficDetector::IsSourceAcceptable() const { 146 bool PrivetTrafficDetector::IsSourceAcceptable() const {
147 for (size_t i = 0; i < networks_.size(); ++i) { 147 for (size_t i = 0; i < networks_.size(); ++i) {
148 if (net::IPNumberMatchesPrefix(recv_addr_.address(), networks_[i].address, 148 if (net::IPNumberMatchesPrefix(recv_addr_.address().bytes(),
149 networks_[i].address,
149 networks_[i].prefix_length)) { 150 networks_[i].prefix_length)) {
150 return true; 151 return true;
151 } 152 }
152 } 153 }
153 return false; 154 return false;
154 } 155 }
155 156
156 bool PrivetTrafficDetector::IsPrivetPacket(int rv) const { 157 bool PrivetTrafficDetector::IsPrivetPacket(int rv) const {
157 if (rv <= static_cast<int>(sizeof(net::dns_protocol::Header)) || 158 if (rv <= static_cast<int>(sizeof(net::dns_protocol::Header)) ||
158 !IsSourceAcceptable()) { 159 !IsSourceAcceptable()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 base::Unretained(this))); 195 base::Unretained(this)));
195 } while (rv > 0); 196 } while (rv > 0);
196 197
197 if (rv != net::ERR_IO_PENDING) 198 if (rv != net::ERR_IO_PENDING)
198 return rv; 199 return rv;
199 200
200 return net::OK; 201 return net::OK;
201 } 202 }
202 203
203 } // namespace cloud_print 204 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/service_discovery_client_mac.mm ('k') | chrome/test/chromedriver/net/websocket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698