1 From cdc3af7c29f82b71c2ce76fb6aa28dd6b3d9e5cd Mon Sep 17 00:00:00 2001
2 From: Chengyi Zhao <chengyi1.zhao@archermind.com>
3 Date: Thu, 11 Jul 2013 10:00:31 +0800
4 Subject: [PATCH 21/32] Tethering: Add hidden access point support in
7 Change-Id: I73fccf5f322ee2597f8f58d5e3d7f60ddeb0a641
9 doc/technology-api.txt | 5 +++++
10 gsupplicant/gsupplicant.h | 7 +++++++
11 gsupplicant/supplicant.c | 4 ++++
12 include/technology.h | 2 +-
13 plugins/bluetooth.c | 2 +-
14 plugins/bluetooth_legacy.c | 2 +-
15 plugins/ethernet.c | 2 +-
16 plugins/gadget.c | 2 +-
17 plugins/wifi.c | 13 ++++++++++---
18 src/technology.c | 33 ++++++++++++++++++++++++++++++++-
19 10 files changed, 63 insertions(+), 9 deletions(-)
21 diff --git a/doc/technology-api.txt b/doc/technology-api.txt
22 index f97eac0..2fbc876 100644
23 --- a/doc/technology-api.txt
24 +++ b/doc/technology-api.txt
25 @@ -97,3 +97,8 @@ Properties boolean Powered [readwrite]
26 This property is only valid for the WiFi technology,
27 and is then mapped to the WPA pre-shared key clients
28 will have to use in order to establish a connection.
30 + boolean Hidden [readwrite]
32 + This option allows to enable or disable the support
33 + for the hidden Wi-Fi tethering.
34 diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
35 index 1fab1ba..c5dad72 100644
36 --- a/gsupplicant/gsupplicant.h
37 +++ b/gsupplicant/gsupplicant.h
38 @@ -129,6 +129,12 @@ typedef enum {
39 G_SUPPLICANT_PEER_GROUP_FAILED,
40 } GSupplicantPeerState;
42 +enum GSupplicantAPHiddenSSID {
43 + G_SUPPLICANT_AP_NO_SSID_HIDING,
44 + G_SUPPLICANT_AP_HIDDEN_SSID_ZERO_LEN,
45 + G_SUPPLICANT_AP_HIDDEN_SSID_ZERO_CONTENTS,
48 struct _GSupplicantSSID {
50 unsigned int ssid_len;
51 @@ -150,6 +156,7 @@ struct _GSupplicantSSID {
55 + int ignore_broadcast_ssid;
58 typedef struct _GSupplicantSSID GSupplicantSSID;
59 diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
60 index 5ff9b3d..59bf279 100644
61 --- a/gsupplicant/supplicant.c
62 +++ b/gsupplicant/supplicant.c
63 @@ -4659,6 +4659,10 @@ static void interface_add_network_params(DBusMessageIter *iter, void *user_data)
64 DBUS_TYPE_BYTE, &ssid->ssid,
67 + supplicant_dbus_dict_append_basic(&dict, "ignore_broadcast_ssid",
69 + &ssid->ignore_broadcast_ssid);
71 supplicant_dbus_dict_close(iter, &dict);
74 diff --git a/include/technology.h b/include/technology.h
75 index b13d4ec..8efe9e7 100644
76 --- a/include/technology.h
77 +++ b/include/technology.h
78 @@ -63,7 +63,7 @@ struct connman_technology_driver {
80 int (*set_tethering) (struct connman_technology *technology,
81 const char *identifier, const char *passphrase,
82 - const char *bridge, bool enabled);
83 + const char *bridge, bool enabled, bool hidden);
84 int (*set_regdom) (struct connman_technology *technology,
87 diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
88 index 28df406..f8abeac 100644
89 --- a/plugins/bluetooth.c
90 +++ b/plugins/bluetooth.c
91 @@ -854,7 +854,7 @@ static void bluetooth_tech_remove(struct connman_technology *technology)
93 static int bluetooth_tech_set_tethering(struct connman_technology *technology,
94 const char *identifier, const char *passphrase,
95 - const char *bridge, bool enabled)
96 + const char *bridge, bool enabled, bool hidden)
98 GHashTableIter hash_iter;
100 diff --git a/plugins/bluetooth_legacy.c b/plugins/bluetooth_legacy.c
101 index 2d7a9e0..a9ff574 100644
102 --- a/plugins/bluetooth_legacy.c
103 +++ b/plugins/bluetooth_legacy.c
104 @@ -1234,7 +1234,7 @@ static void disable_nap(gpointer key, gpointer value, gpointer user_data)
106 static int tech_set_tethering(struct connman_technology *technology,
107 const char *identifier, const char *passphrase,
108 - const char *bridge, bool enabled)
109 + const char *bridge, bool enabled, bool hidden)
111 struct tethering_info info = {
112 .technology = technology,
113 diff --git a/plugins/ethernet.c b/plugins/ethernet.c
114 index b8e52ce..4e71346 100644
115 --- a/plugins/ethernet.c
116 +++ b/plugins/ethernet.c
117 @@ -309,7 +309,7 @@ static void eth_tech_disable_tethering(struct connman_technology *technology,
119 static int eth_tech_set_tethering(struct connman_technology *technology,
120 const char *identifier, const char *passphrase,
121 - const char *bridge, bool enabled)
122 + const char *bridge, bool enabled, bool hidden)
124 if (!connman_technology_is_tethering_allowed(
125 CONNMAN_SERVICE_TYPE_ETHERNET))
126 diff --git a/plugins/gadget.c b/plugins/gadget.c
127 index 94f6648..97807d8 100644
128 --- a/plugins/gadget.c
129 +++ b/plugins/gadget.c
130 @@ -291,7 +291,7 @@ static void gadget_tech_disable_tethering(struct connman_technology *technology,
132 static int gadget_tech_set_tethering(struct connman_technology *technology,
133 const char *identifier, const char *passphrase,
134 - const char *bridge, bool enabled)
135 + const char *bridge, bool enabled, bool hidden)
137 DBG("bridge %s enabled %d", bridge, enabled);
139 diff --git a/plugins/wifi.c b/plugins/wifi.c
140 index b5bc3ba..21f9912 100644
143 @@ -2927,7 +2927,8 @@ struct wifi_tethering_info {
144 GSupplicantSSID *ssid;
147 -static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)
148 +static GSupplicantSSID *ssid_ap_init(const char *ssid,
149 + const char *passphrase, bool hidden)
153 @@ -2952,6 +2953,12 @@ static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)
154 ap->passphrase = passphrase;
158 + ap->ignore_broadcast_ssid =
159 + G_SUPPLICANT_AP_HIDDEN_SSID_ZERO_CONTENTS;
161 + ap->ignore_broadcast_ssid = G_SUPPLICANT_AP_NO_SSID_HIDING;
166 @@ -3032,7 +3039,7 @@ static void sta_remove_callback(int result,
168 static int tech_set_tethering(struct connman_technology *technology,
169 const char *identifier, const char *passphrase,
170 - const char *bridge, bool enabled)
171 + const char *bridge, bool enabled, bool hidden)
174 GSupplicantInterface *interface;
175 @@ -3085,7 +3092,7 @@ static int tech_set_tethering(struct connman_technology *technology,
177 info->technology = technology;
178 info->wifi->bridge = bridge;
179 - info->ssid = ssid_ap_init(identifier, passphrase);
180 + info->ssid = ssid_ap_init(identifier, passphrase, hidden);
184 diff --git a/src/technology.c b/src/technology.c
185 index be66c3a..679c779 100644
186 --- a/src/technology.c
187 +++ b/src/technology.c
188 @@ -66,6 +66,7 @@ struct connman_technology {
190 char *tethering_ident;
191 char *tethering_passphrase;
192 + bool tethering_hidden;
194 bool enable_persistent; /* Save the tech state */
196 @@ -177,6 +178,9 @@ static void technology_save(struct connman_technology *technology)
197 g_key_file_set_boolean(keyfile, identifier, "Tethering",
198 technology->tethering_persistent);
200 + g_key_file_set_boolean(keyfile, identifier, "Hidden",
201 + technology->tethering_hidden);
203 if (technology->tethering_ident)
204 g_key_file_set_string(keyfile, identifier,
205 "Tethering.Identifier",
206 @@ -233,9 +237,11 @@ static int set_tethering(struct connman_technology *technology,
208 const char *ident, *passphrase, *bridge;
209 GSList *tech_drivers;
212 ident = technology->tethering_ident;
213 passphrase = technology->tethering_passphrase;
214 + hidden = technology->tethering_hidden;
216 __sync_synchronize();
217 if (!technology->enabled)
218 @@ -256,7 +262,7 @@ static int set_tethering(struct connman_technology *technology,
221 err = driver->set_tethering(technology, ident, passphrase,
223 + bridge, enabled, hidden);
225 if (result == -EINPROGRESS)
227 @@ -523,6 +529,11 @@ static void append_properties(DBusMessageIter *iter,
229 &technology->tethering_passphrase);
231 + val = technology->tethering_hidden;
232 + connman_dbus_dict_append_basic(&dict, "Hidden",
236 connman_dbus_dict_close(iter, &dict);
239 @@ -936,6 +947,25 @@ static DBusMessage *set_property(DBusConnection *conn,
240 &technology->tethering_passphrase);
243 + } else if (g_str_equal(name, "Hidden")) {
244 + dbus_bool_t hidden;
246 + if (type != DBUS_TYPE_BOOLEAN)
247 + return __connman_error_invalid_arguments(msg);
249 + dbus_message_iter_get_basic(&value, &hidden);
251 + if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
252 + return __connman_error_not_supported(msg);
254 + technology->tethering_hidden = hidden;
255 + technology_save(technology);
257 + connman_dbus_property_changed_basic(technology->path,
258 + CONNMAN_TECHNOLOGY_INTERFACE,
262 } else if (g_str_equal(name, "Powered")) {
265 @@ -1204,6 +1234,7 @@ static struct connman_technology *technology_get(enum connman_service_type type)
267 technology->refcount = 1;
268 technology->type = type;
269 + technology->tethering_hidden = FALSE;
270 technology->path = g_strdup_printf("%s/technology/%s",
272 if (type == CONNMAN_SERVICE_TYPE_P2P) {