1 // Copyright 2018 The Chromium Authors 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 NET_DNS_PUBLIC_UTIL_H_ 6 #define NET_DNS_PUBLIC_UTIL_H_ 7 8 #include <stdint.h> 9 10 #include <string> 11 12 #include "net/base/address_family.h" 13 #include "net/base/ip_endpoint.h" 14 #include "net/base/net_export.h" 15 16 namespace url { 17 class SchemeHostPort; 18 } 19 20 // Basic utility functions for interaction with MDNS and host resolution. 21 namespace net::dns_util { 22 23 // Gets the endpoint for the multicast group a socket should join to receive 24 // MDNS messages. Such sockets should also bind to the endpoint from 25 // GetMDnsReceiveEndPoint(). 26 // 27 // This is also the endpoint messages should be sent to to send MDNS messages. 28 NET_EXPORT IPEndPoint GetMdnsGroupEndPoint(AddressFamily address_family); 29 30 // Gets the endpoint sockets should be bound to to receive MDNS messages. Such 31 // sockets should also join the multicast group from GetMDnsGroupEndPoint(). 32 NET_EXPORT IPEndPoint GetMdnsReceiveEndPoint(AddressFamily address_family); 33 34 // Determine the new hostname for an HTTPS record query by performing "Port 35 // Prefix Naming" as defined by draft-ietf-dnsop-svcb-https-08, Section 9.1. 36 // 37 // If non-null, `out_port` is set to the port used for the query, which might 38 // not be the same as `host.port()`, e.g. if port 80 is converted to 443 for 39 // scheme upgrade. 40 NET_EXPORT std::string GetNameForHttpsQuery(const url::SchemeHostPort& host, 41 uint16_t* out_port = nullptr); 42 43 } // namespace net::dns_util 44 45 #endif // NET_DNS_PUBLIC_UTIL_H_ 46