Commit cefc03e5 authored by Slava Monich's avatar Slava Monich

Merge branch 'pcscf' into 'master'

Expose P-CSCF address(es) over D-Bus

See merge request mer-core/ofono!285
parents 85d99536 b95a089c
......@@ -278,6 +278,13 @@ Properties boolean Active [readwrite]
via this proxy. All other values are left
out in this case.
array{string} ProxyCSCF [readonly, optional]
Holds the list of P-CSCF (SIP proxy) for this
context. Only used by IMS connections.
This is a Sailfish OS specific extension.
dict IPv6.Settings [readonly, optional]
Holds all the IPv6 network settings
......@@ -304,6 +311,13 @@ Properties boolean Active [readwrite]
Holds the gateway IP for this connection.
array{string} ProxyCSCF [readonly, optional]
Holds the list of P-CSCF (SIP proxy) for this
context. Only used by IMS connections.
This is a Sailfish OS specific extension.
string MessageProxy [readwrite, MMS only]
Holds the MMS Proxy setting.
......
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2019 Jolla Ltd.
* Copyright (C) 2015-2021 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
......@@ -254,34 +254,59 @@ static void ril_gprs_context_set_gateway(struct ofono_gprs_context *gc,
ofono_gprs_context_set_ipv6_gateway(gc, ipv6_gw);
}
static void ril_gprs_context_set_dns_servers(struct ofono_gprs_context *gc,
const struct ril_data_call *call)
typedef void (*ofono_gprs_context_list_setter_t)(struct ofono_gprs_context *gc,
const char **list);
static void ril_gprs_context_set_servers(struct ofono_gprs_context *gc,
char * const *list, ofono_gprs_context_list_setter_t set_ipv4,
ofono_gprs_context_list_setter_t set_ipv6)
{
int i;
char * const *list = call->dnses;
const char **ip_list = NULL, **ip_ptr = NULL;
const char **ipv6_list = NULL, **ipv6_ptr = NULL;
const int n = gutil_strv_length(list);
const char **ip_dns = g_new0(const char *, n+1);
const char **ipv6_dns = g_new0(const char *, n+1);
const char **ip_ptr = ip_dns;
const char **ipv6_ptr = ipv6_dns;
for (i = 0; i < n; i++) {
const char *addr = list[i];
switch (ril_gprs_context_address_family(addr)) {
case AF_INET:
if (!ip_ptr) {
ip_list = g_new0(const char *, n - i + 1);
ip_ptr = ip_list;
}
*ip_ptr++ = addr;
break;
case AF_INET6:
if (!ipv6_ptr) {
ipv6_list = g_new0(const char *, n - i + 1);
ipv6_ptr = ipv6_list;
}
*ipv6_ptr++ = addr;
break;
}
}
ofono_gprs_context_set_ipv4_dns_servers(gc, ip_dns);
ofono_gprs_context_set_ipv6_dns_servers(gc, ipv6_dns);
set_ipv4(gc, ip_list);
set_ipv6(gc, ipv6_list);
g_free(ip_list);
g_free(ipv6_list);
}
static void ril_gprs_context_set_dns_servers(struct ofono_gprs_context *gc,
const struct ril_data_call *call)
{
ril_gprs_context_set_servers(gc, call->dnses,
ofono_gprs_context_set_ipv4_dns_servers,
ofono_gprs_context_set_ipv6_dns_servers);
}
g_free(ip_dns);
g_free(ipv6_dns);
static void ril_gprs_context_set_proxy_cscf(struct ofono_gprs_context *gc,
const struct ril_data_call *call)
{
ril_gprs_context_set_servers(gc, call->pcscf,
ofono_gprs_context_set_ipv4_proxy_cscf,
ofono_gprs_context_set_ipv6_proxy_cscf);
}
/* Only compares the stuff that's important to us */
......@@ -289,7 +314,8 @@ static void ril_gprs_context_set_dns_servers(struct ofono_gprs_context *gc,
#define DATA_CALL_ADDRESS_CHANGED (0x02)
#define DATA_CALL_GATEWAY_CHANGED (0x04)
#define DATA_CALL_DNS_CHANGED (0x08)
#define DATA_CALL_ALL_CHANGED (0x0f)
#define DATA_CALL_PCSCF_CHANGED (0x10)
#define DATA_CALL_ALL_CHANGED (0x1f)
static int ril_gprs_context_data_call_change(
const struct ril_data_call *c1,
const struct ril_data_call *c2)
......@@ -315,6 +341,10 @@ static int ril_gprs_context_data_call_change(
changes |= DATA_CALL_DNS_CHANGED;
}
if (!gutil_strv_equal(c1->pcscf, c2->pcscf)) {
changes |= DATA_CALL_PCSCF_CHANGED;
}
return changes;
} else {
return DATA_CALL_ALL_CHANGED;
......@@ -387,6 +417,11 @@ static void ril_gprs_context_call_list_changed(struct ril_data *data, void *arg)
ril_gprs_context_set_dns_servers(gc, call);
}
if (change & DATA_CALL_PCSCF_CHANGED) {
DBG("P-CSCF changed");
ril_gprs_context_set_proxy_cscf(gc, call);
}
ofono_gprs_context_signal_change(gc, gcd->active_ctx_cid);
ril_data_call_free(prev_call);
}
......@@ -428,6 +463,7 @@ static void ril_gprs_context_activate_primary_cb(struct ril_data *data,
ril_gprs_context_set_address(gc, call);
ril_gprs_context_set_gateway(gc, call);
ril_gprs_context_set_dns_servers(gc, call);
ril_gprs_context_set_proxy_cscf(gc, call);
ril_error_init_ok(&error);
}
......
......@@ -3,6 +3,7 @@
* oFono - Open Source Telephony
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
* Copyright (C) 2015-2021 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
......@@ -128,6 +129,8 @@ void ofono_gprs_context_set_ipv4_gateway(struct ofono_gprs_context *gc,
const char *gateway);
void ofono_gprs_context_set_ipv4_dns_servers(struct ofono_gprs_context *gc,
const char **dns);
void ofono_gprs_context_set_ipv4_proxy_cscf(struct ofono_gprs_context *gc,
const char **pcscf); /* Since mer/1.23+git30 */
void ofono_gprs_context_set_ipv6_address(struct ofono_gprs_context *gc,
const char *address);
......@@ -137,6 +140,8 @@ void ofono_gprs_context_set_ipv6_gateway(struct ofono_gprs_context *gc,
const char *gateway);
void ofono_gprs_context_set_ipv6_dns_servers(struct ofono_gprs_context *gc,
const char **dns);
void ofono_gprs_context_set_ipv6_proxy_cscf(struct ofono_gprs_context *gc,
const char **pcscf); /* Since mer/1.23+git30 */
void ofono_gprs_context_signal_change(struct ofono_gprs_context *gc,
unsigned int cid);
......
......@@ -3,7 +3,7 @@
* oFono - Open Source Telephony
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
* Copyright (C) 2015-2020 Jolla Ltd.
* Copyright (C) 2015-2021 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
......@@ -97,6 +97,7 @@ struct ipv4_settings {
char *netmask;
char *gateway;
char **dns;
char **pcscf;
char *proxy;
};
......@@ -105,6 +106,7 @@ struct ipv6_settings {
unsigned char prefix_len;
char *gateway;
char **dns;
char **pcscf;
};
struct context_settings {
......@@ -410,6 +412,7 @@ static void context_settings_free(struct context_settings *settings)
g_free(settings->ipv4->netmask);
g_free(settings->ipv4->gateway);
g_strfreev(settings->ipv4->dns);
g_strfreev(settings->ipv4->pcscf);
g_free(settings->ipv4->proxy);
g_free(settings->ipv4);
......@@ -420,6 +423,7 @@ static void context_settings_free(struct context_settings *settings)
g_free(settings->ipv6->ip);
g_free(settings->ipv6->gateway);
g_strfreev(settings->ipv6->dns);
g_strfreev(settings->ipv6->pcscf);
g_free(settings->ipv6);
settings->ipv6 = NULL;
......@@ -484,6 +488,11 @@ static void context_settings_append_ipv4(struct context_settings *settings,
DBUS_TYPE_STRING,
&settings->ipv4->dns);
if (settings->ipv4->pcscf)
ofono_dbus_dict_append_array(&array, "ProxyCSCF",
DBUS_TYPE_STRING,
&settings->ipv4->pcscf);
done:
dbus_message_iter_close_container(&variant, &array);
......@@ -549,6 +558,11 @@ static void context_settings_append_ipv6(struct context_settings *settings,
DBUS_TYPE_STRING,
&settings->ipv6->dns);
if (settings->ipv6->pcscf)
ofono_dbus_dict_append_array(&array, "ProxyCSCF",
DBUS_TYPE_STRING,
&settings->ipv6->pcscf);
done:
dbus_message_iter_close_container(&variant, &array);
......@@ -3417,6 +3431,18 @@ void ofono_gprs_context_set_ipv4_dns_servers(struct ofono_gprs_context *gc,
settings->ipv4->dns = g_strdupv((char **) dns);
}
void ofono_gprs_context_set_ipv4_proxy_cscf(struct ofono_gprs_context *gc,
const char **pcscf)
{
struct context_settings *settings = gc->settings;
if (settings->ipv4 == NULL)
return;
g_strfreev(settings->ipv4->pcscf);
settings->ipv4->pcscf = g_strdupv((char **) pcscf);
}
void ofono_gprs_context_set_ipv6_address(struct ofono_gprs_context *gc,
const char *address)
{
......@@ -3464,6 +3490,18 @@ void ofono_gprs_context_set_ipv6_dns_servers(struct ofono_gprs_context *gc,
settings->ipv6->dns = g_strdupv((char **) dns);
}
void ofono_gprs_context_set_ipv6_proxy_cscf(struct ofono_gprs_context *gc,
const char **pcscf)
{
struct context_settings *settings = gc->settings;
if (settings->ipv6 == NULL)
return;
g_strfreev(settings->ipv6->pcscf);
settings->ipv6->pcscf = g_strdupv((char **) pcscf);
}
void ofono_gprs_context_signal_change(struct ofono_gprs_context *gc,
unsigned int cid)
{
......
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