Tunnel.h 4.87 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
Tunnel.h
Copyright (C) 2015  Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
15 16
*/

Ghislain MARY's avatar
Ghislain MARY committed
17 18 19 20
#pragma once

#include "Enums.h"
#include "Utils.h"
21

22

23 24 25
// Do not treat doxygen documentation as XML
#pragma warning(push)
#pragma warning(disable : 4635)
26
#include "linphone/linphone_tunnel.h"
27
#pragma warning(pop)
Ghislain MARY's avatar
Ghislain MARY committed
28

29
namespace BelledonneCommunications
Ghislain MARY's avatar
Ghislain MARY committed
30
{
31
	namespace Linphone
Ghislain MARY's avatar
Ghislain MARY committed
32
	{
33
		namespace Native
Ghislain MARY's avatar
Ghislain MARY committed
34
		{
35
			ref class Core;
36 37

			/// <summary>
38
			/// Tunnel server configuration.
39
			/// </summary>
40
			public ref class TunnelConfig sealed
Ghislain MARY's avatar
Ghislain MARY committed
41
			{
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
			public:
				/// <summary>
				/// Constructs a TunnelConfig.
				/// </summary>
				/// <param name="host">The tunnel server host</param>
				/// <param name="port">The tunnel server port</param>
				/// <param name="udpMirrorPort">The tunnel server UDP mirror port</param>
				/// <param name="roundTripDelay">The round trip delay</param>
				TunnelConfig(Platform::String^ host, int port, int udpMirrorPort, int roundTripDelay);

				/// <summary>
				/// The tunnel server host.
				/// </summary>
				property Platform::String^ Host
				{
					Platform::String^ get();
					void set(Platform::String^ value);
				}

				/// <summary>
				/// The tunnel server port.
				/// </summary>
				property int Port
				{
					int get();
					void set(int value);
				}

				/// <summary>
				/// The round trip delay.
				/// </summary>
				property int RoundTripDelay
				{
					int get();
					void set(int value);
				}

				/// <summary>
				/// The tunnel server UDP mirror port.
				/// </summary>
				property int UdpMirrorPort
				{
					int get();
					void set(int value);
				}

				/// <summary>
				/// Gets a string representation of the TunnelConfig.
				/// </summary>
				/// <returns>The string representation of the tunnel config</returns>
				virtual Platform::String^ ToString() override;

			private:
				Platform::String^ host;
				int port;
				int udpMirrorPort;
				int roundTripDelay;
			};
Ghislain MARY's avatar
Ghislain MARY committed
100 101 102


			/// <summary>
103
			/// Main object obtained by LinphoneCore.GetTunnel()
Ghislain MARY's avatar
Ghislain MARY committed
104
			/// </summary>
105
			public ref class Tunnel sealed
106
			{
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
			public:
				/// <summary>
				/// Enables the tunnel.
				/// </summary>
				property bool IsEnabled
				{
					bool get();
					void set(bool value);
				}

				/// <summary>
				/// Add a server to the tunnel configuration
				/// </summary>
				/// <param name="host">Tunnel server IP address</param>
				/// <param name="port">Tunnel server TLS port, recommended value is 443</param>
				void AddServer(Platform::String^ host, int port);

				/// <summary>
				/// Add a server to the tunnel configuration
				/// </summary>
				/// <param name="host">Tunnel server IP address</param>
				/// <param name="port">Tunnel server TLS port, recommended value is 443</param>
				/// <param name="udpMirrorPort">Remote port on the tunnel server side used to test UDP reachability</param>
				/// <param name="roundTripDelay">UDP packet round trip delay in ms considered as acceptable. Recommended value is 1000 ms.</param>
				void AddServer(Platform::String^ host, int port, int udpMirrorPort, int roundTripDelay);

				/// <summary>
				/// Start tunnel need detection.
				/// </summary>
				void AutoDetect();

				/// <summary>
				/// Removes all tunnel server addresses previously entered with AddServer().
				/// </summary>
				void CleanServers();

				/// <summary>
				/// Returns an IList&lt;Object&gt; where each object is a TunnelConfig.
				/// </summary>
				/// <returns>A list of TunnelConfig</returns>
				Windows::Foundation::Collections::IVector<Platform::Object^>^ GetServers();

				/// <summary>
				/// Set an optional http proxy to go through when connecting to tunnel server.
				/// </summary>
				/// <param name="host">Http proxy host</param>
				/// <param name="port">Http proxy port</param>
				/// <param name="username">Optional http proxy username if the proxy request authentication. Currently only basic authentication is supported. Use null if not needed.</param>
				/// <param name="password">Optional http proxy password. Use null if not needed.</param>
				void SetHttpProxy(Platform::String^ host, int port, Platform::String^ username, Platform::String^ password);

			private:
				friend ref class Core;

				Tunnel(::LinphoneTunnel *tunnel);
				~Tunnel();

				::LinphoneTunnel *lt;
			};
		}
Ghislain MARY's avatar
Ghislain MARY committed
167 168
	}
}