blob: 5ea7fe565f5b56dbe27c31e15a6b2e4a7d9c4ad2 [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
Adrien Béraud370257c2023-08-15 20:53:09 -040019#include "../igd.h"
20#include "ip_utils.h"
Adrien Béraud612b55b2023-05-29 10:42:04 -040021
22#include <map>
23#include <string>
24#include <chrono>
25#include <functional>
26
Adrien Béraud1ae60aa2023-07-07 09:55:09 -040027namespace dhtnet {
Adrien Béraud612b55b2023-05-29 10:42:04 -040028namespace upnp {
29
30class UPnPIGD : public IGD
31{
32public:
33 UPnPIGD(std::string&& UDN,
34 std::string&& baseURL,
35 std::string&& friendlyName,
36 std::string&& serviceType,
37 std::string&& serviceId,
38 std::string&& locationURL,
39 std::string&& controlURL,
40 std::string&& eventSubURL,
41 IpAddr&& localIp = {},
42 IpAddr&& publicIp = {});
43
44 ~UPnPIGD() {}
45
46 bool operator==(IGD& other) const;
47 bool operator==(UPnPIGD& other) const;
48
49 const std::string& getBaseURL() const
50 {
51 std::lock_guard<std::mutex> lock(mutex_);
52 return baseURL_;
53 }
54 const std::string& getFriendlyName() const
55 {
56 std::lock_guard<std::mutex> lock(mutex_);
57 return friendlyName_;
58 }
59 const std::string& getServiceType() const
60 {
61 std::lock_guard<std::mutex> lock(mutex_);
62 return serviceType_;
63 }
64 const std::string& getServiceId() const
65 {
66 std::lock_guard<std::mutex> lock(mutex_);
67 return serviceId_;
68 }
69 const std::string& getLocationURL() const
70 {
71 std::lock_guard<std::mutex> lock(mutex_);
72 return locationURL_;
73 }
74 const std::string& getControlURL() const
75 {
76 std::lock_guard<std::mutex> lock(mutex_);
77 return controlURL_;
78 }
79 const std::string& getEventSubURL() const
80 {
81 std::lock_guard<std::mutex> lock(mutex_);
82 return eventSubURL_;
83 }
84
85 const std::string toString() const override { return controlURL_; }
86
87private:
88 std::string baseURL_ {};
89 std::string friendlyName_ {};
90 std::string serviceType_ {};
91 std::string serviceId_ {};
92 std::string locationURL_ {};
93 std::string controlURL_ {};
94 std::string eventSubURL_ {};
95};
96
97} // namespace upnp
Sébastien Blin464bdff2023-07-19 08:02:53 -040098} // namespace dhtnet