From 4bc67e3645d0e8c42a54f1174254cd17109743e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 16 Sep 2014 16:09:14 +0200 Subject: [PATCH] Add transport_SIP boolean parameter in "tunnel" of the configuration file If this parameter is set to 1, SIP packets will pass through tunnels when the tunnel mode is enabled. If set to 0, SIP packets will be directly sent to proxies whatever the state of tunnels --- coreapi/TunnelManager.cc | 4 ++++ coreapi/TunnelManager.hh | 7 ++++++- coreapi/linphone_tunnel.cc | 12 +++++++++++- coreapi/linphone_tunnel.h | 14 ++++++++++++++ coreapi/linphone_tunnel_stubs.c | 2 ++ coreapi/linphonecore.c | 4 +++- 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index 35927b5e0..6c50abf13 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -400,6 +400,10 @@ void TunnelManager::tunnelizeSipPackets(bool enable){ } } +bool TunnelManager::tunnelizeSipPacketsEnabled() const { + return mTunnelizeSipPackets; +} + void TunnelManager::setHttpProxy(const char *host,int port, const char *username, const char *passwd){ mHttpUserName=username?username:""; mHttpPasswd=passwd?passwd:""; diff --git a/coreapi/TunnelManager.hh b/coreapi/TunnelManager.hh index 0c6f8c5b4..c7d8eeb9f 100644 --- a/coreapi/TunnelManager.hh +++ b/coreapi/TunnelManager.hh @@ -122,7 +122,12 @@ class UdpMirrorClient; * @param enable If set to TRUE, SIP packets will pass through the tunnel. * If set to FALSE, SIP packets will pass by the configured proxies. */ - void tunnelizeSipPackets(bool enable = true); + void tunnelizeSipPackets(bool enable); + /** + * @brief Check whether the tunnel manager is set to tunnelize SIP packets + * @return True, SIP packets pass through the tunnel + */ + bool tunnelizeSipPacketsEnabled() const; /** * @brief Destructor */ diff --git a/coreapi/linphone_tunnel.cc b/coreapi/linphone_tunnel.cc index 7a79140d9..8804bcc23 100644 --- a/coreapi/linphone_tunnel.cc +++ b/coreapi/linphone_tunnel.cc @@ -328,6 +328,15 @@ bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel) { return tunnel->auto_detect_enabled; } +void linphone_tunnel_enable_sip_packets_transport(LinphoneTunnel *tunnel, bool_t enable) { + bcTunnel(tunnel)->tunnelizeSipPackets(enable); + lp_config_set_int(config(tunnel), "tunnel", "transport_SIP", (enable ? TRUE : FALSE)); +} + +bool_t linphone_tunnel_sip_packets_transport_is_enabled(const LinphoneTunnel *tunnel) { + return bcTunnel(tunnel)->tunnelizeSipPacketsEnabled() ? TRUE : FALSE; +} + static void my_ortp_logv(OrtpLogLevel level, const char *fmt, va_list args){ ortp_logv(level,fmt,args); } @@ -338,8 +347,9 @@ static void my_ortp_logv(OrtpLogLevel level, const char *fmt, va_list args){ */ 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); linphone_tunnel_enable_logs_with_handler(tunnel,TRUE,my_ortp_logv); linphone_tunnel_load_config(tunnel); + linphone_tunnel_enable_sip_packets_transport(tunnel, tunnelizeSIPPackets); linphone_tunnel_enable(tunnel, enabled); } - diff --git a/coreapi/linphone_tunnel.h b/coreapi/linphone_tunnel.h index 50e58c7c0..a6266a2f1 100644 --- a/coreapi/linphone_tunnel.h +++ b/coreapi/linphone_tunnel.h @@ -196,6 +196,20 @@ LINPHONE_PUBLIC void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel); */ 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 a tunnel + * @param tunnel Tunnel to configure + * @param enable If true, SIP packets shall pass through a tunnel + */ +LINPHONE_PUBLIC void linphone_tunnel_enable_sip_packets_transport(LinphoneTunnel *tunnel, bool_t enable); + +/** + * @brief Checks wether tunnel is set to transport SIP packets + * @param LinphoneTunnel + * @return tunnel True, SIP packets shall pass through a tunnel + */ +LINPHONE_PUBLIC bool_t linphone_tunnel_sip_packets_transport_is_enabled(const LinphoneTunnel *tunnel); + /** * Set an optional http proxy to go through when connecting to tunnel server. * @param tunnel LinphoneTunnel object diff --git a/coreapi/linphone_tunnel_stubs.c b/coreapi/linphone_tunnel_stubs.c index 5b93bca64..a79ee5eb6 100644 --- a/coreapi/linphone_tunnel_stubs.c +++ b/coreapi/linphone_tunnel_stubs.c @@ -85,3 +85,5 @@ void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel){ void linphone_tunnel_configure(LinphoneTunnel *tunnel){ } +void linphone_tunnel_enable_sip_packets_transport(LinphoneTunnel *tunnel, bool_t enable) {} +bool_t linphone_tunnel_sip_packets_transport_is_enabled(const LinphoneTunnel *tunnel) {} diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 1e1c7fbbb..240149837 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1025,7 +1025,9 @@ static void linphone_core_start(LinphoneCore * lc) { ui_config_read(lc); #ifdef TUNNEL_ENABLED lc->tunnel=linphone_core_tunnel_new(lc); - if (lc->tunnel) linphone_tunnel_configure(lc->tunnel); + if (lc->tunnel) { + linphone_tunnel_configure(lc->tunnel); + } #endif linphone_core_notify_display_status(lc,_("Ready"));