Android-cuttlefish cvd tool
mdns_service_info.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <string>
20#include <tuple>
21
22#include <discovery/dnssd/public/dns_sd_instance_endpoint.h>
23#include <platform/base/ip_address.h>
24
25#include "client/mdns_utils.h"
26
27namespace mdns {
28
30 std::string instance;
31 std::string service;
32 openscreen::IPAddress v4_address;
33 openscreen::IPAddress v6_address;
34 uint16_t port;
35
36 std::string v4_address_string() const;
37 std::string v6_address_string() const;
38
39 // Store keys/values from TXT resource record
40 std::unordered_map<std::string, std::string> attributes;
41}; // ServiceInfo
42
43inline std::ostream& operator<<(std::ostream& os, const ServiceInfo& service_info) {
44 os << "Instance: " << service_info.instance << ", Service: " << service_info.service
45 << ", Port: " << service_info.port << ", IPv4: " << service_info.v4_address
46 << ", IPv6: " << service_info.v6_address;
47 return os;
48}
49
50openscreen::ErrorOr<ServiceInfo> DnsSdInstanceEndpointToServiceInfo(
51 const openscreen::discovery::DnsSdInstanceEndpoint& endpoint);
52
53std::tuple<bool, std::string, std::string> ParseTxtKeyValue(const std::string& kv);
54
55} // namespace mdns
Definition: discovered_services.cpp:21
std::tuple< bool, std::string, std::string > ParseTxtKeyValue(const std::string &kv)
Definition: mdns_service_info.cpp:38
ErrorOr< ServiceInfo > DnsSdInstanceEndpointToServiceInfo(const discovery::DnsSdInstanceEndpoint &endpoint)
Definition: mdns_service_info.cpp:73
std::ostream & operator<<(std::ostream &os, const ServiceInfo &service_info)
Definition: mdns_service_info.h:43
Definition: mdns_service_info.h:29
std::string v6_address_string() const
Definition: mdns_service_info.cpp:31
std::string v4_address_string() const
Definition: mdns_service_info.cpp:25
openscreen::IPAddress v4_address
Definition: mdns_service_info.h:32
openscreen::IPAddress v6_address
Definition: mdns_service_info.h:33
uint16_t port
Definition: mdns_service_info.h:34
std::string service
Definition: mdns_service_info.h:31
std::string instance
Definition: mdns_service_info.h:30
std::unordered_map< std::string, std::string > attributes
Definition: mdns_service_info.h:40