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 | #include "upnp_igd.h" |
| 18 | |
Adrien Béraud | 1ae60aa | 2023-07-07 09:55:09 -0400 | [diff] [blame] | 19 | namespace dhtnet { |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 20 | namespace upnp { |
| 21 | |
| 22 | UPnPIGD::UPnPIGD(std::string&& UDN, |
| 23 | std::string&& baseURL, |
| 24 | std::string&& friendlyName, |
| 25 | std::string&& serviceType, |
| 26 | std::string&& serviceId, |
| 27 | std::string&& locationURL, |
| 28 | std::string&& controlURL, |
| 29 | std::string&& eventSubURL, |
| 30 | IpAddr&& localIp, |
| 31 | IpAddr&& publicIp) |
| 32 | : IGD(NatProtocolType::PUPNP) |
| 33 | { |
| 34 | uid_ = std::move(UDN); |
| 35 | baseURL_ = std::move(baseURL); |
| 36 | friendlyName_ = std::move(friendlyName); |
| 37 | serviceType_ = std::move(serviceType); |
| 38 | serviceId_ = std::move(serviceId); |
| 39 | locationURL_ = std::move(locationURL); |
| 40 | controlURL_ = std::move(controlURL); |
| 41 | eventSubURL_ = std::move(eventSubURL); |
| 42 | localIp_ = std::move(localIp); |
| 43 | publicIp_ = std::move(publicIp); |
| 44 | } |
| 45 | |
| 46 | bool |
| 47 | UPnPIGD::operator==(IGD& other) const |
| 48 | { |
| 49 | return localIp_ == other.getLocalIp() and publicIp_ == other.getPublicIp(); |
| 50 | } |
| 51 | |
| 52 | bool |
| 53 | UPnPIGD::operator==(UPnPIGD& other) const |
| 54 | { |
| 55 | if (localIp_ and publicIp_) { |
| 56 | if (localIp_ != other.localIp_ or publicIp_ != other.publicIp_) { |
| 57 | return false; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | return uid_ == other.uid_ and baseURL_ == other.baseURL_ |
| 62 | and friendlyName_ == other.friendlyName_ and serviceType_ == other.serviceType_ |
| 63 | and serviceId_ == other.serviceId_ and locationURL_ == other.locationURL_ |
| 64 | and controlURL_ == other.controlURL_ and eventSubURL_ == other.eventSubURL_; |
| 65 | } |
| 66 | |
| 67 | } // namespace upnp |
Sébastien Blin | 464bdff | 2023-07-19 08:02:53 -0400 | [diff] [blame] | 68 | } // namespace dhtnet |