Commit 10bc1540 authored by François Grisez's avatar François Grisez

Change the LinphoneTunnel C API

* The tunnel manager are now thre mode : disable, enable and auto
* Two new functions: linphone_tunnel_set_mode() and linphone_tunnel_get_mode()
* linphone_tunnel_enable(), linphone_tunnel_enabled(), linphone_tunnel_auto_detect()
and linphone_tunnel_auto_detect_enabled() are now deprecated.
parent df8d324a
......@@ -25,11 +25,11 @@
#include <android/log.h>
#endif
belledonnecomm::TunnelManager *bcTunnel(const LinphoneTunnel *tunnel);
using namespace belledonnecomm;
using namespace ::std;
void TunnelManager::addServer(const char *ip, int port,unsigned int udpMirrorPort,unsigned int delay) {
if (ip == NULL) {
ip = "";
......@@ -52,7 +52,6 @@ void TunnelManager::cleanServers() {
mServerAddrs.clear();
UdpMirrorClientList::iterator it;
mAutoDetectStarted=false;
for (it = mUdpMirrorClients.begin(); it != mUdpMirrorClients.end();) {
UdpMirrorClient& s=*it++;
s.stop();
......@@ -96,8 +95,8 @@ RtpTransport *TunnelManager::createRtpTransport(int port){
return t;
}
void TunnelManager::connect() {
if (!mTunnelClient) {
void TunnelManager::startClient() {
if (mTunnelClient == NULL) {
mTunnelClient = new TunnelClient();
mTunnelClient->setCallback((TunnelClientController::StateCallback)tunnelCallback,this);
list<ServerAddr>::iterator it;
......@@ -108,10 +107,23 @@ void TunnelManager::connect() {
mTunnelClient->setHttpProxy(mHttpProxyHost.c_str(), mHttpProxyPort, mHttpUserName.c_str(), mHttpPasswd.c_str());
}
mTunnelClient->start();
linphone_core_set_rtp_transport_factories(mCore,&mTransportFactories);
if(mTunnelizeSipPackets) {
sal_enable_tunnel(mCore->sal, mTunnelClient);
}
}
void TunnelManager::stopClient(){
linphone_core_set_rtp_transport_factories(mCore,NULL);
sal_disable_tunnel(mCore->sal);
if (mTunnelClient){
delete mTunnelClient;
mTunnelClient=NULL;
}
}
bool TunnelManager::isConnected() const {
return mTunnelClient && mTunnelClient->isReady() && mIsConnected;
return mTunnelClient != NULL && mTunnelClient->isReady();
}
int TunnelManager::customSendto(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen){
......@@ -131,13 +143,17 @@ int TunnelManager::customRecvfrom(struct _RtpTransport *t, mblk_t *msg, int flag
TunnelManager::TunnelManager(LinphoneCore* lc) :
mCore(lc),
mEnabled(false),
#ifndef USE_BELLESIP
mSipSocket(NULL),
mExosipTransport(NULL),
#endif
mMode(LinphoneTunnelModeDisable),
mTunnelClient(NULL),
mAutoDetectStarted(false),
mIsConnected(false),
mHttpProxyPort(0),
mPreviousRegistrationEnabled(false),
mTunnelizeSipPackets(true)
mTunnelizeSipPackets(true),
mVTable(NULL)
{
linphone_core_add_iterate_hook(mCore,(LinphoneCoreIterateHook)sOnIterate,this);
mTransportFactories.audio_rtcp_func=sCreateRtpTransport;
......@@ -148,33 +164,20 @@ TunnelManager::TunnelManager(LinphoneCore* lc) :
mTransportFactories.video_rtcp_func_data=this;
mTransportFactories.video_rtp_func=sCreateRtpTransport;
mTransportFactories.video_rtp_func_data=this;
mVTable = linphone_vtable_new();
mVTable->network_reachable = networkReachableCb;
}
TunnelManager::~TunnelManager(){
disconnect();
}
void TunnelManager::disconnect(){
sal_disable_tunnel(mCore->sal);
if (mTunnelClient){
delete mTunnelClient;
mTunnelClient=NULL;
}
stopClient();
if(mMode == LinphoneTunnelModeAuto) linphone_core_remove_listener(mCore, mVTable);
linphone_vtable_destroy(mVTable);
}
void TunnelManager::registration(){
LinphoneProxyConfig* lProxy;
// tunnel was enabled
if (isConnected()){
linphone_core_set_rtp_transport_factories(mCore,&mTransportFactories);
if(mTunnelizeSipPackets) {
sal_enable_tunnel(mCore->sal, mTunnelClient);
}
}
// registration occurs always after an unregistation has been made. First we
// need to reset the previous registration mode
LinphoneProxyConfig* lProxy;
linphone_core_get_default_proxy(mCore, &lProxy);
if (lProxy) {
linphone_proxy_config_edit(lProxy);
......@@ -184,13 +187,11 @@ void TunnelManager::registration(){
}
void TunnelManager::processTunnelEvent(const Event &ev){
if (mEnabled && mTunnelClient->isReady()){
mIsConnected=true;
if (ev.mData.mConnected){
ms_message("Tunnel is up, registering now");
registration();
}else if (mEnabled && !mTunnelClient->isReady()){
/* we got disconnected from the tunnel */
mIsConnected=false;
} else {
ms_error("Tunnel has been disconnected");
}
}
......@@ -225,27 +226,34 @@ void TunnelManager::waitUnRegistration() {
/*Each time tunnel is enabled/disabled, we need to unregister previous session and re-register. Since tunnel initialization
is asynchronous, we temporary disable auto register while tunnel sets up, and reenable it when re-registering. */
void TunnelManager::enable(bool isEnable) {
ms_message("Turning tunnel [%s]", isEnable ?"on" : "off");
if (isEnable && !mEnabled){
mEnabled=true;
//1 unregister
waitUnRegistration();
//2 insert tunnel
connect();
}else if (!isEnable && mEnabled){
//1 unregister
void TunnelManager::setMode(LinphoneTunnelMode mode) {
if(mMode != mode) {
waitUnRegistration();
// 2 stop tunnel
mEnabled=false;
disconnect();
mIsConnected=false;
linphone_core_set_rtp_transport_factories(mCore,NULL);
sal_disable_tunnel(mCore->sal);
// 3 register
registration();
switch(mode) {
case LinphoneTunnelModeEnable:
mMode = mode;
linphone_core_remove_listener(mCore, mVTable);
startClient();
/* registration is done by proccessTunnelEvent() when the tunnel
the tunnel succeed to connect */
break;
case LinphoneTunnelModeDisable:
mMode = mode;
linphone_core_remove_listener(mCore, mVTable);
stopClient();
registration();
break;
case LinphoneTunnelModeAuto:
mMode = mode;
linphone_core_add_listener(mCore, mVTable);
autoDetect();
/* Registration is not needed because processUdpMirrorEvent() will
call either connect() or disconnect(). Should disconnect() is called,
processUdpMirrorEvent() care to call registratin() */
break;
default:
ms_error("TunnelManager::setMode(): invalid mode (%d)", mode);
}
}
}
......@@ -317,15 +325,15 @@ void TunnelManager::enableLogs(bool isEnabled,LogHandler logHandler) {
}
bool TunnelManager::isEnabled() const {
return mEnabled;
LinphoneTunnelMode TunnelManager::getMode() const {
return mMode;
}
void TunnelManager::processUdpMirrorEvent(const Event &ev){
if (ev.mData.mHaveUdp) {
LOGI("Tunnel is not required, disabling");
enable(false);
mAutoDetectStarted = false;
stopClient();
registration();
} else {
mCurrentUdpMirrorClient++;
if (mCurrentUdpMirrorClient !=mUdpMirrorClients.end()) {
......@@ -336,9 +344,8 @@ void TunnelManager::processUdpMirrorEvent(const Event &ev){
lUdpMirrorClient.start(TunnelManager::sUdpMirrorClientCallback,(void*)this);
} else {
LOGI("Tunnel is required, enabling; no backup udp mirror available");
mAutoDetectStarted = false;
startClient();
}
enable(true);
}
}
......@@ -356,21 +363,22 @@ void TunnelManager::sUdpMirrorClientCallback(bool isUdpAvailable, void* data) {
thiz->postEvent(ev);
}
void TunnelManager::networkReachableCb(LinphoneCore *lc, bool_t reachable) {
TunnelManager *tunnel = bcTunnel(linphone_core_get_tunnel(lc));
if(reachable && tunnel->getMode() == LinphoneTunnelModeAuto) {
tunnel->autoDetect();
}
}
void TunnelManager::autoDetect() {
// first check if udp mirrors was provisionned
if (mUdpMirrorClients.empty()) {
LOGE("No UDP mirror server configured aborting auto detection");
return;
}
if (mAutoDetectStarted) {
LOGE("auto detection already in progress, restarting");
(*mCurrentUdpMirrorClient).stop();
}
mAutoDetectStarted=true;
mCurrentUdpMirrorClient =mUdpMirrorClients.begin();
mCurrentUdpMirrorClient = mUdpMirrorClients.begin();
UdpMirrorClient &lUdpMirrorClient=*mCurrentUdpMirrorClient;
lUdpMirrorClient.start(TunnelManager::sUdpMirrorClientCallback,(void*)this);
}
void TunnelManager::setHttpProxyAuthInfo(const char* username,const char* passwd) {
......@@ -382,8 +390,10 @@ void TunnelManager::setHttpProxyAuthInfo(const char* username,const char* passwd
void TunnelManager::tunnelizeSipPackets(bool enable){
if(enable != mTunnelizeSipPackets) {
mTunnelizeSipPackets = enable;
if(mEnabled && isConnected()) {
if(isConnected()) {
waitUnRegistration();
if(mTunnelizeSipPackets) sal_enable_tunnel(mCore->sal, mTunnelClient);
else sal_disable_tunnel(mCore->sal);
registration();
}
}
......
......@@ -15,6 +15,7 @@
#include <tunnel/client.hh>
#include <tunnel/udp_mirror.hh>
#include "linphonecore.h"
#include "linphone_tunnel.h"
#ifndef USE_BELLESIP
extern "C" {
......@@ -70,22 +71,15 @@ namespace belledonnecomm {
**/
void reconnect();
/**
* Sets whether tunneling of SIP and RTP is required.
* @param isEnabled If true enter in tunneled mode, if false exits from tunneled mode.
* The TunnelManager takes care of refreshing SIP registration when switching on or off the tunneled mode.
*
**/
void enable(bool isEnabled);
/**
* In auto detect mode, the tunnel manager try to establish a real time rtp cummunication with the tunnel server on specified port.
*<br/>In case of success, the tunnel is automatically turned off. Otherwise, if no udp commmunication is feasible, tunnel mode is turned on.
*<br/> Call this method each time to run the auto detection algorithm
* @brief setMode
* @param mode
*/
void autoDetect();
void setMode(LinphoneTunnelMode mode);
/**
* Returns a boolean indicating whether tunneled operation is enabled.
**/
bool isEnabled() const;
* @brief Return the tunnel mode
* @return #LinphoneTunnelMode
*/
LinphoneTunnelMode getMode() const;
/**
* Enables debug logs of the Tunnel subsystem.
**/
......@@ -147,6 +141,7 @@ namespace belledonnecomm {
* @return True whether the tunnel is connected
*/
bool isConnected() const;
private:
enum EventType{
UdpMirrorClientEvent,
......@@ -168,6 +163,7 @@ namespace belledonnecomm {
static void tunnelCallback(bool connected, TunnelManager *zis);
static void sOnIterate(TunnelManager *zis);
static void sUdpMirrorClientCallback(bool result, void* data);
static void networkReachableCb(LinphoneCore *lc, bool_t reachable);
private:
void onIterate();
......@@ -176,8 +172,9 @@ namespace belledonnecomm {
void processTunnelEvent(const Event &ev);
void processUdpMirrorEvent(const Event &ev);
void postEvent(const Event &ev);
void connect();
void disconnect();
void startClient();
void stopClient();
void autoDetect();
private:
LinphoneCore* mCore;
......@@ -185,14 +182,13 @@ namespace belledonnecomm {
TunnelSocket *mSipSocket;
eXosip_transport_hooks_t mExosipTransport;
#endif
bool mEnabled;
LinphoneTunnelMode mMode;
std::queue<Event> mEvq;
std::list <ServerAddr> mServerAddrs;
UdpMirrorClientList mUdpMirrorClients;
UdpMirrorClientList::iterator mCurrentUdpMirrorClient;
TunnelClient* mTunnelClient;
Mutex mMutex;
bool mAutoDetectStarted;
bool mIsConnected;
LinphoneRtpTransportFactories mTransportFactories;
std::string mHttpUserName;
......@@ -201,6 +197,7 @@ namespace belledonnecomm {
int mHttpProxyPort;
bool mPreviousRegistrationEnabled;
bool mTunnelizeSipPackets;
LinphoneCoreVTable *mVTable;
};
/**
......
......@@ -29,6 +29,11 @@
#include "private.h"
#include "lpconfig.h"
static const char *_tunnel_mode_str[3] = { "disable", "enable", "auto" };
static LinphoneTunnelMode _string_to_tunnel_mode(const char *string);
static const char *_tunnel_mode_to_string(LinphoneTunnelMode mode);
LinphoneTunnel* linphone_core_get_tunnel(const LinphoneCore *lc){
return lc->tunnel;
}
......@@ -36,7 +41,6 @@ LinphoneTunnel* linphone_core_get_tunnel(const LinphoneCore *lc){
struct _LinphoneTunnel {
belledonnecomm::TunnelManager *manager;
MSList *config_list;
bool_t auto_detect_enabled;
};
extern "C" LinphoneTunnel* linphone_core_tunnel_new(LinphoneCore *lc){
......@@ -45,7 +49,7 @@ extern "C" LinphoneTunnel* linphone_core_tunnel_new(LinphoneCore *lc){
return tunnel;
}
static inline belledonnecomm::TunnelManager *bcTunnel(const LinphoneTunnel *tunnel){
belledonnecomm::TunnelManager *bcTunnel(const LinphoneTunnel *tunnel){
return tunnel->manager;
}
......@@ -232,14 +236,13 @@ void linphone_tunnel_clean_servers(LinphoneTunnel *tunnel){
linphone_tunnel_save_config(tunnel);
}
void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled){
tunnel->auto_detect_enabled = FALSE;
lp_config_set_int(config(tunnel),"tunnel","enabled",(int)enabled);
bcTunnel(tunnel)->enable(enabled);
void linphone_tunnel_set_mode(LinphoneTunnel *tunnel, LinphoneTunnelMode mode){
lp_config_set_string(config(tunnel),"tunnel","mode", _tunnel_mode_to_string(mode));
bcTunnel(tunnel)->setMode(mode);
}
bool_t linphone_tunnel_enabled(const LinphoneTunnel *tunnel){
return bcTunnel(tunnel)->isEnabled();
LinphoneTunnelMode linphone_tunnel_get_mode(const LinphoneTunnel *tunnel){
return bcTunnel(tunnel)->getMode();
}
bool_t linphone_tunnel_connected(const LinphoneTunnel *tunnel){
......@@ -319,18 +322,9 @@ void linphone_tunnel_reconnect(LinphoneTunnel *tunnel){
bcTunnel(tunnel)->reconnect();
}
void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel){
tunnel->auto_detect_enabled = TRUE;
bcTunnel(tunnel)->autoDetect();
}
bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel) {
return tunnel->auto_detect_enabled;
}
void linphone_tunnel_enable_sip(LinphoneTunnel *tunnel, bool_t enable) {
bcTunnel(tunnel)->tunnelizeSipPackets(enable);
lp_config_set_int(config(tunnel), "tunnel", "transport_SIP", (enable ? TRUE : FALSE));
lp_config_set_int(config(tunnel), "tunnel", "sip", (enable ? TRUE : FALSE));
}
bool_t linphone_tunnel_sip_enabled(const LinphoneTunnel *tunnel) {
......@@ -341,15 +335,52 @@ static void my_ortp_logv(OrtpLogLevel level, const char *fmt, va_list args){
ortp_logv(level,fmt,args);
}
static LinphoneTunnelMode _string_to_tunnel_mode(const char *string) {
if(string != NULL) {
int i;
for(i=0; i<3 && strcmp(string, _tunnel_mode_str[i]) != 0; i++);
if(i<3) {
return (LinphoneTunnelMode)i;
} else {
ms_error("Invalid tunnel mode '%s'", string);
return LinphoneTunnelModeDisable;
}
} else {
return LinphoneTunnelModeDisable;
}
}
static const char *_tunnel_mode_to_string(LinphoneTunnelMode mode) {
return _tunnel_mode_str[mode];
}
/**
* Startup tunnel using configuration.
* Called internally from linphonecore at startup.
*/
void linphone_tunnel_configure(LinphoneTunnel *tunnel){
bool_t enabled=(bool_t)lp_config_get_int(config(tunnel),"tunnel","enabled",FALSE);
bool_t tunnelizeSIPPackets = (bool_t)lp_config_get_int(config(tunnel), "tunnel", "transport_SIP", TRUE);
LinphoneTunnelMode mode = _string_to_tunnel_mode(lp_config_get_string(config(tunnel), "tunnel", "mode", NULL));
bool_t tunnelizeSIPPackets = (bool_t)lp_config_get_int(config(tunnel), "tunnel", "sip", TRUE);
linphone_tunnel_enable_logs_with_handler(tunnel,TRUE,my_ortp_logv);
linphone_tunnel_load_config(tunnel);
linphone_tunnel_enable_sip(tunnel, tunnelizeSIPPackets);
linphone_tunnel_enable(tunnel, enabled);
linphone_tunnel_set_mode(tunnel, mode);
}
/* Deprecated functions */
void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled) {
if(enabled) linphone_tunnel_set_mode(tunnel, LinphoneTunnelModeEnable);
else linphone_tunnel_set_mode(tunnel, LinphoneTunnelModeDisable);
}
bool_t linphone_tunnel_enabled(const LinphoneTunnel *tunnel) {
return linphone_tunnel_get_mode(tunnel) == LinphoneTunnelModeEnable;
}
void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel) {
linphone_tunnel_set_mode(tunnel, LinphoneTunnelModeAuto);
}
bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel) {
return linphone_tunnel_get_mode(tunnel) == LinphoneTunnelModeAuto;
}
......@@ -51,8 +51,8 @@ extern "C"
typedef struct _LinphoneTunnelConfig LinphoneTunnelConfig;
typedef enum _LinphoneTunnelMode {
LinphoneTunnelModeDisabled,
LinphoneTunnelModeEnabled,
LinphoneTunnelModeDisable,
LinphoneTunnelModeEnable,
LinphoneTunnelModeAuto
} LinphoneTunnelMode;
......@@ -157,19 +157,21 @@ LINPHONE_PUBLIC const MSList *linphone_tunnel_get_servers(const LinphoneTunnel *
LINPHONE_PUBLIC void linphone_tunnel_clean_servers(LinphoneTunnel *tunnel);
/**
* Sets whether tunneling of SIP and RTP is required.
* @brief Set tunnel mode
* The tunnel mode can be 'enable', 'disable' or 'auto'
* If the mode is set to 'auto', the tunnel manager will try to established an RTP session
* with the tunnel server on the UdpMirrorPort. If the connection fail, the tunnel is automatically
* activated whereas the tunnel is automatically disabled if the connection succeed.
* @param tunnel object
* @param enabled If true enter in tunneled mode, if false exits from tunneled mode.
* The TunnelManager takes care of refreshing SIP registration when switching on or off the tunneled mode.
*
* @param mode See #LinphoneTunnelMode
**/
LINPHONE_PUBLIC void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled);
LINPHONE_PUBLIC void linphone_tunnel_set_mode(LinphoneTunnel *tunnel, LinphoneTunnelMode mode);
/**
* @param tunnel object
* Returns a boolean indicating whether tunneled operation is enabled.
**/
LINPHONE_PUBLIC bool_t linphone_tunnel_enabled(const LinphoneTunnel *tunnel);
LINPHONE_PUBLIC LinphoneTunnelMode linphone_tunnel_get_mode(const LinphoneTunnel *tunnel);
/**
* @param tunnel object
......@@ -186,22 +188,6 @@ LINPHONE_PUBLIC bool_t linphone_tunnel_connected(const LinphoneTunnel *tunnel);
**/
LINPHONE_PUBLIC void linphone_tunnel_reconnect(LinphoneTunnel *tunnel);
/**
* Start tunnel need detection.
* @param tunnel object
* In auto detect mode, the tunnel manager try to establish a real time rtp cummunication with the tunnel server on specified port.
*<br>In case of success, the tunnel is automatically turned off. Otherwise, if no udp commmunication is feasible, tunnel mode is turned on.
*<br> Call this method each time to run the auto detection algorithm
*/
LINPHONE_PUBLIC void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel);
/**
* Tells whether tunnel auto detection is enabled.
* @param[in] tunnel LinphoneTunnel object.
* @return TRUE if auto detection is enabled, FALSE otherwise.
*/
LINPHONE_PUBLIC bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel);
/**
* @brief Set whether SIP packets must be directly sent to a UA or pass through the tunnel
* @param tunnel Tunnel to configure
......@@ -236,8 +222,50 @@ LINPHONE_PUBLIC void linphone_tunnel_set_http_proxy(LinphoneTunnel *tunnel, cons
**/
LINPHONE_PUBLIC void linphone_tunnel_get_http_proxy(LinphoneTunnel*tunnel,const char **host, int *port, const char **username, const char **passwd);
/**
* @brief Set authentication info for the http proxy
* @param tunnel LinphoneTunnel object
* @param username User name
* @param passwd Password
*/
LINPHONE_PUBLIC void linphone_tunnel_set_http_proxy_auth_info(LinphoneTunnel*tunnel, const char* username,const char* passwd);
/**
* @deprecated Replaced by linphone_tunnel_set_mode()
* @brief Sets whether tunneling of SIP and RTP is required.
* @param tunnel object
* @param enabled If true enter in tunneled mode, if false exits from tunneled mode.
* The TunnelManager takes care of refreshing SIP registration when switching on or off the tunneled mode.
*
**/
LINPHONE_PUBLIC void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled);
/**
* @deprecated Replaced by linphone_tunnel_get_mode()
* @brief Check whether tunnel is enabled
* @param tunnel Tunnel object
* @return Returns a boolean indicating whether tunneled operation is enabled.
**/
LINPHONE_PUBLIC bool_t linphone_tunnel_enabled(const LinphoneTunnel *tunnel);
/**
* @deprecated Replaced by linphone_tunnel_set_mode(LinphoneTunnelModeAuto)
* @brief Start tunnel need detection.
* @param tunnel object
* In auto detect mode, the tunnel manager try to establish a real time rtp cummunication with the tunnel server on specified port.
* <br>In case of success, the tunnel is automatically turned off. Otherwise, if no udp commmunication is feasible, tunnel mode is turned on.
* <br> Call this method each time to run the auto detection algorithm
*/
LINPHONE_PUBLIC void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel);
/**
* @deprecated Replaced by linphone_tunnel_get_mode()
* @brief Tells whether tunnel auto detection is enabled.
* @param[in] tunnel LinphoneTunnel object.
* @return TRUE if auto detection is enabled, FALSE otherwise.
*/
LINPHONE_PUBLIC bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel);
/**
* @}
......
......@@ -52,11 +52,11 @@ const MSList *linphone_tunnel_get_servers(const LinphoneTunnel *tunnel){
void linphone_tunnel_clean_servers(LinphoneTunnel *tunnel){
}
void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled){
void linphone_tunnel_set_mode(LinphoneTunnel *tunnel, LinphoneTunnelMode mode) {
}
bool_t linphone_tunnel_enabled(const LinphoneTunnel *tunnel){
return FALSE;
LinphoneTunnelMode linphone_tunnel_get_mode(const LinphoneTunnel *tunnel){
return LinphoneTunnelModeDisable;
}
bool_t linphone_tunnel_connected(const LinphoneTunnel *tunnel){
......@@ -79,11 +79,14 @@ void linphone_tunnel_get_http_proxy(LinphoneTunnel*tunnel,const char **host, int
void linphone_tunnel_reconnect(LinphoneTunnel *tunnel){
}
void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel){
}
void linphone_tunnel_configure(LinphoneTunnel *tunnel){
}
void linphone_tunnel_enable_sip(LinphoneTunnel *tunnel, bool_t enable) {}
bool_t linphone_tunnel_sip_enabled(const LinphoneTunnel *tunnel) { return FALSE; }
/* Deprecated functions */
void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled) {}
bool_t linphone_tunnel_enabled(const LinphoneTunnel *tunnel) { return FALSE; }
void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel) {}
bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel) { return FALSE; }
......@@ -4466,7 +4466,7 @@ LinphoneFirewallPolicy _linphone_core_get_firewall_policy_with_lie(const Linphon
const char *policy;
if(lie) {
LinphoneTunnel *tunnel = linphone_core_get_tunnel(lc);
if(tunnel != NULL && linphone_tunnel_enabled(tunnel)) {
if(tunnel != NULL && linphone_tunnel_get_mode(tunnel)) {
return LinphonePolicyNoFirewall;
}
}
......
......@@ -1409,7 +1409,7 @@ static bool_t can_register(LinphoneProxyConfig *cfg){
#endif //BUILD_UPNP
if (lc->sip_conf.register_only_when_network_is_up){
LinphoneTunnel *tunnel=linphone_core_get_tunnel(lc);
if (tunnel && linphone_tunnel_enabled(tunnel)){
if (tunnel && linphone_tunnel_get_mode(tunnel)){
return linphone_tunnel_connected(tunnel);
}else{
return lc->network_reachable;
......
......@@ -1592,7 +1592,7 @@ void linphone_gtk_edit_tunnel(GtkButton *button){
if (port==0) port=443;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(w,"port")), port);
if (linphone_tunnel_enabled(tunnel)){
if (linphone_tunnel_get_mode(tunnel)){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"radio_enable")),1);
} else{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"radio_disable")),1);
......@@ -1636,7 +1636,7 @@ void linphone_gtk_tunnel_ok(GtkButton *button){
linphone_tunnel_config_set_host(config, host);
linphone_tunnel_config_set_port(config, port);
linphone_tunnel_add_server(tunnel, config);
linphone_tunnel_enable(tunnel,enabled);
linphone_tunnel_set_mode(tunnel, (enabled ? LinphoneTunnelModeEnable : LinphoneTunnelModeDisable));
linphone_tunnel_set_http_proxy(tunnel,http_host,http_port,username,password);
gtk_widget_destroy(w);
......
......@@ -91,7 +91,7 @@ static void call_with_transport_base(bool_t use_tunnel, LinphoneMediaEncryption
tmp_char = linphone_address_as_string(route);
linphone_proxy_config_set_route(proxy, tmp_char);
ms_free(tmp_char);
linphone_tunnel_enable(tunnel, TRUE);
linphone_tunnel_set_mode(tunnel, LinphoneTunnelModeEnable);
linphone_tunnel_config_set_host(config, "tunnel.linphone.org");
linphone_tunnel_config_set_port(config, 443);
linphone_tunnel_add_server(tunnel, config);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment