Adrien Béraud | cb75362 | 2023-07-17 22:32:49 -0400 | [diff] [blame] | 1 | /* |
| 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éraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 17 | #pragma once |
| 18 | |
Adrien Béraud | 67ff077 | 2023-07-12 11:22:29 -0400 | [diff] [blame] | 19 | #include "ip_utils.h" |
| 20 | |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 21 | #include <functional> |
| 22 | #include <vector> |
| 23 | #include <string> |
Adrien Béraud | 67ff077 | 2023-07-12 11:22:29 -0400 | [diff] [blame] | 24 | #include <memory> |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 25 | |
Adrien Béraud | 1ae60aa | 2023-07-07 09:55:09 -0400 | [diff] [blame] | 26 | namespace dhtnet { |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 27 | |
Adrien Béraud | 25c30c4 | 2023-07-05 13:46:54 -0400 | [diff] [blame] | 28 | namespace upnp { |
| 29 | class UPnPContext; |
| 30 | } |
| 31 | |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 32 | class IceTransportFactory; |
| 33 | using IceTransportCompleteCb = std::function<void(bool)>; |
| 34 | |
| 35 | struct 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 | |
| 45 | struct 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 | |
| 70 | struct IceTransportOptions |
| 71 | { |
Amna | 81221ad | 2023-09-14 17:33:26 -0400 | [diff] [blame] | 72 | std::shared_ptr<IceTransportFactory> factory {}; |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 73 | 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éraud | 25c30c4 | 2023-07-05 13:46:54 -0400 | [diff] [blame] | 85 | std::shared_ptr<upnp::UPnPContext> upnpContext {}; |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } |