*
* Connection Manager
*
- * Copyright (C) 2007-2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2013 Intel Corporation. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2011 BWM Car IT GmbH. All rights reserved.
+ * Copyright (C) 2011-2014 BMW Car IT GmbH.
*
* 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
/* Modem Interface */
char *serial;
- connman_bool_t powered;
- connman_bool_t online;
+ bool powered;
+ bool online;
uint8_t interfaces;
- connman_bool_t ignore;
+ bool ignore;
- connman_bool_t set_powered;
+ bool set_powered;
/* CDMA ConnectionManager Interface */
- connman_bool_t cdma_cm_powered;
+ bool cdma_cm_powered;
/* ConnectionManager Interface */
- connman_bool_t attached;
- connman_bool_t cm_powered;
+ bool attached;
+ bool cm_powered;
/* ConnectionContext Interface */
- connman_bool_t active;
- connman_bool_t set_active;
- connman_bool_t valid_apn; /* APN is 'valid' if length > 0 */
+ bool active;
+ bool valid_apn; /* APN is 'valid' if length > 0 */
/* SimManager Interface */
char *imsi;
char *name;
uint8_t strength;
uint8_t data_strength; /* 1xEVDO signal strength */
- connman_bool_t roaming;
+ bool registered;
+ bool roaming;
/* pending calls */
DBusPendingCall *call_set_property;
return NULL;
pos = strrchr(path, '/');
- if (pos == NULL)
+ if (!pos)
return NULL;
return pos + 1;
struct network_context *context;
context = g_try_new0(struct network_context, 1);
- if (context == NULL)
+ if (!context)
return NULL;
context->path = g_strdup(path);
static void set_connected(struct modem_data *modem)
{
struct connman_service *service;
- connman_bool_t setip = FALSE;
+ bool setip = false;
enum connman_ipconfig_method method;
char *nameservers;
int index;
index = modem->context->index;
- if (index < 0 || modem->context->ipv4_address == NULL) {
+ method = modem->context->ipv4_method;
+ if (index < 0 || (!modem->context->ipv4_address &&
+ method == CONNMAN_IPCONFIG_METHOD_FIXED)) {
connman_error("Invalid index and/or address");
return;
}
service = connman_service_lookup_from_network(modem->network);
- if (service == NULL)
+ if (!service)
return;
- method = modem->context->ipv4_method;
- if (method == CONNMAN_IPCONFIG_METHOD_FIXED ||
- method == CONNMAN_IPCONFIG_METHOD_DHCP)
- {
- connman_service_create_ip4config(service, index);
- connman_network_set_index(modem->network, index);
-
- connman_network_set_ipv4_method(modem->network, method);
+ connman_service_create_ip4config(service, index);
+ connman_network_set_ipv4_method(modem->network, method);
- setip = TRUE;
+ if (method == CONNMAN_IPCONFIG_METHOD_FIXED ||
+ method == CONNMAN_IPCONFIG_METHOD_DHCP) {
+ setip = true;
}
if (method == CONNMAN_IPCONFIG_METHOD_FIXED) {
}
method = modem->context->ipv6_method;
- if (method == CONNMAN_IPCONFIG_METHOD_FIXED) {
- connman_service_create_ip6config(service, index);
- connman_network_set_ipv6_method(modem->network, method);
- connman_network_set_ipaddress(modem->network,
- modem->context->ipv6_address);
- setip = TRUE;
+ connman_service_create_ip6config(service, index);
+ connman_network_set_ipv6_method(modem->network, method);
+
+ if (method == CONNMAN_IPCONFIG_METHOD_AUTO) {
+ setip = true;
}
/* Set the nameservers */
- if (modem->context->ipv4_nameservers != NULL &&
- modem->context->ipv6_nameservers != NULL) {
+ if (modem->context->ipv4_nameservers &&
+ modem->context->ipv6_nameservers) {
nameservers = g_strdup_printf("%s %s",
modem->context->ipv4_nameservers,
modem->context->ipv6_nameservers);
connman_network_set_nameservers(modem->network, nameservers);
g_free(nameservers);
- } else if (modem->context->ipv4_nameservers != NULL) {
+ } else if (modem->context->ipv4_nameservers) {
connman_network_set_nameservers(modem->network,
modem->context->ipv4_nameservers);
- } else if (modem->context->ipv6_nameservers != NULL) {
+ } else if (modem->context->ipv6_nameservers) {
connman_network_set_nameservers(modem->network,
modem->context->ipv6_nameservers);
}
- if (setip == TRUE)
- connman_network_set_connected(modem->network, TRUE);
+ if (setip) {
+ connman_network_set_index(modem->network, index);
+ connman_network_set_connected(modem->network, true);
+ }
}
static void set_disconnected(struct modem_data *modem)
{
DBG("%s", modem->path);
- if (modem->network == NULL)
- return;
+ if (modem->network)
+ connman_network_set_connected(modem->network, false);
+
+ if (modem->context) {
+ g_free(modem->context->ipv4_nameservers);
+ modem->context->ipv4_nameservers = NULL;
+ if (modem->context->ipv4_method != CONNMAN_IPCONFIG_METHOD_OFF)
+ modem->context->ipv4_method =
+ CONNMAN_IPCONFIG_METHOD_UNKNOWN;
- connman_network_set_connected(modem->network, FALSE);
+ g_free(modem->context->ipv6_nameservers);
+ modem->context->ipv6_nameservers = NULL;
+ if (modem->context->ipv6_method != CONNMAN_IPCONFIG_METHOD_OFF)
+ modem->context->ipv6_method =
+ CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+ }
}
typedef void (*set_property_cb)(struct modem_data *data,
- connman_bool_t success);
+ bool success);
typedef void (*get_properties_cb)(struct modem_data *data,
DBusMessageIter *dict);
struct property_info *info = user_data;
DBusMessage *reply;
DBusError error;
- connman_bool_t success = TRUE;
+ bool success = true;
DBG("%s path %s %s.%s", info->modem->path,
info->path, info->interface, info->property);
info->path, info->interface, info->property,
error.name, error.message);
dbus_error_free(&error);
- success = FALSE;
+ success = false;
}
- if (info->set_property_cb != NULL)
+ if (info->set_property_cb)
(*info->set_property_cb)(info->modem, success);
dbus_message_unref(reply);
DBG("%s path %s %s.%s", modem->path, path, interface, property);
- if (modem->call_set_property != NULL) {
+ if (modem->call_set_property) {
DBG("Cancel pending SetProperty");
dbus_pending_call_cancel(modem->call_set_property);
message = dbus_message_new_method_call(OFONO_SERVICE, path,
interface, SET_PROPERTY);
- if (message == NULL)
+ if (!message)
return -ENOMEM;
dbus_message_iter_init_append(message, &iter);
connman_dbus_property_append_basic(&iter, property, type, value);
- if (dbus_connection_send_with_reply(connection, message,
- &modem->call_set_property, TIMEOUT) == FALSE) {
+ if (!dbus_connection_send_with_reply(connection, message,
+ &modem->call_set_property, TIMEOUT)) {
connman_error("Failed to change property: %s %s.%s",
path, interface, property);
dbus_message_unref(message);
return -EINVAL;
}
- if (modem->call_set_property == NULL) {
+ if (!modem->call_set_property) {
connman_error("D-Bus connection not available");
dbus_message_unref(message);
return -EINVAL;
}
info = g_try_new0(struct property_info, 1);
- if (info == NULL) {
+ if (!info) {
dbus_message_unref(message);
return -ENOMEM;
}
goto done;
}
- if (dbus_message_iter_init(reply, &array) == FALSE)
+ if (!dbus_message_iter_init(reply, &array))
goto done;
if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
dbus_message_iter_recurse(&array, &dict);
- if (info->get_properties_cb != NULL)
+ if (info->get_properties_cb)
(*info->get_properties_cb)(info->modem, &dict);
done:
DBG("%s path %s %s", modem->path, path, interface);
- if (modem->call_get_properties != NULL) {
+ if (modem->call_get_properties) {
connman_error("Pending GetProperties");
return -EBUSY;
}
message = dbus_message_new_method_call(OFONO_SERVICE, path,
interface, GET_PROPERTIES);
- if (message == NULL)
+ if (!message)
return -ENOMEM;
- if (dbus_connection_send_with_reply(connection, message,
- &modem->call_get_properties, TIMEOUT) == FALSE) {
+ if (!dbus_connection_send_with_reply(connection, message,
+ &modem->call_get_properties, TIMEOUT)) {
connman_error("Failed to call %s.GetProperties()", interface);
dbus_message_unref(message);
return -EINVAL;
}
- if (modem->call_get_properties == NULL) {
+ if (!modem->call_get_properties) {
connman_error("D-Bus connection not available");
dbus_message_unref(message);
return -EINVAL;
}
info = g_try_new0(struct property_info, 1);
- if (info == NULL) {
+ if (!info) {
dbus_message_unref(message);
return -ENOMEM;
}
}
static void context_set_active_reply(struct modem_data *modem,
- connman_bool_t success)
+ bool success)
{
DBG("%s", modem->path);
- if (success == TRUE) {
+ if (success) {
/*
* Don't handle do anything on success here. oFono will send
* the change via PropertyChanged singal.
* cycle the modem in such cases?
*/
- if (modem->network == NULL) {
+ if (!modem->network) {
/*
* In the case where we power down the device
* we don't wait for the reply, therefore the network
}
static int context_set_active(struct modem_data *modem,
- connman_bool_t active)
+ dbus_bool_t active)
{
int err;
&active,
context_set_active_reply);
- if (active == FALSE && err == -EINPROGRESS)
+ if (!active && err == -EINPROGRESS)
return 0;
return err;
}
static void cdma_cm_set_powered_reply(struct modem_data *modem,
- connman_bool_t success)
+ bool success)
{
DBG("%s", modem->path);
- if (success == TRUE) {
+ if (success) {
/*
* Don't handle do anything on success here. oFono will send
* the change via PropertyChanged singal.
* cycle the modem in such cases?
*/
- if (modem->network == NULL) {
+ if (!modem->network) {
/*
* In the case where we power down the device
* we don't wait for the reply, therefore the network
CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
}
-static int cdma_cm_set_powered(struct modem_data *modem, connman_bool_t powered)
+static int cdma_cm_set_powered(struct modem_data *modem, dbus_bool_t powered)
{
int err;
&powered,
cdma_cm_set_powered_reply);
- if (powered == FALSE && err == -EINPROGRESS)
+ if (!powered && err == -EINPROGRESS)
return 0;
return err;
}
-static int modem_set_online(struct modem_data *modem, connman_bool_t online)
+static int modem_set_online(struct modem_data *modem, dbus_bool_t online)
{
DBG("%s online %d", modem->path, online);
NULL);
}
-static int cm_set_powered(struct modem_data *modem, connman_bool_t powered)
+static int cm_set_powered(struct modem_data *modem, dbus_bool_t powered)
{
int err;
&powered,
NULL);
- if (powered == FALSE && err == -EINPROGRESS)
+ if (!powered && err == -EINPROGRESS)
return 0;
return err;
}
-static int modem_set_powered(struct modem_data *modem, connman_bool_t powered)
+static int modem_set_powered(struct modem_data *modem, dbus_bool_t powered)
{
int err;
&powered,
NULL);
- if (powered == FALSE && err == -EINPROGRESS)
+ if (!powered && err == -EINPROGRESS)
return 0;
return err;
}
-static connman_bool_t has_interface(uint8_t interfaces,
+static bool has_interface(uint8_t interfaces,
enum ofono_api api)
{
if ((interfaces & api) == api)
- return TRUE;
+ return true;
- return FALSE;
+ return false;
}
static uint8_t extract_interfaces(DBusMessageIter *array)
dbus_message_iter_get_basic(&entry, &name);
- if (g_str_equal(name, OFONO_SIM_INTERFACE) == TRUE)
+ if (g_str_equal(name, OFONO_SIM_INTERFACE))
interfaces |= OFONO_API_SIM;
- else if (g_str_equal(name, OFONO_NETREG_INTERFACE) == TRUE)
+ else if (g_str_equal(name, OFONO_NETREG_INTERFACE))
interfaces |= OFONO_API_NETREG;
- else if (g_str_equal(name, OFONO_CM_INTERFACE) == TRUE)
+ else if (g_str_equal(name, OFONO_CM_INTERFACE))
interfaces |= OFONO_API_CM;
- else if (g_str_equal(name, OFONO_CDMA_CM_INTERFACE) == TRUE)
+ 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) == TRUE)
+ else if (g_str_equal(name, OFONO_CDMA_NETREG_INTERFACE))
interfaces |= OFONO_API_CDMA_NETREG;
dbus_message_iter_next(&entry);
dbus_message_iter_get_basic(&entry, &nameserver);
- if (nameservers == NULL) {
+ if (!nameservers) {
nameservers = g_strdup(nameserver);
} else {
tmp = nameservers;
const char *interface = NULL;
int index = -1;
+ connman_ipaddress_free(context->ipv4_address);
+ context->ipv4_address = NULL;
+ context->index = -1;
+
if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
return;
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);
- if (g_str_equal(key, "Interface") == TRUE) {
+ if (g_str_equal(key, "Interface")) {
dbus_message_iter_get_basic(&value, &interface);
DBG("Interface %s", interface);
index = connman_inet_ifindex(interface);
DBG("index %d", index);
- } else if (g_str_equal(key, "Method") == TRUE) {
+ } else if (g_str_equal(key, "Method")) {
dbus_message_iter_get_basic(&value, &val);
DBG("Method %s", val);
- if (g_strcmp0(val, "static") == 0) {
+ if (g_strcmp0(val, "static") == 0)
context->ipv4_method = CONNMAN_IPCONFIG_METHOD_FIXED;
- } else if (g_strcmp0(val, "dhcp") == 0) {
+ else if (g_strcmp0(val, "dhcp") == 0)
context->ipv4_method = CONNMAN_IPCONFIG_METHOD_DHCP;
- break;
- }
- } else if (g_str_equal(key, "Address") == TRUE) {
+
+ } else if (g_str_equal(key, "Address")) {
dbus_message_iter_get_basic(&value, &val);
address = g_strdup(val);
DBG("Address %s", address);
- } else if (g_str_equal(key, "Netmask") == TRUE) {
+ } else if (g_str_equal(key, "Netmask")) {
dbus_message_iter_get_basic(&value, &val);
netmask = g_strdup(val);
DBG("Netmask %s", netmask);
- } else if (g_str_equal(key, "DomainNameServers") == TRUE) {
+ } else if (g_str_equal(key, "DomainNameServers")) {
nameservers = extract_nameservers(&value);
DBG("Nameservers %s", nameservers);
- } else if (g_str_equal(key, "Gateway") == TRUE) {
+ } else if (g_str_equal(key, "Gateway")) {
dbus_message_iter_get_basic(&value, &val);
gateway = g_strdup(val);
if (index < 0)
goto out;
+ context->index = index;
+
if (context->ipv4_method != CONNMAN_IPCONFIG_METHOD_FIXED)
goto out;
context->ipv4_address = connman_ipaddress_alloc(CONNMAN_IPCONFIG_TYPE_IPV4);
- if (context->ipv4_address == NULL)
+ if (!context->ipv4_address) {
+ context->index = -1;
goto out;
+ }
- context->index = index;
connman_ipaddress_set_ipv4(context->ipv4_address, address,
netmask, gateway);
+ g_free(context->ipv4_nameservers);
context->ipv4_nameservers = nameservers;
out:
const char *interface = NULL;
int index = -1;
+ connman_ipaddress_free(context->ipv6_address);
+ context->ipv6_address = NULL;
+ context->index = -1;
+
if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
return;
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);
- if (g_str_equal(key, "Interface") == TRUE) {
+ if (g_str_equal(key, "Interface")) {
dbus_message_iter_get_basic(&value, &interface);
DBG("Interface %s", interface);
index = connman_inet_ifindex(interface);
DBG("index %d", index);
- } else if (g_str_equal(key, "Address") == TRUE) {
+ } else if (g_str_equal(key, "Address")) {
dbus_message_iter_get_basic(&value, &val);
address = g_strdup(val);
DBG("Address %s", address);
- } else if (g_str_equal(key, "PrefixLength") == TRUE) {
+ } else if (g_str_equal(key, "PrefixLength")) {
dbus_message_iter_get_basic(&value, &prefix_length);
DBG("prefix length %d", prefix_length);
- } else if (g_str_equal(key, "DomainNameServers") == TRUE) {
+ } else if (g_str_equal(key, "DomainNameServers")) {
nameservers = extract_nameservers(&value);
DBG("Nameservers %s", nameservers);
- } else if (g_str_equal(key, "Gateway") == TRUE) {
+ } else if (g_str_equal(key, "Gateway")) {
dbus_message_iter_get_basic(&value, &val);
gateway = g_strdup(val);
if (index < 0)
goto out;
- context->ipv6_method = CONNMAN_IPCONFIG_METHOD_FIXED;
+ context->ipv6_method = CONNMAN_IPCONFIG_METHOD_AUTO;
context->ipv6_address =
connman_ipaddress_alloc(CONNMAN_IPCONFIG_TYPE_IPV6);
- if (context->ipv6_address == NULL)
+ if (!context->ipv6_address)
goto out;
context->index = index;
connman_ipaddress_set_ipv6(context->ipv6_address, address,
prefix_length, gateway);
+ g_free(context->ipv6_nameservers);
context->ipv6_nameservers = nameservers;
out:
g_free(gateway);
}
-static connman_bool_t ready_to_create_device(struct modem_data *modem)
+static bool ready_to_create_device(struct modem_data *modem)
{
/*
* There are three different modem types which behave slightly
* before we are able to create a device.
*/
- if (modem->device != NULL)
- return FALSE;
+ if (modem->device)
+ return false;
- if (modem->imsi != NULL || modem->serial != NULL)
- return TRUE;
+ if (modem->imsi || modem->serial)
+ return true;
- return FALSE;
+ return false;
}
static void create_device(struct modem_data *modem)
DBG("%s", modem->path);
- if (modem->imsi != NULL)
+ if (modem->imsi)
ident = modem->imsi;
- else if (modem->serial != NULL)
+ else if (modem->serial)
ident = modem->serial;
- if (connman_dbus_validate_ident(ident) == FALSE)
+ if (!connman_dbus_validate_ident(ident))
ident = connman_dbus_encode_string(ident);
else
ident = g_strdup(ident);
- device = connman_device_create(ident, CONNMAN_DEVICE_TYPE_CELLULAR);
- if (device == NULL)
+ device = connman_device_create("ofono", CONNMAN_DEVICE_TYPE_CELLULAR);
+ if (!device)
goto out;
DBG("device %p", device);
{
DBG("%s", modem->path);
- connman_device_set_powered(modem->device, FALSE);
+ connman_device_set_powered(modem->device, false);
- if (modem->network != NULL) {
+ if (modem->network) {
connman_device_remove_network(modem->device, modem->network);
connman_network_unref(modem->network);
modem->network = NULL;
DBG("%s", modem->path);
- if (modem->network != NULL)
+ if (modem->network)
return;
modem->network = connman_network_create(modem->context->path,
CONNMAN_NETWORK_TYPE_CELLULAR);
- if (modem->network == NULL)
+ if (!modem->network)
return;
DBG("network %p", modem->network);
connman_network_set_string(modem->network, "Path",
modem->context->path);
- if (modem->name != NULL)
+ if (modem->name)
connman_network_set_name(modem->network, modem->name);
else
connman_network_set_name(modem->network, "");
group = get_ident(modem->context->path);
connman_network_set_group(modem->network, group);
- connman_network_set_available(modem->network, TRUE);
-
connman_network_set_bool(modem->network, "Roaming",
modem->roaming);
{
DBG("%s", modem->path);
- if (modem->network == NULL)
+ if (!modem->network)
return;
DBG("network %p", modem->network);
modem->network = NULL;
}
+static int set_context_ipconfig(struct network_context *context,
+ const char *protocol)
+{
+ DBG("context %p protocol %s", context, protocol);
+
+ if (!context || !protocol)
+ return -EINVAL;
+
+ if (g_str_equal(protocol, "ip")) {
+ if (context->ipv4_method == CONNMAN_IPCONFIG_METHOD_OFF)
+ context->ipv4_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+
+ context->ipv6_method = CONNMAN_IPCONFIG_METHOD_OFF;
+
+ connman_ipaddress_free(context->ipv6_address);
+ context->ipv6_address = NULL;
+
+ } else if (g_str_equal(protocol, "ipv6")) {
+ if (context->ipv6_method == CONNMAN_IPCONFIG_METHOD_OFF)
+ context->ipv6_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+
+ context->ipv4_method = CONNMAN_IPCONFIG_METHOD_OFF;
+
+ connman_ipaddress_free(context->ipv4_address);
+ context->ipv4_address = NULL;
+
+ } else if (g_str_equal(protocol, "dual")) {
+ if (context->ipv4_method == CONNMAN_IPCONFIG_METHOD_OFF)
+ context->ipv4_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+
+ if (context->ipv6_method == CONNMAN_IPCONFIG_METHOD_OFF)
+ context->ipv6_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+ }
+
+ DBG("ipv4 method %d ipv6 method %d", context->ipv4_method,
+ context->ipv6_method);
+
+ return 0;
+}
+
static int add_cm_context(struct modem_data *modem, const char *context_path,
DBusMessageIter *dict)
{
const char *context_type = NULL;
struct network_context *context = NULL;
- connman_bool_t active = FALSE;
+ dbus_bool_t active = FALSE;
+ const char *ip_protocol = NULL;
DBG("%s context path %s", modem->path, context_path);
- if (modem->context != NULL) {
+ if (modem->context) {
/*
* We have already assigned a context to this modem
* and we do only support one Internet context.
}
context = network_context_alloc(context_path);
- if (context == NULL)
+ if (!context)
return -ENOMEM;
while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) {
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);
- if (g_str_equal(key, "Type") == TRUE) {
+ if (g_str_equal(key, "Type")) {
dbus_message_iter_get_basic(&value, &context_type);
DBG("%s context %s type %s", modem->path,
context_path, context_type);
- } else if (g_str_equal(key, "Settings") == TRUE) {
+ } else if (g_str_equal(key, "Settings")) {
DBG("%s Settings", modem->path);
extract_ipv4_settings(&value, context);
- } else if (g_str_equal(key, "IPv6.Settings") == TRUE) {
+ } else if (g_str_equal(key, "IPv6.Settings")) {
DBG("%s IPv6.Settings", modem->path);
extract_ipv6_settings(&value, context);
- } else if (g_str_equal(key, "Active") == TRUE) {
+ } else if (g_str_equal(key, "Active")) {
dbus_message_iter_get_basic(&value, &active);
DBG("%s Active %d", modem->path, active);
- } else if (g_str_equal(key, "AccessPointName") == TRUE) {
+ } else if (g_str_equal(key, "AccessPointName")) {
const char *apn;
dbus_message_iter_get_basic(&value, &apn);
- if (apn != NULL && strlen(apn) > 0)
- modem->valid_apn = TRUE;
+ if (apn && strlen(apn) > 0)
+ modem->valid_apn = true;
else
- modem->valid_apn = FALSE;
+ modem->valid_apn = false;
DBG("%s AccessPointName '%s'", modem->path, apn);
+ } else if (g_str_equal(key, "Protocol") &&
+ dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING ) {
+
+ dbus_message_iter_get_basic(&value, &ip_protocol);
+
+ DBG("%s Protocol %s", modem->path, ip_protocol);
}
+
dbus_message_iter_next(dict);
}
return -EINVAL;
}
+ if (ip_protocol)
+ set_context_ipconfig(context, ip_protocol);
+
modem->context = context;
modem->active = active;
g_hash_table_replace(context_hash, g_strdup(context_path), modem);
- if (modem->valid_apn == TRUE && modem->attached == TRUE &&
+ if (modem->valid_apn && modem->attached &&
has_interface(modem->interfaces,
- OFONO_API_NETREG) == TRUE) {
+ OFONO_API_NETREG)) {
add_network(modem);
}
static void remove_cm_context(struct modem_data *modem,
const char *context_path)
{
- if (modem->context == NULL)
+ if (!modem->context)
return;
- if (modem->network != NULL)
+ if (modem->network)
remove_network(modem);
g_hash_table_remove(context_hash, context_path);
network_context_free(modem->context);
modem->context = NULL;
- modem->valid_apn = FALSE;
+ modem->valid_apn = false;
- if (modem->network != NULL)
+ if (modem->network)
remove_network(modem);
}
DBG("context_path %s", context_path);
modem = g_hash_table_lookup(context_hash, context_path);
- if (modem == NULL)
+ if (!modem)
return TRUE;
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ if (!dbus_message_iter_init(message, &iter))
return TRUE;
dbus_message_iter_get_basic(&iter, &key);
* Active. Settings will always be send before Active = True.
* That means we don't have to order here.
*/
- if (g_str_equal(key, "Settings") == TRUE) {
+ if (g_str_equal(key, "Settings")) {
DBG("%s Settings", modem->path);
extract_ipv4_settings(&value, modem->context);
- } else if (g_str_equal(key, "IPv6.Settings") == TRUE) {
+ } else if (g_str_equal(key, "IPv6.Settings")) {
DBG("%s IPv6.Settings", modem->path);
extract_ipv6_settings(&value, modem->context);
- } else if (g_str_equal(key, "Active") == TRUE) {
- dbus_message_iter_get_basic(&value, &modem->active);
+ } else if (g_str_equal(key, "Active")) {
+ dbus_bool_t active;
+
+ dbus_message_iter_get_basic(&value, &active);
+ modem->active = active;
DBG("%s Active %d", modem->path, modem->active);
- if (modem->active == TRUE)
+ if (modem->active)
set_connected(modem);
else
set_disconnected(modem);
- } else if (g_str_equal(key, "AccessPointName") == TRUE) {
+ } else if (g_str_equal(key, "AccessPointName")) {
const char *apn;
dbus_message_iter_get_basic(&value, &apn);
DBG("%s AccessPointName %s", modem->path, apn);
- if (apn != NULL && strlen(apn) > 0) {
- modem->valid_apn = TRUE;
+ if (apn && strlen(apn) > 0) {
+ modem->valid_apn = true;
- if (modem->network != NULL)
+ if (modem->network)
return TRUE;
- if (modem->attached == FALSE)
+ if (!modem->attached)
return TRUE;
- if (has_interface(modem->interfaces,
- OFONO_API_NETREG) == FALSE) {
+ if (!has_interface(modem->interfaces,
+ OFONO_API_NETREG))
return TRUE;
- }
add_network(modem);
- if (modem->active == TRUE)
+ if (modem->active)
set_connected(modem);
} else {
- modem->valid_apn = FALSE;
+ modem->valid_apn = false;
- if (modem->network == NULL)
+ if (!modem->network)
return TRUE;
remove_network(modem);
}
+
+ } else if (g_str_equal(key, "Protocol") &&
+ dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING ) {
+ const char *ip_protocol;
+
+ dbus_message_iter_get_basic(&value, &ip_protocol);
+
+ set_context_ipconfig(modem->context, ip_protocol);
}
return TRUE;
dbus_error_init(&error);
- if (dbus_set_error_from_message(&error, reply) == TRUE) {
+ if (dbus_set_error_from_message(&error, reply)) {
connman_error("%s", error.message);
dbus_error_free(&error);
goto done;
}
- if (dbus_message_iter_init(reply, &array) == FALSE)
+ if (!dbus_message_iter_init(reply, &array))
goto done;
if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
DBG("%s", modem->path);
- if (modem->call_get_contexts != NULL)
+ if (modem->call_get_contexts)
return -EBUSY;
message = dbus_message_new_method_call(OFONO_SERVICE, modem->path,
OFONO_CM_INTERFACE, GET_CONTEXTS);
- if (message == NULL)
+ if (!message)
return -ENOMEM;
- if (dbus_connection_send_with_reply(connection, message,
- &modem->call_get_contexts, TIMEOUT) == FALSE) {
+ if (!dbus_connection_send_with_reply(connection, message,
+ &modem->call_get_contexts, TIMEOUT)) {
connman_error("Failed to call GetContexts()");
dbus_message_unref(message);
return -EINVAL;
}
- if (modem->call_get_contexts == NULL) {
+ if (!modem->call_get_contexts) {
connman_error("D-Bus connection not available");
dbus_message_unref(message);
return -EINVAL;
DBG("%s", path);
modem = g_hash_table_lookup(modem_hash, path);
- if (modem == NULL)
+ if (!modem)
return TRUE;
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ if (!dbus_message_iter_init(message, &iter))
return TRUE;
dbus_message_iter_get_basic(&iter, &context_path);
DBG("context path %s", path);
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ if (!dbus_message_iter_init(message, &iter))
return TRUE;
dbus_message_iter_get_basic(&iter, &context_path);
modem = g_hash_table_lookup(context_hash, context_path);
- if (modem == NULL)
+ if (!modem)
return TRUE;
remove_cm_context(modem, context_path);
g_free(modem->name);
modem->name = g_strdup(name);
- if (modem->network == NULL)
+ if (!modem->network)
return;
connman_network_set_name(modem->network, modem->name);
DBG("%s Strength %d", modem->path, modem->strength);
- if (modem->network == NULL)
+ if (!modem->network)
return;
/*
DBG("%s Data Strength %d", modem->path, modem->data_strength);
- if (modem->network == NULL)
+ if (!modem->network)
return;
/*
connman_network_update(modem->network);
}
-static void netreg_update_roaming(struct modem_data *modem,
+static void netreg_update_status(struct modem_data *modem,
DBusMessageIter *value)
{
char *status;
- connman_bool_t roaming;
+ bool roaming;
dbus_message_iter_get_basic(value, &status);
- if (g_str_equal(status, "roaming") == TRUE)
- roaming = TRUE;
- else
- roaming = FALSE;
+ roaming = g_str_equal(status, "roaming");
+ modem->registered = roaming || g_str_equal(status, "registered");
if (roaming == modem->roaming)
return;
modem->roaming = roaming;
- if (modem->network == NULL)
+ if (!modem->network)
return;
connman_network_set_bool(modem->network,
return;
alpha2 = mcc_country_codes[mcc - 200];
- if (alpha2 != NULL)
+ if (alpha2)
connman_technology_set_regdom(alpha2);
}
const char *key;
modem = g_hash_table_lookup(modem_hash, path);
- if (modem == NULL)
+ if (!modem)
return TRUE;
- if (modem->ignore == TRUE)
+ if (modem->ignore)
return TRUE;
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ 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") == TRUE)
+ if (g_str_equal(key, "Name"))
netreg_update_name(modem, &value);
- else if (g_str_equal(key, "Strength") == TRUE)
+ else if (g_str_equal(key, "Strength"))
netreg_update_strength(modem, &value);
- else if (g_str_equal(key, "Status") == TRUE)
- netreg_update_roaming(modem, &value);
- else if (g_str_equal(key, "MobileCountryCode") == TRUE)
+ else if (g_str_equal(key, "Status"))
+ netreg_update_status(modem, &value);
+ else if (g_str_equal(key, "MobileCountryCode"))
netreg_update_regdom(modem, &value);
return TRUE;
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);
- if (g_str_equal(key, "Name") == TRUE)
+ if (g_str_equal(key, "Name"))
netreg_update_name(modem, &value);
- else if (g_str_equal(key, "Strength") == TRUE)
+ else if (g_str_equal(key, "Strength"))
netreg_update_strength(modem, &value);
- else if (g_str_equal(key, "Status") == TRUE)
- netreg_update_roaming(modem, &value);
- else if (g_str_equal(key, "MobileCountryCode") == TRUE)
+ else if (g_str_equal(key, "Status"))
+ netreg_update_status(modem, &value);
+ else if (g_str_equal(key, "MobileCountryCode"))
netreg_update_regdom(modem, &value);
dbus_message_iter_next(dict);
}
- if (modem->context == NULL) {
+ if (!modem->context) {
/*
* netgreg_get_properties() was issued after we got
* cm_get_contexts_reply() where we create the
return;
}
- if (modem->valid_apn == TRUE)
+ if (modem->valid_apn)
add_network(modem);
- if (modem->active == TRUE)
+ if (modem->active)
set_connected(modem);
}
static void add_cdma_network(struct modem_data *modem)
{
/* Be sure that device is created before adding CDMA network */
- if (modem->device == NULL)
+ 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 == NULL)
+ if (!modem->context)
modem->context = network_context_alloc(modem->path);
- if (modem->name == NULL)
+ if (!modem->name)
modem->name = g_strdup("CDMA Network");
add_network(modem);
- if (modem->cdma_cm_powered == TRUE)
+ if (modem->cdma_cm_powered)
set_connected(modem);
}
DBG("");
modem = g_hash_table_lookup(modem_hash, path);
- if (modem == NULL)
+ if (!modem)
return TRUE;
- if (modem->ignore == TRUE)
+ if (modem->ignore)
return TRUE;
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ 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") == TRUE)
+ if (g_str_equal(key, "Name"))
netreg_update_name(modem, &value);
- else if (g_str_equal(key, "Strength") == TRUE)
+ else if (g_str_equal(key, "Strength"))
netreg_update_strength(modem, &value);
- else if (g_str_equal(key, "DataStrength") == TRUE)
+ else if (g_str_equal(key, "DataStrength"))
netreg_update_datastrength(modem, &value);
- else if (g_str_equal(key, "Status") == TRUE)
- netreg_update_roaming(modem, &value);
+ else if (g_str_equal(key, "Status"))
+ netreg_update_status(modem, &value);
- add_cdma_network(modem);
+ if (modem->registered)
+ add_cdma_network(modem);
+ else
+ remove_network(modem);
return TRUE;
}
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);
- if (g_str_equal(key, "Name") == TRUE)
+ if (g_str_equal(key, "Name"))
netreg_update_name(modem, &value);
- else if (g_str_equal(key, "Strength") == TRUE)
+ else if (g_str_equal(key, "Strength"))
netreg_update_strength(modem, &value);
- else if (g_str_equal(key, "DataStrength") == TRUE)
+ else if (g_str_equal(key, "DataStrength"))
netreg_update_datastrength(modem, &value);
- else if (g_str_equal(key, "Status") == TRUE)
- netreg_update_roaming(modem, &value);
+ else if (g_str_equal(key, "Status"))
+ netreg_update_status(modem, &value);
dbus_message_iter_next(dict);
}
- add_cdma_network(modem);
+ if (modem->registered)
+ add_cdma_network(modem);
+ else
+ remove_network(modem);
}
static int cdma_netreg_get_properties(struct modem_data *modem)
static void cm_update_attached(struct modem_data *modem,
DBusMessageIter *value)
{
- dbus_message_iter_get_basic(value, &modem->attached);
+ dbus_bool_t attached;
+
+ dbus_message_iter_get_basic(value, &attached);
+ modem->attached = attached;
DBG("%s Attached %d", modem->path, modem->attached);
- if (modem->attached == FALSE)
+ if (!modem->attached) {
+ remove_network(modem);
return;
+ }
- if (has_interface(modem->interfaces,
- OFONO_API_NETREG) == FALSE) {
+ if (!has_interface(modem->interfaces, OFONO_API_NETREG))
return;
- }
netreg_get_properties(modem);
}
static void cm_update_powered(struct modem_data *modem,
DBusMessageIter *value)
{
- dbus_message_iter_get_basic(value, &modem->cm_powered);
+ dbus_bool_t cm_powered;
+
+ dbus_message_iter_get_basic(value, &cm_powered);
+ modem->cm_powered = cm_powered;
DBG("%s ConnnectionManager Powered %d", modem->path,
modem->cm_powered);
- if (modem->cm_powered == TRUE)
+ if (modem->cm_powered)
return;
cm_set_powered(modem, TRUE);
const char *key;
modem = g_hash_table_lookup(modem_hash, path);
- if (modem == NULL)
+ if (!modem)
return TRUE;
- if (modem->ignore == TRUE)
+ if (modem->ignore)
return TRUE;
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ 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, "Attached") == TRUE)
+ if (g_str_equal(key, "Attached"))
cm_update_attached(modem, &value);
- else if (g_str_equal(key, "Powered") == TRUE)
+ else if (g_str_equal(key, "Powered"))
cm_update_powered(modem, &value);
return TRUE;
static void cdma_cm_update_powered(struct modem_data *modem,
DBusMessageIter *value)
{
- dbus_message_iter_get_basic(value, &modem->cdma_cm_powered);
+ 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->network == NULL)
+ if (!modem->network)
return;
- if (modem->cdma_cm_powered == TRUE)
+ if (modem->cdma_cm_powered)
set_connected(modem);
else
set_disconnected(modem);
const char *key;
modem = g_hash_table_lookup(modem_hash, path);
- if (modem == NULL)
+ if (!modem)
return TRUE;
- if (modem->online == TRUE && modem->network == NULL)
+ if (modem->online && !modem->network)
cdma_netreg_get_properties(modem);
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ 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") == TRUE)
+ if (g_str_equal(key, "Powered"))
cdma_cm_update_powered(modem, &value);
- if (g_str_equal(key, "Settings") == TRUE)
+ if (g_str_equal(key, "Settings"))
cdma_cm_update_settings(modem, &value);
return TRUE;
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);
- if (g_str_equal(key, "Attached") == TRUE)
+ if (g_str_equal(key, "Attached"))
cm_update_attached(modem, &value);
- else if (g_str_equal(key, "Powered") == TRUE)
+ else if (g_str_equal(key, "Powered"))
cm_update_powered(modem, &value);
dbus_message_iter_next(dict);
{
DBG("%s", modem->path);
- if (modem->online == TRUE)
+ if (modem->online)
cdma_netreg_get_properties(modem);
while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) {
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);
- if (g_str_equal(key, "Powered") == TRUE)
+ if (g_str_equal(key, "Powered"))
cdma_cm_update_powered(modem, &value);
- if (g_str_equal(key, "Settings") == TRUE)
+ if (g_str_equal(key, "Settings"))
cdma_cm_update_settings(modem, &value);
dbus_message_iter_next(dict);
}
static void sim_update_imsi(struct modem_data *modem,
- DBusMessageIter* value)
+ DBusMessageIter *value)
{
char *imsi;
const char *key;
modem = g_hash_table_lookup(modem_hash, path);
- if (modem == NULL)
+ if (!modem)
return TRUE;
- if (modem->ignore == TRUE)
+ if (modem->ignore)
return TRUE;
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ 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, "SubscriberIdentity") == TRUE) {
+ if (g_str_equal(key, "SubscriberIdentity")) {
sim_update_imsi(modem, &value);
- if (ready_to_create_device(modem) == FALSE)
+ if (!ready_to_create_device(modem))
return TRUE;
/*
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);
- if (g_str_equal(key, "SubscriberIdentity") == TRUE) {
+ if (g_str_equal(key, "SubscriberIdentity")) {
sim_update_imsi(modem, &value);
- if (ready_to_create_device(modem) == FALSE)
+ if (!ready_to_create_device(modem))
return;
/*
*/
create_device(modem);
- if (modem->online == FALSE)
+ if (!modem->online)
return;
/*
* state machine will not go to next step. We have to
* trigger it from here.
*/
- if (has_interface(modem->interfaces, OFONO_API_CM) == TRUE) {
+ if (has_interface(modem->interfaces, OFONO_API_CM)) {
cm_get_properties(modem);
cm_get_contexts(modem);
}
sim_properties_reply, modem);
}
-static connman_bool_t api_added(uint8_t old_iface, uint8_t new_iface,
+static bool api_added(uint8_t old_iface, uint8_t new_iface,
enum ofono_api api)
{
- if (has_interface(old_iface, api) == FALSE &&
- has_interface(new_iface, api) == TRUE) {
+ if (!has_interface(old_iface, api) &&
+ has_interface(new_iface, api)) {
DBG("%s added", api2string(api));
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-static connman_bool_t api_removed(uint8_t old_iface, uint8_t new_iface,
+static bool api_removed(uint8_t old_iface, uint8_t new_iface,
enum ofono_api api)
{
- if (has_interface(old_iface, api) == TRUE &&
- has_interface(new_iface, api) == FALSE) {
+ if (has_interface(old_iface, api) &&
+ !has_interface(new_iface, api)) {
DBG("%s removed", api2string(api));
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
static void modem_update_interfaces(struct modem_data *modem,
{
DBG("%s", modem->path);
- if (api_added(old_ifaces, new_ifaces, OFONO_API_SIM) == TRUE) {
- if (modem->imsi == NULL &&
- modem->set_powered == FALSE) {
+ if (api_added(old_ifaces, new_ifaces, OFONO_API_SIM)) {
+ if (!modem->imsi &&
+ !modem->set_powered) {
/*
* Only use do GetProperties() when
* device has not been powered up.
}
}
- if (api_added(old_ifaces, new_ifaces, OFONO_API_CM) == TRUE) {
- if (modem->device != NULL) {
+ if (api_added(old_ifaces, new_ifaces, OFONO_API_CM)) {
+ if (modem->device) {
cm_get_properties(modem);
cm_get_contexts(modem);
}
}
- if (api_added(old_ifaces, new_ifaces, OFONO_API_CDMA_CM) == TRUE) {
- if (ready_to_create_device(modem) == TRUE)
+ 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 != NULL)
+ if (modem->device)
cdma_cm_get_properties(modem);
}
- if (api_added(old_ifaces, new_ifaces, OFONO_API_NETREG) == TRUE) {
- if (modem->attached == TRUE)
+ 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) == TRUE) {
+ 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) == TRUE) {
+ if (api_removed(old_ifaces, new_ifaces, OFONO_API_CM))
remove_cm_context(modem, modem->context->path);
- }
- if (api_removed(old_ifaces, new_ifaces, OFONO_API_CDMA_CM) == TRUE) {
+ if (api_removed(old_ifaces, new_ifaces, OFONO_API_CDMA_CM))
remove_cm_context(modem, modem->context->path);
- }
- if (api_removed(old_ifaces, new_ifaces, OFONO_API_NETREG) == TRUE) {
+ if (api_removed(old_ifaces, new_ifaces, OFONO_API_NETREG))
remove_network(modem);
- }
- if (api_removed(old_ifaces, new_ifaces, OFONO_API_CDMA_NETREG == TRUE)) {
+ if (api_removed(old_ifaces, new_ifaces, OFONO_API_CDMA_NETREG))
remove_network(modem);
- }
}
static gboolean modem_changed(DBusConnection *conn, DBusMessage *message,
const char *key;
modem = g_hash_table_lookup(modem_hash, path);
- if (modem == NULL)
+ if (!modem)
return TRUE;
- if (modem->ignore == TRUE)
+ if (modem->ignore)
return TRUE;
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ 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") == TRUE) {
- dbus_message_iter_get_basic(&value, &modem->powered);
+ if (g_str_equal(key, "Powered")) {
+ dbus_bool_t powered;
+
+ dbus_message_iter_get_basic(&value, &powered);
+ modem->powered = powered;
DBG("%s Powered %d", modem->path, modem->powered);
- if (modem->powered == FALSE)
+ if (!modem->powered)
modem_set_powered(modem, TRUE);
- } else if (g_str_equal(key, "Online") == TRUE) {
- dbus_message_iter_get_basic(&value, &modem->online);
+ } else if (g_str_equal(key, "Online")) {
+ dbus_bool_t online;
+
+ dbus_message_iter_get_basic(&value, &online);
+ modem->online = online;
DBG("%s Online %d", modem->path, modem->online);
- if (modem->device == NULL)
+ if (!modem->device)
return TRUE;
connman_device_set_powered(modem->device, modem->online);
- } else if (g_str_equal(key, "Interfaces") == TRUE) {
+ } else if (g_str_equal(key, "Interfaces")) {
uint8_t interfaces;
interfaces = extract_interfaces(&value);
modem_update_interfaces(modem, modem->interfaces, interfaces);
modem->interfaces = interfaces;
- } else if (g_str_equal(key, "Serial") == TRUE) {
+ } else if (g_str_equal(key, "Serial")) {
char *serial;
dbus_message_iter_get_basic(&value, &serial);
DBG("%s Serial %s", modem->path, modem->serial);
if (has_interface(modem->interfaces,
- OFONO_API_CDMA_CM) == TRUE) {
- if (ready_to_create_device(modem) == TRUE)
+ OFONO_API_CDMA_CM)) {
+ if (ready_to_create_device(modem)) {
create_device(modem);
+ if (modem->registered)
+ add_cdma_network(modem);
+ }
}
}
DBG("%s", path);
modem = g_hash_table_lookup(modem_hash, path);
- if (modem != NULL) {
+ if (modem) {
/*
* When oFono powers up we ask for the modems and oFono is
* reporting with modem_added signal the modems. Only
}
modem = g_try_new0(struct modem_data, 1);
- if (modem == NULL)
+ if (!modem)
return;
modem->path = g_strdup(path);
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);
- if (g_str_equal(key, "Powered") == TRUE) {
- dbus_message_iter_get_basic(&value, &modem->powered);
+ if (g_str_equal(key, "Powered")) {
+ dbus_bool_t powered;
+
+ dbus_message_iter_get_basic(&value, &powered);
+ modem->powered = powered;
DBG("%s Powered %d", modem->path, modem->powered);
- } else if (g_str_equal(key, "Online") == TRUE) {
- dbus_message_iter_get_basic(&value, &modem->online);
+ } else if (g_str_equal(key, "Online")) {
+ dbus_bool_t online;
+
+ dbus_message_iter_get_basic(&value, &online);
+ modem->online = online;
DBG("%s Online %d", modem->path, modem->online);
- } else if (g_str_equal(key, "Interfaces") == TRUE) {
+ } else if (g_str_equal(key, "Interfaces")) {
modem->interfaces = extract_interfaces(&value);
DBG("%s Interfaces 0x%02x", modem->path,
modem->interfaces);
- } else if (g_str_equal(key, "Serial") == TRUE) {
+ } else if (g_str_equal(key, "Serial")) {
char *serial;
dbus_message_iter_get_basic(&value, &serial);
modem->serial = g_strdup(serial);
DBG("%s Serial %s", modem->path, modem->serial);
- } else if (g_str_equal(key, "Type") == TRUE) {
+ } else if (g_str_equal(key, "Type")) {
char *type;
dbus_message_iter_get_basic(&value, &type);
DBG("%s Type %s", modem->path, type);
if (g_strcmp0(type, "hardware") != 0) {
DBG("%s Ignore this modem", modem->path);
- modem->ignore = TRUE;
+ modem->ignore = true;
}
}
dbus_message_iter_next(prop);
}
- if (modem->ignore == TRUE)
+ if (modem->ignore)
return;
- if (modem->powered == FALSE) {
+ if (!modem->powered) {
modem_set_powered(modem, TRUE);
return;
}
DBG("%s", modem->path);
- if (modem->ignore == TRUE)
+ if (modem->ignore)
return;
modem_set_powered(modem, FALSE);
DBG("%s", modem->path);
- if (modem->call_set_property != NULL)
+ if (modem->call_set_property)
dbus_pending_call_cancel(modem->call_set_property);
- if (modem->call_get_properties != NULL)
+ if (modem->call_get_properties)
dbus_pending_call_cancel(modem->call_get_properties);
- if (modem->call_get_contexts != NULL)
+ if (modem->call_get_contexts)
dbus_pending_call_cancel(modem->call_get_contexts);
- if (modem->device != NULL)
+ if (modem->device)
destroy_device(modem);
- if (modem->context != NULL)
+ if (modem->context)
remove_cm_context(modem, modem->context->path);
g_free(modem->serial);
DBG("");
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ if (!dbus_message_iter_init(message, &iter))
return TRUE;
dbus_message_iter_get_basic(&iter, &path);
DBG("");
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ if (!dbus_message_iter_init(message, &iter))
return TRUE;
dbus_message_iter_get_basic(&iter, &path);
dbus_error_init(&error);
- if (dbus_set_error_from_message(&error, reply) == TRUE) {
+ if (dbus_set_error_from_message(&error, reply)) {
connman_error("%s", error.message);
dbus_error_free(&error);
goto done;
}
- if (dbus_message_iter_init(reply, &array) == FALSE)
+ if (!dbus_message_iter_init(reply, &array))
goto done;
dbus_message_iter_recurse(&array, &dict);
message = dbus_message_new_method_call(OFONO_SERVICE, "/",
OFONO_MANAGER_INTERFACE, GET_MODEMS);
- if (message == NULL)
+ if (!message)
return -ENOMEM;
- if (dbus_connection_send_with_reply(connection, message,
- &call, TIMEOUT) == FALSE) {
+ if (!dbus_connection_send_with_reply(connection, message,
+ &call, TIMEOUT)) {
connman_error("Failed to call GetModems()");
dbus_message_unref(message);
return -EINVAL;
}
- if (call == NULL) {
+ if (!call) {
connman_error("D-Bus connection not available");
dbus_message_unref(message);
return -EINVAL;
modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, remove_modem);
- if (modem_hash == NULL)
+ if (!modem_hash)
return;
context_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
- if (context_hash == NULL) {
+ if (!context_hash) {
g_hash_table_destroy(modem_hash);
return;
}
{
DBG("");
- if (modem_hash == NULL || context_hash == NULL)
+ if (!modem_hash || !context_hash)
return;
g_hash_table_destroy(modem_hash);
DBG("%s network %p", modem->path, network);
- if (has_interface(modem->interfaces, OFONO_API_CM) == TRUE)
+ if (has_interface(modem->interfaces, OFONO_API_CM))
return context_set_active(modem, TRUE);
- else if (has_interface(modem->interfaces, OFONO_API_CDMA_CM) == 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");
DBG("%s network %p", modem->path, network);
- if (has_interface(modem->interfaces, OFONO_API_CM) == TRUE)
+ if (has_interface(modem->interfaces, OFONO_API_CM))
return context_set_active(modem, FALSE);
- else if (has_interface(modem->interfaces, OFONO_API_CDMA_CM) == TRUE)
+ else if (has_interface(modem->interfaces, OFONO_API_CDMA_CM))
return cdma_cm_set_powered(modem, FALSE);
connman_error("Connection manager interface not available");
DBG("%s device %p", modem->path, device);
- if (modem->online == TRUE)
+ if (modem->online)
return 0;
return modem_set_online(modem, TRUE);
DBG("%s device %p", modem->path, device);
- if (modem->online == FALSE)
+ if (!modem->online)
return 0;
return modem_set_online(modem, FALSE);
DBG("");
connection = connman_dbus_get_connection();
- if (connection == NULL)
+ if (!connection)
return -EIO;
watch = g_dbus_add_service_watch(connection,
{
DBG("");
- if (modem_hash != NULL) {
+ if (modem_hash) {
/*
* We should propably wait for the SetProperty() reply
* message, because ...
modem_hash = NULL;
}
- if (context_hash != NULL) {
+ if (context_hash) {
g_hash_table_destroy(context_hash);
context_hash = NULL;
}