blob: 9f335058e76f77e037c92cb7790e07489179f070 [file] [log] [blame]
Adrien Béraud612b55b2023-05-29 10:42:04 -04001/*
2 * Copyright (C) 2004-2023 Savoir-faire Linux Inc.
3 *
Adrien Béraudcb753622023-07-17 22:32:49 -04004 * This program is free software: you can redistribute it and/or modify
Adrien Béraud612b55b2023-05-29 10:42:04 -04005 * it under the terms of the GNU General Public License as published by
Adrien Béraudcb753622023-07-17 22:32:49 -04006 * the Free Software Foundation, either version 3 of the License, or
Adrien Béraud612b55b2023-05-29 10:42:04 -04007 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Adrien Béraudcb753622023-07-17 22:32:49 -040011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Adrien Béraud612b55b2023-05-29 10:42:04 -040012 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
Adrien Béraudcb753622023-07-17 22:32:49 -040015 * along with this program. If not, see <https://www.gnu.org/licenses/>.
Adrien Béraud612b55b2023-05-29 10:42:04 -040016 */
Adrien Béraud612b55b2023-05-29 10:42:04 -040017#pragma once
18
19#include "connectivity/upnp/protocol/igd.h"
20
21#include "noncopyable.h"
22#include "connectivity/ip_utils.h"
23
24#include <map>
25#include <string>
26#include <chrono>
27#include <functional>
28
Adrien Béraud1ae60aa2023-07-07 09:55:09 -040029namespace dhtnet {
Adrien Béraud612b55b2023-05-29 10:42:04 -040030namespace upnp {
31
32class UPnPIGD : public IGD
33{
34public:
35 UPnPIGD(std::string&& UDN,
36 std::string&& baseURL,
37 std::string&& friendlyName,
38 std::string&& serviceType,
39 std::string&& serviceId,
40 std::string&& locationURL,
41 std::string&& controlURL,
42 std::string&& eventSubURL,
43 IpAddr&& localIp = {},
44 IpAddr&& publicIp = {});
45
46 ~UPnPIGD() {}
47
48 bool operator==(IGD& other) const;
49 bool operator==(UPnPIGD& other) const;
50
51 const std::string& getBaseURL() const
52 {
53 std::lock_guard<std::mutex> lock(mutex_);
54 return baseURL_;
55 }
56 const std::string& getFriendlyName() const
57 {
58 std::lock_guard<std::mutex> lock(mutex_);
59 return friendlyName_;
60 }
61 const std::string& getServiceType() const
62 {
63 std::lock_guard<std::mutex> lock(mutex_);
64 return serviceType_;
65 }
66 const std::string& getServiceId() const
67 {
68 std::lock_guard<std::mutex> lock(mutex_);
69 return serviceId_;
70 }
71 const std::string& getLocationURL() const
72 {
73 std::lock_guard<std::mutex> lock(mutex_);
74 return locationURL_;
75 }
76 const std::string& getControlURL() const
77 {
78 std::lock_guard<std::mutex> lock(mutex_);
79 return controlURL_;
80 }
81 const std::string& getEventSubURL() const
82 {
83 std::lock_guard<std::mutex> lock(mutex_);
84 return eventSubURL_;
85 }
86
87 const std::string toString() const override { return controlURL_; }
88
89private:
90 std::string baseURL_ {};
91 std::string friendlyName_ {};
92 std::string serviceType_ {};
93 std::string serviceId_ {};
94 std::string locationURL_ {};
95 std::string controlURL_ {};
96 std::string eventSubURL_ {};
97};
98
99} // namespace upnp
Sébastien Blin464bdff2023-07-19 08:02:53 -0400100} // namespace dhtnet