1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
From 8594fb5e2fc347984457e2e46b175eb3cf57951f Mon Sep 17 00:00:00 2001
Message-Id: <8594fb5e2fc347984457e2e46b175eb3cf57951f.1334369310.git.paul.eggleton@linux.intel.com>
In-Reply-To: <cover.1334369310.git.paul.eggleton@linux.intel.com>
References: <cover.1334369310.git.paul.eggleton@linux.intel.com>
From: Paul Eggleton <paul.eggleton@linux.intel.com>
Date: Sat, 14 Apr 2012 01:11:53 +0100
Subject: [PATCH 3/6] Fix setting IPv4 configuration
Values in the hashtable for IPv4.Configuration need to be variants, not
strings, and don't pass address entries if the method is dhcp.
Upstream-Status: Submitted
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
common/connman-client.c | 32 +++++++++++++++++++++++++-------
1 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/common/connman-client.c b/common/connman-client.c
index 9d755c4..e4441ad 100644
--- a/common/connman-client.c
+++ b/common/connman-client.c
@@ -39,6 +39,11 @@
#define CONNMAN_CLIENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
CONNMAN_TYPE_CLIENT, ConnmanClientPrivate))
+#ifndef DBUS_TYPE_G_DICTIONARY
+#define DBUS_TYPE_G_DICTIONARY \
+ (dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
+#endif
+
typedef struct _ConnmanClientPrivate ConnmanClientPrivate;
struct _ConnmanClientPrivate {
@@ -248,6 +253,16 @@ GtkTreeModel *connman_client_get_device_model(ConnmanClient *client)
return model;
}
+void hash_table_value_string_insert( GHashTable *hash, gpointer key, const char *str )
+{
+ GValue *itemvalue;
+
+ itemvalue = g_slice_new0(GValue);
+ g_value_init(itemvalue, G_TYPE_STRING);
+ g_value_set_string(itemvalue, str);
+ g_hash_table_insert(hash, key, itemvalue);
+}
+
gboolean connman_client_set_ipv4(ConnmanClient *client, const gchar *device,
struct ipv4_config *ipv4_config)
{
@@ -255,12 +270,7 @@ gboolean connman_client_set_ipv4(ConnmanClient *client, const gchar *device,
DBusGProxy *proxy;
GValue value = { 0 };
gboolean ret;
- GHashTable *ipv4 = g_hash_table_new(g_str_hash, g_str_equal);
-
- g_hash_table_insert(ipv4, "Method", (gpointer)ipv4_config->method);
- g_hash_table_insert(ipv4, "Address", (gpointer)ipv4_config->address);
- g_hash_table_insert(ipv4, "Netmask", (gpointer)ipv4_config->netmask);
- g_hash_table_insert(ipv4, "Gateway", (gpointer)ipv4_config->gateway);
+ GHashTable *ipv4 = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
DBG("client %p", client);
@@ -270,7 +280,15 @@ gboolean connman_client_set_ipv4(ConnmanClient *client, const gchar *device,
proxy = connman_dbus_get_proxy(priv->store, device);
if (proxy == NULL)
return FALSE;
- g_value_init(&value, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
+
+ hash_table_value_string_insert(ipv4, "Method", ipv4_config->method);
+ if( g_strcmp0(ipv4_config->method, "dhcp" ) != 0 ) {
+ hash_table_value_string_insert(ipv4, "Address", ipv4_config->address);
+ hash_table_value_string_insert(ipv4, "Netmask", ipv4_config->netmask);
+ hash_table_value_string_insert(ipv4, "Gateway", ipv4_config->gateway);
+ }
+
+ g_value_init(&value, DBUS_TYPE_G_DICTIONARY);
g_value_set_boxed(&value, ipv4);
ret = connman_set_property(proxy, "IPv4.Configuration", &value, NULL);
--
1.7.5.4
|