struct nameserver_entry *entry = NULL;
gchar **options;
- if (g_str_has_prefix(key, "foreign_option_") == FALSE)
+ if (!g_str_has_prefix(key, "foreign_option_"))
return NULL;
options = g_strsplit(value, " ", 3);
- if (options[0] != NULL &&
+ if (options[0] &&
!strcmp(options[0], "dhcp-option") &&
- options[1] != NULL &&
+ options[1] &&
!strcmp(options[1], "DNS") &&
- options[2] != NULL) {
+ options[2]) {
entry = g_try_new(struct nameserver_entry, 1);
- if (entry == NULL)
+ if (!entry)
return NULL;
entry->nameserver = g_strdup(options[2]);
gchar **options;
char *domain = NULL;
- if (g_str_has_prefix(key, "foreign_option_") == FALSE)
+ if (!g_str_has_prefix(key, "foreign_option_"))
return NULL;
options = g_strsplit(value, " ", 3);
- if (options[0] != NULL &&
+ if (options[0] &&
!strcmp(options[0], "dhcp-option") &&
- options[1] != NULL &&
+ options[1] &&
!strcmp(options[1], "DOMAIN") &&
- options[2] != NULL) {
+ options[2]) {
domain = g_strdup(options[2]);
}
DBG("%s = %s", key, value);
- if (!strcmp(key, "trusted_ip")) {
- vpn_provider_set_string(provider, "Gateway", value);
+ if (!strcmp(key, "trusted_ip"))
gateway = g_strdup(value);
- }
- if (!strcmp(key, "ifconfig_local")) {
- vpn_provider_set_string(provider, "Address", value);
+ if (!strcmp(key, "ifconfig_local"))
address = g_strdup(value);
- }
- if (!strcmp(key, "ifconfig_remote")) {
- vpn_provider_set_string(provider, "Peer", value);
+ if (!strcmp(key, "ifconfig_remote"))
peer = g_strdup(value);
- }
- if (g_str_has_prefix(key, "route_") == TRUE)
+ if (g_str_has_prefix(key, "route_"))
vpn_provider_append_route(provider, key, value);
- if ((ns_entry = ov_append_dns_entries(key, value)) != NULL)
+ if ((ns_entry = ov_append_dns_entries(key, value)))
nameserver_list = g_slist_prepend(nameserver_list,
ns_entry);
else {
char *domain = ov_get_domain_name(key, value);
- if (domain != NULL) {
+ if (domain) {
vpn_provider_set_domain(provider, domain);
g_free(domain);
}
}
ipaddress = connman_ipaddress_alloc(AF_INET);
- if (ipaddress == NULL) {
+ if (!ipaddress) {
g_slist_free_full(nameserver_list, free_ns_entry);
g_free(address);
g_free(gateway);
connman_ipaddress_set_peer(ipaddress, peer);
vpn_provider_set_ipaddress(provider, ipaddress);
- if (nameserver_list != NULL) {
+ if (nameserver_list) {
char *nameservers = NULL;
GSList *tmp;
nameserver_list = g_slist_sort(nameserver_list, cmp_ns);
- for (tmp = nameserver_list; tmp != NULL;
+ for (tmp = nameserver_list; tmp;
tmp = g_slist_next(tmp)) {
struct nameserver_entry *ns = tmp->data;
- if (nameservers == NULL) {
+ if (!nameservers) {
nameservers = g_strdup(ns->nameserver);
} else {
char *str;
if (strncmp(ov_options[i].cm_opt, "OpenVPN.", 8) == 0) {
option = vpn_provider_get_string(provider,
ov_options[i].cm_opt);
- if (option == NULL)
+ if (!option)
continue;
g_key_file_set_string(keyfile,
int i;
for (i = 0; i < (int)ARRAY_SIZE(ov_options); i++) {
- if (ov_options[i].ov_opt == NULL)
+ if (!ov_options[i].ov_opt)
continue;
option = vpn_provider_get_string(provider,
ov_options[i].cm_opt);
- if (option == NULL)
+ if (!option)
continue;
if (connman_task_add_argument(task,
static int ov_connect(struct vpn_provider *provider,
struct connman_task *task, const char *if_name,
- vpn_provider_connect_cb_t cb, void *user_data)
+ vpn_provider_connect_cb_t cb, const char *dbus_sender,
+ void *user_data)
{
const char *option;
int err = 0, fd;
option = vpn_provider_get_string(provider, "Host");
- if (option == NULL) {
+ if (!option) {
connman_error("Host not set; cannot enable VPN");
return -EINVAL;
}
task_append_config_data(provider, task);
option = vpn_provider_get_string(provider, "OpenVPN.ConfigFile");
- if (option == NULL) {
+ if (!option) {
/*
* Set some default options if user has no config file.
*/
option = vpn_provider_get_string(provider, "OpenVPN.TLSAuth");
- if (option != NULL) {
+ if (option) {
connman_task_add_argument(task, "--tls-auth", option);
option = vpn_provider_get_string(provider,
"OpenVPN.TLSAuthDir");
- if (option != NULL)
+ if (option)
connman_task_add_argument(task, option, NULL);
}
}
done:
- if (cb != NULL)
+ if (cb)
cb(provider, user_data, err);
return err;