From: Khem Raj <raj.khem@gmail.com> Not all libc implementation have those functions, and the way to determine if they do is to check __RES which is explained in resolv.h thusly: /* * Revision information. This is the release date in YYYYMMDD format. * It can change every day so the right thing to do with it is use it * in preprocessor commands such as "#if (__RES > 19931104)". Do not * compare for equality; rather, use it to determine whether your resolver * is new enough to contain a certain feature. */ Indeed, it needs to be at least 19991006. The portion of the patch that implements a fallback is ported from Alpine Linux: http://git.alpinelinux.org/cgit/aports/plain/testing/connman/libresolv.patch --- gweb/gresolv.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gweb/gresolv.c b/gweb/gresolv.c index 8101d718..9f1477c3 100644 --- a/gweb/gresolv.c +++ b/gweb/gresolv.c @@ -879,7 +879,9 @@ GResolv *g_resolv_new(int index) resolv->index = index; resolv->nameserver_list = NULL; +#if (__RES >= 19991006) res_ninit(&resolv->res); +#endif return resolv; } @@ -920,7 +922,9 @@ void g_resolv_unref(GResolv *resolv) flush_nameservers(resolv); +#if (__RES >= 19991006) res_nclose(&resolv->res); +#endif g_free(resolv); } @@ -1024,6 +1028,7 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname, debug(resolv, "hostname %s", hostname); if (!resolv->nameserver_list) { +#if (__RES >= 19991006) int i; for (i = 0; i < resolv->res.nscount; i++) { @@ -1043,6 +1048,22 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname, if (inet_ntop(family, sa_addr, buf, sizeof(buf))) g_resolv_add_nameserver(resolv, buf, 53, 0); } +#else + FILE *f = fopen("/etc/resolv.conf", "r"); + if (f) { + char line[256], *s; + int i; + while (fgets(line, sizeof(line), f)) { + if (strncmp(line, "nameserver", 10) || !isspace(line[10])) + continue; + for (s = &line[11]; isspace(s[0]); s++); + for (i = 0; s[i] && !isspace(s[i]); i++); + s[i] = 0; + g_resolv_add_nameserver(resolv, s, 53, 0); + } + fclose(f); + } +#endif if (!resolv->nameserver_list) g_resolv_add_nameserver(resolv, "127.0.0.1", 53, 0); -- 2.39.2
Add support for ignoring devices used by NBD to mount root the same way ConnMan ignores devices used for NFS roots. nbdroot= nbddev= parameters are used by Debian and Tizen initramfs scripts to configure NBD for mounting as root device. Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com> --- src/inet.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/inet.c b/src/inet.c index 8a1e3423..5032cf25 100644 --- a/src/inet.c +++ b/src/inet.c @@ -5086,6 +5086,10 @@ static int get_nfs_server_ip(const char *cmdline_file, const char *pnp_file, for (pp = args; *pp; pp++) { if (!strcmp(*pp, "root=/dev/nfs")) break; + if (!strncmp(*pp, "root=/dev/nbd", strlen("root=/dev/nbd"))) + break; + if (!strncmp(*pp, "nbddev=", strlen("nbddev="))) + break; } /* no rootnfs found */ if (!*pp) @@ -5095,6 +5099,8 @@ static int get_nfs_server_ip(const char *cmdline_file, const char *pnp_file, for (pp = args; *pp; pp++) { if (!strncmp(*pp, "nfsroot=", strlen("nfsroot="))) break; + if (!strncmp(*pp, "nbdroot=", strlen("nbdroot="))) + break; } /* no nfsroot argument found */ if (!*pp) -- 2.39.2
The result from basename is not guaranteed to be. I'm running connmand 1.42 on Yocto Kirkstone and in this setup log identities ending up in the journal are garbage and change during the run of a connmand process. Explicitly allocating the log identity fixes this behaviour and gives the expected 'connmand'. --- src/log.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/log.c b/src/log.c index f7483194..108dcb0b 100644 --- a/src/log.c +++ b/src/log.c @@ -36,6 +36,11 @@ static const char *program_exec; static const char *program_path; +/* + * Provide a log identy to syslog whose lifetime is greater than the timespan + * we're logging. The result from basename does not guarantee that. + */ +static char *syslog_identity; /* This makes sure we always have a __debug section. */ CONNMAN_DEBUG_ALIAS(dummy); @@ -212,7 +217,11 @@ int __connman_log_init(const char *program, const char *debug, if (backtrace) signal_setup(signal_handler); - openlog(basename(program), option, LOG_DAEMON); + /* Clean up any previos identity and set the new one. */ + g_free(syslog_identity); + syslog_identity = g_path_get_basename(program); + + openlog(syslog_identity, option, LOG_DAEMON); syslog(LOG_INFO, "%s version %s", program_name, program_version); @@ -228,5 +237,8 @@ void __connman_log_cleanup(gboolean backtrace) if (backtrace) signal_setup(SIG_DFL); + g_free(syslog_identity); + syslog_identity = NULL; + g_strfreev(enabled); } -- 2.34.1
I encountered garbled and changing log identifiers from connmand 1.42 running on Yocto Kirkstone. Feb 09 02:40:18 foo time[590]: Connection Manager version 1.42 Feb 09 02:40:18 foo time[590]: ../connman-1.42/src/dbus.c:__connman_dbus_init() Feb 09 02:40:18 foo time[590]: ../connman-1.42/src/main.c:parse_config() parsing main.conf Feb 09 02:40:18 foo time[590]: Online check disabled by main config. Feb 09 02:40:19 foo U[590]: ../connman-1.42/src/inotify.c:__connman_inotify_init() Feb 09 02:40:19 foo U[590]: ../connman-1.42/src/technology.c:__connman_technology_init() This variant is slightly patched (see https://git.yoctoproject.org/poky/tree/meta/recipes-connectivity/connman/connman/0001-src-log.c-Include-libgen.h-for-basename-API.patch) which creates a use-after-free situation. But nevertheless there is no lifetime requirement communicated for the 'program' argument passed to '__connman_log_init' and on the other hand 'basename' might as well return a pointer to an internal buffer. In either case, a locally allocated log identity string will prevent potential issues. Best regards, Christian Christian Meusel (1): log: Use a log identity always valid while logging src/log.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.34.1
Immediately call service_complete in case of connection failure and no connman agent. --- src/service.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/service.c b/src/service.c index f3e022c9..805cfca7 100644 --- a/src/service.c +++ b/src/service.c @@ -9189,12 +9189,14 @@ static int service_indicate_state(struct connman_service *service) case CONNMAN_SERVICE_STATE_FAILURE: if (service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_USER || service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_NATIVE) { - connman_agent_report_error(service, service->path, + result = connman_agent_report_error(service, + service->path, error2string(service->error), report_error_cb, get_dbus_sender(service), NULL); - goto notifier; + if (result == -EINPROGRESS) + goto notifier; } service_complete(service); break; -- 2.25.1
I have a modem that is not able to reactivate a context just after a disconnection (I have an error in AT+CGDCONT in this case). Some seconds later, connection is possible. With connman 1.39, here is what happens when I disconnect and reconnect corresponding connman service: root@klk-zcel-030030:~ # date; connmanctl disconnect cellular_206018060790006_context1; date; connmanctl connect cellular_206018060790006_context1; date Tue Feb 20 10:00:19 UTC 2024 Disconnected cellular_206018060790006_context1 Tue Feb 20 10:00:19 UTC 2024 Error /net/connman/service/cellular_206018060790006_context1: Input/output error Tue Feb 20 10:00:20 UTC 2024 With connman 1.41, behavior changes: root@klk-zcel-030030:/# date; connmanctl disconnect cellular_206018060790006_context1; date; connmanctl connect cellular_206018060790006_context1; date Tue Jan 2 15:41:31 UTC 2024 Disconnected cellular_206018060790006_context1 Tue Jan 2 15:41:31 UTC 2024 Error /net/connman/service/cellular_206018060790006_context1: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. Tue Jan 2 15:43:31 UTC 2024 "connmanctl connect" lasts 2 minutes (it ends with connection timeout). After the first unsuccessful connection attempt, nothing happens. No new context activation is asked to Ofono. During these 2 minutes, if I try to connect the service, I receive an "in progress" error. This looks like a bug to me. Change comes from commit 8ea2d67a6e8935d06f71b1ec77a2f89d72be49eb (service: Complete only after user connection retries). service_complete is not called anymore when error is received from ofono plugin. We wait for agent to call report_error_cb. There is no agent in this case so report_error_cb is never called. I think that service_complete should be called if there is no agent. Christophe Ronco (1): service: End connection if connection failure and no agent src/service.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.25.1
There are currently ways to implement both of these, but a runtime configurable way in the connman startup for both would be nice. A) The way to get connman to work with systemd-resolved is to recompile with a flag: --with-dns-backend=systemd-resolved A setting in /etc/connman/main.conf to select either resolvconf or systemd-resolved would be awesome. B) Same with turning off ipv6. As it is, we can specify something in a *.config or in the settings file in the 'service' folder: IPv6.method=off or by issuing: connmanctl *service* ipv6=off Once again, if the user is having ipv6 problems, being able to turn it off for all interfaces in the main.conf would be nice. Now that ipv6 is active by default in the kernel and in many other packages, new problems appear: We have noticed that avahi will advertise spurious un-routable ipv6 addresses and that Mozilla seems to also have troubles when ipv4 and ipv6 are 'on' but only an ipv4 address is available. Thanks! Keith
--- src/technology.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/technology.c b/src/technology.c index 65fb9854..270d83d0 100644 --- a/src/technology.c +++ b/src/technology.c @@ -479,8 +479,10 @@ static void technology_load(struct connman_technology *technology) enc = g_key_file_get_string(keyfile, identifier, "Tethering.Passphrase", NULL); - if (enc) + if (enc) { technology->tethering_passphrase = g_strcompress(enc); + g_free(enc); + } technology->tethering_freq = g_key_file_get_integer(keyfile, identifier, "Tethering.Freq", NULL); -- 2.34.1
--- plugins/wifi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/wifi.c b/plugins/wifi.c index cc30d258..12389fa6 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -3405,11 +3405,11 @@ static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology ap->security = G_SUPPLICANT_SECURITY_NONE; ap->passphrase = NULL; } else { - ap->security = G_SUPPLICANT_SECURITY_PSK; - ap->protocol = G_SUPPLICANT_PROTO_RSN; - ap->pairwise_cipher = G_SUPPLICANT_PAIRWISE_CCMP; - ap->group_cipher = G_SUPPLICANT_GROUP_CCMP; - ap->passphrase = g_strdup(passphrase); + ap->security = G_SUPPLICANT_SECURITY_PSK; + ap->protocol = G_SUPPLICANT_PROTO_RSN; + ap->pairwise_cipher = G_SUPPLICANT_PAIRWISE_CCMP; + ap->group_cipher = G_SUPPLICANT_GROUP_CCMP; + ap->passphrase = g_strdup(passphrase); } return ap; -- 2.34.1
A GSupplicantSSID instance was leaked in ssid_ap_init() in case connman_technology_get_wifi_tethering() didn't succeed. --- plugins/wifi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/wifi.c b/plugins/wifi.c index ba5aa2d7..cc30d258 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -3387,8 +3387,10 @@ static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology ret = connman_technology_get_wifi_tethering(technology, &ssid, &passphrase, &freq); - if (ret == false) + if (ret == false) { + g_free(ap); return NULL; + } ap->mode = G_SUPPLICANT_MODE_MASTER; ap->ssid = g_strdup(ssid); -- 2.34.1
The bug frequently causes junk being written to the Tethering.Identifier and Tethering.Passphrase entries in the settings file. This in turn prevents Connman from starting up at all the next time it is run. To reproduce with connmanctl, use the following commands: enable wifi tether wifi on MyNetwork ThePassphrase tether wifi off Then have a look at the settings file. Disabling tethering causes a call of remove_ssid() from interface_select_network_result() in gsupplicant/supplicant.c, which frees the SSID and passphrase strings of the given GSupplicantSSID structure (originally initialized by the wifi plugin). These strings, however, are shared with a connman_technology structure, and they are accessed in technology_save() (called indirectly from set_property() in technology.c) after they have been freed. To fix this bug, the affected strings are copied into the GSupplicantSSID structure instead of simply assigning them. We make sure (1) to free them in case supplicant didn't take the GSupplicantSSID structure due to an error, and (2) to avoid double frees in ap_create_callback() and sta_remove_callback(). Originally, there were two GSupplicantSSID instances in the wifi plugin: one for the supplicant, and one stored in the wifi_data's tethering_param structure. The latter, however, was never used, so this commit removes its allocation to avoid a new memory leak, to save memory, and to generally avoid confusion. The bug fixed by this commit was introduced in 481d08f108. --- plugins/wifi.c | 54 ++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/plugins/wifi.c b/plugins/wifi.c index ed7437f5..ba5aa2d7 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -2547,6 +2547,16 @@ static bool handle_sae_authentication_failure(struct connman_network *network, return true; } +static void wifi_data_free_tethering_info(struct wifi_data *wifi) +{ + if (!wifi->tethering_param) + return; + + g_assert(wifi->tethering_param->ssid == NULL); + g_free(wifi->tethering_param); + wifi->tethering_param = NULL; +} + static void interface_state(GSupplicantInterface *interface) { struct connman_network *network; @@ -2568,11 +2578,7 @@ static void interface_state(GSupplicantInterface *interface) return; if (state == G_SUPPLICANT_STATE_COMPLETED) { - if (wifi->tethering_param) { - g_free(wifi->tethering_param->ssid); - g_free(wifi->tethering_param); - wifi->tethering_param = NULL; - } + wifi_data_free_tethering_info(wifi); if (wifi->tethering) stop_autoscan(device); @@ -2832,9 +2838,7 @@ static void ap_create_fail(GSupplicantInterface *interface) connman_technology_tethering_notify(wifi_technology,false); } - g_free(wifi->tethering_param->ssid); - g_free(wifi->tethering_param); - wifi->tethering_param = NULL; + wifi_data_free_tethering_info(wifi); } } @@ -3387,7 +3391,7 @@ static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology return NULL; ap->mode = G_SUPPLICANT_MODE_MASTER; - ap->ssid = ssid; + ap->ssid = g_strdup(ssid); ap->ssid_len = strlen(ssid); ap->scan_ssid = 0; if (freq) @@ -3403,7 +3407,7 @@ static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology ap->protocol = G_SUPPLICANT_PROTO_RSN; ap->pairwise_cipher = G_SUPPLICANT_PAIRWISE_CCMP; ap->group_cipher = G_SUPPLICANT_GROUP_CCMP; - ap->passphrase = passphrase; + ap->passphrase = g_strdup(passphrase); } return ap; @@ -3423,9 +3427,7 @@ static void ap_start_callback(int result, GSupplicantInterface *interface, if (info->wifi->ap_supported == WIFI_AP_SUPPORTED) { connman_technology_tethering_notify(info->technology, false); - g_free(info->wifi->tethering_param->ssid); - g_free(info->wifi->tethering_param); - info->wifi->tethering_param = NULL; + wifi_data_free_tethering_info(info->wifi); } } @@ -3448,14 +3450,10 @@ static void ap_create_callback(int result, if (info->wifi->ap_supported == WIFI_AP_SUPPORTED) { connman_technology_tethering_notify(info->technology, false); - g_free(info->wifi->tethering_param->ssid); - g_free(info->wifi->tethering_param); - info->wifi->tethering_param = NULL; - + wifi_data_free_tethering_info(info->wifi); } g_free(info->ifname); - g_free(info->ssid); g_free(info); return; } @@ -3483,14 +3481,10 @@ static void sta_remove_callback(int result, info->wifi->tethering = false; connman_technology_tethering_notify(info->technology, false); - if (info->wifi->ap_supported == WIFI_AP_SUPPORTED) { - g_free(info->wifi->tethering_param->ssid); - g_free(info->wifi->tethering_param); - info->wifi->tethering_param = NULL; - } + if (info->wifi->ap_supported == WIFI_AP_SUPPORTED) + wifi_data_free_tethering_info(info->wifi); g_free(info->ifname); - g_free(info->ssid); g_free(info); return; } @@ -3563,9 +3557,6 @@ static int enable_wifi_tethering(struct connman_technology *technology, info->ifname = g_strdup(ifname); wifi->tethering_param->technology = technology; - wifi->tethering_param->ssid = ssid_ap_init(technology); - if (!wifi->tethering_param->ssid) - goto failed; info->wifi->tethering = true; info->wifi->ap_supported = WIFI_AP_SUPPORTED; @@ -3584,10 +3575,13 @@ static int enable_wifi_tethering(struct connman_technology *technology, failed: g_free(info->ifname); - g_free(info->ssid); + if (info->ssid) { + g_free((char *)info->ssid->ssid); + g_free((char *)info->ssid->passphrase); + g_free(info->ssid); + } g_free(info); - g_free(wifi->tethering_param); - wifi->tethering_param = NULL; + wifi_data_free_tethering_info(wifi); /* * Remove bridge if it was correctly created but remove -- 2.34.1
I've noticed that the settings file gets corrupted when disabling wifi tethering. Wrong strings and/or binary junk are written to the file, preventing Connman from starting up the next time it is run. I have tracked down the breaking commit (481d08f108) and was able to patch the problem. While at it, I found and patched two more memory leaks. Robert Tiemann (4): wifi: Fix use-after-free when tethering is disabled. wifi: Fix memory leak. wifi: Fix indentation. technology: Fix memory leak. plugins/wifi.c | 66 +++++++++++++++++++++++------------------------- src/technology.c | 4 ++- 2 files changed, 34 insertions(+), 36 deletions(-) -- 2.34.1
Hi Brian,
> This fixes the signdness warnings in dnsproxy.c
> ---
> src/dnsproxy.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/dnsproxy.c b/src/dnsproxy.c
> index d4242560..72e77f96 100644
> --- a/src/dnsproxy.c
> +++ b/src/dnsproxy.c
> @@ -436,7 +436,7 @@ static void update_cached_ttl(unsigned char *ptr, int len, int new_ttl)
> ptr += DNS_HEADER_SIZE;
> len -= DNS_HEADER_SIZE;
>
> - if (len < DNS_QUESTION_SIZE + 1)
> + if (len < 0 || (unsigned int)len < DNS_QUESTION_SIZE + 1)
> return;
I love that you are trying to address these warnings. However just casting the issue away is not really helpful. Lets us proper types for the variables and have the checks make sense.
Background is that I want the compiler to keep warning us about these. Once you cast, the warning is gone forever.
Regards
Marcel
This fixes the signdness warnings in dnsproxy.c --- src/dnsproxy.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dnsproxy.c b/src/dnsproxy.c index d4242560..72e77f96 100644 --- a/src/dnsproxy.c +++ b/src/dnsproxy.c @@ -436,7 +436,7 @@ static void update_cached_ttl(unsigned char *ptr, int len, int new_ttl) ptr += DNS_HEADER_SIZE; len -= DNS_HEADER_SIZE; - if (len < DNS_QUESTION_SIZE + 1) + if (len < 0 || (unsigned int)len < DNS_QUESTION_SIZE + 1) return; /* skip the query, which is a name and a struct domain_question */ @@ -459,7 +459,7 @@ static void update_cached_ttl(unsigned char *ptr, int len, int new_ttl) break; rr = (void*)ptr; - if (len < sizeof(*rr)) + if ((unsigned int)len < sizeof(*rr)) /* incomplete record */ break; @@ -520,7 +520,7 @@ static void send_cached_response(int sk, const unsigned char *ptr, size_t len, connman_error("Cannot send cached DNS response: %s", strerror(errno)); } - else if (err != len || dns_len != (len - offset)) + else if ((unsigned int)err != len || dns_len != (len - offset)) debug("Packet length mismatch, sent %d wanted %zd dns %zd", err, len, dns_len); } @@ -656,7 +656,7 @@ static int append_data(unsigned char *buf, size_t size, const char *data) while (true) { const char *dot = strchr(data, '.'); - len = dot ? dot - data : strlen(data); + len = dot ? (unsigned int)(dot - data) : strlen(data); if (len == 0) break; @@ -1063,7 +1063,7 @@ static int parse_response(const unsigned char *buf, size_t buflen, qlen = strlen(question); ptr += qlen + 1; /* skip \0 */ - if ((eptr - ptr) < DNS_QUESTION_SIZE) + if ((unsigned int)(eptr - ptr) < DNS_QUESTION_SIZE) return -EINVAL; q = (void *) ptr; @@ -2031,7 +2031,7 @@ static int dns_reply_fixup_domains( const char *domain; /* full header plus at least one byte for the hostname length */ - if (reply_len < header_len + 1) + if (reply_len < (unsigned int)(header_len + 1)) return -EINVAL; section_counts[0] = hdr->ancount; @@ -2521,7 +2521,7 @@ hangup: connman_error("DNS proxy error %s", strerror(errno)); goto hangup; - } else if (bytes_recv < sizeof(reply_len)) + } else if ((unsigned int)bytes_recv < sizeof(reply_len)) return TRUE; /* the header contains the length of the message -- 2.34.1
Hello: This series was applied to connman.git (master) by Marcel Holtmann <marcel@holtmann.org>: On Thu, 25 Jan 2024 16:28:47 -0600 you wrote: > oFono 2.2 removed all support for CDMA since most CDMA networks have > now been shut down. Remove support for CDMA inside the ofono plugin as > well. > --- > plugins/ofono.c | 425 +----------------------------------------------- > 1 file changed, 8 insertions(+), 417 deletions(-) Here is the summary with links: - [v2,1/2] ofono: Remove support for CDMA https://git.kernel.org/pub/scm/network/connman/connman.git/?id=ff19b5985aaf - [v2,2/2] ofono: Don't invoke SetProperty unnecessarily https://git.kernel.org/pub/scm/network/connman/connman.git/?id=ee0046efd0f3 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
When org.ofono.Modem.Powered property changes, connman invokes the SetProperty method again with the new value. This is pointless and only creates unnecessary DBus traffic. connmand[30]: plugins/ofono.c:modem_set_powered() /phonesim powered 1 connmand[30]: plugins/ofono.c:set_property() /phonesim path /phonesim org.ofono.Modem.Powered connmand[30]: plugins/ofono.c:set_property_reply() /phonesim path /phonesim org.ofono.Modem.Powered connmand[30]: plugins/ofono.c:modem_changed() /phonesim Powered 1 connmand[30]: plugins/ofono.c:modem_set_powered() /phonesim powered 1 connmand[30]: plugins/ofono.c:set_property() /phonesim path /phonesim org.ofono.Modem.Powered connmand[30]: plugins/ofono.c:set_property_reply() /phonesim path /phonesim org.ofono.Modem.Powered Fixes: 054dacc71c6a ("ofono: Set "powered" property according to value") --- plugins/ofono.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 9d0d44547a2c..65a722fd85d6 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -1969,12 +1969,11 @@ static gboolean modem_changed(DBusConnection *conn, DBusMessage *message, dbus_bool_t powered; dbus_message_iter_get_basic(&value, &powered); + modem->powered = powered; + modem->set_powered = powered; DBG("%s Powered %d", modem->path, modem->powered); - - /* Set the powered according to the value */ - modem_set_powered(modem, powered); } else if (g_str_equal(key, "Online")) { dbus_bool_t online; -- 2.43.0
oFono 2.2 removed all support for CDMA since most CDMA networks have now been shut down. Remove support for CDMA inside the ofono plugin as well. --- plugins/ofono.c | 425 +----------------------------------------------- 1 file changed, 8 insertions(+), 417 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 8bb5394926e0..9d0d44547a2c 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -52,8 +52,6 @@ #define OFONO_NETREG_INTERFACE OFONO_SERVICE ".NetworkRegistration" #define OFONO_CM_INTERFACE OFONO_SERVICE ".ConnectionManager" #define OFONO_CONTEXT_INTERFACE OFONO_SERVICE ".ConnectionContext" -#define OFONO_CDMA_CM_INTERFACE OFONO_SERVICE ".cdma.ConnectionManager" -#define OFONO_CDMA_NETREG_INTERFACE OFONO_SERVICE ".cdma.NetworkRegistration" #define MODEM_ADDED "ModemAdded" #define MODEM_REMOVED "ModemRemoved" @@ -72,8 +70,6 @@ enum ofono_api { OFONO_API_SIM = 0x1, OFONO_API_NETREG = 0x2, OFONO_API_CM = 0x4, - OFONO_API_CDMA_NETREG = 0x8, - OFONO_API_CDMA_CM = 0x10, }; /* @@ -103,27 +99,6 @@ enum ofono_api { * successful the modem is connected to the network. oFono will inform * the plugin about IP configuration through the updating the context's * properties. - * - * CDMA working flow: - * - * When a new modem appears, the plugin always powers it up. This - * allows the plugin to create connman_device either using IMSI either - * using modem Serial if the modem got a SIM interface or not. - * - * As for GSM, the core will call modem_enable() if the technology - * is enabled. modem_enable() will then set the modem online. - * If the technology is disabled then modem_disable() will just set the - * modem offline. The modem is always kept powered all the time. - * - * After setting the modem online the plugin waits for CdmaConnectionManager - * interface to appear. Then, once CdmaNetworkRegistration appears, a new - * Service will be created and registered at the core. - * - * When asked to connect to the network (network_connect()) the plugin - * will power up the CdmaConnectionManager interface. - * If the operation is successful the modem is connected to the network. - * oFono will inform the plugin about IP configuration through the - * updating CdmaConnectionManager settings properties. */ static DBusConnection *connection; @@ -166,9 +141,6 @@ struct modem_data { bool set_powered; - /* CDMA ConnectionManager Interface */ - bool cdma_cm_powered; - /* ConnectionManager Interface */ bool attached; bool cm_powered; @@ -179,7 +151,6 @@ struct modem_data { /* Netreg Interface */ char *name; uint8_t strength; - uint8_t data_strength; /* 1xEVDO signal strength */ bool registered; bool roaming; @@ -198,10 +169,6 @@ static const char *api2string(enum ofono_api api) return "netreg"; case OFONO_API_CM: return "cm"; - case OFONO_API_CDMA_NETREG: - return "cdma-netreg"; - case OFONO_API_CDMA_CM: - return "cmda-cm"; } return "unknown"; @@ -660,63 +627,6 @@ static int context_set_active(struct modem_data *modem, return err; } -static void cdma_cm_set_powered_reply(struct modem_data *modem, - struct network_context *context, bool success) -{ - DBG("%s", context->path); - - if (success) { - /* - * Don't handle do anything on success here. oFono will send - * the change via PropertyChanged signal. - */ - return; - } - - /* - * Powered = True might fail due a timeout. That means oFono - * still tries to go online. If we retry to set Powered = True, - * we just get a InProgress error message. Should we power - * cycle the modem in such cases? - */ - - if (!context->network) { - /* - * In the case where we power down the device - * we don't wait for the reply, therefore the network - * might already be gone. - */ - return; - } - - connman_network_set_error(context->network, - CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL); -} - -static int cdma_cm_set_powered(struct modem_data *modem, dbus_bool_t powered) -{ - int err; - struct network_context *context = NULL; - - if (!modem->context_list) - return -1; - - DBG("%s powered %d", modem->path, powered); - - /* In case of CDMA, there is only one context */ - context = modem->context_list->data; - err = set_property(modem, context, modem->path, - OFONO_CDMA_CM_INTERFACE, - "Powered", DBUS_TYPE_BOOLEAN, - &powered, - cdma_cm_set_powered_reply); - - if (!powered && err == -EINPROGRESS) - return 0; - - return err; -} - static int modem_set_online(struct modem_data *modem, dbus_bool_t online) { DBG("%s online %d", modem->path, online); @@ -793,10 +703,6 @@ static uint8_t extract_interfaces(DBusMessageIter *array) interfaces |= OFONO_API_NETREG; else if (g_str_equal(name, OFONO_CM_INTERFACE)) interfaces |= OFONO_API_CM; - else if (g_str_equal(name, OFONO_CDMA_CM_INTERFACE)) - interfaces |= OFONO_API_CDMA_CM; - else if (g_str_equal(name, OFONO_CDMA_NETREG_INTERFACE)) - interfaces |= OFONO_API_CDMA_NETREG; dbus_message_iter_next(&entry); } @@ -1018,27 +924,19 @@ out: g_free(gateway); } +/* + * This functions tests if we have the necessary information gathered + * before we are able to create a device. + */ static bool ready_to_create_device(struct modem_data *modem) { - /* - * There are three different modem types which behave slightly - * different: - * - GSM modems will expose the SIM interface then the - * CM interface. - * - CDMA modems will expose CM first and sometime later - * a unique serial number. - * - * This functions tests if we have the necessary information gathered - * before we are able to create a device. - */ - if (modem->device) return false; - if (modem->imsi || modem->serial) - return true; + if (!modem->imsi) + return false; - return false; + return true; } static void create_device(struct modem_data *modem) @@ -1050,8 +948,6 @@ static void create_device(struct modem_data *modem) if (modem->imsi) ident = modem->imsi; - else if (modem->serial) - ident = modem->serial; if (!connman_dbus_validate_ident(ident)) ident = connman_dbus_encode_string(ident); @@ -1611,22 +1507,6 @@ static void netreg_update_strength(struct modem_data *modem, if (!modem->context_list) return; - /* - * GSM: - * We don't have 2 signal notifications we always report the strength - * signal. data_strength is always equal to 0. - * - * CDMA: - * In the case we have a data_strength signal (from 1xEVDO network) - * we don't need to update the value with strength signal (from 1xCDMA) - * because the modem is registered to 1xEVDO network for data call. - * In case we have no data_strength signal (not registered to 1xEVDO - * network), we must report the strength signal (registered to 1xCDMA - * network e.g slow mode). - */ - if (modem->data_strength != 0) - return; - /* For all the context */ for (list = modem->context_list; list; list = list->next) { struct network_context *context = list->data; @@ -1639,39 +1519,6 @@ static void netreg_update_strength(struct modem_data *modem, } } -/* Retrieve 1xEVDO Data Strength signal */ -static void netreg_update_datastrength(struct modem_data *modem, - DBusMessageIter *value) -{ - GSList *list; - - dbus_message_iter_get_basic(value, &modem->data_strength); - - DBG("%s Data Strength %d", modem->path, modem->data_strength); - - if (!modem->context_list) - return; - - /* - * CDMA modem is not registered to 1xEVDO network, let - * update_signal_strength() reporting the value on the Strength signal - * notification. - */ - if (modem->data_strength == 0) - return; - - /* For all the context */ - for (list = modem->context_list; list; list = list->next) { - struct network_context *context = list->data; - - if (context->network) { - connman_network_set_strength(context->network, - modem->data_strength); - connman_network_update(context->network); - } - } -} - static void netreg_update_status(struct modem_data *modem, DBusMessageIter *value) { @@ -1821,115 +1668,6 @@ static int netreg_get_properties(struct modem_data *modem) netreg_properties_reply, modem); } -static void add_cdma_network(struct modem_data *modem) -{ - struct network_context *context = NULL; - /* Be sure that device is created before adding CDMA network */ - if (!modem->device) - return; - - /* - * CDMA modems don't need contexts for data call, however the current - * add_network() logic needs one, so we create one to proceed. - */ - if (!modem->context_list) { - context = network_context_alloc(modem->path); - modem->context_list = g_slist_prepend(modem->context_list, - context); - } else - context = modem->context_list->data; - - if (!modem->name) - modem->name = g_strdup("CDMA Network"); - - add_network(modem, context); - - if (modem->cdma_cm_powered) - set_connected(modem, context); -} - -static gboolean cdma_netreg_changed(DBusConnection *conn, - DBusMessage *message, - void *user_data) -{ - const char *path = dbus_message_get_path(message); - struct modem_data *modem; - DBusMessageIter iter, value; - const char *key; - - DBG(""); - - modem = g_hash_table_lookup(modem_hash, path); - if (!modem) - return TRUE; - - if (modem->ignore) - return TRUE; - - if (!dbus_message_iter_init(message, &iter)) - return TRUE; - - dbus_message_iter_get_basic(&iter, &key); - - dbus_message_iter_next(&iter); - dbus_message_iter_recurse(&iter, &value); - - if (g_str_equal(key, "Name")) - netreg_update_name(modem, &value); - else if (g_str_equal(key, "Strength")) - netreg_update_strength(modem, &value); - else if (g_str_equal(key, "DataStrength")) - netreg_update_datastrength(modem, &value); - else if (g_str_equal(key, "Status")) - netreg_update_status(modem, &value); - - if (modem->registered) - add_cdma_network(modem); - else - remove_all_networks(modem); - - return TRUE; -} - -static void cdma_netreg_properties_reply(struct modem_data *modem, - DBusMessageIter *dict) -{ - DBG("%s", modem->path); - - while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) { - DBusMessageIter entry, value; - const char *key; - - dbus_message_iter_recurse(dict, &entry); - dbus_message_iter_get_basic(&entry, &key); - - dbus_message_iter_next(&entry); - dbus_message_iter_recurse(&entry, &value); - - if (g_str_equal(key, "Name")) - netreg_update_name(modem, &value); - else if (g_str_equal(key, "Strength")) - netreg_update_strength(modem, &value); - else if (g_str_equal(key, "DataStrength")) - netreg_update_datastrength(modem, &value); - else if (g_str_equal(key, "Status")) - netreg_update_status(modem, &value); - - dbus_message_iter_next(dict); - } - - if (modem->registered) - add_cdma_network(modem); - else - remove_all_networks(modem); -} - -static int cdma_netreg_get_properties(struct modem_data *modem) -{ - return get_properties(modem->path, OFONO_CDMA_NETREG_INTERFACE, - cdma_netreg_properties_reply, modem); -} - static void cm_update_attached(struct modem_data *modem, DBusMessageIter *value) { @@ -1999,67 +1737,6 @@ static gboolean cm_changed(DBusConnection *conn, DBusMessage *message, return TRUE; } -static void cdma_cm_update_powered(struct modem_data *modem, - DBusMessageIter *value) -{ - struct network_context *context = NULL; - dbus_bool_t cdma_cm_powered; - - dbus_message_iter_get_basic(value, &cdma_cm_powered); - modem->cdma_cm_powered = cdma_cm_powered; - - DBG("%s CDMA cm Powered %d", modem->path, modem->cdma_cm_powered); - - if (!modem->context_list) - return; - - /* In case of CDMA, there is only one context */ - context = modem->context_list->data; - if (modem->cdma_cm_powered) - set_connected(modem, context); - else - set_disconnected(context); -} - -static void cdma_cm_update_settings(struct modem_data *modem, - DBusMessageIter *value) -{ - DBG("%s Settings", modem->path); - - extract_ipv4_settings(value, modem->context_list->data); -} - -static gboolean cdma_cm_changed(DBusConnection *conn, - DBusMessage *message, void *user_data) -{ - const char *path = dbus_message_get_path(message); - struct modem_data *modem; - DBusMessageIter iter, value; - const char *key; - - modem = g_hash_table_lookup(modem_hash, path); - if (!modem) - return TRUE; - - if (modem->online && !modem->context_list) - cdma_netreg_get_properties(modem); - - if (!dbus_message_iter_init(message, &iter)) - return TRUE; - - dbus_message_iter_get_basic(&iter, &key); - - dbus_message_iter_next(&iter); - dbus_message_iter_recurse(&iter, &value); - - if (g_str_equal(key, "Powered")) - cdma_cm_update_powered(modem, &value); - if (g_str_equal(key, "Settings")) - cdma_cm_update_settings(modem, &value); - - return TRUE; -} - static void cm_properties_reply(struct modem_data *modem, DBusMessageIter *dict) { DBG("%s", modem->path); @@ -2089,39 +1766,6 @@ static int cm_get_properties(struct modem_data *modem) cm_properties_reply, modem); } -static void cdma_cm_properties_reply(struct modem_data *modem, - DBusMessageIter *dict) -{ - DBG("%s", modem->path); - - if (modem->online) - cdma_netreg_get_properties(modem); - - while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) { - DBusMessageIter entry, value; - const char *key; - - dbus_message_iter_recurse(dict, &entry); - dbus_message_iter_get_basic(&entry, &key); - - dbus_message_iter_next(&entry); - dbus_message_iter_recurse(&entry, &value); - - if (g_str_equal(key, "Powered")) - cdma_cm_update_powered(modem, &value); - if (g_str_equal(key, "Settings")) - cdma_cm_update_settings(modem, &value); - - dbus_message_iter_next(dict); - } -} - -static int cdma_cm_get_properties(struct modem_data *modem) -{ - return get_properties(modem->path, OFONO_CDMA_CM_INTERFACE, - cdma_cm_properties_reply, modem); -} - static void sim_update_imsi(struct modem_data *modem, DBusMessageIter *value) { @@ -2279,25 +1923,11 @@ static void modem_update_interfaces(struct modem_data *modem, } } - if (api_added(old_ifaces, new_ifaces, OFONO_API_CDMA_CM)) { - if (ready_to_create_device(modem)) { - create_device(modem); - if (modem->registered) - add_cdma_network(modem); - } - - if (modem->device) - cdma_cm_get_properties(modem); - } - if (api_added(old_ifaces, new_ifaces, OFONO_API_NETREG)) { if (modem->attached) netreg_get_properties(modem); } - if (api_added(old_ifaces, new_ifaces, OFONO_API_CDMA_NETREG)) - cdma_netreg_get_properties(modem); - if (api_removed(old_ifaces, new_ifaces, OFONO_API_CM)) { if (modem->call_get_contexts) { DBG("cancelling pending GetContexts call"); @@ -2308,14 +1938,8 @@ static void modem_update_interfaces(struct modem_data *modem, remove_all_contexts(modem); } - if (api_removed(old_ifaces, new_ifaces, OFONO_API_CDMA_CM)) - remove_all_contexts(modem); - if (api_removed(old_ifaces, new_ifaces, OFONO_API_NETREG)) remove_all_networks(modem); - - if (api_removed(old_ifaces, new_ifaces, OFONO_API_CDMA_NETREG)) - remove_all_networks(modem); } static gboolean modem_changed(DBusConnection *conn, DBusMessage *message, @@ -2385,15 +2009,6 @@ static gboolean modem_changed(DBusConnection *conn, DBusMessage *message, modem->serial = g_strdup(serial); DBG("%s Serial %s", modem->path, modem->serial); - - if (has_interface(modem->interfaces, - OFONO_API_CDMA_CM)) { - if (ready_to_create_device(modem)) { - create_device(modem); - if (modem->registered) - add_cdma_network(modem); - } - } } return TRUE; @@ -2717,8 +2332,6 @@ static int network_connect(struct connman_network *network) if (has_interface(modem->interfaces, OFONO_API_CM)) return context_set_active(modem, context, TRUE); - else if (has_interface(modem->interfaces, OFONO_API_CDMA_CM)) - return cdma_cm_set_powered(modem, TRUE); connman_error("Connection manager interface not available"); @@ -2741,8 +2354,6 @@ static int network_disconnect(struct connman_network *network) if (has_interface(modem->interfaces, OFONO_API_CM)) return context_set_active(modem, context, FALSE); - else if (has_interface(modem->interfaces, OFONO_API_CDMA_CM)) - return cdma_cm_set_powered(modem, FALSE); connman_error("Connection manager interface not available"); @@ -2833,8 +2444,6 @@ static guint context_added_watch; static guint context_removed_watch; static guint netreg_watch; static guint context_watch; -static guint cdma_cm_watch; -static guint cdma_netreg_watch; static int ofono_init(void) { @@ -2907,25 +2516,11 @@ static int ofono_init(void) netreg_changed, NULL, NULL); - cdma_cm_watch = g_dbus_add_signal_watch(connection, OFONO_SERVICE, - NULL, OFONO_CDMA_CM_INTERFACE, - PROPERTY_CHANGED, - cdma_cm_changed, - NULL, NULL); - - cdma_netreg_watch = g_dbus_add_signal_watch(connection, OFONO_SERVICE, - NULL, OFONO_CDMA_NETREG_INTERFACE, - PROPERTY_CHANGED, - cdma_netreg_changed, - NULL, NULL); - - if (watch == 0 || modem_added_watch == 0 || modem_removed_watch == 0 || modem_watch == 0 || cm_watch == 0 || sim_watch == 0 || context_added_watch == 0 || context_removed_watch == 0 || - context_watch == 0 || netreg_watch == 0 || - cdma_cm_watch == 0 || cdma_netreg_watch == 0) { + context_watch == 0 || netreg_watch == 0) { err = -EIO; goto remove; } @@ -2950,8 +2545,6 @@ static int ofono_init(void) return 0; remove: - g_dbus_remove_watch(connection, cdma_netreg_watch); - g_dbus_remove_watch(connection, cdma_cm_watch); g_dbus_remove_watch(connection, netreg_watch); g_dbus_remove_watch(connection, context_watch); g_dbus_remove_watch(connection, context_removed_watch); @@ -2994,8 +2587,6 @@ static void ofono_exit(void) connman_device_driver_unregister(&modem_driver); connman_network_driver_unregister(&network_driver); - g_dbus_remove_watch(connection, cdma_netreg_watch); - g_dbus_remove_watch(connection, cdma_cm_watch); g_dbus_remove_watch(connection, netreg_watch); g_dbus_remove_watch(connection, context_watch); g_dbus_remove_watch(connection, context_removed_watch); -- 2.43.0
When org.ofono.Modem.Powered property changes, connman invokes the SetProperty method again with the new value. This is pointless and only creates unnecessary DBus traffic. connmand[30]: plugins/ofono.c:modem_set_powered() /phonesim powered 1 connmand[30]: plugins/ofono.c:set_property() /phonesim path /phonesim org.ofono.Modem.Powered connmand[30]: plugins/ofono.c:set_property_reply() /phonesim path /phonesim org.ofono.Modem.Powered connmand[30]: plugins/ofono.c:modem_changed() /phonesim Powered 1 connmand[30]: plugins/ofono.c:modem_set_powered() /phonesim powered 1 connmand[30]: plugins/ofono.c:set_property() /phonesim path /phonesim org.ofono.Modem.Powered connmand[30]: plugins/ofono.c:set_property_reply() /phonesim path /phonesim org.ofono.Modem.Powered Fixes: 054dacc71c6a ("ofono: Set "powered" property according to value") --- plugins/ofono.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 9d0d44547a2c..6b711b979046 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -1969,12 +1969,11 @@ static gboolean modem_changed(DBusConnection *conn, DBusMessage *message, dbus_bool_t powered; dbus_message_iter_get_basic(&value, &powered); - modem->powered = powered; DBG("%s Powered %d", modem->path, modem->powered); - /* Set the powered according to the value */ - modem_set_powered(modem, powered); + modem->powered = powered; + modem->set_powered = powered; } else if (g_str_equal(key, "Online")) { dbus_bool_t online; -- 2.43.0
oFono 2.2 removed all support for CDMA since most CDMA networks have now been shut down. Remove support for CDMA inside the ofono plugin as well. --- plugins/ofono.c | 425 +----------------------------------------------- 1 file changed, 8 insertions(+), 417 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 8bb5394926e0..9d0d44547a2c 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -52,8 +52,6 @@ #define OFONO_NETREG_INTERFACE OFONO_SERVICE ".NetworkRegistration" #define OFONO_CM_INTERFACE OFONO_SERVICE ".ConnectionManager" #define OFONO_CONTEXT_INTERFACE OFONO_SERVICE ".ConnectionContext" -#define OFONO_CDMA_CM_INTERFACE OFONO_SERVICE ".cdma.ConnectionManager" -#define OFONO_CDMA_NETREG_INTERFACE OFONO_SERVICE ".cdma.NetworkRegistration" #define MODEM_ADDED "ModemAdded" #define MODEM_REMOVED "ModemRemoved" @@ -72,8 +70,6 @@ enum ofono_api { OFONO_API_SIM = 0x1, OFONO_API_NETREG = 0x2, OFONO_API_CM = 0x4, - OFONO_API_CDMA_NETREG = 0x8, - OFONO_API_CDMA_CM = 0x10, }; /* @@ -103,27 +99,6 @@ enum ofono_api { * successful the modem is connected to the network. oFono will inform * the plugin about IP configuration through the updating the context's * properties. - * - * CDMA working flow: - * - * When a new modem appears, the plugin always powers it up. This - * allows the plugin to create connman_device either using IMSI either - * using modem Serial if the modem got a SIM interface or not. - * - * As for GSM, the core will call modem_enable() if the technology - * is enabled. modem_enable() will then set the modem online. - * If the technology is disabled then modem_disable() will just set the - * modem offline. The modem is always kept powered all the time. - * - * After setting the modem online the plugin waits for CdmaConnectionManager - * interface to appear. Then, once CdmaNetworkRegistration appears, a new - * Service will be created and registered at the core. - * - * When asked to connect to the network (network_connect()) the plugin - * will power up the CdmaConnectionManager interface. - * If the operation is successful the modem is connected to the network. - * oFono will inform the plugin about IP configuration through the - * updating CdmaConnectionManager settings properties. */ static DBusConnection *connection; @@ -166,9 +141,6 @@ struct modem_data { bool set_powered; - /* CDMA ConnectionManager Interface */ - bool cdma_cm_powered; - /* ConnectionManager Interface */ bool attached; bool cm_powered; @@ -179,7 +151,6 @@ struct modem_data { /* Netreg Interface */ char *name; uint8_t strength; - uint8_t data_strength; /* 1xEVDO signal strength */ bool registered; bool roaming; @@ -198,10 +169,6 @@ static const char *api2string(enum ofono_api api) return "netreg"; case OFONO_API_CM: return "cm"; - case OFONO_API_CDMA_NETREG: - return "cdma-netreg"; - case OFONO_API_CDMA_CM: - return "cmda-cm"; } return "unknown"; @@ -660,63 +627,6 @@ static int context_set_active(struct modem_data *modem, return err; } -static void cdma_cm_set_powered_reply(struct modem_data *modem, - struct network_context *context, bool success) -{ - DBG("%s", context->path); - - if (success) { - /* - * Don't handle do anything on success here. oFono will send - * the change via PropertyChanged signal. - */ - return; - } - - /* - * Powered = True might fail due a timeout. That means oFono - * still tries to go online. If we retry to set Powered = True, - * we just get a InProgress error message. Should we power - * cycle the modem in such cases? - */ - - if (!context->network) { - /* - * In the case where we power down the device - * we don't wait for the reply, therefore the network - * might already be gone. - */ - return; - } - - connman_network_set_error(context->network, - CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL); -} - -static int cdma_cm_set_powered(struct modem_data *modem, dbus_bool_t powered) -{ - int err; - struct network_context *context = NULL; - - if (!modem->context_list) - return -1; - - DBG("%s powered %d", modem->path, powered); - - /* In case of CDMA, there is only one context */ - context = modem->context_list->data; - err = set_property(modem, context, modem->path, - OFONO_CDMA_CM_INTERFACE, - "Powered", DBUS_TYPE_BOOLEAN, - &powered, - cdma_cm_set_powered_reply); - - if (!powered && err == -EINPROGRESS) - return 0; - - return err; -} - static int modem_set_online(struct modem_data *modem, dbus_bool_t online) { DBG("%s online %d", modem->path, online); @@ -793,10 +703,6 @@ static uint8_t extract_interfaces(DBusMessageIter *array) interfaces |= OFONO_API_NETREG; else if (g_str_equal(name, OFONO_CM_INTERFACE)) interfaces |= OFONO_API_CM; - else if (g_str_equal(name, OFONO_CDMA_CM_INTERFACE)) - interfaces |= OFONO_API_CDMA_CM; - else if (g_str_equal(name, OFONO_CDMA_NETREG_INTERFACE)) - interfaces |= OFONO_API_CDMA_NETREG; dbus_message_iter_next(&entry); } @@ -1018,27 +924,19 @@ out: g_free(gateway); } +/* + * This functions tests if we have the necessary information gathered + * before we are able to create a device. + */ static bool ready_to_create_device(struct modem_data *modem) { - /* - * There are three different modem types which behave slightly - * different: - * - GSM modems will expose the SIM interface then the - * CM interface. - * - CDMA modems will expose CM first and sometime later - * a unique serial number. - * - * This functions tests if we have the necessary information gathered - * before we are able to create a device. - */ - if (modem->device) return false; - if (modem->imsi || modem->serial) - return true; + if (!modem->imsi) + return false; - return false; + return true; } static void create_device(struct modem_data *modem) @@ -1050,8 +948,6 @@ static void create_device(struct modem_data *modem) if (modem->imsi) ident = modem->imsi; - else if (modem->serial) - ident = modem->serial; if (!connman_dbus_validate_ident(ident)) ident = connman_dbus_encode_string(ident); @@ -1611,22 +1507,6 @@ static void netreg_update_strength(struct modem_data *modem, if (!modem->context_list) return; - /* - * GSM: - * We don't have 2 signal notifications we always report the strength - * signal. data_strength is always equal to 0. - * - * CDMA: - * In the case we have a data_strength signal (from 1xEVDO network) - * we don't need to update the value with strength signal (from 1xCDMA) - * because the modem is registered to 1xEVDO network for data call. - * In case we have no data_strength signal (not registered to 1xEVDO - * network), we must report the strength signal (registered to 1xCDMA - * network e.g slow mode). - */ - if (modem->data_strength != 0) - return; - /* For all the context */ for (list = modem->context_list; list; list = list->next) { struct network_context *context = list->data; @@ -1639,39 +1519,6 @@ static void netreg_update_strength(struct modem_data *modem, } } -/* Retrieve 1xEVDO Data Strength signal */ -static void netreg_update_datastrength(struct modem_data *modem, - DBusMessageIter *value) -{ - GSList *list; - - dbus_message_iter_get_basic(value, &modem->data_strength); - - DBG("%s Data Strength %d", modem->path, modem->data_strength); - - if (!modem->context_list) - return; - - /* - * CDMA modem is not registered to 1xEVDO network, let - * update_signal_strength() reporting the value on the Strength signal - * notification. - */ - if (modem->data_strength == 0) - return; - - /* For all the context */ - for (list = modem->context_list; list; list = list->next) { - struct network_context *context = list->data; - - if (context->network) { - connman_network_set_strength(context->network, - modem->data_strength); - connman_network_update(context->network); - } - } -} - static void netreg_update_status(struct modem_data *modem, DBusMessageIter *value) { @@ -1821,115 +1668,6 @@ static int netreg_get_properties(struct modem_data *modem) netreg_properties_reply, modem); } -static void add_cdma_network(struct modem_data *modem) -{ - struct network_context *context = NULL; - /* Be sure that device is created before adding CDMA network */ - if (!modem->device) - return; - - /* - * CDMA modems don't need contexts for data call, however the current - * add_network() logic needs one, so we create one to proceed. - */ - if (!modem->context_list) { - context = network_context_alloc(modem->path); - modem->context_list = g_slist_prepend(modem->context_list, - context); - } else - context = modem->context_list->data; - - if (!modem->name) - modem->name = g_strdup("CDMA Network"); - - add_network(modem, context); - - if (modem->cdma_cm_powered) - set_connected(modem, context); -} - -static gboolean cdma_netreg_changed(DBusConnection *conn, - DBusMessage *message, - void *user_data) -{ - const char *path = dbus_message_get_path(message); - struct modem_data *modem; - DBusMessageIter iter, value; - const char *key; - - DBG(""); - - modem = g_hash_table_lookup(modem_hash, path); - if (!modem) - return TRUE; - - if (modem->ignore) - return TRUE; - - if (!dbus_message_iter_init(message, &iter)) - return TRUE; - - dbus_message_iter_get_basic(&iter, &key); - - dbus_message_iter_next(&iter); - dbus_message_iter_recurse(&iter, &value); - - if (g_str_equal(key, "Name")) - netreg_update_name(modem, &value); - else if (g_str_equal(key, "Strength")) - netreg_update_strength(modem, &value); - else if (g_str_equal(key, "DataStrength")) - netreg_update_datastrength(modem, &value); - else if (g_str_equal(key, "Status")) - netreg_update_status(modem, &value); - - if (modem->registered) - add_cdma_network(modem); - else - remove_all_networks(modem); - - return TRUE; -} - -static void cdma_netreg_properties_reply(struct modem_data *modem, - DBusMessageIter *dict) -{ - DBG("%s", modem->path); - - while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) { - DBusMessageIter entry, value; - const char *key; - - dbus_message_iter_recurse(dict, &entry); - dbus_message_iter_get_basic(&entry, &key); - - dbus_message_iter_next(&entry); - dbus_message_iter_recurse(&entry, &value); - - if (g_str_equal(key, "Name")) - netreg_update_name(modem, &value); - else if (g_str_equal(key, "Strength")) - netreg_update_strength(modem, &value); - else if (g_str_equal(key, "DataStrength")) - netreg_update_datastrength(modem, &value); - else if (g_str_equal(key, "Status")) - netreg_update_status(modem, &value); - - dbus_message_iter_next(dict); - } - - if (modem->registered) - add_cdma_network(modem); - else - remove_all_networks(modem); -} - -static int cdma_netreg_get_properties(struct modem_data *modem) -{ - return get_properties(modem->path, OFONO_CDMA_NETREG_INTERFACE, - cdma_netreg_properties_reply, modem); -} - static void cm_update_attached(struct modem_data *modem, DBusMessageIter *value) { @@ -1999,67 +1737,6 @@ static gboolean cm_changed(DBusConnection *conn, DBusMessage *message, return TRUE; } -static void cdma_cm_update_powered(struct modem_data *modem, - DBusMessageIter *value) -{ - struct network_context *context = NULL; - dbus_bool_t cdma_cm_powered; - - dbus_message_iter_get_basic(value, &cdma_cm_powered); - modem->cdma_cm_powered = cdma_cm_powered; - - DBG("%s CDMA cm Powered %d", modem->path, modem->cdma_cm_powered); - - if (!modem->context_list) - return; - - /* In case of CDMA, there is only one context */ - context = modem->context_list->data; - if (modem->cdma_cm_powered) - set_connected(modem, context); - else - set_disconnected(context); -} - -static void cdma_cm_update_settings(struct modem_data *modem, - DBusMessageIter *value) -{ - DBG("%s Settings", modem->path); - - extract_ipv4_settings(value, modem->context_list->data); -} - -static gboolean cdma_cm_changed(DBusConnection *conn, - DBusMessage *message, void *user_data) -{ - const char *path = dbus_message_get_path(message); - struct modem_data *modem; - DBusMessageIter iter, value; - const char *key; - - modem = g_hash_table_lookup(modem_hash, path); - if (!modem) - return TRUE; - - if (modem->online && !modem->context_list) - cdma_netreg_get_properties(modem); - - if (!dbus_message_iter_init(message, &iter)) - return TRUE; - - dbus_message_iter_get_basic(&iter, &key); - - dbus_message_iter_next(&iter); - dbus_message_iter_recurse(&iter, &value); - - if (g_str_equal(key, "Powered")) - cdma_cm_update_powered(modem, &value); - if (g_str_equal(key, "Settings")) - cdma_cm_update_settings(modem, &value); - - return TRUE; -} - static void cm_properties_reply(struct modem_data *modem, DBusMessageIter *dict) { DBG("%s", modem->path); @@ -2089,39 +1766,6 @@ static int cm_get_properties(struct modem_data *modem) cm_properties_reply, modem); } -static void cdma_cm_properties_reply(struct modem_data *modem, - DBusMessageIter *dict) -{ - DBG("%s", modem->path); - - if (modem->online) - cdma_netreg_get_properties(modem); - - while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) { - DBusMessageIter entry, value; - const char *key; - - dbus_message_iter_recurse(dict, &entry); - dbus_message_iter_get_basic(&entry, &key); - - dbus_message_iter_next(&entry); - dbus_message_iter_recurse(&entry, &value); - - if (g_str_equal(key, "Powered")) - cdma_cm_update_powered(modem, &value); - if (g_str_equal(key, "Settings")) - cdma_cm_update_settings(modem, &value); - - dbus_message_iter_next(dict); - } -} - -static int cdma_cm_get_properties(struct modem_data *modem) -{ - return get_properties(modem->path, OFONO_CDMA_CM_INTERFACE, - cdma_cm_properties_reply, modem); -} - static void sim_update_imsi(struct modem_data *modem, DBusMessageIter *value) { @@ -2279,25 +1923,11 @@ static void modem_update_interfaces(struct modem_data *modem, } } - if (api_added(old_ifaces, new_ifaces, OFONO_API_CDMA_CM)) { - if (ready_to_create_device(modem)) { - create_device(modem); - if (modem->registered) - add_cdma_network(modem); - } - - if (modem->device) - cdma_cm_get_properties(modem); - } - if (api_added(old_ifaces, new_ifaces, OFONO_API_NETREG)) { if (modem->attached) netreg_get_properties(modem); } - if (api_added(old_ifaces, new_ifaces, OFONO_API_CDMA_NETREG)) - cdma_netreg_get_properties(modem); - if (api_removed(old_ifaces, new_ifaces, OFONO_API_CM)) { if (modem->call_get_contexts) { DBG("cancelling pending GetContexts call"); @@ -2308,14 +1938,8 @@ static void modem_update_interfaces(struct modem_data *modem, remove_all_contexts(modem); } - if (api_removed(old_ifaces, new_ifaces, OFONO_API_CDMA_CM)) - remove_all_contexts(modem); - if (api_removed(old_ifaces, new_ifaces, OFONO_API_NETREG)) remove_all_networks(modem); - - if (api_removed(old_ifaces, new_ifaces, OFONO_API_CDMA_NETREG)) - remove_all_networks(modem); } static gboolean modem_changed(DBusConnection *conn, DBusMessage *message, @@ -2385,15 +2009,6 @@ static gboolean modem_changed(DBusConnection *conn, DBusMessage *message, modem->serial = g_strdup(serial); DBG("%s Serial %s", modem->path, modem->serial); - - if (has_interface(modem->interfaces, - OFONO_API_CDMA_CM)) { - if (ready_to_create_device(modem)) { - create_device(modem); - if (modem->registered) - add_cdma_network(modem); - } - } } return TRUE; @@ -2717,8 +2332,6 @@ static int network_connect(struct connman_network *network) if (has_interface(modem->interfaces, OFONO_API_CM)) return context_set_active(modem, context, TRUE); - else if (has_interface(modem->interfaces, OFONO_API_CDMA_CM)) - return cdma_cm_set_powered(modem, TRUE); connman_error("Connection manager interface not available"); @@ -2741,8 +2354,6 @@ static int network_disconnect(struct connman_network *network) if (has_interface(modem->interfaces, OFONO_API_CM)) return context_set_active(modem, context, FALSE); - else if (has_interface(modem->interfaces, OFONO_API_CDMA_CM)) - return cdma_cm_set_powered(modem, FALSE); connman_error("Connection manager interface not available"); @@ -2833,8 +2444,6 @@ static guint context_added_watch; static guint context_removed_watch; static guint netreg_watch; static guint context_watch; -static guint cdma_cm_watch; -static guint cdma_netreg_watch; static int ofono_init(void) { @@ -2907,25 +2516,11 @@ static int ofono_init(void) netreg_changed, NULL, NULL); - cdma_cm_watch = g_dbus_add_signal_watch(connection, OFONO_SERVICE, - NULL, OFONO_CDMA_CM_INTERFACE, - PROPERTY_CHANGED, - cdma_cm_changed, - NULL, NULL); - - cdma_netreg_watch = g_dbus_add_signal_watch(connection, OFONO_SERVICE, - NULL, OFONO_CDMA_NETREG_INTERFACE, - PROPERTY_CHANGED, - cdma_netreg_changed, - NULL, NULL); - - if (watch == 0 || modem_added_watch == 0 || modem_removed_watch == 0 || modem_watch == 0 || cm_watch == 0 || sim_watch == 0 || context_added_watch == 0 || context_removed_watch == 0 || - context_watch == 0 || netreg_watch == 0 || - cdma_cm_watch == 0 || cdma_netreg_watch == 0) { + context_watch == 0 || netreg_watch == 0) { err = -EIO; goto remove; } @@ -2950,8 +2545,6 @@ static int ofono_init(void) return 0; remove: - g_dbus_remove_watch(connection, cdma_netreg_watch); - g_dbus_remove_watch(connection, cdma_cm_watch); g_dbus_remove_watch(connection, netreg_watch); g_dbus_remove_watch(connection, context_watch); g_dbus_remove_watch(connection, context_removed_watch); @@ -2994,8 +2587,6 @@ static void ofono_exit(void) connman_device_driver_unregister(&modem_driver); connman_network_driver_unregister(&network_driver); - g_dbus_remove_watch(connection, cdma_netreg_watch); - g_dbus_remove_watch(connection, cdma_cm_watch); g_dbus_remove_watch(connection, netreg_watch); g_dbus_remove_watch(connection, context_watch); g_dbus_remove_watch(connection, context_removed_watch); -- 2.43.0
While testing the online check on continuous mode, I found out that it does not downgrades the service after the threshold is met.Seems like ipv6 being on state (ready) already prevents the downgrade. My assumption comes from inspecting src/service.c:is_online_check_failure_threshold_met_predicate Is this the correct behavior? connman is on master@807ad961777ffffad36f53ea034583466a7073de my main.conf file : [General] PreferredTechnologies=wifi,ethernet DefaultAutoConnectTechnologies=wifi,ethernet BackgroundScanning=true EnableOnlineCheck=true OnlineCheckConnectTimeout=10 OnlineCheckMode=continuous OnlineCheckIntervalStyle=geometric OnlineCheckInitialInterval=1 OnlineCheckMaxInterval=8 OnlineCheckFailuresThreshold=1 relevant log: connmand[2065]: /usr/src/debug/connman/1.43-r0/src/service.c:online_check_counters_log() service 0x18f29b0 (wifi_e8fb1ccdfacb_6d7563686f626f6d3547_managed_psk) ipv4 state 5 (online) failure(s/es) 2 ipv6 state 4 (ready) failure(s/es) 0 connmand[2065]: /usr/src/debug/connman/1.43-r0/src/service.c:online_check_counter_threshold_is_met() service 0x18f29b0 (wifi_e8fb1ccdfacb_6d7563686f626f6d3547_managed_psk) failure threshold 1 failure(s) met 0 connmand[2065]: /usr/src/debug/connman/1.43-r0/src/service.c:handle_continuous_online_check_failure() failures threshold was met 0 failures threshold is met 0 default 1 connmand[2065]: /usr/src/debug/connman/1.43-r0/src/service.c:online_check_counters_log() service 0x18f29b0 (wifi_e8fb1ccdfacb_6d7563686f626f6d3547_managed_psk) ipv4 state 5 (online) failure(s/es) 2 ipv6 state 4 (ready) failure(s/es) 0 connmand[2065]: /usr/src/debug/connman/1.43-r0/src/service.c:online_check_counter_threshold_is_met() service 0x18f29b0 (wifi_e8fb1ccdfacb_6d7563686f626f6d3547_managed_psk) failure threshold 1 failure(s) met 0 connmand[2065]: /usr/src/debug/connman/1.43-r0/src/service.c:handle_continuous_online_check_failure() failures threshold was met 0, default 1 connmand[2065]: /usr/src/debug/connman/1.43-r0/src/service.c:complete_online_check() reschedule online check 1
Please disregard this request. The dbus messages are substantially
different. Implementation would be a headache and it is definitely a
corner case. In the end I figured out a better way.
Keith
On Fri, Dec 22, 2023 at 4:07 PM KeithG <ys3al35l@gmail.com> wrote:
>
> I am back on the project. I feel it would be a great add to connman.
> What it is: Feature to allow connman to scan for ssids while iwd is in ap mode
> Background: I know connman can tether and we have done that, but this
> has 2 issues. 1) it creates another interface called tether which is
> confusing to some users as we are using conman in a headless audio
> player 2) tether will not allow us to set a preferred IP address.
>
> The iwd team added this functionality a while back where if iwd is in
> ap mode, it can still scan for networks. iwd allows us to set the wlan
> adapter into ap mode with a preferred IP and keeps the same adapter
> listed (wlan0 in our case). I would love to see connman be able to do
> this as well. With this functionality, we could use iwd/connman for
> 'wireless setup' of our audio player. We are currently using hostapd
> and it is balky, disconnects and is slow.
>
> Daniel Wagner created this patch to iwd.c back in January 2023 which I
> incorporated and built into a current (git from head, source built)
> connman package. The resulting binary works fine in station mode with
> iwd, but it still will not allow 'connmanctl scan wifi' when iwd is in
> ap mode though iwd can do it.
>
> When iwd is in ap mode, if you issue a command 'iwctl ap wlan0 scan'
> then 'iwctl ap wlan0 get-networks' it returns the available networks
> similarly as it does in station mode.
>
> if iwd is in ap mode and 'connmanctl scan wifi' is sent, connman takes
> a long time and finally returns. The log of the iwd plugin when I did
> this is:
>
> https://pastebin.com/AHq2XkUs
>
> The patch from Daniel Wagner is here:
> ---
>
> Only compile tested :)
>
> plugins/iwd.c | 54 ++++++++++++++++++++++++++++++
> ++++++++++++++++-----
> 1 file changed, 49 insertions(+), 5 deletions(-)
>
> diff --git a/plugins/iwd.c b/plugins/iwd.c
> index 2fe49a23316b..491a0e41da89 100644
> --- a/plugins/iwd.c
> +++ b/plugins/iwd.c
> @@ -633,15 +633,28 @@ static void cm_device_scan_cb(DBusMessage
> *message, void *user_data)
> }
> }
>
> -static int cm_device_scan(struct connman_device *device,
> - struct connman_device_scan_params *params)
> +static void cm_ap_scan_cb(DBusMessage *message, void *user_data)
> +{
> + const char *path = user_data;
> + struct iwd_ap *iwdap;
> +
> + iwdap = g_hash_table_lookup(access_points, path);
> + if (!iwdap)
> + return;
> +
> + if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
> + const char *dbus_error = dbus_message_get_error_name(message);
> +
> + DBG("%s scan failed: %s", path, dbus_error);
> + }
> +}
> +
> +static int cm_station_scan(struct connman_device *device,
> + struct connman_device_scan_params *param)
> {
> struct iwd_device *iwdd = connman_device_get_data(device);
> struct iwd_station *iwds;
>
> - if (strcmp(iwdd->mode, "station"))
> - return -EINVAL;
> -
> iwds = g_hash_table_lookup(stations, iwdd->path);
> if (!iwds)
> return -EIO;
> @@ -653,6 +666,37 @@ static int cm_device_scan(struct connman_device *device,
> return -EINPROGRESS;
> }
>
> +static int cm_ap_scan(struct connman_device *device,
> + struct connman_device_scan_params *param)
> +{
> + struct iwd_device *iwdd = connman_device_get_data(device);
> + struct iwd_ap *iwdap;
> +
> + iwdap = g_hash_table_lookup(access_points, iwdd->path);
> + if (!iwdap)
> + return -EIO;
> +
> + if (!g_dbus_proxy_method_call(iwdap->proxy, "Scan",
> + NULL, cm_ap_scan_cb, g_strdup(iwdap->path), g_free))
> + return -EIO;
> +
> + return -EINPROGRESS;
> +}
> +
> +static int cm_device_scan(struct connman_device *device,
> + struct connman_device_scan_params *params)
> +{
> + struct iwd_device *iwdd = connman_device_get_data(device);
> +
> + if (!strcmp(iwdd->mode, "station"))
> + return cm_station_scan(device, params);
> +
> + if (!strcmp(iwdd->mode, "ap"))
> + return cm_ap_scan(device, params);
> +
> + return -EINVAL;
> +}
> +
> static struct connman_device_driver device_driver = {
> .name = "iwd",
> .type = CONNMAN_DEVICE_TYPE_WIFI,
> --
> 2.39.0
Hi all, On 1/15/24 09:56, Marcel Holtmann wrote: > Hi Khem, > >> Use POSIX version of basename. This comes to front with latest musl >> which dropped the declaration from string.h [1] it fails to build with >> clang-17+ because it treats implicit function declaration as error. >> >> Fix it by applying the basename on a copy of string since posix version >> may modify the input string. >> >> [1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7 >> >> Signed-off-by: Khem Raj <raj.khem@gmail.com> >> --- >> v2: Fix formatting >> >> src/log.c | 6 ++++-- >> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/src/log.c b/src/log.c >> index 554b046..2df3af7 100644 >> --- a/src/log.c >> +++ b/src/log.c >> @@ -24,6 +24,7 @@ >> #endif >> >> #include <stdio.h> >> +#include <libgen.h> >> #include <unistd.h> >> #include <stdarg.h> >> #include <stdlib.h> >> @@ -196,6 +197,7 @@ int __connman_log_init(const char *program, const char *debug, >> const char *program_name, const char *program_version) >> { >> static char path[PATH_MAX]; >> + char* tmp = strdup(program); > > declaration are char *tmp; > And perhaps use g_strdup() instead? coding-style.txt indirectly refers to use of g_ functions when available, as it is done with the rest of the codebase. Also, when small allocations fail the program should crash (M8). >> int option = LOG_NDELAY | LOG_PID; >> >> program_exec = program; >> @@ -212,8 +214,8 @@ int __connman_log_init(const char *program, const char *debug, >> if (backtrace) >> signal_setup(signal_handler); >> >> - openlog(basename(program), option, LOG_DAEMON); >> - > > Put the strdup here. > > And you need to handle tmp == NULL since then it seems basename returns a constant “.”. > >> + openlog(basename(tmp), option, LOG_DAEMON); >> + free(tmp); > I was just thinking maybe it would be better to handle the duplication of the program name, argv[0] in main.c (both connmand and vpnd), where it is given as initialization arg to __connman_log_init()? Cheers, Jussi
Hi Khem, > Use POSIX version of basename. This comes to front with latest musl > which dropped the declaration from string.h [1] it fails to build with > clang-17+ because it treats implicit function declaration as error. > > Fix it by applying the basename on a copy of string since posix version > may modify the input string. > > [1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7 > > Signed-off-by: Khem Raj <raj.khem@gmail.com> > --- > v2: Fix formatting > > src/log.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/src/log.c b/src/log.c > index 554b046..2df3af7 100644 > --- a/src/log.c > +++ b/src/log.c > @@ -24,6 +24,7 @@ > #endif > > #include <stdio.h> > +#include <libgen.h> > #include <unistd.h> > #include <stdarg.h> > #include <stdlib.h> > @@ -196,6 +197,7 @@ int __connman_log_init(const char *program, const char *debug, > const char *program_name, const char *program_version) > { > static char path[PATH_MAX]; > + char* tmp = strdup(program); declaration are char *tmp; > int option = LOG_NDELAY | LOG_PID; > > program_exec = program; > @@ -212,8 +214,8 @@ int __connman_log_init(const char *program, const char *debug, > if (backtrace) > signal_setup(signal_handler); > > - openlog(basename(program), option, LOG_DAEMON); > - Put the strdup here. And you need to handle tmp == NULL since then it seems basename returns a constant “.”. > + openlog(basename(tmp), option, LOG_DAEMON); > + free(tmp); Regards Marcel
Hi Khem,
> Use POSIX version of basename. This comes to front with latest musl
> which dropped the declaration from string.h [1] it fails to build with
> clang-17+ because it treats implicit function declaration as error.
>
> Fix it by applying the basename on a copy of string since posix version
> may modify the input string.
>
> [1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
> src/log.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/log.c b/src/log.c
> index 554b046..941e078 100644
> --- a/src/log.c
> +++ b/src/log.c
> @@ -24,6 +24,7 @@
> #endif
>
> #include <stdio.h>
> +#include <libgen.h>
> #include <unistd.h>
> #include <stdarg.h>
> #include <stdlib.h>
> @@ -196,6 +197,7 @@ int __connman_log_init(const char *program, const char *debug,
> const char *program_name, const char *program_version)
> {
> static char path[PATH_MAX];
> + char* tmp = strdup(program);
> int option = LOG_NDELAY | LOG_PID;
>
> program_exec = program;
> @@ -212,8 +214,8 @@ int __connman_log_init(const char *program, const char *debug,
> if (backtrace)
> signal_setup(signal_handler);
>
> - openlog(basename(program), option, LOG_DAEMON);
> -
> + openlog(basename(tmp), option, LOG_DAEMON);
> + free(tmp);
can you please follow the coding style.
Regards
Marcel
I am trying to set up connman to work with resolvectl/systemd-resolved Is there a way to do this without re-building with a flag? According to the Arch Wiki, connman would need to be rebuilt with this flag: --with-dns-backend=systemd-resolved to work with resolved. Could this be added as a runtime config in /etc/connman/main.conf? Keith