blob: 33ac76efcc4a466a8f9644defaf8dc089e1eb9a5 [file] [log] [blame]
Adrien Béraudcb753622023-07-17 22:32:49 -04001/*
2 * Copyright (C) 2004-2023 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
Adrien Béraud612b55b2023-05-29 10:42:04 -040017#pragma once
18
Adrien Béraud67ff0772023-07-12 11:22:29 -040019#include "ip_utils.h"
20
Adrien Béraud612b55b2023-05-29 10:42:04 -040021#include <functional>
22#include <vector>
23#include <string>
Adrien Béraud67ff0772023-07-12 11:22:29 -040024#include <memory>
Adrien Béraud612b55b2023-05-29 10:42:04 -040025
Adrien Béraud1ae60aa2023-07-07 09:55:09 -040026namespace dhtnet {
Adrien Béraud612b55b2023-05-29 10:42:04 -040027
Adrien Béraud25c30c42023-07-05 13:46:54 -040028namespace upnp {
29class UPnPContext;
30}
31
Adrien Béraud612b55b2023-05-29 10:42:04 -040032class IceTransportFactory;
33using IceTransportCompleteCb = std::function<void(bool)>;
34
35struct StunServerInfo
36{
37 inline StunServerInfo& setUri(const std::string& args) {
38 uri = args;
39 return *this;
40 }
41
42 std::string uri; // server URI, mandatory
43};
44
45struct TurnServerInfo
46{
47 inline TurnServerInfo& setUri(const std::string& args) {
48 uri = args;
49 return *this;
50 }
51 inline TurnServerInfo& setUsername(const std::string& args) {
52 username = args;
53 return *this;
54 }
55 inline TurnServerInfo& setPassword(const std::string& args) {
56 password = args;
57 return *this;
58 }
59 inline TurnServerInfo& setRealm(const std::string& args) {
60 realm = args;
61 return *this;
62 }
63
64 std::string uri; // server URI, mandatory
65 std::string username; // credentials username (optional, empty if not used)
66 std::string password; // credentials password (optional, empty if not used)
67 std::string realm; // credentials realm (optional, empty if not used)
68};
69
70struct IceTransportOptions
71{
Amna81221ad2023-09-14 17:33:26 -040072 std::shared_ptr<IceTransportFactory> factory {};
Adrien Béraud612b55b2023-05-29 10:42:04 -040073 bool master {true};
74 unsigned streamsCount {1};
75 unsigned compCountPerStream {1};
76 bool upnpEnable {false};
77 IceTransportCompleteCb onInitDone {};
78 IceTransportCompleteCb onNegoDone {};
79 std::vector<StunServerInfo> stunServers;
80 std::vector<TurnServerInfo> turnServers;
81 bool tcpEnable {false};
82 // Addresses used by the account owning the transport instance.
83 IpAddr accountLocalAddr {};
84 IpAddr accountPublicAddr {};
Adrien Béraud25c30c42023-07-05 13:46:54 -040085 std::shared_ptr<upnp::UPnPContext> upnpContext {};
Adrien Béraud612b55b2023-05-29 10:42:04 -040086};
87
88}