| // Copyright 2017 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.mdns; |
| |
| using fuchsia.net; |
| using zx; |
| |
| /// Provides description relating to a service instance. In typical use, TXT |
| /// strings consist of a key and value separated by '='. TXT strings must be |
| /// at most 255 characters long and are UTF-8-encoded. |
| @available(deprecated=9) |
| alias txt_string = string:255; |
| |
| /// Discoverable protocol for resolving host names to IP addresses. |
| /// Deprecated: use HostNameResolver. |
| @available(deprecated=9) |
| @discoverable |
| protocol Resolver { |
| /// Gets the addresses for the specified host. `timeout` specifies how long |
| /// the service should wait before giving up when waiting for a response to |
| /// a resolution query. In typical use, a timeout of two or three seconds |
| /// is recommended. |
| /// |
| /// A successful resolution may return one or both addresses. An |
| /// unsuccessful resolution is indicated when both addresses are null. |
| ResolveHostName(struct { |
| host host_name; |
| timeout zx.Duration; |
| }) -> (struct { |
| v4_address box<fuchsia.net.Ipv4Address>; |
| v6_address box<fuchsia.net.Ipv6Address>; |
| }); |
| }; |
| |
| /// Discoverable protocol for finding service instances. |
| /// Deprecated: use ServiceInstanceSubscriber. |
| @available(deprecated=9) |
| @discoverable |
| protocol Subscriber { |
| /// Subscribes to a service. The subscription lasts until `subscriber` is |
| /// unbound. |
| SubscribeToService(resource struct { |
| service service_name; |
| subscriber client_end:ServiceSubscriber; |
| }); |
| }; |
| |
| /// Client-implemented interface for subscribers. Method replies are used to |
| /// throttle traffic. The service won't necessarily wait for a reply before |
| /// calling another method. |
| @available(deprecated=9) |
| protocol ServiceSubscriber { |
| /// Notifies the subscriber that a service instance has been discovered. |
| OnInstanceDiscovered(struct { |
| instance ServiceInstance; |
| }) -> (); |
| |
| /// Notifies the subscriber that addresses or text for a known service |
| /// instance have changed. |
| OnInstanceChanged(struct { |
| instance ServiceInstance; |
| }) -> (); |
| |
| /// Notifies the subscriber that a known service instance has been lost. |
| OnInstanceLost(struct { |
| service service_name; |
| instance instance_name; |
| }) -> (); |
| |
| /// Notifies the subscriber that a PTR query has been sent. |
| OnQuery(struct { |
| resource_type ResourceType; |
| }) -> (); |
| }; |
| |
| /// Discoverable protocol for publishing service instances. |
| /// Deprecated: use ServiceInstancePublisher. |
| @available(deprecated=9) |
| @discoverable |
| protocol Publisher { |
| /// Publishes a service instance. `publication_responder` is consulted via its |
| /// `OnPublication` method for initial announcements and to answer queries. |
| /// The service is published until the `publication_responder` channel closes. In |
| /// addition to announcements and queries for the service type, all queries |
| /// for subtypes are answered subject to filtering through the responder. |
| /// `perform_probe` indicates whether a probe for a conflicting instance |
| /// should be performed before publishing the instance. This value should |
| /// be `true` unless the instance name is known to be unique. |
| /// |
| /// If a service with the same service and instance names is already published, the |
| /// old publication will be terminated, and the responder channel for the old |
| /// publication will be closed. |
| PublishServiceInstance(resource struct { |
| service service_name; |
| instance instance_name; |
| media Media; |
| perform_probe bool; |
| publication_responder client_end:PublicationResponder; |
| }) -> () error Error; |
| }; |
| |
| /// Client-supplied publication responder interface. |
| @available(deprecated=9) |
| protocol PublicationResponder { |
| /// Provides instance information for initial announcements and query |
| /// responses relating to the service instance specified in |
| /// `ServiceInstancePublisher.PublishServiceInstance`. If the publication relates to a |
| /// subtype of the service, `subtype` contains the subtype, otherwise |
| /// it is null. If `publication` is null, no announcement or response is |
| /// transmitted. Strings in `text` are transmitted in the TXT record. |
| OnPublication(struct { |
| publication_cause PublicationCause; |
| subtype subtype_name:optional; |
| source_addresses vector<fuchsia.net.IpAddress>:MAX_ADDRESSES; |
| }) -> (struct { |
| publication box<Publication>; |
| }); |
| |
| /// Sets the subtypes for the service instance. The specified subtypes will |
| /// be announced subject to filtering through the responder. The initial |
| /// subtype collection is empty. |
| -> SetSubtypes(struct { |
| subtypes vector<subtype_name>:MAX_SUBTYPES; |
| }); |
| |
| /// Initiates reannouncement of the service instance due to a change in the |
| /// instance's port number or text strings. All announcements are filtered |
| /// through `OnPublication`, which replies with the new port and text |
| /// values. |
| -> Reannounce(); |
| }; |
| |
| /// Describes the cause of a publication. |
| @available(deprecated=9) |
| type PublicationCause = strict enum : uint32 { |
| /// Indicates the publication is part of an initial announcement. |
| ANNOUNCEMENT = 1; |
| |
| /// Indicates the publication is in response to a question that requests a |
| /// multicast response. |
| QUERY_MULTICAST_RESPONSE = 2; |
| |
| /// Indicates the publication is in response to a question that requests a |
| /// unicast response. |
| QUERY_UNICAST_RESPONSE = 3; |
| }; |
| |
| /// Describes an initial instance announcement or query response. In typical |
| /// use, the default SRV priority, SRV weight and TTL values should be used. TTL |
| /// values are rounded down to the nearest second. TTL values less than one |
| /// second are not permitted and will result in the `PublicationResponder` |
| /// channel being closed. |
| @available(deprecated=9) |
| type Publication = struct { |
| /// The port at which the service instance is addressable. |
| port uint16; |
| |
| /// Text strings describing the instance. |
| text vector<txt_string>:MAX_TEXT_STRINGS; |
| |
| /// The priority of the SRV resource record for this publication. See |
| /// [RFC6763](https://tools.ietf.org/html/rfc6763) for details. |
| @allow_deprecated_struct_defaults |
| srv_priority uint16 = DEFAULT_SRV_PRIORITY; |
| |
| /// The weight of the SRV resource record for this publication. See |
| /// [RFC6763](https://tools.ietf.org/html/rfc6763) for details. |
| @allow_deprecated_struct_defaults |
| srv_weight uint16 = DEFAULT_SRV_WEIGHT; |
| |
| /// Time-to-live for PTR resource records. |
| @allow_deprecated_struct_defaults |
| ptr_ttl zx.Duration = DEFAULT_PTR_TTL; |
| |
| /// Time-to-live for SRV resource records. |
| @allow_deprecated_struct_defaults |
| srv_ttl zx.Duration = DEFAULT_SRV_TTL; |
| |
| /// Time-to-live for TXT resource records. |
| @allow_deprecated_struct_defaults |
| txt_ttl zx.Duration = DEFAULT_TXT_TTL; |
| }; |
| |
| @available(deprecated=9) |
| const DEFAULT_SRV_PRIORITY uint16 = 0; |
| @available(deprecated=9) |
| const DEFAULT_SRV_WEIGHT uint16 = 0; |
| @available(deprecated=9) |
| const DEFAULT_PTR_TTL zx.Duration = 120000000000; // 2 minutes |
| @available(deprecated=9) |
| const DEFAULT_SRV_TTL zx.Duration = 120000000000; // 2 minutes |
| @available(deprecated=9) |
| const DEFAULT_TXT_TTL zx.Duration = 4500000000000; // 75 minutes |
| |
| /// Error values for instance publishing. |
| @available(deprecated=9) |
| type Error = strict enum : uint32 { |
| /// The specified service name is invalid. |
| INVALID_SERVICE_NAME = 1; |
| |
| /// The specified instance name is invalid. |
| INVALID_INSTANCE_NAME = 2; |
| |
| /// The specified service instance is already being published by another |
| /// host on the subnet. This result occurs when an initial probe discovers |
| /// a conflicting instance. |
| ALREADY_PUBLISHED_ON_SUBNET = 4; |
| |
| // The specified `Media` value is invalid. |
| INVALID_MEDIA = 5; |
| }; |