blob: 21a2617f9b890fa3cd1bbb92ba2195a5937eb220 [file] [log] [blame]
// 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.
#include "garnet/bin/mdns/service/address_responder.h"
#include "garnet/bin/mdns/service/mdns_names.h"
#include "lib/fxl/logging.h"
#include "lib/fxl/time/time_point.h"
namespace mdns {
AddressResponder::AddressResponder(MdnsAgent::Host* host) : MdnsAgent(host) {}
AddressResponder::~AddressResponder() {}
void AddressResponder::Start(const std::string& host_full_name) {
FXL_DCHECK(!host_full_name.empty());
host_full_name_ = host_full_name;
}
void AddressResponder::ReceiveQuestion(const DnsQuestion& question,
const ReplyAddress& reply_address) {
if ((question.type_ == DnsType::kA || question.type_ == DnsType::kAaaa ||
question.type_ == DnsType::kAny) &&
question.name_.dotted_string_ == host_full_name_) {
SendAddresses(MdnsResourceSection::kAnswer, reply_address);
}
}
} // namespace mdns