Commit b1f7136e authored by Guillaume Beraudo's avatar Guillaume Beraudo
Browse files

Detect SSL support in exosip and disable TLS accordingly.

parent e6d835fa
......@@ -529,6 +529,10 @@ static void sip_config_read(LinphoneCore *lc)
random_port=(0xDFFF&random())+1024;
else random_port=0;
if (!sal_is_transport_enabled(lc->sal, SalTransportTLS)) {
tr.tls_port=0;
}
if (tr.udp_port==0 && tr.tcp_port==0 && tr.tls_port==0){
tr.udp_port=5060;
}
......@@ -1689,6 +1693,17 @@ int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *tr){
return 0;
}
/**
* Set a non null value to the enabled transports.
**/
int linphone_core_get_transports_supported(LinphoneCore *lc, LCSipTransports *transports) {
transports->udp_port=sal_is_transport_enabled(lc->sal, SalTransportUDP);
transports->tcp_port=sal_is_transport_enabled(lc->sal, SalTransportTCP);
transports->tls_port=sal_is_transport_enabled(lc->sal, SalTransportTLS);
transports->dtls_port=sal_is_transport_enabled(lc->sal, SalTransportDTLS);
return 0;
}
/**
* Sets the UDP port to be used by SIP.
*
......
......@@ -1132,6 +1132,8 @@ int linphone_core_get_sip_port(LinphoneCore *lc);
int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports *transports);
int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *transports);
int linphone_core_get_transports_supported(LinphoneCore *lc, LCSipTransports *transports);
/**
*
* Give access to the UDP sip socket. Can be useful to configure this socket as persistent I.E kCFStreamNetworkServiceType set to kCFStreamNetworkServiceTypeVoIP)
......
......@@ -53,6 +53,7 @@ typedef enum {
SalTransportDTLS /*DTLS*/
}SalTransport;
bool_t sal_is_transport_enabled(Sal *sal, SalTransport transport);
const char* sal_transport_to_string(SalTransport transport);
SalTransport sal_transport_parse(const char*);
/* Address manipulation API*/
......
......@@ -284,6 +284,7 @@ Sal * sal_init(){
sal->verify_server_certs=TRUE;
sal->expire_old_contact=FALSE;
sal->dscp=-1;
sal->exosip_has_ssl=eXosip_tls_verify_certificate(0) != -1;
return sal;
}
......@@ -2521,3 +2522,10 @@ int sal_call_update(SalOp *h, const char *subject){
void sal_reuse_authorization(Sal *ctx, bool_t value) {
ctx->reuse_authorization=value;
}
bool_t sal_is_transport_enabled(Sal *sal, SalTransport transport) {
if (transport == SalTransportTLS || transport == SalTransportDTLS) {
return sal->exosip_has_ssl;
}
return TRUE;
}
......@@ -49,6 +49,7 @@ struct Sal{
bool_t reuse_authorization;
bool_t verify_server_certs;
bool_t expire_old_contact;
bool_t exosip_has_ssl;
};
struct SalOp{
......
......@@ -321,13 +321,14 @@
<object class="GtkComboBox" id="proto_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">model8</property>
<!-- <property name="model">model8</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
-->
</object>
</child>
<child>
......
......@@ -875,6 +875,56 @@ static void linphone_gtk_show_media_encryption(GtkWidget *pb){
g_object_unref(G_OBJECT(model));
}
static void linphone_gtk_show_transports(GtkWidget *pb){
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *combo=linphone_gtk_get_widget(pb,"proto_combo");
GtkTreeModel *model;
GtkListStore *store;
GtkTreeIter iter;
GtkCellRenderer *renderer=gtk_cell_renderer_text_new();
LCSipTransports enabled,tr;
model=GTK_TREE_MODEL((store=gtk_list_store_new(1,G_TYPE_STRING)));
gtk_combo_box_set_model(GTK_COMBO_BOX(combo),model);
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo),renderer,TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo),renderer,"text",0,NULL);
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,_("UDP"),-1);
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,_("TCP"),-1);
linphone_core_get_transports_supported(lc, &enabled);
if (enabled.tls_port != 0){
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,_("TLS"),-1);
}
linphone_core_get_sip_transports(lc,&tr);
if (tr.tcp_port > 0) {
gtk_combo_box_set_active(GTK_COMBO_BOX(linphone_gtk_get_widget(pb,"proto_combo")), 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"proto_port")),
tr.tcp_port);
}
else if (tr.tls_port > 0) {
gtk_combo_box_set_active(GTK_COMBO_BOX(linphone_gtk_get_widget(pb,"proto_combo")), 2);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"proto_port")),
tr.tls_port);
}
else {
gtk_combo_box_set_active(GTK_COMBO_BOX(linphone_gtk_get_widget(pb,"proto_combo")), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"proto_port")),
tr.udp_port);
}
g_signal_connect(G_OBJECT(combo),"changed",(GCallback)linphone_gtk_proto_changed,NULL);
g_object_unref(G_OBJECT(model));
}
void linphone_gtk_parameters_destroyed(GtkWidget *pb){
GtkWidget *mw=linphone_gtk_get_main_window();
g_object_set_data(G_OBJECT(mw),"parameters",NULL);
......@@ -907,7 +957,6 @@ void linphone_gtk_show_parameters(void){
GtkWidget *codec_list;
int mtu;
int ui_advanced;
LCSipTransports tr;
if (pb==NULL) {
pb=linphone_gtk_create_window("parameters");
......@@ -921,28 +970,8 @@ void linphone_gtk_show_parameters(void){
/* NETWORK CONFIG */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb,"ipv6_enabled")),
linphone_core_ipv6_enabled(lc));
linphone_core_get_sip_transports(lc,&tr);
if (tr.tcp_port > 0) {
gtk_combo_box_set_active(GTK_COMBO_BOX(linphone_gtk_get_widget(pb,"proto_combo")), 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"proto_port")),
tr.tcp_port);
}
else if (tr.tls_port > 0) {
gtk_combo_box_set_active(GTK_COMBO_BOX(linphone_gtk_get_widget(pb,"proto_combo")), 2);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"proto_port")),
tr.tls_port);
}
else {
gtk_combo_box_set_active(GTK_COMBO_BOX(linphone_gtk_get_widget(pb,"proto_combo")), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"proto_port")),
tr.udp_port);
}
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"audio_rtp_port")),
linphone_core_get_audio_port(lc));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"video_rtp_port")),
linphone_core_get_video_port(lc));
linphone_gtk_show_transports(pb);
linphone_gtk_show_media_encryption(pb);
......@@ -1020,8 +1049,6 @@ void linphone_gtk_show_parameters(void){
linphone_gtk_ui_level_adapt(pb);
g_signal_connect(G_OBJECT(linphone_gtk_get_widget(pb,"proto_port")),"value-changed",(GCallback)linphone_gtk_update_my_port,NULL);
g_signal_connect(G_OBJECT(linphone_gtk_get_widget(pb,"proto_combo")),"changed",(GCallback)linphone_gtk_proto_changed,NULL);
if (linphone_core_tunnel_available()){
gtk_widget_set_visible(GTK_WIDGET(linphone_gtk_get_widget(pb,"tunnel_edit_button")), TRUE);
......
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