xref: /aosp_15_r20/external/openscreen/osp/public/service_info.h (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1 // Copyright 2018 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 OSP_PUBLIC_SERVICE_INFO_H_
6 #define OSP_PUBLIC_SERVICE_INFO_H_
7 
8 #include <cstdint>
9 #include <string>
10 
11 #include "platform/api/network_interface.h"
12 #include "platform/base/ip_address.h"
13 
14 namespace openscreen {
15 namespace osp {
16 
17 constexpr char kOpenScreenServiceName[] = "_openscreen._udp";
18 
19 // This contains canonical information about a specific Open Screen service
20 // found on the network via our discovery mechanism (mDNS).
21 struct ServiceInfo {
22   ServiceInfo() = default;
23   ServiceInfo(ServiceInfo&&) noexcept = default;
24   ServiceInfo(const ServiceInfo&) = default;
25 
26   ServiceInfo& operator=(ServiceInfo&&) = default;
27   ServiceInfo& operator=(const ServiceInfo&) = default;
28 
29   bool operator==(const ServiceInfo& other) const;
30   bool operator!=(const ServiceInfo& other) const;
31 
32   bool Update(std::string friendly_name,
33               NetworkInterfaceIndex network_interface_index,
34               const IPEndpoint& v4_endpoint,
35               const IPEndpoint& v6_endpoint);
36 
37   // Identifier uniquely identifying the Open Screen service.
38   std::string service_id;
39 
40   // User visible name of the Open Screen service in UTF-8.
41   std::string friendly_name;
42 
43   // The index of the network interface that the screen was discovered on.
44   NetworkInterfaceIndex network_interface_index = kInvalidNetworkInterfaceIndex;
45 
46   // The network endpoints to create a new connection to the Open Screen
47   // service.
48   IPEndpoint v4_endpoint;
49   IPEndpoint v6_endpoint;
50 };
51 
52 }  // namespace osp
53 }  // namespace openscreen
54 
55 #endif  // OSP_PUBLIC_SERVICE_INFO_H_
56