| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| library fuchsia.net; |
| |
| struct IpAddressInfo { |
| /// All of the IPv4 addresses for the requested hostname. |
| vector<Ipv4Address>:256 ipv4_addrs; |
| /// All of the IPv6 addresses for the requested hostname. |
| vector<Ipv6Address>:256 ipv6_addrs; |
| /// The canonical name of the requested hostname (usually the DNS CNAME record, if one exists). |
| string:256? canonical_name; |
| }; |
| |
| enum LookupError { |
| /// No result was found for this query. |
| NOT_FOUND = 1; |
| /// The lookup failed, but may succeed at a later time. For instance, the |
| /// network or DNS server may be unreachable. |
| TRANSIENT = 2; |
| /// The lookup failed due to an invalid argument (for instance, the hostname was not encoded |
| /// correctly, or was too long). |
| INVALID_ARGS = 3; |
| /// The lookup failed due to an internal error. |
| INTERNAL_ERROR = 4; |
| }; |
| |
| bits LookupIpOptions : uint8 { |
| /// If the lookup should return IPv4 addresses. |
| V4_ADDRS = 0b001; |
| /// If the lookup should return IPv6 addresses. |
| V6_ADDRS = 0b010; |
| /// If the lookup should return a canonical_name, if one exists. |
| CNAME_LOOKUP = 0b100; |
| }; |
| |
| /// The maximum length of a hostname, as per [RFC 1035 section 2.3.4](https://tools.ietf.org/html/rfc1035#section-2.3.4). |
| const uint64 MAX_HOSTNAME_SIZE = 255; |
| |
| /// A hostname. |
| /// |
| /// Although the maximum length of a domain or hostname is 255 characters, |
| /// each label within a name must not be longer than 63 characters as per |
| /// [RFC 1035 section 2.3.4](https://tools.ietf.org/html/rfc1035#section-2.3.4). |
| /// A label in a host name is the alphanumeric characters or hyphens, seperated |
| /// by a period (e.g. abc.com has two labels, 'abc' and 'com'). |
| using Hostname = string:MAX_HOSTNAME_SIZE; |
| |
| // TODO(49741): Move to fuchsia.net.name once build unification is done. |
| [Discoverable] |
| protocol NameLookup { |
| /// Look up a list of IP addresses by hostname. |
| /// |
| /// If `hostname` is an Internationalized Domain Name, it must be encoded as per RFC 3490. |
| LookupIp(Hostname hostname, LookupIpOptions options) -> (IpAddressInfo addr) error LookupError; |
| /// Look up a hostname by IP address. |
| LookupHostname(IpAddress addr) -> (Hostname hostname) error LookupError; |
| }; |