blob: 8c8a580e943b490a945e97f8a6502ab36e6faae8 [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#include "upnp_igd.h"
18
Adrien Béraud1ae60aa2023-07-07 09:55:09 -040019namespace dhtnet {
Adrien Béraud612b55b2023-05-29 10:42:04 -040020namespace upnp {
21
22UPnPIGD::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
46bool
47UPnPIGD::operator==(IGD& other) const
48{
49 return localIp_ == other.getLocalIp() and publicIp_ == other.getPublicIp();
50}
51
52bool
53UPnPIGD::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 Blin464bdff2023-07-19 08:02:53 -040068} // namespace dhtnet