mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-06 21:33:08 +00:00
Port tunnel to belle-sip.
This commit is contained in:
parent
46bf8a0684
commit
82c498a711
6 changed files with 51 additions and 4 deletions
|
|
@ -126,6 +126,9 @@ AM_CFLAGS=\
|
|||
if BUILD_WIZARD
|
||||
AM_CFLAGS+= -DBUILD_WIZARD
|
||||
endif
|
||||
if USE_BELLESIP
|
||||
AM_CFLAGS+= -DUSE_BELLESIP
|
||||
endif
|
||||
|
||||
AM_CXXFLAGS=$(AM_CFLAGS)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "linphonecore_utils.h"
|
||||
#include "eXosip2/eXosip_transport_hook.h"
|
||||
#include "tunnel/udp_mirror.hh"
|
||||
#include "private.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
|
|
@ -27,6 +28,8 @@
|
|||
using namespace belledonnecomm;
|
||||
using namespace ::std;
|
||||
|
||||
#ifndef USE_BELLESIP
|
||||
|
||||
Mutex TunnelManager::sMutex;
|
||||
|
||||
int TunnelManager::eXosipSendto(int fd,const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen,void* userdata){
|
||||
|
|
@ -99,6 +102,7 @@ int TunnelManager::eXosipSelect(int max_fds, fd_set *s1, fd_set *s2, fd_set *s3,
|
|||
return select(max_fds,s1,s2,s3,tv);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void TunnelManager::addServer(const char *ip, int port,unsigned int udpMirrorPort,unsigned int delay) {
|
||||
|
|
@ -181,7 +185,9 @@ void TunnelManager::start() {
|
|||
}
|
||||
mTunnelClient->start();
|
||||
|
||||
#ifndef USE_BELLESIP
|
||||
if (mSipSocket == NULL) mSipSocket =mTunnelClient->createSocket(5060);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool TunnelManager::isStarted() {
|
||||
|
|
@ -209,17 +215,21 @@ int TunnelManager::customRecvfrom(struct _RtpTransport *t, mblk_t *msg, int flag
|
|||
|
||||
TunnelManager::TunnelManager(LinphoneCore* lc) :TunnelClientController()
|
||||
,mCore(lc)
|
||||
#ifndef USE_BELLESIP
|
||||
,mSipSocket(NULL)
|
||||
#endif
|
||||
,mCallback(NULL)
|
||||
,mEnabled(false)
|
||||
,mTunnelClient(NULL)
|
||||
,mAutoDetectStarted(false)
|
||||
,mHttpProxyPort(0){
|
||||
|
||||
#ifndef USE_BELLESIP
|
||||
mExosipTransport.data=this;
|
||||
mExosipTransport.recvfrom=eXosipRecvfrom;
|
||||
mExosipTransport.sendto=eXosipSendto;
|
||||
mExosipTransport.select=eXosipSelect;
|
||||
#endif
|
||||
linphone_core_add_iterate_hook(mCore,(LinphoneCoreIterateHook)sOnIterate,this);
|
||||
mTransportFactories.audio_rtcp_func=sCreateRtpTransport;
|
||||
mTransportFactories.audio_rtcp_func_data=this;
|
||||
|
|
@ -236,6 +246,9 @@ TunnelManager::~TunnelManager(){
|
|||
}
|
||||
|
||||
void TunnelManager::stopClient(){
|
||||
#ifdef USE_BELLESIP
|
||||
sal_disable_tunnel(mCore->sal);
|
||||
#else
|
||||
eXosip_transport_hook_register(NULL);
|
||||
if (mSipSocket != NULL){
|
||||
sMutex.lock();
|
||||
|
|
@ -243,6 +256,7 @@ void TunnelManager::stopClient(){
|
|||
mSipSocket = NULL;
|
||||
sMutex.unlock();
|
||||
}
|
||||
#endif
|
||||
if (mTunnelClient){
|
||||
delete mTunnelClient;
|
||||
mTunnelClient=NULL;
|
||||
|
|
@ -257,6 +271,9 @@ void TunnelManager::processTunnelEvent(const Event &ev){
|
|||
ms_message("Tunnel is up, registering now");
|
||||
linphone_core_set_firewall_policy(mCore,LinphonePolicyNoFirewall);
|
||||
linphone_core_set_rtp_transport_factories(mCore,&mTransportFactories);
|
||||
#ifdef USE_BELLESIP
|
||||
sal_enable_tunnel(mCore->sal, mTunnelClient);
|
||||
#else
|
||||
eXosip_transport_hook_register(&mExosipTransport);
|
||||
//force transport to udp
|
||||
LCSipTransports lTransport;
|
||||
|
|
@ -267,6 +284,7 @@ void TunnelManager::processTunnelEvent(const Event &ev){
|
|||
lTransport.dtls_port=0;
|
||||
|
||||
linphone_core_set_sip_transports(mCore, &lTransport);
|
||||
#endif
|
||||
//register
|
||||
if (lProxy) {
|
||||
linphone_proxy_config_done(lProxy);
|
||||
|
|
@ -320,7 +338,11 @@ void TunnelManager::enable(bool isEnable) {
|
|||
|
||||
linphone_core_set_rtp_transport_factories(mCore,NULL);
|
||||
|
||||
#ifdef USE_BELLESIP
|
||||
sal_disable_tunnel(mCore->sal);
|
||||
#else
|
||||
eXosip_transport_hook_register(NULL);
|
||||
#endif
|
||||
//Restore transport and firewall policy
|
||||
linphone_core_set_sip_transports(mCore, &mRegularTransport);
|
||||
linphone_core_set_firewall_policy(mCore, mPreviousFirewallPolicy);
|
||||
|
|
@ -387,7 +409,7 @@ void TunnelManager::enableLogs(bool isEnabled,LogHandler logHandler) {
|
|||
#ifdef ANDROID
|
||||
else SetLogHandler(linphone_android_tunnel_log_handler);
|
||||
#else
|
||||
else SetLogHandler(default_log_handler);
|
||||
else SetLogHandler(tunnel_default_log_handler);
|
||||
#endif
|
||||
|
||||
if (isEnabled) {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,12 @@
|
|||
#include "tunnel/client.hh"
|
||||
#include "linphonecore.h"
|
||||
|
||||
#ifndef USE_BELLESIP
|
||||
extern "C" {
|
||||
#include "eXosip2/eXosip_transport_hook.h"
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace belledonnecomm {
|
||||
class TunnelClient;
|
||||
class UdpMirrorClient;
|
||||
|
|
@ -159,8 +162,10 @@ class UdpMirrorClient;
|
|||
void postEvent(const Event &ev);
|
||||
LinphoneCore* mCore;
|
||||
LCSipTransports mRegularTransport;
|
||||
#ifndef USE_BELLESIP
|
||||
TunnelSocket *mSipSocket;
|
||||
eXosip_transport_hooks_t mExosipTransport;
|
||||
#endif
|
||||
StateCallback mCallback;
|
||||
void * mCallbackData;
|
||||
bool mEnabled;
|
||||
|
|
|
|||
|
|
@ -515,6 +515,21 @@ void sal_set_keepalive_period(Sal *ctx,unsigned int value){
|
|||
}
|
||||
return ;
|
||||
}
|
||||
int sal_enable_tunnel(Sal *ctx, void *tunnelclient) {
|
||||
int result;
|
||||
|
||||
sal_unlisten_ports(ctx);
|
||||
belle_sip_listening_point_t* lp = belle_sip_tunnel_listening_point_new(ctx->stack, tunnelclient);
|
||||
if (lp == NULL) return -1;
|
||||
|
||||
belle_sip_listening_point_set_keep_alive(lp, ctx->keep_alive);
|
||||
result = belle_sip_provider_add_listening_point(ctx->prov, lp);
|
||||
set_tls_properties(ctx);
|
||||
return result;
|
||||
}
|
||||
void sal_disable_tunnel(Sal *ctx) {
|
||||
sal_unlisten_ports(ctx);
|
||||
}
|
||||
/**
|
||||
* returns keepalive period in ms
|
||||
* 0 desactiaved
|
||||
|
|
|
|||
|
|
@ -5366,6 +5366,9 @@ static void linphone_core_uninit(LinphoneCore *lc)
|
|||
video_preview_stop(lc->previewstream);
|
||||
lc->previewstream=NULL;
|
||||
}
|
||||
#endif
|
||||
#ifdef TUNNEL_ENABLED
|
||||
if (lc->tunnel) linphone_tunnel_destroy(lc->tunnel);
|
||||
#endif
|
||||
ms_event_queue_destroy(lc->msevq);
|
||||
lc->msevq=NULL;
|
||||
|
|
@ -5414,9 +5417,6 @@ static void linphone_core_uninit(LinphoneCore *lc)
|
|||
linphone_core_message_storage_close(lc);
|
||||
ortp_exit();
|
||||
linphone_core_set_state(lc,LinphoneGlobalOff,"Off");
|
||||
#ifdef TUNNEL_ENABLED
|
||||
if (lc->tunnel) linphone_tunnel_destroy(lc->tunnel);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t curtime){
|
||||
|
|
|
|||
|
|
@ -383,6 +383,8 @@ void sal_set_user_agent(Sal *ctx, const char *user_agent);
|
|||
/*keepalive period in ms*/
|
||||
void sal_set_keepalive_period(Sal *ctx,unsigned int value);
|
||||
void sal_use_tcp_tls_keepalive(Sal *ctx, bool_t enabled);
|
||||
int sal_enable_tunnel(Sal *ctx, void *tunnelclient);
|
||||
void sal_disable_tunnel(Sal *ctx);
|
||||
/**
|
||||
* returns keepalive period in ms
|
||||
* 0 desactiaved
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue