2 * Network Configuration Module
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include "network-state.h"
26 #include "wifi-power.h"
28 static struct wifi_authentication_data *wifi_authdata;
30 gboolean handle_get_sim_imsi(Wifi *wifi, GDBusMethodInvocation *context)
34 g_return_val_if_fail(wifi != NULL, TRUE);
36 __netconfig_wifi_get_sim_imsi(wifi, context);
41 gboolean handle_req_sim_auth(Wifi *wifi, GDBusMethodInvocation *context, GVariant *rand_data)
43 gboolean result = TRUE;
44 GArray *rand_data_garray;
47 guchar *out_auth_data;
51 DBG("Request SIM Authentication");
53 g_return_val_if_fail(wifi != NULL, TRUE);
55 g_variant_get(rand_data, "ay", &iter);
56 length = g_variant_iter_n_children(iter);
57 out_auth_data = g_new0(guchar, length);
59 while (g_variant_iter_loop(iter, "y", &byte)) {
60 *(out_auth_data + i) = byte;
63 g_variant_iter_free(iter);
65 rand_data_garray = g_array_sized_new(FALSE, FALSE, sizeof(guchar), length);
66 memcpy(rand_data_garray->data, out_auth_data, length);
67 g_free(out_auth_data);
68 rand_data_garray->len = length;
70 result = __netconfig_wifi_req_sim_auth(rand_data_garray, context, &wifi_authdata);
71 g_array_free(rand_data_garray, FALSE);
74 wifi_complete_req_sim_auth(wifi, context, result);
79 gboolean handle_req_aka_auth(Wifi *wifi, GDBusMethodInvocation *context, GVariant *rand_data, GVariant *autn_data)
81 netconfig_error_e ret = NETCONFIG_NO_ERROR;
82 gboolean result = FALSE;
85 guchar *out_auth_data;
88 GArray *rand_data_garray;
89 GArray *autn_data_garray;
91 DBG("Request AKA Authentication");
93 g_return_val_if_fail(wifi != NULL, TRUE);
95 g_variant_get(rand_data, "ay", &iter);
96 length = g_variant_iter_n_children(iter);
97 out_auth_data = g_new0(guchar, length);
98 while (g_variant_iter_loop(iter, "y", &byte)) {
99 *(out_auth_data + i) = byte;
102 g_variant_iter_free(iter);
104 rand_data_garray = g_array_sized_new(FALSE, FALSE, sizeof(guchar), length);
105 memcpy(rand_data_garray->data, out_auth_data, length);
106 g_free(out_auth_data);
107 rand_data_garray->len = length;
110 g_variant_get(autn_data, "ay", &iter);
111 length = g_variant_iter_n_children(iter);
112 out_auth_data = g_new0(guchar, length);
113 while (g_variant_iter_loop(iter, "y", &byte)) {
114 *(out_auth_data + i) = byte;
117 g_variant_iter_free(iter);
119 autn_data_garray = g_array_sized_new(FALSE, FALSE, sizeof(guchar), length);
120 memcpy(autn_data_garray->data, out_auth_data, length);
121 g_free(out_auth_data);
122 autn_data_garray->len = length;
124 ret = __netconfig_wifi_req_aka_auth(rand_data_garray, autn_data_garray, context, &wifi_authdata);
125 if (ret == NETCONFIG_NO_ERROR) {
127 wifi_complete_req_aka_auth(wifi, context, result);
128 } else if (ret == NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM) {
129 netconfig_error_dbus_method_return(context,
130 NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM, "FailReqSimAuthWrongParam");
132 netconfig_error_dbus_method_return(context,
133 NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH, "FailReqSimAuth");
136 g_array_free(rand_data_garray, FALSE);
137 g_array_free(autn_data_garray, FALSE);
142 gboolean handle_get_sim_auth(Wifi *wifi, GDBusMethodInvocation *context)
144 DBG("Get SIM Authdata");
146 g_return_val_if_fail(wifi != NULL, TRUE);
148 __netconfig_wifi_get_sim_authdata(wifi, context, &wifi_authdata);
153 gboolean handle_get_aka_auth(Wifi *wifi, GDBusMethodInvocation *context)
155 DBG("Get AKA Authdata");
157 g_return_val_if_fail(wifi != NULL, TRUE);
159 __netconfig_wifi_get_aka_authdata(wifi, context, &wifi_authdata);
164 EXPORT_SYM void netconfig_complete_get_sim_imsi(void *wifi, GDBusMethodInvocation *context, char *imsi)
166 wifi_complete_get_sim_imsi((Wifi*)wifi, context, imsi);
169 EXPORT_SYM void netconfig_complete_get_aka_auth(void *wifi, GDBusMethodInvocation *context, GArray *array)
171 wifi_complete_get_aka_auth((Wifi*)wifi, context, array->data);
174 EXPORT_SYM void netconfig_complete_get_sim_auth(void *wifi, GDBusMethodInvocation *context, GArray *array)
176 wifi_complete_get_sim_auth((Wifi*)wifi, context, array->data);
179 EXPORT_SYM void netconfig_wifi_power_on()
181 #if defined TIZEN_WEARABLE
182 wifi_power_on_wearable(NULL, TRUE);