blob: 18be2d4ac7b1dde4d5172872692f0ca1e6d76f8c [file] [log] [blame]
Adrien Béraud612b55b2023-05-29 10:42:04 -04001/*
2 * Copyright (C) 2004-2023 Savoir-faire Linux Inc.
3 *
4 * Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
5 * Author: Eden Abitbol <eden.abitbol@savoirfairelinux.com>
6 * Author: Mohamed Chibani <mohamed.chibani@savoirfairelinux.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#include "upnp_igd.h"
24
Adrien Béraud1ae60aa2023-07-07 09:55:09 -040025namespace dhtnet {
Adrien Béraud612b55b2023-05-29 10:42:04 -040026namespace upnp {
27
28UPnPIGD::UPnPIGD(std::string&& UDN,
29 std::string&& baseURL,
30 std::string&& friendlyName,
31 std::string&& serviceType,
32 std::string&& serviceId,
33 std::string&& locationURL,
34 std::string&& controlURL,
35 std::string&& eventSubURL,
36 IpAddr&& localIp,
37 IpAddr&& publicIp)
38 : IGD(NatProtocolType::PUPNP)
39{
40 uid_ = std::move(UDN);
41 baseURL_ = std::move(baseURL);
42 friendlyName_ = std::move(friendlyName);
43 serviceType_ = std::move(serviceType);
44 serviceId_ = std::move(serviceId);
45 locationURL_ = std::move(locationURL);
46 controlURL_ = std::move(controlURL);
47 eventSubURL_ = std::move(eventSubURL);
48 localIp_ = std::move(localIp);
49 publicIp_ = std::move(publicIp);
50}
51
52bool
53UPnPIGD::operator==(IGD& other) const
54{
55 return localIp_ == other.getLocalIp() and publicIp_ == other.getPublicIp();
56}
57
58bool
59UPnPIGD::operator==(UPnPIGD& other) const
60{
61 if (localIp_ and publicIp_) {
62 if (localIp_ != other.localIp_ or publicIp_ != other.publicIp_) {
63 return false;
64 }
65 }
66
67 return uid_ == other.uid_ and baseURL_ == other.baseURL_
68 and friendlyName_ == other.friendlyName_ and serviceType_ == other.serviceType_
69 and serviceId_ == other.serviceId_ and locationURL_ == other.locationURL_
70 and controlURL_ == other.controlURL_ and eventSubURL_ == other.eventSubURL_;
71}
72
73} // namespace upnp
74} // namespace jami