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

Unified Diff: net/dns/dns_query.cc

Issue 9716020: Add base::HostToNetXX() & NetToHostXX(), and use them to replace htonX() & ntohX() in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/dns_config_service_posix_unittest.cc ('k') | net/dns/dns_response.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_query.cc
diff --git a/net/dns/dns_query.cc b/net/dns/dns_query.cc
index 45d7c16c1e3ceb015d823481a8b144da72065d8f..72e97cf729949abfe4bc8c239afe9c0c7b701dcb 100644
--- a/net/dns/dns_query.cc
+++ b/net/dns/dns_query.cc
@@ -28,9 +28,9 @@ DnsQuery::DnsQuery(uint16 id, const base::StringPiece& qname, uint16 qtype)
dns_protocol::Header* header =
reinterpret_cast<dns_protocol::Header*>(io_buffer_->data());
memset(header, 0, sizeof(dns_protocol::Header));
- header->id = htons(id);
- header->flags = htons(dns_protocol::kFlagRD);
- header->qdcount = htons(1);
+ header->id = base::HostToNet16(id);
+ header->flags = base::HostToNet16(dns_protocol::kFlagRD);
+ header->qdcount = base::HostToNet16(1);
// Write question section after the header.
BigEndianWriter writer(reinterpret_cast<char*>(header + 1), question_size);
@@ -49,7 +49,7 @@ DnsQuery* DnsQuery::CloneWithNewId(uint16 id) const {
uint16 DnsQuery::id() const {
const dns_protocol::Header* header =
reinterpret_cast<const dns_protocol::Header*>(io_buffer_->data());
- return ntohs(header->id);
+ return base::NetToHost16(header->id);
}
base::StringPiece DnsQuery::qname() const {
@@ -77,7 +77,7 @@ DnsQuery::DnsQuery(const DnsQuery& orig, uint16 id) {
io_buffer_.get()->size());
dns_protocol::Header* header =
reinterpret_cast<dns_protocol::Header*>(io_buffer_->data());
- header->id = htons(id);
+ header->id = base::HostToNet16(id);
}
} // namespace net
« no previous file with comments | « net/dns/dns_config_service_posix_unittest.cc ('k') | net/dns/dns_response.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698