aboutsummaryrefslogtreecommitdiff
path: root/osp/public/service_info.h
blob: 7c95ff2eb1639ba45f62bf9534f022622508ceb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef OSP_PUBLIC_SERVICE_INFO_H_
#define OSP_PUBLIC_SERVICE_INFO_H_

#include <cstdint>
#include <string>

#include "platform/api/network_interface.h"
#include "platform/base/ip_address.h"

namespace openscreen {
namespace osp {

constexpr char kOpenScreenServiceName[] = "_openscreen._udp";

// This contains canonical information about a specific Open Screen service
// found on the network via our discovery mechanism (mDNS).
struct ServiceInfo {
  ServiceInfo() = default;
  ServiceInfo(ServiceInfo&&) noexcept = default;
  ServiceInfo(const ServiceInfo&) = default;

  ServiceInfo& operator=(ServiceInfo&&) = default;
  ServiceInfo& operator=(const ServiceInfo&) = default;

  bool operator==(const ServiceInfo& other) const;
  bool operator!=(const ServiceInfo& other) const;

  bool Update(std::string friendly_name,
              NetworkInterfaceIndex network_interface_index,
              const IPEndpoint& v4_endpoint,
              const IPEndpoint& v6_endpoint);

  // Identifier uniquely identifying the Open Screen service.
  std::string service_id;

  // User visible name of the Open Screen service in UTF-8.
  std::string friendly_name;

  // The index of the network interface that the screen was discovered on.
  NetworkInterfaceIndex network_interface_index = kInvalidNetworkInterfaceIndex;

  // The network endpoints to create a new connection to the Open Screen
  // service.
  IPEndpoint v4_endpoint;
  IPEndpoint v6_endpoint;
};

}  // namespace osp
}  // namespace openscreen

#endif  // OSP_PUBLIC_SERVICE_INFO_H_