meta-tizen: neard: move recipe and patches to the proper dir
[scm/bb/tizen-distro.git] / meta-tizen / meta-tizen-adaptation / meta / recipes-connectivity / connman / connman / 0009-Tizen-Export-more-wifi-info-in-ConnMan-network-API.patch
1 From 98894f533f23fe532a4449ddaafaa69d39441980 Mon Sep 17 00:00:00 2001
2 From: Arron Wang <arron.wang@intel.com>
3 Date: Mon, 24 Sep 2012 14:18:07 +0800
4 Subject: [PATCH 09/32] Tizen: Export more wifi info in ConnMan network API
5
6 Network client requires additional wifi specific info
7
8 Export the BSSID property
9 Export the MaxRate property
10 Export the detailed info for encryption mode(mixed,aes,tkip,wep,none)
11
12 Export the connman_network get/set method for bssid, maxrate,
13 encryption_mode property
14
15 Change-Id: Ic5744978282e49cb2f70165aaadc7822dc718dfb
16 ---
17  gsupplicant/gsupplicant.h | 10 +++++++
18  gsupplicant/supplicant.c  | 49 +++++++++++++++++++++++++++++++
19  include/network.h         | 17 +++++++++++
20  plugins/wifi.c            | 25 +++++++++++++++-
21  src/network.c             | 73 +++++++++++++++++++++++++++++++++++++++++++++++
22  5 files changed, 173 insertions(+), 1 deletion(-)
23
24 diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
25 index e49aaa6..27826dc 100644
26 --- a/gsupplicant/gsupplicant.h
27 +++ b/gsupplicant/gsupplicant.h
28 @@ -336,6 +336,16 @@ GSupplicantInterface *g_supplicant_peer_get_group_interface(GSupplicantPeer *pee
29  bool g_supplicant_peer_is_client(GSupplicantPeer *peer);
30  bool g_supplicant_peer_has_requested_connection(GSupplicantPeer *peer);
31  
32 +#if defined TIZEN_EXT
33 +/*
34 +* Description: Network client requires additional wifi specific info
35 +*/
36 +const unsigned char *g_supplicant_network_get_bssid(
37 +                                               GSupplicantNetwork *network);
38 +unsigned int g_supplicant_network_get_maxrate(GSupplicantNetwork *network);
39 +const char *g_supplicant_network_get_enc_mode(GSupplicantNetwork *network);
40 +#endif
41 +
42  struct _GSupplicantCallbacks {
43         void (*system_ready) (void);
44         void (*system_killed) (void);
45 diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
46 index 909a617..d2e4a64 100644
47 --- a/gsupplicant/supplicant.c
48 +++ b/gsupplicant/supplicant.c
49 @@ -1169,6 +1169,55 @@ bool g_supplicant_peer_has_requested_connection(GSupplicantPeer *peer)
50         return peer->connection_requested;
51  }
52  
53 +#if defined TIZEN_EXT
54 +/*
55 + * Description: Network client requires additional wifi specific info
56 + */
57 +const unsigned char *g_supplicant_network_get_bssid(GSupplicantNetwork *network)
58 +{
59 +       if (network == NULL || network->best_bss == NULL)
60 +               return NULL;
61 +
62 +       return (const unsigned char *)network->best_bss->bssid;
63 +}
64 +
65 +unsigned int g_supplicant_network_get_maxrate(GSupplicantNetwork *network)
66 +{
67 +       if (network == NULL || network->best_bss == NULL)
68 +               return 0;
69 +
70 +       return network->best_bss->maxrate;
71 +}
72 +
73 +const char *g_supplicant_network_get_enc_mode(GSupplicantNetwork *network)
74 +{
75 +       if (network == NULL || network->best_bss == NULL)
76 +               return NULL;
77 +
78 +       if (network->best_bss->security == G_SUPPLICANT_SECURITY_PSK ||
79 +           network->best_bss->security == G_SUPPLICANT_SECURITY_IEEE8021X) {
80 +               unsigned int pairwise;
81 +
82 +               pairwise = network->best_bss->rsn_pairwise |
83 +                               network->best_bss->wpa_pairwise;
84 +
85 +               if ((pairwise & G_SUPPLICANT_PAIRWISE_CCMP) &&
86 +                   (pairwise & G_SUPPLICANT_PAIRWISE_TKIP))
87 +                       return "mixed";
88 +               else if (pairwise & G_SUPPLICANT_PAIRWISE_CCMP)
89 +                       return "aes";
90 +               else if (pairwise & G_SUPPLICANT_PAIRWISE_TKIP)
91 +                       return "tkip";
92 +
93 +       } else if (network->best_bss->security == G_SUPPLICANT_SECURITY_WEP)
94 +               return "wep";
95 +       else if (network->best_bss->security == G_SUPPLICANT_SECURITY_NONE)
96 +               return "none";
97 +
98 +       return NULL;
99 +}
100 +#endif
101 +
102  static void merge_network(GSupplicantNetwork *network)
103  {
104         GString *str;
105 diff --git a/include/network.h b/include/network.h
106 index d772699..180f2a2 100644
107 --- a/include/network.h
108 +++ b/include/network.h
109 @@ -116,6 +116,23 @@ int connman_network_set_nameservers(struct connman_network *network,
110                                 const char *nameservers);
111  int connman_network_set_domain(struct connman_network *network,
112                                      const char *domain);
113 +#if defined TIZEN_EXT
114 +/*
115 + * Description: Network client requires additional wifi specific info
116 + */
117 +int connman_network_set_bssid(struct connman_network *network,
118 +                               const unsigned char *bssid);
119 +unsigned char *connman_network_get_bssid(struct connman_network *network);
120 +
121 +int connman_network_set_maxrate(struct connman_network *network,
122 +                               unsigned int maxrate);
123 +unsigned int connman_network_get_maxrate(struct connman_network *network);
124 +
125 +int connman_network_set_enc_mode(struct connman_network *network,
126 +                               const char *encryption_mode);
127 +const char *connman_network_get_enc_mode(struct connman_network *network);
128 +#endif
129 +
130  int connman_network_set_name(struct connman_network *network,
131                                                         const char *name);
132  int connman_network_set_strength(struct connman_network *network,
133 diff --git a/plugins/wifi.c b/plugins/wifi.c
134 index 5f2ebf1..69a0e23 100644
135 --- a/plugins/wifi.c
136 +++ b/plugins/wifi.c
137 @@ -2602,7 +2602,14 @@ static void network_added(GSupplicantNetwork *supplicant_network)
138  
139         connman_network_set_frequency(network,
140                         g_supplicant_network_get_frequency(supplicant_network));
141 -
142 +#if defined TIZEN_EXT
143 +       connman_network_set_bssid(network,
144 +                       g_supplicant_network_get_bssid(supplicant_network));
145 +       connman_network_set_maxrate(network,
146 +                       g_supplicant_network_get_maxrate(supplicant_network));
147 +       connman_network_set_enc_mode(network,
148 +                       g_supplicant_network_get_enc_mode(supplicant_network));
149 +#endif
150         connman_network_set_available(network, true);
151         connman_network_set_string(network, "WiFi.Mode", mode);
152  
153 @@ -2658,6 +2665,12 @@ static void network_changed(GSupplicantNetwork *network, const char *property)
154         const char *name, *identifier;
155         struct connman_network *connman_network;
156  
157 +#if defined TIZEN_EXT
158 +       const unsigned char *bssid;
159 +       unsigned int maxrate;
160 +       uint16_t frequency;
161 +#endif
162 +
163         interface = g_supplicant_network_get_interface(network);
164         wifi = g_supplicant_interface_get_data(interface);
165         identifier = g_supplicant_network_get_identifier(network);
166 @@ -2677,6 +2690,16 @@ static void network_changed(GSupplicantNetwork *network, const char *property)
167                                         calculate_strength(network));
168                connman_network_update(connman_network);
169         }
170 +
171 +#if defined TIZEN_EXT
172 +       bssid = g_supplicant_network_get_bssid(network);
173 +       maxrate = g_supplicant_network_get_maxrate(network);
174 +       frequency = g_supplicant_network_get_frequency(network);
175 +
176 +       connman_network_set_bssid(connman_network, bssid);
177 +       connman_network_set_maxrate(connman_network, maxrate);
178 +       connman_network_set_frequency(connman_network, frequency);
179 +#endif
180  }
181  
182  static void apply_peer_services(GSupplicantPeer *peer,
183 diff --git a/src/network.c b/src/network.c
184 index b388995..c40a079 100644
185 --- a/src/network.c
186 +++ b/src/network.c
187 @@ -41,6 +41,11 @@
188   */
189  #define RS_REFRESH_TIMEOUT     3
190  
191 +#if defined TIZEN_EXT
192 +#define WIFI_ENCYPTION_MODE_LEN_MAX 6
193 +#define WIFI_BSSID_LEN_MAX 6
194 +#endif
195 +
196  static GSList *network_list = NULL;
197  static GSList *driver_list = NULL;
198  
199 @@ -87,6 +92,11 @@ struct connman_network {
200                 bool wps;
201                 bool use_wps;
202                 char *pin_wps;
203 +#if defined TIZEN_EXT
204 +               char encryption_mode[WIFI_ENCYPTION_MODE_LEN_MAX];
205 +               unsigned char bssid[WIFI_BSSID_LEN_MAX];
206 +               unsigned int maxrate;
207 +#endif
208         } wifi;
209  
210  };
211 @@ -1737,6 +1747,69 @@ int connman_network_set_ipaddress(struct connman_network *network,
212         return 0;
213  }
214  
215 +#if defined TIZEN_EXT
216 +/*
217 + * Description: Network client requires additional wifi specific info
218 + */
219 +int connman_network_set_bssid(struct connman_network *network,
220 +                               const unsigned char *bssid)
221 +{
222 +       int i = 0;
223 +
224 +       if (bssid == NULL)
225 +               return -EINVAL;
226 +
227 +       DBG("network %p bssid %02x:%02x:%02x:%02x:%02x:%02x", network,
228 +                       bssid[0], bssid[1], bssid[2],
229 +                       bssid[3], bssid[4], bssid[5]);
230 +
231 +       for (;i < WIFI_BSSID_LEN_MAX;i++)
232 +               network->wifi.bssid[i] = bssid[i];
233 +
234 +       return 0;
235 +}
236 +
237 +unsigned char *connman_network_get_bssid(struct connman_network *network)
238 +{
239 +       return (unsigned char *)network->wifi.bssid;
240 +}
241 +
242 +int connman_network_set_maxrate(struct connman_network *network,
243 +                               unsigned int maxrate)
244 +{
245 +       DBG("network %p maxrate %d", network, maxrate);
246 +
247 +       network->wifi.maxrate = maxrate;
248 +
249 +       return 0;
250 +}
251 +
252 +unsigned int connman_network_get_maxrate(struct connman_network *network)
253 +{
254 +       return network->wifi.maxrate;
255 +}
256 +
257 +int connman_network_set_enc_mode(struct connman_network *network,
258 +                               const char *encryption_mode)
259 +{
260 +       if (encryption_mode == NULL)
261 +               return -EINVAL;
262 +
263 +       DBG("network %p encryption mode %s", network, encryption_mode);
264 +
265 +       g_strlcpy(network->wifi.encryption_mode, encryption_mode,
266 +                                       WIFI_ENCYPTION_MODE_LEN_MAX);
267 +
268 +       return 0;
269 +}
270 +
271 +const char *connman_network_get_enc_mode(struct connman_network *network)
272 +{
273 +       return (const char *)network->wifi.encryption_mode;
274 +}
275 +
276 +#endif
277 +
278  int connman_network_set_nameservers(struct connman_network *network,
279                                 const char *nameservers)
280  {
281 -- 
282 1.8.1.4
283