Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004-2023 Savoir-faire Linux Inc. |
| 3 | * |
Adrien Béraud | cb75362 | 2023-07-17 22:32:49 -0400 | [diff] [blame] | 4 | * This program is free software: you can redistribute it and/or modify |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 5 | * it under the terms of the GNU General Public License as published by |
Adrien Béraud | cb75362 | 2023-07-17 22:32:49 -0400 | [diff] [blame] | 6 | * the Free Software Foundation, either version 3 of the License, or |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 7 | * (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éraud | cb75362 | 2023-07-17 22:32:49 -0400 | [diff] [blame] | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
Adrien Béraud | cb75362 | 2023-07-17 22:32:49 -0400 | [diff] [blame] | 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 16 | */ |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 17 | #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éraud | 1ae60aa | 2023-07-07 09:55:09 -0400 | [diff] [blame] | 29 | namespace dhtnet { |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 30 | namespace upnp { |
| 31 | |
| 32 | class UPnPIGD : public IGD |
| 33 | { |
| 34 | public: |
| 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 | |
| 89 | private: |
| 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 Blin | 464bdff | 2023-07-19 08:02:53 -0400 | [diff] [blame] | 100 | } // namespace dhtnet |