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)
36 g_return_val_if_fail(wifi != NULL, FALSE);
38 ret = __netconfig_wifi_get_sim_imsi(wifi, context);
43 gboolean handle_req_sim_auth(Wifi *wifi, GDBusMethodInvocation *context, GVariant *rand_data)
45 gboolean result = TRUE;
46 GArray *rand_data_garray;
49 guchar *out_auth_data;
53 DBG("Request SIM Authentication");
55 g_return_val_if_fail(wifi != NULL, FALSE);
57 g_variant_get(rand_data, "ay", &iter);
58 length = g_variant_iter_n_children(iter);
59 out_auth_data = g_new0(guchar, length);
61 while (g_variant_iter_loop(iter, "y", &byte)) {
62 *(out_auth_data + i) = byte;
65 g_variant_iter_free(iter);
67 rand_data_garray = g_array_sized_new(FALSE, FALSE, sizeof(guchar), length);
68 memcpy(rand_data_garray->data, out_auth_data, length);
69 g_free(out_auth_data);
70 rand_data_garray->len = length;
72 result = __netconfig_wifi_req_sim_auth(rand_data_garray, context, &wifi_authdata);
73 g_array_free(rand_data_garray, FALSE);
76 wifi_complete_req_sim_auth(wifi, context, result);
81 gboolean handle_req_aka_auth(Wifi *wifi, GDBusMethodInvocation *context, GVariant *rand_data, GVariant *autn_data)
83 netconfig_error_e ret = NETCONFIG_NO_ERROR;
84 gboolean result = FALSE;
87 guchar *out_auth_data;
90 GArray *rand_data_garray;
91 GArray *autn_data_garray;
93 DBG("Request AKA Authentication");
95 g_return_val_if_fail(wifi != NULL, FALSE);
97 g_variant_get(rand_data, "ay", &iter);
98 length = g_variant_iter_n_children(iter);
99 out_auth_data = g_new0(guchar, length);
100 while (g_variant_iter_loop(iter, "y", &byte)) {
101 *(out_auth_data + i) = byte;
104 g_variant_iter_free(iter);
106 rand_data_garray = g_array_sized_new(FALSE, FALSE, sizeof(guchar), length);
107 memcpy(rand_data_garray->data, out_auth_data, length);
108 g_free(out_auth_data);
109 rand_data_garray->len = length;
112 g_variant_get(autn_data, "ay", &iter);
113 length = g_variant_iter_n_children(iter);
114 out_auth_data = g_new0(guchar, length);
115 while (g_variant_iter_loop(iter, "y", &byte)) {
116 *(out_auth_data + i) = byte;
119 g_variant_iter_free(iter);
121 autn_data_garray = g_array_sized_new(FALSE, FALSE, sizeof(guchar), length);
122 memcpy(autn_data_garray->data, out_auth_data, length);
123 g_free(out_auth_data);
124 autn_data_garray->len = length;
126 ret = __netconfig_wifi_req_aka_auth(rand_data_garray, autn_data_garray, context, &wifi_authdata);
127 if (ret == NETCONFIG_NO_ERROR) {
129 wifi_complete_req_aka_auth(wifi, context, result);
130 } else if (ret == NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM) {
131 netconfig_error_dbus_method_return(context,
132 NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM, "FailReqSimAuthWrongParam");
134 netconfig_error_dbus_method_return(context,
135 NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH, "FailReqSimAuth");
138 g_array_free(rand_data_garray, FALSE);
139 g_array_free(autn_data_garray, FALSE);
144 gboolean handle_get_sim_auth(Wifi *wifi, GDBusMethodInvocation *context)
148 DBG("Get SIM Authdata");
150 g_return_val_if_fail(wifi != NULL, FALSE);
152 ret = __netconfig_wifi_get_sim_authdata(wifi, context, &wifi_authdata);
156 gboolean handle_get_aka_auth(Wifi *wifi, GDBusMethodInvocation *context)
160 DBG("Get AKA Authdata");
162 g_return_val_if_fail(wifi != NULL, FALSE);
164 ret = __netconfig_wifi_get_aka_authdata(wifi, context, &wifi_authdata);
169 EXPORT_SYM void netconfig_complete_get_sim_imsi(void *wifi, GDBusMethodInvocation *context, char *imsi)
171 wifi_complete_get_sim_imsi((Wifi*)wifi, context, imsi);
174 EXPORT_SYM void netconfig_complete_get_aka_auth(void *wifi, GDBusMethodInvocation *context, GArray *array)
176 wifi_complete_get_aka_auth((Wifi*)wifi, context, array->data);
179 EXPORT_SYM void netconfig_complete_get_sim_auth(void *wifi, GDBusMethodInvocation *context, GArray *array)
181 wifi_complete_get_sim_auth((Wifi*)wifi, context, array->data);
184 EXPORT_SYM void netconfig_wifi_power_on()
186 #if defined TIZEN_WEARABLE
187 wifi_power_on_wearable(TRUE);