blob: f0d9574b99ae8c59ce9a65ed96d7b39ecbc41ec0 [file] [log] [blame]
[email protected]d0d49dd82012-01-26 00:03:591// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]c36f0642009-09-09 01:10:502// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef NET_BASE_DNS_UTIL_H_
6#define NET_BASE_DNS_UTIL_H_
[email protected]c36f0642009-09-09 01:10:507
8#include <string>
9
[email protected]b3ccac82010-08-04 15:54:4010#include "base/basictypes.h"
[email protected]d069c11a2013-04-13 00:01:5511#include "base/strings/string_piece.h"
[email protected]172da1b2011-08-12 15:52:2612#include "net/base/net_export.h"
[email protected]b3ccac82010-08-04 15:54:4013
[email protected]c36f0642009-09-09 01:10:5014namespace net {
15
16// DNSDomainFromDot - convert a domain string to DNS format. From DJB's
17// public domain DNS library.
18//
19// dotted: a string in dotted form: "www.google.com"
20// out: a result in DNS form: "\x03www\x06google\x03com\x00"
[email protected]7556ea22011-12-08 19:29:1521NET_EXPORT_PRIVATE bool DNSDomainFromDot(const base::StringPiece& dotted,
[email protected]172da1b2011-08-12 15:52:2622 std::string* out);
[email protected]c36f0642009-09-09 01:10:5023
[email protected]d0d49dd82012-01-26 00:03:5924// DNSDomainToString converts a domain in DNS format to a dotted string.
25// Excludes the dot at the end.
[email protected]7556ea22011-12-08 19:29:1526NET_EXPORT_PRIVATE std::string DNSDomainToString(
27 const base::StringPiece& domain);
[email protected]f060be32011-02-17 17:20:2828
[email protected]c36f0642009-09-09 01:10:5029// Returns true iff the given character is in the set of valid DNS label
30// characters as given in RFC 3490, 4.1, 3(a)
[email protected]172da1b2011-08-12 15:52:2631NET_EXPORT_PRIVATE bool IsSTD3ASCIIValidCharacter(char c);
[email protected]c36f0642009-09-09 01:10:5032
[email protected]13c340e12010-03-08 19:29:4133// Returns the hostname by trimming the ending dot, if one exists.
[email protected]7556ea22011-12-08 19:29:1534NET_EXPORT std::string TrimEndingDot(const base::StringPiece& host);
35
[email protected]c36f0642009-09-09 01:10:5036} // namespace net
37
38#endif // NET_BASE_DNS_UTIL_H_