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 | |
Adrien Béraud | 370257c | 2023-08-15 20:53:09 -0400 | [diff] [blame] | 19 | #include "../igd.h" |
| 20 | #include "ip_utils.h" |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 21 | |
| 22 | #include <map> |
| 23 | #include <string> |
| 24 | #include <chrono> |
| 25 | #include <functional> |
| 26 | |
Adrien Béraud | 1ae60aa | 2023-07-07 09:55:09 -0400 | [diff] [blame] | 27 | namespace dhtnet { |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 28 | namespace upnp { |
| 29 | |
| 30 | class UPnPIGD : public IGD |
| 31 | { |
| 32 | public: |
| 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 | |
| 87 | private: |
| 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 Blin | 464bdff | 2023-07-19 08:02:53 -0400 | [diff] [blame] | 98 | } // namespace dhtnet |