1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef DISCOVERY_COMMON_CONFIG_H_ 6 #define DISCOVERY_COMMON_CONFIG_H_ 7 8 #include <vector> 9 10 #include "platform/base/interface_info.h" 11 12 namespace openscreen { 13 namespace discovery { 14 15 // This struct provides parameters needed to initialize the discovery pipeline. 16 struct Config { 17 /***************************************** 18 * Common Settings 19 *****************************************/ 20 21 // Interfaces on which services should be published, and on which discovery 22 // should listen for announced service instances. 23 std::vector<InterfaceInfo> network_info; 24 25 // Maximum allowed size in bytes for the rdata in an incoming record. All 26 // received records with rdata size exceeding this size will be dropped. 27 // The default value is taken from RFC 6763 section 6.2. 28 int maximum_valid_rdata_size = 1300; 29 30 /***************************************** 31 * Publisher Settings 32 *****************************************/ 33 34 // Determines whether publishing of services is enabled. 35 bool enable_publication = true; 36 37 // Number of times new mDNS records should be announced, using an exponential 38 // back off. See RFC 6762 section 8.3 for further details. Per RFC, this value 39 // is expected to be in the range of 2 to 8. 40 int new_record_announcement_count = 8; 41 42 // Maximum number of truncated messages that the receiver may receive for a 43 // single query from any given host. 44 // The supported record type with the largest expected data size is a TXT 45 // record. RFC 6763 section 6.1 states that the "maximum sensible size" for 46 // one such record is "a few hundred bytes". Given that an mDNS Message's size 47 // is bounded by 9000 bytes, each message can be expected to hold at least 30 48 // records, meaning that the default value of 8 allows for 240 records, or 49 // more in the case of non-TXT records. 50 int maximum_truncated_messages_per_query = 8; 51 52 // Maximum number of concurrent truncated queries that may be tracked by a 53 // single network interface. 54 // By the same logic stated in the above config value, truncated queries 55 // should be relatively rare. Each truncated query lives for at most one 56 // second after the last truncated packet is received, so receiving 64 such 57 // queries in a short timespan is unlinkely. 58 int maximum_concurrent_truncated_queries_per_interface = 64; 59 60 // Maximum number of known answers allowed for a given truncated query. 61 // A default value of 256 is used because this is the maximum number of 62 // devices on a LAN. 63 int maximum_known_answer_records_per_query = 256; 64 65 /***************************************** 66 * Querier Settings 67 *****************************************/ 68 69 // Determines whether querying is enabled. 70 bool enable_querying = true; 71 72 // Number of times new mDNS records should be announced, using an exponential 73 // back off. -1 signifies that there should be no maximum. 74 int new_query_announcement_count = -1; 75 76 // Limit on the size to which the mDNS Querier Cache may grow. This is used to 77 // prevent a malicious or misbehaving mDNS client from causing the memory 78 // used by mDNS to grow in an unbounded fashion. 79 int querier_max_records_cached = 1024; 80 81 // Sets the querier to ignore all NSEC negative response records received as 82 // responses to outgoing queries. 83 bool ignore_nsec_responses = false; 84 }; 85 86 } // namespace discovery 87 } // namespace openscreen 88 89 #endif // DISCOVERY_COMMON_CONFIG_H_ 90