class MdnsAgent
Defined at line 41 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
Base class for objects that drive mDNS question and record traffic.
Agents that have been 'started' receive all inbound questions and resource records via their
|ReceiveQuestion| and |ReceiveResource| methods. When the agent owner receives an inbound
message, it calls those methods for each question and resource in the message. When that's
done, the owner calls |EndOfMessage| on each agent.
Agents may call any of the protected 'Send' methods (|SendQuestion|, |SendResource| and
|SendAddresses|) at any time. The owner accumulates the questions and resources and sends
them in messages. Typically, agents don't have to worry about sending messages. Messages
are sent for accumulated questions and resources:
1) after |Start| is called on any agent,
2) after an inbound message is processed and all agents have gotten their |EndOfMessage| calls,
3) after an agent is removed (in case it wants to say goodbye),
4) after the completion of any task posted using |PostTaskForTime|.
If an agent wants a message sent asynchronously with respect to agent start, inbound message
arrival, agent removal and posted tasks, the agent should call |FlushSentItems|. Calling
|FlushSentItems| synchronously with those operations isn't harmful.
Public Methods
void ~MdnsAgent ()
Defined at line 97 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void Start (const DnsName & local_host_full_name)
Starts the agent. This method is never called before a shared pointer to
the agent is created, so |shared_from_this| is safe to call.
Specializations should call this method first.
Defined at line 102 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void ReceiveQuestion (const DnsQuestion & question, const ReplyAddress & reply_address, const ReplyAddress & sender_address)
Presents a received question. |sender_address| identifies the sender of the question. If
the question is not marked for unicast response, |reply_address| is the multicast placeholder
address with |Media::kBoth| and |IpVersions::kBoth|. If the question is marked for unicast
response, |reply_address| is the same as |sender_address|. This agent must not call
|RemoveSelf| during a call to this method.
Defined at line 109 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void ReceiveResource (const DnsResource & resource, MdnsResourceSection section, ReplyAddress sender_address)
Presents a received resource. |sender_address| identifies the sender of the resource. This
agent must not call |RemoveSelf| during a call to this method.
Defined at line 114 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void EndOfMessage ()
Signals the end of a message. This agent must not call |RemoveSelf| during
a call to this method.
Defined at line 119 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void OnAddProxyHost (const DnsName & host_full_name, const std::vector<HostAddress> & addresses)
Notifies the agent of the addition of a proxy host.
Defined at line 122 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void OnRemoveProxyHost (const DnsName & host_full_name)
Notifies the agent of the removal of a proxy host.
Defined at line 126 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void OnAddLocalServiceInstance (const ServiceInstance & instance, bool from_proxy)
Notifies the agent of the addition of a local or local proxy service instance. |target|
and |addresses| are empty for local service instances and non-empty for local proxy service
instances. |from_proxy| indicates whether the instance is published by the local host (false)
or a local proxy host (true).
Defined at line 132 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void OnChangeLocalServiceInstance (const ServiceInstance & instance, bool from_proxy)
Notifies the agent of a change to a local or local proxy service instance. |target| and
|addresses| are empty for local service instances and non-empty for local proxy service
instances.|from_proxy| indicates whether the instance is published by the local host (false)
or a local proxy host (true).
Defined at line 138 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void OnRemoveLocalServiceInstance (const DnsName & service_name, const DnsLabel & instance_name, bool from_proxy)
Notifies the agent of the removal of local or local proxy service instance. |from_proxy|
indicates whether the instance is published by the local host (false) or a local proxy host
(true).
Defined at line 143 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void OnLocalHostAddressesChanged ()
Notifies the agent that local host addresses have changed.
Defined at line 147 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void Quit ()
Tells the agent to quit. Any overrides should call this base implementation.
Defined at line 150 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void SetOnQuitCallback (fit::closure on_quit)
Sets the 'on quit' callback that's called when the agent quits. May be called once at most
for a given agent.
Defined at line 160 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
Protected Methods
void MdnsAgent (Owner * owner)
Defined at line 167 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
bool started ()
Defined at line 169 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
zx::time now ()
Gets the current time.
Defined at line 172 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void PostTaskForTime (fit::closure task, zx::time target_time)
Posts a task to be executed at the specified time. Scheduled tasks posted
by agents that have since been removed are not executed.
Defined at line 176 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
std::vector<HostAddress> local_host_addresses ()
Returns the addresses for the local host.
Defined at line 181 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void SendQuestion (std::shared_ptr<DnsQuestion> question, const ReplyAddress & reply_address)
Sends a question to the specified address.
Defined at line 184 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void SendResource (std::shared_ptr<DnsResource> resource, MdnsResourceSection section, const ReplyAddress & reply_address)
Sends a resource to the specified address.
Defined at line 190 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void SendAddresses (MdnsResourceSection section, const ReplyAddress & reply_address)
Sends address resources to the specified address.
Defined at line 196 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void FlushSentItems ()
Flushes sent questions and resources by sending the appropriate messages. This method is only
needed when questions or resources need to be sent asynchronously with respect to |Start|,
|ReceiveQuestion|, |ReceiveResource|, |EndOfMessage|, |Quit| or a task posted using
|PostTaskForTime|. See the discussion at the top of the file.
Defined at line 204 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void AddLocalServiceInstance (const ServiceInstance & instance, bool from_proxy)
Notifies all agents of the addition of a local service instance.
Defined at line 207 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void ChangeLocalServiceInstance (const ServiceInstance & instance, bool from_proxy)
Notifies all agents of a change to a previously-added local service instance.
Defined at line 212 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void Renew (const DnsResource & resource, Media media, IpVersions ip_versions)
Registers the resource for renewal. Before the resource's TTL expires,
an attempt will be made to renew the resource by issuing queries for it.
If the renewal is successful, the agent will receive the renewed resource
(via |ReceiveResource|) and may choose to renew the resource again.
If the renewal fails, the agent will receive a resource record with the
same name and type but with a TTL of zero. The section parameter
accompanying that resource record will be kExpired.
The effect of this call is transient, and there is no way to cancel the
renewal. When an agent loses interest in a particular resource, it should
simply refrain from renewing the incoming records.
Defined at line 227 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void Query (DnsType type, const DnsName & name, Media media, IpVersions ip_versions, zx::time initial_query_time, zx::duration interval, uint32_t interval_multiplier, uint32_t max_queries, bool request_unicast_response)
Registers a resource for repeated queries. At |initial_query_time|, queries for the resource
will be sent until the resource is received or |max_queries| are sent without receiving the
resource. The first interval between queries will be |interval|, with the interval multiplied
by |interval_multiplier| after each query. If the resource is not received, an expiration for
the resource (TTL of zero) will be distributed to all agents.
If all parameters but that last two are the same for two or more calls made consecutively
(without yielding the thread), the queries will be sent in the same message.
Defined at line 239 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h
void RemoveSelf ()
Removes this agent.
Defined at line 247 of file ../../src/connectivity/network/mdns/service/agents/mdns_agent.h