blob: 2ad213ba4caa90270fb2b570bc60b5985533931c [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#pragma once
24
25#include "connectivity/upnp/protocol/igd.h"
26
27#include "noncopyable.h"
28#include "connectivity/ip_utils.h"
29
30#include <map>
31#include <string>
32#include <chrono>
33#include <functional>
34
35namespace jami {
36namespace upnp {
37
38class UPnPIGD : public IGD
39{
40public:
41 UPnPIGD(std::string&& UDN,
42 std::string&& baseURL,
43 std::string&& friendlyName,
44 std::string&& serviceType,
45 std::string&& serviceId,
46 std::string&& locationURL,
47 std::string&& controlURL,
48 std::string&& eventSubURL,
49 IpAddr&& localIp = {},
50 IpAddr&& publicIp = {});
51
52 ~UPnPIGD() {}
53
54 bool operator==(IGD& other) const;
55 bool operator==(UPnPIGD& other) const;
56
57 const std::string& getBaseURL() const
58 {
59 std::lock_guard<std::mutex> lock(mutex_);
60 return baseURL_;
61 }
62 const std::string& getFriendlyName() const
63 {
64 std::lock_guard<std::mutex> lock(mutex_);
65 return friendlyName_;
66 }
67 const std::string& getServiceType() const
68 {
69 std::lock_guard<std::mutex> lock(mutex_);
70 return serviceType_;
71 }
72 const std::string& getServiceId() const
73 {
74 std::lock_guard<std::mutex> lock(mutex_);
75 return serviceId_;
76 }
77 const std::string& getLocationURL() const
78 {
79 std::lock_guard<std::mutex> lock(mutex_);
80 return locationURL_;
81 }
82 const std::string& getControlURL() const
83 {
84 std::lock_guard<std::mutex> lock(mutex_);
85 return controlURL_;
86 }
87 const std::string& getEventSubURL() const
88 {
89 std::lock_guard<std::mutex> lock(mutex_);
90 return eventSubURL_;
91 }
92
93 const std::string toString() const override { return controlURL_; }
94
95private:
96 std::string baseURL_ {};
97 std::string friendlyName_ {};
98 std::string serviceType_ {};
99 std::string serviceId_ {};
100 std::string locationURL_ {};
101 std::string controlURL_ {};
102 std::string eventSubURL_ {};
103};
104
105} // namespace upnp
106} // namespace jami