<manifest>
<define>
<domain name="nfc-manager" />
+ <provide>
+ <label name="nfc-manager::tag" />
+ <label name="nfc-manager::p2p" />
+ <label name="nfc-manager::admin" />
+ <label name="nfc-manager::card_emul" />
+ </provide>
+ <request>
+ <smack request="sys-assert::core" type="rwxat" />
+ </request>
</define>
<assign>
<filesystem path="/usr/bin/nfc-manager-daemon" exec_label="nfc-manager" />
+ <filesystem path="/etc/init.d/libnfc-manager-0" label="_" exec_label="none" />
+ <filesystem path="/etc/rc.d/rc3.d/S81libnfc-manager-0" label="_" exec_label="none" />
+ <filesystem path="/etc/rc.d/rc5.d/S81libnfc-manager-0" label="_" exec_label="none" />
<filesystem path="/usr/bin/ndef-tool" exec_label="nfc-manager" />
<filesystem path="/usr/lib/libnfc.so.1" label="_" />
<filesystem path="/usr/lib/libnfc.so.1.0.0" label="_" />
- <filesystem path="/etc/init.d/libnfc-manager-0" label="_" exec_label="none"/>
</assign>
<request>
<domain name="nfc-manager" />
Name: nfc-manager
Summary: NFC framework manager
-Version: 0.0.33
-Release: 1
+Version: 0.0.37
+Release: 0
Group: libs
License: Flora Software License
Source0: %{name}-%{version}.tar.gz
Source1: libnfc-manager-0.init.in
Source2: nfc-manager.service
+Requires: sys-assert
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gobject-2.0)
BuildRequires: pkgconfig(libssl)
BuildRequires: pkgconfig(pmapi)
BuildRequires: pkgconfig(pkgmgr)
+BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: cmake
BuildRequires: gettext-tools
Requires(post): /sbin/ldconfig
Requires(post): /usr/bin/vconftool
requires(postun): /sbin/ldconfig
+
+
%description
NFC library Manager.
+
%prep
%setup -q
+
%package devel
Summary: Download agent
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
+
%description devel
NFC library Manager (devel)
+
%package -n nfc-common-lib
Summary: NFC common library
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
+
%description -n nfc-common-lib
NFC Common library.
+
%package -n nfc-common-lib-devel
Summary: NFC common library (devel)
Group: libs
Requires: %{name} = %{version}-%{release}
+
%description -n nfc-common-lib-devel
NFC common library (devel)
make
+
%install
cd cmake_tmp
%make_install
cp -af %{SOURCE2} %{buildroot}/usr/lib/systemd/system/
ln -s ../nfc-manager.service %{buildroot}/usr/lib/systemd/system/multi-user.target.wants/nfc-manager.service
+
%post
/sbin/ldconfig
vconftool set -t bool db/nfc/feature 1 -u 5000 -f
vconftool set -t int db/nfc/se_type 0 -u 5000 -f
vconftool set -t bool db/nfc/predefined_item_state 0 -u 5000 -f
vconftool set -t string db/nfc/predefined_item "None" -u 5000 -f
-
vconftool set -t bool memory/private/nfc-manager/popup_disabled 0 -u 5000 -f
ln -s /etc/init.d/libnfc-manager-0 /etc/rc.d/rc3.d/S81libnfc-manager-0 -f
chown :5000 /opt/etc/nfc_debug
chmod 775 /opt/etc/nfc_debug
-
systemctl daemon-reload
if [ $1 == 1 ]; then
systemctl restart nfc-manager.service
fi
+
%postun
/sbin/ldconfig
mkdir -p /etc/rc.d/rc3.d
fi
systemctl daemon-reload
+
%post -n nfc-common-lib -p /sbin/ldconfig
+
%postun -n nfc-common-lib -p /sbin/ldconfig
+
%files
%manifest nfc-manager.manifest
%defattr(-,root,root,-)
/usr/lib/systemd/system/nfc-manager.service
/usr/lib/systemd/system/multi-user.target.wants/nfc-manager.service
+
%files devel
%manifest nfc-manager-devel.manifest
%defattr(-,root,root,-)
/usr/share/license/nfc-common-lib
/usr/share/nfc-manager-daemon/sounds/*
+
%files -n nfc-common-lib-devel
%manifest nfc-common-lib-devel.manifest
%defattr(-,root,root,-)
include/net_nfc_ndef_message_handover.h
include/net_nfc_sign_record.h
include/net_nfc_data.h
- include/net_nfc_apdu.h
include/net_nfc_exchanger.h
include/net_nfc_internal_se.h
include/net_nfc_test.h
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef __NET_NFC_APDU__
-#define __NET_NFC_APDU__
-
-#include "net_nfc_typedef.h"
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
-typedef unsigned int apdu_slot_t;
-typedef unsigned int apdu_channel_t;
-typedef void (* net_nfc_apdu_response_cb ) (net_nfc_error_e result, apdu_channel_t channel, data_h data, void* user_data);
-
-/**
-@addtogroup NET_NFC_MANAGER_APDU
-@{
-
-*/
-
-/**
- initialize the apdu api. the callback function will be called when the data is arrived from simcard or SE
-
- @param[in] callback callback function
- @param[in] user_data context value that will be delivered to the callback function
-
- @return return the result of the calling the function
-*/
-net_nfc_error_e net_nfc_register_apdu_cb (net_nfc_apdu_response_cb callback, void * user_data);
-
-/**
-
- allows to select the slot. UICC or SE
-
- <ul>
- <li> slot# 0 : UICC <\li>
- <li> slot# 1 : Secure Element<\li>
- </ul>
-
- @param[in] slot slot for mms
-
- @return return the result of the calling the function
-*/
-net_nfc_error_e net_nfc_select_apdu_slot (apdu_slot_t slot);
-
-/**
- Answer to reset is the sequence of bytes output by a chip card after the card reader has electrically reset the card.
- The ATR tells the reader which communication capabilities the card has. The format of the ATR is defined in ISO/IEC 7816-3.[1]
- this function return ATR data if the simcard is available, or NULL will be returned
-
- @param[out] data ATR data will be returned if the simcard is available.
-
- @return return the result of the calling the function
-
-*/
-net_nfc_error_e net_nfc_get_apdu_answer_to_reset (data_h data);
-
-/**
- this opens a channel to communicate with application on the simcard.
- you may open the channel with
-
- @param[out] channel return the assined chennel
- @param[in] aid application id that mached in the simcard application
-
- @return return the result of the calling the function
-
-*/
-net_nfc_error_e net_nfc_open_apdu_channel (apdu_channel_t *channel , net_nfc_string_t aid);
-
-/**
- send the apud data to opened channel.
-
- @param[in] channel channel number that already opened
- @param[in] data data value that will be send
-
- @return return the result of the calling the function
-*/
-net_nfc_error_e net_nfc_send_apdu_command (apdu_channel_t channel, data_t data);
-
-/**
- closes opened channel
-
- @param[in] channel channel number
-
- @return return the result of the calling the function
-*/
-net_nfc_error_e net_nfc_close_apdu_channel (apdu_channel_t channel);
-
-/**
- disconnect all the channel and return to original state. it stops calling callback function
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NOT_REGISTERED unset is requested but the callback was not registered before
-*/
-net_nfc_error_e net_nfc_unset_apdu_cb (void);
-
-
-/**
-@}
-*/
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
-
-
#else
void net_nfc_client_call_dispatcher_in_current_context(net_nfc_response_cb client_cb, net_nfc_response_msg_t* msg);
#endif
-bool net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg);
+net_nfc_error_e net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg);
#endif
void net_nfc_client_socket_finalize();
bool net_nfc_client_is_connected();
-net_nfc_error_e net_nfc_client_send_reqeust(net_nfc_request_msg_t *msg, ...);
-net_nfc_error_e net_nfc_client_send_reqeust_sync(net_nfc_request_msg_t *msg, ...);
+net_nfc_error_e net_nfc_client_send_request(net_nfc_request_msg_t *msg, ...);
+net_nfc_error_e net_nfc_client_send_request_sync(net_nfc_request_msg_t *msg, ...);
void _net_nfc_client_set_cookies(const char * cookie, size_t size);
void _net_nfc_client_free_cookies(void);
/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __NET_NFC_INTERNAL_SE_H__
#define __NET_NFC_INTERNAL_SE_H__
#include "net_nfc_typedef.h"
-
#ifdef __cplusplus
- extern "C" {
+extern "C"
+{
#endif
-
/**
@addtogroup NET_NFC_MANAGER_SECURE_ELEMENT
NFC Manager defines are defined in <net_nfc_typedef.h>
- @li @c #net_nfc_set_secure_element_type set secure element type
- @li @c #net_nfc_get_secure_element_type get current selected secure element
- @li @c #net_nfc_open_internal_secure_element open selected secure element
- @li @c #net_nfc_close_internal_secure_element close selected secure element
- @li @c #net_nfc_send_apdu send apdu
-
-
-
+ @li @c #net_nfc_set_secure_element_type set secure element type
+ @li @c #net_nfc_get_secure_element_type get current selected secure element
+ @li @c #net_nfc_open_internal_secure_element open selected secure element
+ @li @c #net_nfc_open_internal_secure_element_sync open selected secure element (synchronous)
+ @li @c #net_nfc_close_internal_secure_element close selected secure element
+ @li @c #net_nfc_close_internal_secure_element_sync close selected secure element (synchronous)
+ @li @c #net_nfc_send_apdu send apdu to opened secure element
+ @li @c #net_nfc_send_apdu_sync send apdu to opened secure element (synchronous)
+ @li @c #net_nfc_get_atr request atr of secure element
+ @li @c #net_nfc_get_atr_sync request atr of secure element (synchronous)
*/
/**
- set secure element type. secure element will be a UICC or ESE. only one secure element is selected in a time. external reader can communicate with
- secure element by emitting RF
+ set secure element type. secure element will be a UICC or ESE.
+ only one secure element is selected in a time.
+ external reader can communicate with secure element by emitting RF
\par Sync (or) Async: Sync
This is a Asynchronous API
@return return the result of the calling the function
@exception NET_NFC_INVALID_PARAM not supported se_type
-
*/
-
-net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, void* trans_param);
+net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, void *trans_param);
/**
get current select se type.
- \par Sync (or) Async: Sync
+ \par Sync (or) Async: Async
+ This is a Asynchronous API
+
+ @param[in] trans_param user data that will be delivered to callback
+
+ @return return the result of the calling the function
+*/
+net_nfc_error_e net_nfc_get_secure_element_type(void *trans_param);
+
+/**
+ open and initialize the type of secure element.
+ if the type of secure element is selected, then change mode as MODE OFF
+ to prevent to be detected by external reader
+
+ \par Sync (or) Async: Async
This is a Asynchronous API
@param[in] se_type secure element type
@return return the result of the calling the function
@exception NET_NFC_INVALID_PARAM not supported se_type
-
*/
-
-net_nfc_error_e net_nfc_get_secure_element_type(void* trans_param);
+net_nfc_error_e net_nfc_open_internal_secure_element(net_nfc_se_type_e se_type, void *trans_param);
/**
- open and intialize the type of secure element. if the type of secure element is selected, then change mode as MODE OFF to prevent to be detected by external reader
+ open and initialize the type of secure element.
+ if the type of secure element is selected, then change mode as MODE OFF
+ to prevent to be detected by external reader
\par Sync (or) Async: Sync
This is a Asynchronous API
@param[in] se_type secure element type
- @param[in] trans_param user data that will be delivered to callback
+ @param[out] handle the handle of opened secure element
@return return the result of the calling the function
@exception NET_NFC_INVALID_PARAM not supported se_type
-
*/
-
-net_nfc_error_e net_nfc_open_internal_secure_element(net_nfc_se_type_e se_type, void* trans_param);
+net_nfc_error_e net_nfc_open_internal_secure_element_sync(net_nfc_se_type_e se_type, net_nfc_target_handle_h *handle);
/**
- close opend secure element and change back to previous setting
+ close opened secure element and change back to previous setting
- \par Sync (or) Async: Sync
+ \par Sync (or) Async: Async
This is a Asynchronous API
- @param[in] handle the handle of opend secure element
+ @param[in] handle the handle of opened secure element
@param[in] trans_param user data that will be delivered to callback
@return return the result of the calling the function
- @exception NET_NFC_INVALID_PARAM not supported se_type
+ @exception NET_NFC_INVALID_PARAM invalid secure element handle
+*/
+net_nfc_error_e net_nfc_close_internal_secure_element(net_nfc_target_handle_h handle, void *trans_param);
+
+/**
+ close opened secure element and change back to previous setting
+
+ \par Sync (or) Async: Sync
+ This is a Asynchronous API
+
+ @param[in] handle the handle of opened secure element
+ @return return the result of the calling the function
+
+ @exception NET_NFC_INVALID_PARAM invalid secure element handle
*/
+net_nfc_error_e net_nfc_close_internal_secure_element_sync(net_nfc_target_handle_h handle);
+
+/**
+ send apdu to opened secure element
+
+ \par Sync (or) Async: Async
+ This is a Asynchronous API
+
+ @param[in] handle the handle of opened secure element
+ @param[in] apdu apdu command to send
+ @param[in] trans_param user data that will be delivered to callback
+
+ @return return the result of the calling the function
-net_nfc_error_e net_nfc_close_internal_secure_element(net_nfc_target_handle_h handle, void* trans_param);
+ @exception NET_NFC_INVALID_PARAM invalid secure element handle
+ @exception NET_NFC_NULL_PARAM data is null or empty
+*/
+net_nfc_error_e net_nfc_send_apdu(net_nfc_target_handle_h handle, data_h apdu, void *trans_param);
/**
- send apdu to opend secure element
+ send apdu to opened secure element
- \par Sync (or) Async: Sync
+ \par Sync (or) Async: Async
This is a Asynchronous API
- @param[in] handle the handle of opend secure element
+ @param[in] handle the handle of opened secure element
@param[in] apdu apdu command to send
+ @param[out] response result of apdu
+
+ @return return the result of the calling the function
+
+ @exception NET_NFC_INVALID_PARAM invalid secure element handle or parameter
+ @exception NET_NFC_NULL_PARAM data is null or empty
+*/
+net_nfc_error_e net_nfc_send_apdu_sync(net_nfc_target_handle_h handle, data_h apdu, data_h *response);
+
+/**
+ request atr of secure element
+
+ \par Sync (or) Async: Async
+ This is a Asynchronous API
+
+ @param[in] handle the handle of opened secure element
@param[in] trans_param user data that will be delivered to callback
@return return the result of the calling the function
@exception NET_NFC_INVALID_PARAM invalid
*/
+net_nfc_error_e net_nfc_get_atr(net_nfc_target_handle_h handle, void *trans_param);
+
+/**
+ request atr of secure element
-net_nfc_error_e net_nfc_send_apdu(net_nfc_target_handle_h handle, data_h apdu, void* trans_param);
+ \par Sync (or) Async: Sync
+ This is a Asynchronous API
+
+ @param[in] handle the handle of opened secure element
+ @param[out] atr Answer to reset of secure element
+
+ @return return the result of the calling the function
+
+ @exception NET_NFC_INVALID_PARAM invalid
+*/
+net_nfc_error_e net_nfc_get_atr_sync(net_nfc_target_handle_h handle, data_h *atr);
#ifdef __cplusplus
}
}
break;
+ case NET_NFC_MESSAGE_GET_ATR_SE :
+ {
+ data_s *atr = &(((net_nfc_response_get_atr_t *)msg->detail_message)->data);
+
+ if (atr->length > 0)
+ {
+ if (client_cb != NULL)
+ client_cb(msg->response_type, ((net_nfc_response_get_atr_t *)msg->detail_message)->result, atr, client_context->register_user_param, (void *)((net_nfc_response_get_atr_t *)(msg->detail_message))->user_param);
+ }
+ else
+ {
+ if (client_cb != NULL)
+ client_cb(msg->response_type, ((net_nfc_response_get_atr_t *)msg->detail_message)->result, NULL, client_context->register_user_param, (void *)((net_nfc_response_get_atr_t *)(msg->detail_message))->user_param);
+ }
+ }
+ break;
+
case NET_NFC_MESSAGE_NOTIFY :
{
if (client_cb != NULL)
if (data->length > 0)
{
if (client_cb != NULL)
- client_cb(msg->response_type, ((net_nfc_response_transceive_t *)msg->detail_message)->result, data, client_context->register_user_param, ((net_nfc_response_transceive_t *)(msg->detail_message))->trans_param);
+ client_cb(msg->response_type, ((net_nfc_response_transceive_t *)msg->detail_message)->result, (void *)data, client_context->register_user_param, ((net_nfc_response_transceive_t *)(msg->detail_message))->trans_param);
}
else
{
return false;
}
-bool net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg)
+net_nfc_error_e net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg)
{
+ net_nfc_error_e result = NET_NFC_OK;
// client_context_t *client_context = NULL;
- if (msg == NULL || msg->detail_message == NULL)
- return false;
-
DEBUG_CLIENT_MSG("synchronous callback, message = [%d]", msg->response_type);
// client_context = net_nfc_get_client_context();
break;
case NET_NFC_MESSAGE_OPEN_INTERNAL_SE :
+ {
+ net_nfc_response_open_internal_se_t *response = (net_nfc_response_open_internal_se_t *)msg->detail_message;
+ net_nfc_target_handle_h *handle = (net_nfc_target_handle_h *)response->user_param;
+
+ /* return */
+ result = response->result;
+
+ if (handle != NULL) {
+ *handle = (net_nfc_target_handle_h)response->handle;
+ }
+ }
break;
case NET_NFC_MESSAGE_CLOSE_INTERNAL_SE :
+ {
+ net_nfc_response_close_internal_se_t *response = (net_nfc_response_close_internal_se_t *)msg->detail_message;
+
+ /* return */
+ result = response->result;
+ }
break;
case NET_NFC_MESSAGE_SEND_APDU_SE :
+ {
+ net_nfc_response_send_apdu_t *response = (net_nfc_response_send_apdu_t *)msg->detail_message;
+ data_h *data = (data_h *)response->user_param;
+
+ /* return */
+ result = response->result;
+
+ if (data != NULL && response->data.buffer != NULL &&
+ response->data.length > 0) {
+ net_nfc_create_data(data, response->data.buffer,
+ response->data.length);
+ }
+ }
+ break;
+
+ case NET_NFC_MESSAGE_GET_ATR_SE :
+ {
+ net_nfc_response_get_atr_t *response = (net_nfc_response_get_atr_t *)msg->detail_message;
+ data_h *data = (data_h *)response->user_param;
+
+ /* return */
+ result = response->result;
+
+ if (data != NULL && response->data.buffer != NULL &&
+ response->data.length > 0) {
+ net_nfc_create_data(data, response->data.buffer,
+ response->data.length);
+ }
+ }
break;
case NET_NFC_MESSAGE_NOTIFY :
net_nfc_response_is_tag_connected_t *response = (net_nfc_response_is_tag_connected_t *)msg->detail_message;
net_nfc_response_is_tag_connected_t *context = (net_nfc_response_is_tag_connected_t *)response->trans_param;
+ /* return */
+ result = response->result;
+
if (context != NULL)
{
context->result = response->result;
net_nfc_response_get_current_tag_info_t *response = (net_nfc_response_get_current_tag_info_t *)msg->detail_message;
net_nfc_response_get_current_tag_info_t *context = (net_nfc_response_get_current_tag_info_t *)response->trans_param;
+ /* return */
+ result = response->result;
+
if (context != NULL)
{
context->result = response->result;
net_nfc_response_get_current_target_handle_t *response = (net_nfc_response_get_current_target_handle_t *)msg->detail_message;
net_nfc_response_get_current_target_handle_t *context = (net_nfc_response_get_current_target_handle_t *)response->trans_param;
+ /* return */
+ result = response->result;
+
if (context != NULL)
{
context->handle = response->handle;
break;
}
- /* client callback must copy data to client area */
+ /* client callback must copy data to client area */
net_nfc_util_mem_free_detail_msg(NET_NFC_UTIL_MSG_TYPE_RESPONSE, msg->response_type, msg->detail_message);
_net_nfc_util_free_mem(msg);
- return false;
+ return result;
}
static net_nfc_error_e net_nfc_get_tag_info_list(data_s *values, int number_of_keys, net_nfc_tag_info_s **list)
memcpy(&request->data.buffer, ex_data->binary_data.buffer, request->data.length);
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
request->handle = (net_nfc_target_handle_s *)target_handle;
request->type = type;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "net_nfc_tag.h"
-#include "net_nfc_typedef_private.h"
-#include "net_nfc_client_ipc_private.h"
-#include "net_nfc_debug_private.h"
-#include "net_nfc_util_private.h"
-#include "net_nfc_client_nfc_private.h"
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include <string.h>
#include <pthread.h>
+#include "net_nfc_typedef_private.h"
+#include "net_nfc_debug_private.h"
+#include "net_nfc_util_private.h"
+#include "net_nfc_client_ipc_private.h"
+
#ifndef NET_NFC_EXPORT_API
#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
#endif
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, void* trans_param)
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, void *trans_param)
{
net_nfc_error_e ret;
net_nfc_request_set_se_t request = { 0, };
request.se_type = se_type;
request.trans_param = trans_param;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_secure_element_type(void* trans_param)
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_secure_element_type(void *trans_param)
{
net_nfc_error_e ret;
net_nfc_request_get_se_t request = { 0, };
request.request_type = NET_NFC_MESSAGE_GET_SE;
request.trans_param = trans_param;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_open_internal_secure_element(net_nfc_se_type_e se_type, void* trans_param)
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_open_internal_secure_element(net_nfc_se_type_e se_type, void *trans_param)
{
net_nfc_error_e ret;
net_nfc_request_open_internal_se_t request = { 0, };
request.se_type = se_type;
request.trans_param = trans_param;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_open_internal_secure_element_sync(net_nfc_se_type_e se_type, net_nfc_target_handle_h *handle)
+{
+ net_nfc_request_open_internal_se_t request = { 0, };
+ net_nfc_target_handle_h temp = NULL;
+ net_nfc_error_e result;
+
+ if (se_type < NET_NFC_SE_TYPE_NONE || se_type > NET_NFC_SE_TYPE_UICC) {
+ return NET_NFC_INVALID_PARAM;
+ }
+
+ request.length = sizeof(net_nfc_request_open_internal_se_t);
+ request.request_type = NET_NFC_MESSAGE_OPEN_INTERNAL_SE;
+ request.se_type = se_type;
+ request.user_param = (uint32_t)&temp;
+
+ result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
+ if (result == NET_NFC_OK) {
+ if (temp != NULL) {
+ *handle = temp;
+ } else {
+ DEBUG_ERR_MSG("NULL handle returned data returned");
+ result = NET_NFC_OPERATION_FAIL;
+ }
+ } else{
+ DEBUG_ERR_MSG("net_nfc_client_send_request_sync failed [%d]", result);
+ }
+
+ return result;
+}
+
NET_NFC_EXPORT_API net_nfc_error_e net_nfc_close_internal_secure_element(net_nfc_target_handle_h handle, void *trans_param)
{
net_nfc_error_e ret;
request.handle = (net_nfc_target_handle_s *)handle;
request.trans_param = trans_param;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_apdu(net_nfc_target_handle_h handle, data_h apdu, void* trans_param)
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_close_internal_secure_element_sync(net_nfc_target_handle_h handle)
+{
+ net_nfc_error_e result;
+ net_nfc_request_close_internal_se_t request = { 0, };
+
+ if (handle == NULL) {
+ return NET_NFC_NULL_PARAMETER;
+ }
+
+ request.length = sizeof(net_nfc_request_close_internal_se_t);
+ request.request_type = NET_NFC_MESSAGE_CLOSE_INTERNAL_SE;
+ request.handle = (net_nfc_target_handle_s *)handle;
+
+ result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
+
+ return result;
+}
+
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_apdu(net_nfc_target_handle_h handle, data_h apdu, void *trans_param)
{
net_nfc_error_e ret;
net_nfc_request_send_apdu_t *request = NULL;
request->data.length = apdu_data->length;
memcpy(&request->data.buffer, apdu_data->buffer, request->data.length);
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
+
+ _net_nfc_util_free_mem(request);
+
+ return ret;
+}
+
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_apdu_sync(net_nfc_target_handle_h handle, data_h apdu, data_h *response)
+{
+ net_nfc_request_send_apdu_t *request = NULL;
+ data_s *apdu_data = (data_s *)apdu;
+ net_nfc_error_e result;
+ uint32_t length;
+ data_h resp = NULL;
+
+ if (handle == NULL || apdu_data == NULL || apdu_data->buffer == NULL || apdu_data->length == 0)
+ {
+ return NET_NFC_NULL_PARAMETER;
+ }
+
+ length = sizeof(net_nfc_request_send_apdu_t) + apdu_data->length;
+
+ _net_nfc_util_alloc_mem(request, length);
+ if (request == NULL)
+ {
+ return NET_NFC_ALLOC_FAIL;
+ }
+
+ request->length = length;
+ request->request_type = NET_NFC_MESSAGE_SEND_APDU_SE;
+ request->handle = (net_nfc_target_handle_s *)handle;
+ request->user_param = (uint32_t)&resp;
+
+ request->data.length = apdu_data->length;
+ memcpy(&request->data.buffer, apdu_data->buffer, request->data.length);
+
+ result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)request, NULL);
+ if (result == NET_NFC_OK) {
+ if (resp != NULL) {
+ *response = resp;
+ } else {
+ DEBUG_ERR_MSG("NULL response returned");
+ result = NET_NFC_OPERATION_FAIL;
+ }
+ } else {
+ DEBUG_ERR_MSG("net_nfc_client_send_request_sync failed [%d]", result);
+ }
_net_nfc_util_free_mem(request);
+ return result;
+}
+
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_atr(net_nfc_target_handle_h handle, void *trans_param)
+{
+ net_nfc_error_e ret;
+ net_nfc_request_get_atr_t request = { 0, };
+
+ if (handle == NULL)
+ {
+ return NET_NFC_NULL_PARAMETER;
+ }
+
+ request.length = sizeof(net_nfc_request_get_atr_t);
+ request.request_type = NET_NFC_MESSAGE_GET_ATR_SE;
+ request.handle = (net_nfc_target_handle_s *)handle;
+ request.user_param = (uint32_t)trans_param;
+
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
+
return ret;
}
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_atr_sync(net_nfc_target_handle_h handle, data_h *atr)
+{
+ net_nfc_request_get_atr_t request = { 0, };
+ data_h response = NULL;
+ net_nfc_error_e result;
+
+ if (handle == NULL) {
+ return NET_NFC_NULL_PARAMETER;
+ }
+
+ request.length = sizeof(net_nfc_request_get_atr_t);
+ request.request_type = NET_NFC_MESSAGE_GET_ATR_SE;
+ request.handle = (net_nfc_target_handle_s *)handle;
+ request.user_param = (uint32_t)&response;
+
+ result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
+ if (result == NET_NFC_OK) {
+ if (response != NULL) {
+ *atr = response;
+ } else {
+ result = NET_NFC_OPERATION_FAIL;
+ }
+ }
+
+ return result;
+}
static pthread_cond_t g_client_ipc_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t cb_lock = PTHREAD_MUTEX_INITIALIZER;
static net_nfc_response_cb client_cb = NULL;
+static net_nfc_error_e sync_result;
#ifdef G_MAIN_LOOP
static GIOChannel *g_client_channel = NULL;
static net_nfc_error_e net_nfc_client_wait_sync_call(int timeout)
{
net_nfc_error_e result = NET_NFC_OPERATION_FAIL;
+ struct timeval now;
+ struct timespec ts;
- if (pthread_cond_wait(&g_client_ipc_cond, &g_client_ipc_mutex) == 0)
+ gettimeofday(&now, NULL);
+ ts.tv_sec = now.tv_sec + timeout;
+ ts.tv_nsec = now.tv_usec * 1000;
+
+ if (pthread_cond_timedwait(&g_client_ipc_cond, &g_client_ipc_mutex,
+ &ts) == 0)
{
- result = NET_NFC_OK;
+ result = sync_result;
}
return result;
net_nfc_client_ipc_lock();
}
-static void net_nfc_client_notify_sync_call()
+static void net_nfc_client_notify_sync_call(net_nfc_error_e result)
{
+ sync_result = result;
+
pthread_cond_signal(&g_client_ipc_cond);
net_nfc_client_ipc_unlock();
}
msg = net_nfc_client_read_response_msg(&result);
pthread_mutex_lock(&cb_lock);
- if (msg != NULL)
+ if (msg != NULL && msg->detail_message != NULL)
{
/* TODO : need to remove */
net_nfc_response_msg_t *temp = (net_nfc_response_msg_t *)(msg->detail_message);
;
if (NET_NFC_FLAGS_IS_SYNC_CALL(temp->flags))
{
+ net_nfc_error_e result;
+
net_nfc_client_recv_sync_call();
/* call a callback in IPC thread */
- net_nfc_client_dispatch_sync_response(msg);
+ result = net_nfc_client_dispatch_sync_response(msg);
/* unset sync call flag */
- net_nfc_client_notify_sync_call();
+ net_nfc_client_notify_sync_call(result);
}
else
{
}
}
-net_nfc_error_e net_nfc_client_send_reqeust(net_nfc_request_msg_t *msg, ...)
+net_nfc_error_e net_nfc_client_send_request(net_nfc_request_msg_t *msg, ...)
{
va_list list;
net_nfc_error_e result = NET_NFC_OK;
return result;
}
-net_nfc_error_e net_nfc_client_send_reqeust_sync(net_nfc_request_msg_t *msg, ...)
+net_nfc_error_e net_nfc_client_send_request_sync(net_nfc_request_msg_t *msg, ...)
{
va_list list;
net_nfc_error_e result = NET_NFC_OK;
if (result == NET_NFC_OK)
{
- result = net_nfc_client_wait_sync_call(0);
+ result = net_nfc_client_wait_sync_call(3);
}
net_nfc_client_post_sync_call();
return NET_NFC_OK;
}
-
request->service_name.length = srv_name_count;
memcpy(&request->service_name.buffer, psocket_data->service_name, request->service_name.length);
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
request.client_socket = psocket_data->client_socket;
request.trans_param = trans_param;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
pthread_mutex_unlock(&llcp_lock);
request.client_socket = psocket_data->client_socket;
request.trans_param = trans_param;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
_remove_internal_socket(psocket_data);
request->data.length = data_private->length;
memcpy(&request->data.buffer, data_private->buffer, request->data.length);
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
request.trans_param = trans_param;
request.req_length = req_length;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
pthread_mutex_unlock(&llcp_lock);
request->data.length = data_private->length;
memcpy(&request->data.buffer, data_private->buffer, request->data.length);
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
request.trans_param = trans_param;
request.req_length = req_length;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
pthread_mutex_unlock(&llcp_lock);
request.miu = psocket_data->miu;
request.rw = psocket_data->rw;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
pthread_mutex_unlock(&llcp_lock);
request->service_name.length = svc_name_length;
memcpy(&request->service_name.buffer, service_name, request->service_name.length);
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
request.trans_param = trans_param;
memcpy(&(request.config), config, sizeof(net_nfc_llcp_config_info_s));
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
request.request_type = NET_NFC_MESSAGE_GET_CURRENT_TARGET_HANDLE;
request.trans_param = trans_param;
- result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ result = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return result;
}
request.request_type = NET_NFC_MESSAGE_GET_CURRENT_TARGET_HANDLE;
request.trans_param = (void *)&response;
- result = net_nfc_client_send_reqeust_sync((net_nfc_request_msg_t *)&request, NULL);
+ result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
if (result == NET_NFC_OK)
{
*handle = (net_nfc_target_handle_h)response.handle;
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
request.request_type = NET_NFC_MESSAGE_SERVICE_SET_LAUNCH_STATE;
request.set_launch_popup = enable;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
request.request_type = NET_NFC_MESSAGE_SERVICE_CHANGE_CLIENT_STATE;
request.client_state = NET_NFC_CLIENT_ACTIVE_STATE;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
request.request_type = NET_NFC_MESSAGE_SERVICE_CHANGE_CLIENT_STATE;
request.client_state = NET_NFC_CLIENT_INACTIVE_STATE;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
req_msg.request_type = NET_NFC_MESSAGE_SERVICE_INIT;
req_msg.user_param = (uint32_t)context;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&req_msg, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&req_msg, NULL);
return ret;
}
req_msg.request_type = NET_NFC_MESSAGE_SERVICE_DEINIT;
req_msg.user_param = (uint32_t)context;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&req_msg, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&req_msg, NULL);
return ret;
}
* limitations under the License.
*/
+#include <string.h>
+#include <pthread.h>
+
#include "net_nfc_tag.h"
#include "net_nfc_typedef_private.h"
#include "net_nfc_client_ipc_private.h"
#include "net_nfc_util_ndef_message.h"
#include "net_nfc_client_nfc_private.h"
-#include <string.h>
-#include <pthread.h>
-
#ifndef NET_NFC_EXPORT_API
#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
#endif
memcpy(&request->key.buffer, struct_key->buffer, request->key.length);
}
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
request->trans_param = trans_param;
request->info.dev_type = (uint32_t)target_info->devType;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
request.handle = (net_nfc_target_handle_s *)handle;
request.trans_param = trans_param;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
return result;
}
- result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ result = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
request.request_type = NET_NFC_MESSAGE_IS_TAG_CONNECTED;
request.trans_param = trans_param;
- result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ result = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return result;
}
request.request_type = NET_NFC_MESSAGE_IS_TAG_CONNECTED;
request.trans_param = (void *)&context;
- result = net_nfc_client_send_reqeust_sync((net_nfc_request_msg_t *)&request, NULL);
+ result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
if (result == NET_NFC_OK)
{
*dev_type = context.devType;
- result = context.result;
}
return result;
tmp_client_context = net_nfc_get_client_context();
if (tmp_client_context != NULL)
{
-
target_info = tmp_client_context->target_info;
if (target_info != NULL)
request.handle = (net_nfc_target_handle_s *)handle;
request.trans_param = trans_param;
- result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ result = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return result;
}
request.request_type = NET_NFC_MESSAGE_GET_CURRENT_TAG_INFO;
request.trans_param = trans_param;
- result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ result = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return result;
}
request.request_type = NET_NFC_MESSAGE_GET_CURRENT_TAG_INFO;
request.trans_param = (void *)&response;
- result = net_nfc_client_send_reqeust_sync((net_nfc_request_msg_t *)&request, NULL);
+ result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
if (result == NET_NFC_OK)
{
- result = response.result;
- if (response.result == NET_NFC_OK)
- {
- /* already allocated memory */
- *info = (net_nfc_target_info_h)response.trans_param;
- }
+ /* already allocated memory */
+ *info = (net_nfc_target_info_h)response.trans_param;
}
return result;
request.length = sizeof(net_nfc_request_test_t);
request.request_type = NET_NFC_MESSAGE_SIM_TEST;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
request.rate = rate;
request.tech = tech;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
request.length = sizeof(net_nfc_request_msg_t);
request.request_type = NET_NFC_MESSAGE_GET_FIRMWARE_VERSION;
- ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+ ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
return ret;
}
request->data.length = len;
memcpy(request->data.buffer, data, len);
- result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+ result = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
_net_nfc_util_free_mem(request);
typedef bool (*net_nfc_oem_controller_deinit)(void);
typedef bool (*net_nfc_oem_controller_register_listener)(target_detection_listener_cb target_detection_listener, se_transaction_listener_cb se_transaction_listener, llcp_event_listener_cb llcp_event_listener, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_unregister_listener)(void);
+typedef bool (*net_nfc_oem_controller_support_nfc)(net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_get_firmware_version)(data_s **data, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_check_firmware_version)(net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_update_firmware)(net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_get_stack_information)(net_nfc_stack_information_s *stack_info, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_configure_discovery)(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e *result);
-typedef bool (*net_nfc_oem_controller_get_secure_element_list)(net_nfc_secure_element_info_s *list, int* count, net_nfc_error_e *result);
-typedef bool (*net_nfc_oem_controller_set_secure_element_mode)(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e *result);
-typedef bool (*net_nfc_oem_controller_check_target_presence)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_exception_handler)(void);
+
+/* tag api */
typedef bool (*net_nfc_oem_controller_connect)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_disconnect)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_check_target_presence)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_check_ndef)(net_nfc_target_handle_s *handle, uint8_t *ndef_card_state, int *max_data_size, int *real_data_size, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_read_ndef)(net_nfc_target_handle_s *handle, data_s **data, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_write_ndef)(net_nfc_target_handle_s *handle, data_s *data, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_make_read_only_ndef)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_format_ndef)(net_nfc_target_handle_s *handle, data_s *secure_key, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_transceive)(net_nfc_target_handle_s *handle, net_nfc_transceive_info_s *info, data_s **data, net_nfc_error_e *result);
-typedef bool (*net_nfc_oem_controller_exception_handler)(void);
typedef bool (*net_nfc_oem_controller_is_ready)(net_nfc_error_e *result);
-// LLCP API DEFINE
-
+/* llcp api */
typedef bool (*net_nfc_oem_controller_llcp_config)(net_nfc_llcp_config_info_s *config, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_llcp_check_llcp)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_llcp_activate_llcp)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_llcp_get_remote_config)(net_nfc_target_handle_s *handle, net_nfc_llcp_config_info_s *config, net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_llcp_get_remote_socket_info)(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_llcp_socket_option_s *option, net_nfc_error_e *result);
+/* secure element api */
+typedef bool (*net_nfc_oem_controller_get_secure_element_list)(net_nfc_secure_element_info_s *list, int* count, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_set_secure_element_mode)(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_secure_element_open)(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s **handle, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_secure_element_get_atr)(net_nfc_target_handle_s *handle, data_s **atr, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_secure_element_send_apdu)(net_nfc_target_handle_s *handle, data_s *command, data_s **response, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_secure_element_close)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
+
+/* test api */
typedef bool (*net_nfc_oem_controller_sim_test)(net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_prbs_test)(net_nfc_error_e *result , int tech , int rate);
-
typedef bool (*net_nfc_oem_controller_test_mode_on)(net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_test_mode_off)(net_nfc_error_e *result);
-
-typedef bool (*net_nfc_oem_controller_support_nfc)(net_nfc_error_e *result);
typedef bool (*net_nfc_oem_controller_eedata_register_set)(net_nfc_error_e *result , uint32_t mode , uint32_t reg_id , data_s *data);
typedef struct _net_nfc_oem_interface_s
net_nfc_oem_controller_support_nfc support_nfc;
net_nfc_oem_controller_eedata_register_set eedata_register_set;
+ net_nfc_oem_controller_secure_element_open secure_element_open;
+ net_nfc_oem_controller_secure_element_get_atr secure_element_get_atr;
+ net_nfc_oem_controller_secure_element_send_apdu secure_element_send_apdu;
+ net_nfc_oem_controller_secure_element_close secure_element_close;
} net_nfc_oem_interface_s;
#endif
NET_NFC_MESSAGE_OPEN_INTERNAL_SE,
NET_NFC_MESSAGE_CLOSE_INTERNAL_SE,
NET_NFC_MESSAGE_SEND_APDU_SE,
+ NET_NFC_MESSAGE_GET_ATR_SE,
NET_NFC_GET_SERVER_STATE,
NET_NFC_MESSAGE_SIM_TEST,
NET_NFC_NPP,
} llcp_app_protocol_e;
-typedef struct data_s *data_h;
+typedef struct _data_s *data_h;
-typedef struct ndef_record_s *ndef_record_h;
+typedef struct _ndef_record_s *ndef_record_h;
-typedef struct ndef_message_s *ndef_message_h;
+typedef struct _ndef_message_s *ndef_message_h;
-typedef struct net_nfc_target_info_s *net_nfc_target_info_h;
+typedef struct _net_nfc_target_info_s *net_nfc_target_info_h;
typedef uint32_t net_nfc_traceive_cmd;
-typedef struct net_nfc_llcp_config_info_s *net_nfc_llcp_config_info_h;
+typedef struct _net_nfc_llcp_config_info_s *net_nfc_llcp_config_info_h;
-typedef struct net_nfc_llcp_socket_option_s *net_nfc_llcp_socket_option_h;
+typedef struct _net_nfc_llcp_socket_option_s *net_nfc_llcp_socket_option_h;
-typedef struct net_nfc_target_handle_s *net_nfc_target_handle_h;
+typedef struct _net_nfc_target_handle_s *net_nfc_target_handle_h;
-typedef struct net_nfc_connection_handover_info_s *net_nfc_connection_handover_info_h;
+typedef struct _net_nfc_connection_handover_info_s *net_nfc_connection_handover_info_h;
typedef uint8_t sap_t;
NET_NFC_EXCHANGER_RAW,
} net_nfc_exchanger_data_type_e;
-typedef struct net_nfc_exchanger_data_s *net_nfc_exchanger_data_h;
+typedef struct _net_nfc_exchanger_data_s *net_nfc_exchanger_data_h;
typedef net_nfc_exchanger_data_h (*net_nfc_exchanger_cb)(net_nfc_exchanger_event_e event, void *user_param);
NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN_STATUS,
} net_nfc_conn_handover_carrier_state_e;
-typedef struct net_nfc_conn_handover_carrier_info_s *net_nfc_conn_handover_carrier_info_h;
-typedef struct net_nfc_conn_handover_info_s *net_nfc_conn_handover_info_h;
+typedef struct _net_nfc_conn_handover_carrier_info_s *net_nfc_conn_handover_carrier_info_h;
+typedef struct _net_nfc_conn_handover_info_s *net_nfc_conn_handover_info_h;
#define MIFARE_KEY_DEFAULT {(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF}
#define MIFARE_KEY_APPLICATION_DIRECTORY {(uint8_t)0xA0,(uint8_t)0xA1,(uint8_t)0xA2,(uint8_t)0xA3,(uint8_t)0xA4,(uint8_t)0xA5}
NET_NFC_BT_ATTRIBUTE_ADDRESS = 0xF0, /* Bluetooth device Address */
} net_nfc_handover_bt_attribute_e;
-typedef struct net_nfc_carrier_config_s *net_nfc_carrier_config_h;
-typedef struct net_nfc_carrier_property_s *net_nfc_property_group_h;
+typedef struct _net_nfc_carrier_config_s *net_nfc_carrier_config_h;
+typedef struct _net_nfc_carrier_property_s *net_nfc_property_group_h;
typedef enum
{
/*
- * Copyright (C) 2010 NXP Semiconductors
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
+ * Copyright (C) 2010 NXP Semiconductors
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __NET_NFC_INTERNAL_TYPEDEF_H__
#define __NET_NFC_INTERNAL_TYPEDEF_H__
#include "net_nfc_typedef.h"
-
typedef enum
{
NET_NFC_POLL_START = 0x01,
{
uint32_t connection_id;
net_nfc_connection_type_e connection_type;
+ net_nfc_target_type_e target_type;
/*++npp++*/
llcp_app_protocol_e app_type;
/*--npp--*/
net_nfc_data_s data;
} net_nfc_request_send_apdu_t;
+typedef struct _net_nfc_request_get_atr_t
+{
+ NET_NFC_REQUEST_MSG_HEADER
+
+ net_nfc_target_handle_s *handle;
+} net_nfc_request_get_atr_t;
+
typedef struct _net_nfc_request_connection_handover_t
{
NET_NFC_REQUEST_MSG_HEADER
void *trans_param;
} net_nfc_response_send_apdu_t;
+typedef struct _net_nfc_response_get_atr_t
+{
+ NET_NFC_RESPONSE_MSG_HEADER
+
+ data_s data;
+} net_nfc_response_get_atr_t;
+
typedef struct _net_nfc_response_get_server_state_t
{
NET_NFC_RESPONSE_MSG_HEADER
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
INCLUDE(FindPkgConfig)
-pkg_check_modules(manager_pkges REQUIRED aul glib-2.0 gobject-2.0 security-server dbus-glib-1 vconf dlog tapi appsvc libcurl bluetooth-api heynoti smartcard-service smartcard-service-common libssl pmapi svi capi-media-wav-player pkgmgr)
+pkg_check_modules(manager_pkges REQUIRED aul glib-2.0 gobject-2.0 security-server dbus-glib-1 vconf dlog tapi appsvc libcurl bluetooth-api heynoti smartcard-service smartcard-service-common libssl pmapi svi capi-media-wav-player pkgmgr pkgmgr-info)
FOREACH(flag ${manager_pkges_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
#include "net_nfc_typedef.h"
#include "net_nfc_typedef_private.h"
+/* common api */
void* net_nfc_controller_onload(void);
bool net_nfc_controller_unload(void* handle);
bool net_nfc_controller_init (net_nfc_error_e* result);
bool net_nfc_controller_update_firmware(net_nfc_error_e* result);
bool net_nfc_controller_get_stack_information(net_nfc_stack_information_s* stack_info, net_nfc_error_e* result);
bool net_nfc_controller_confiure_discovery (net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e* result);
-bool net_nfc_controller_get_secure_element_list(net_nfc_secure_element_info_s* list, int* count, net_nfc_error_e* result);
-bool net_nfc_controller_set_secure_element_mode(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e* result);
bool net_nfc_controller_check_target_presence(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
bool net_nfc_controller_connect(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
bool net_nfc_controller_disconnect(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
bool net_nfc_controller_exception_handler(void);
bool net_nfc_controller_is_ready(net_nfc_error_e* result);
-// LLCP API DEFINE
-
+/* llcp api */
bool net_nfc_controller_llcp_config(net_nfc_llcp_config_info_s * config, net_nfc_error_e * result);
bool net_nfc_controller_llcp_check_llcp(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
bool net_nfc_controller_llcp_activate_llcp(net_nfc_target_handle_s * handle, net_nfc_error_e* result);
bool net_nfc_controller_llcp_get_remote_config (net_nfc_target_handle_s* handle, net_nfc_llcp_config_info_s *config, net_nfc_error_e* result);
bool net_nfc_controller_llcp_get_remote_socket_info (net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, net_nfc_llcp_socket_option_s * option, net_nfc_error_e* result);
+/* secure element api */
+bool net_nfc_controller_secure_element_open(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s **handle, net_nfc_error_e *result);
+bool net_nfc_controller_secure_element_get_atr(net_nfc_target_handle_s *handle, data_s **atr, net_nfc_error_e *result);
+bool net_nfc_controller_secure_element_send_apdu(net_nfc_target_handle_s *handle, data_s *command, data_s **response, net_nfc_error_e *result);
+bool net_nfc_controller_secure_element_close(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
+bool net_nfc_controller_get_secure_element_list(net_nfc_secure_element_info_s* list, int* count, net_nfc_error_e* result);
+bool net_nfc_controller_set_secure_element_mode(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e* result);
-
-// LLCP API DEFINE
-
+/* test api */
bool net_nfc_controller_sim_test(net_nfc_error_e* result);
bool net_nfc_controller_prbs_test(net_nfc_error_e* result , uint32_t tech , uint32_t rate);
/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __NET_NFC_SERVER_DISPATCHER__
#define __NET_NFC_SERVER_DISPATCHER__
#include "net_nfc_typedef_private.h"
-void net_nfc_dispatcher_queue_push(net_nfc_request_msg_t* req_msg);
+void net_nfc_dispatcher_queue_push(net_nfc_request_msg_t *req_msg);
bool net_nfc_dispatcher_start_thread();
void net_nfc_dispatcher_cleanup_queue(void);
void net_nfc_dispatcher_put_cleaner(void);
-
#endif
-
/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef NET_NFC_SERVICE_LLCP_PRIVATE_H
#define NET_NFC_SERVICE_LLCP_PRIVATE_H
/* Service Name should be followed naming rule. */
// service access name
-#define SDP_SAN "urn:nfc:sn:sdp"
-#define IP_SAN "urn:nfc:sn:ip"
-#define SNEP_SAN "urn:nfc:sn:snep"
-#define OBEX_SAN "urn:nfc:sn:obex"
+#define SDP_SAN "urn:nfc:sn:sdp"
+#define IP_SAN "urn:nfc:sn:ip"
+#define SNEP_SAN "urn:nfc:sn:snep"
+#define OBEX_SAN "urn:nfc:sn:obex"
#define CONN_HANDOVER_SAN "urn:nfc:sn:handover"
-#define NPP_SAN "com.android.npp"
-#define NPP_SAP 0x10
-
-#define SDP_SAP 1 /* service discovery protocol service access point */
-#define IP_SAP 2 /* Internet protocol service access point */
-#define OBEX_SAP 3 /* ojbect exchange service access point */
-#define SNEP_SAP 4 /* simple ndef exchange protocol service access point */
+#define NPP_SAN "com.android.npp"
+#define NPP_SAP 0x10
-#define CONN_HANDOVER_SAP 5 /* connection handover service access point */
+#define SDP_SAP 1 /* service discovery protocol service access point */
+#define IP_SAP 2 /* Internet protocol service access point */
+#define OBEX_SAP 3 /* ojbect exchange service access point */
+#define SNEP_SAP 4 /* simple ndef exchange protocol service access point */
-#define SNEP_MAJOR_VER 1
-#define SNEP_MINOR_VER 0
+#define CONN_HANDOVER_SAP 5 /* connection handover service access point */
+#define SNEP_MAJOR_VER 1
+#define SNEP_MINOR_VER 0
-#define NPP_MAJOR_VER 0
-#define NPP_MINOR_VER 1
+#define NPP_MAJOR_VER 0
+#define NPP_MINOR_VER 1
-#define NPP_NDEF_ENTRY 0x00000001
+#define NPP_NDEF_ENTRY 0x00000001
-#define NPP_ACTION_CODE 0x01
+#define NPP_ACTION_CODE 0x01
-#define SNEP_MAX_BUFFER 128 /* simple NDEF exchange protocol */
-#define CH_MAX_BUFFER 128 /* connection handover */
+#define SNEP_MAX_BUFFER 128 /* simple NDEF exchange protocol */
+#define CH_MAX_BUFFER 128 /* connection handover */
typedef enum{
NPP_REQ_CONTINUE = 0x00,
} __attribute__((packed))net_nfc_llcp_npp_t;
#define NET_NFC_COMMON_HANDOVER_CONTEXT unsigned int step;\
- net_nfc_llcp_state_t *llcp_state;\
- void *user_data;\
- net_nfc_error_e result;\
- net_nfc_conn_handover_carrier_type_e request_type;\
- void *data;\
- bool is_requester;
+ net_nfc_llcp_state_t *llcp_state;\
+ void *user_data;\
+ net_nfc_error_e result;\
+ net_nfc_conn_handover_carrier_type_e request_type;\
+ void *data;\
+ bool is_requester;
typedef struct _net_nfc_handover_context_t
{
/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef NET_NFC_SERVICE_PRIVATE_H
void net_nfc_service_msg_processing(data_s* data);
+void net_nfc_service_is_tag_connected(net_nfc_request_msg_t *msg);
+void net_nfc_service_get_current_tag_info(net_nfc_request_msg_t *msg);
+void net_nfc_service_get_current_target_handle(net_nfc_request_msg_t *msg);
+void net_nfc_service_init(net_nfc_request_msg_t *msg);
+void net_nfc_service_deinit(net_nfc_request_msg_t *msg);
+
+void net_nfc_service_restart_polling(net_nfc_request_msg_t *msg);
+void net_nfc_service_get_server_state(net_nfc_request_msg_t *msg);
+
#endif
bool net_nfc_service_transfer_apdu(int client_fd, data_s *apdu, void *trans_param);
bool net_nfc_service_request_atr(int client_fd, void *trans_param);
bool net_nfc_service_se_transaction_receive(net_nfc_request_msg_t* msg);
+void net_nfc_service_se_send_apdu(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_get_atr(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_close_se(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_open_se(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_set_se(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_get_se(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_cleanup();
#endif
/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef NET_NFC_SERVICE_TAG_PRIVATE_H
void net_nfc_service_clean_tag_context(net_nfc_request_target_detected_t* stand_alone, net_nfc_error_e result);
void net_nfc_service_watch_dog(net_nfc_request_msg_t* req_msg);
+void net_nfc_service_tag_make_readonly(net_nfc_request_msg_t *msg);
+void net_nfc_service_tag_read_ndef(net_nfc_request_msg_t *msg);
+void net_nfc_service_tag_write_ndef(net_nfc_request_msg_t *msg);
+void net_nfc_service_tag_format_ndef(net_nfc_request_msg_t *msg);
+
#endif
--- /dev/null
+/*
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NET_NFC_SERVICE_TEST_PRIVATE_H
+#define NET_NFC_SERVICE_TEST_PRIVATE_H
+
+#include "net_nfc_typedef_private.h"
+
+void net_nfc_service_test_sim_test(net_nfc_request_msg_t *msg);
+void net_nfc_service_test_get_firmware_version(net_nfc_request_msg_t *msg);
+void net_nfc_service_test_prbs_test(net_nfc_request_msg_t *msg);
+void net_nfc_service_test_set_eedata(net_nfc_request_msg_t *msg);
+
+#endif
}
}
+bool net_nfc_controller_secure_element_open(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s **handle, net_nfc_error_e *result)
+{
+ int ret_val = 0;
+
+ ret_val = pm_lock_state(LCD_NORMAL, GOTO_STATE_NOW, 0);
+
+ if (g_interface.secure_element_open != NULL)
+ {
+ return g_interface.secure_element_open(element_type, handle, result);
+ }
+ else
+ {
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
+ DEBUG_SERVER_MSG("interface is null");
+ return false;
+ }
+}
+
+bool net_nfc_controller_secure_element_get_atr(net_nfc_target_handle_s *handle, data_s **atr, net_nfc_error_e *result)
+{
+ if (g_interface.secure_element_get_atr != NULL)
+ {
+ return g_interface.secure_element_get_atr(handle, atr, result);
+ }
+ else
+ {
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
+ DEBUG_SERVER_MSG("interface is null");
+ return false;
+ }
+}
+
+bool net_nfc_controller_secure_element_send_apdu(net_nfc_target_handle_s *handle, data_s *command, data_s **response, net_nfc_error_e *result)
+{
+ if (g_interface.secure_element_send_apdu != NULL)
+ {
+ return g_interface.secure_element_send_apdu(handle, command, response, result);
+ }
+ else
+ {
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
+ DEBUG_SERVER_MSG("interface is null");
+ return false;
+ }
+}
+
+bool net_nfc_controller_secure_element_close(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
+{
+ int ret_val = 0;
+
+ ret_val = pm_unlock_state(LCD_NORMAL, PM_RESET_TIMER);
+
+ if (g_interface.secure_element_close != NULL)
+ {
+ return g_interface.secure_element_close(handle, result);
+ }
+ else
+ {
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
+ DEBUG_SERVER_MSG("interface is null");
+ return false;
+ }
+}
+
bool net_nfc_controller_check_target_presence(net_nfc_target_handle_s* handle, net_nfc_error_e* result)
{
if (g_interface.check_presence != NULL)
#include <string.h>
#include <unistd.h>
#include <pthread.h>
-#include <stdarg.h>
#include <glib.h>
#include "vconf.h"
#include "net_nfc_service_llcp_private.h"
#include "net_nfc_service_llcp_handover_private.h"
#include "net_nfc_service_tag_private.h"
-#include "net_nfc_manager_util_private.h"
#include "net_nfc_service_se_private.h"
+#include "net_nfc_service_test_private.h"
+#include "net_nfc_manager_util_private.h"
#include "net_nfc_util_access_control_private.h"
#include "net_nfc_server_context_private.h"
static pthread_mutex_t g_dispatcher_queue_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_t g_dispatcher_thread;
-static uint8_t g_se_prev_type = SECURE_ELEMENT_TYPE_INVALID;
-static uint8_t g_se_prev_mode = SECURE_ELEMENT_OFF_MODE;
-
static void *_net_nfc_dispatcher_thread_func(void *data);
static net_nfc_request_msg_t *_net_nfc_dispatcher_queue_pop();
while ((req_msg = _net_nfc_dispatcher_queue_pop()) != NULL)
{
- DEBUG_MSG("abandon request : %d", req_msg->request_type);
+ DEBUG_ERR_MSG("abandon request : %d", req_msg->request_type);
_net_nfc_util_free_mem(req_msg);
}
static void *_net_nfc_dispatcher_thread_func(void *data)
{
- net_nfc_request_msg_t *req_msg = NULL;
+ net_nfc_request_msg_t *req_msg;
DEBUG_SERVER_MSG("net_nfc_controller_thread is created ");
{
case NET_NFC_MESSAGE_SERVICE_CLEANER :
{
- DEBUG_SERVER_MSG("client is terminated abnormally");
-
- if (g_se_prev_type == SECURE_ELEMENT_TYPE_ESE)
- {
- net_nfc_error_e result = NET_NFC_OK;
- net_nfc_target_handle_s *ese_handle = net_nfc_service_se_get_current_ese_handle();
-
- if (ese_handle != NULL)
- {
- DEBUG_SERVER_MSG("ese_handle was not freed and disconnected");
-
- net_nfc_service_se_close_ese();
-#ifdef BROADCAST_MESSAGE
- net_nfc_server_set_server_state(NET_NFC_SERVER_IDLE);
-#endif
- }
-
- if ((g_se_prev_type != net_nfc_service_se_get_se_type()) || (g_se_prev_mode != net_nfc_service_se_get_se_mode()))
- {
- net_nfc_controller_set_secure_element_mode(g_se_prev_type, g_se_prev_mode, &result);
-
- net_nfc_service_se_set_se_type(g_se_prev_type);
- net_nfc_service_se_set_se_mode(g_se_prev_mode);
- }
- }
- else if (g_se_prev_type == SECURE_ELEMENT_TYPE_UICC)
- {
- net_nfc_service_tapi_deinit();
- }
- else
- {
- DEBUG_SERVER_MSG("SE type is not valid");
- }
+ net_nfc_service_se_cleanup();
}
break;
case NET_NFC_MESSAGE_SEND_APDU_SE :
{
- net_nfc_request_send_apdu_t *detail = (net_nfc_request_send_apdu_t *)req_msg;
-
- if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
- {
- data_s apdu_data = { NULL, 0 };
-
- if (net_nfc_util_duplicate_data(&apdu_data, &detail->data) == false)
- break;
-
- net_nfc_service_transfer_apdu(req_msg->client_fd, &apdu_data, detail->trans_param);
-
- net_nfc_util_free_data(&apdu_data);
- }
- else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
- {
- data_s *data = NULL;
- net_nfc_error_e result = NET_NFC_OK;
- net_nfc_transceive_info_s info;
- bool success = true;
-
- info.dev_type = NET_NFC_ISO14443_A_PICC;
- if (net_nfc_util_duplicate_data(&info.trans_data, &detail->data) == false)
- {
- DEBUG_ERR_MSG("alloc failed");
- break;
- }
-
- if ((success = net_nfc_controller_transceive(detail->handle, &info, &data, &result)) == true)
- {
- if (data != NULL)
- {
- DEBUG_SERVER_MSG("trasceive data recieved [%d], Success = %d", data->length, success);
- }
- }
- else
- {
- DEBUG_SERVER_MSG("trasceive is failed = [%d]", result);
- }
- net_nfc_util_free_data(&info.trans_data);
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_send_apdu_t resp = { 0 };
-
- resp.length = sizeof(net_nfc_response_send_apdu_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
- resp.result = result;
-
- if (success && data != NULL)
- {
- DEBUG_MSG("send response send apdu msg");
- resp.data.length = data->length;
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_send_apdu_t),
- data->buffer, data->length, NULL);
- }
- else
- {
- DEBUG_MSG("send response send apdu msg");
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
- }
- }
- }
- else
- {
- DEBUG_SERVER_MSG("invalid se handle");
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_send_apdu_t resp = { 0 };
-
- resp.length = sizeof(net_nfc_response_send_apdu_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
- resp.result = NET_NFC_INVALID_PARAM;
+ net_nfc_service_se_send_apdu(req_msg);
+ }
+ break;
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
- }
- }
+ case NET_NFC_MESSAGE_GET_ATR_SE :
+ {
+ net_nfc_service_se_get_atr(req_msg);
}
break;
case NET_NFC_MESSAGE_CLOSE_INTERNAL_SE :
{
- net_nfc_request_close_internal_se_t *detail = (net_nfc_request_close_internal_se_t *)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
-
- if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
- {
- /*deinit TAPI*/
- DEBUG_SERVER_MSG("UICC is current secure element");
- net_nfc_service_tapi_deinit();
-
- }
- else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
- {
- result = net_nfc_service_se_close_ese();
-#ifdef BROADCAST_MESSAGE
- net_nfc_server_unset_server_state(NET_NFC_SE_CONNECTED);
-#endif
- }
- else
- {
- DEBUG_ERR_MSG("invalid se handle received handle = [0x%p] and current handle = [0x%p]", detail->handle, net_nfc_service_se_get_current_ese_handle());
- }
-
- if ((g_se_prev_type != net_nfc_service_se_get_se_type()) || (g_se_prev_mode != net_nfc_service_se_get_se_mode()))
- {
- /*return back se mode*/
- net_nfc_controller_set_secure_element_mode(g_se_prev_type, g_se_prev_mode, &result);
-
- net_nfc_service_se_set_se_type(g_se_prev_type);
- net_nfc_service_se_set_se_mode(g_se_prev_mode);
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_close_internal_se_t resp = { 0 };
-
- resp.length = sizeof(net_nfc_response_close_internal_se_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
- resp.result = result;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_close_internal_se_t), NULL);
- }
+ net_nfc_service_se_close_se(req_msg);
}
break;
case NET_NFC_MESSAGE_OPEN_INTERNAL_SE :
{
- net_nfc_request_open_internal_se_t *detail = (net_nfc_request_open_internal_se_t *)req_msg;
- net_nfc_target_handle_s *handle = NULL;
- net_nfc_error_e result = NET_NFC_OK;
-
- g_se_prev_type = net_nfc_service_se_get_se_type();
- g_se_prev_mode = net_nfc_service_se_get_se_mode();
-
- if (detail->se_type == SECURE_ELEMENT_TYPE_UICC)
- {
- /*off ESE*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
-
- /*Off UICC. UICC SHOULD not be detected by external reader when being communicated in internal process*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
-
- net_nfc_service_se_set_se_type(SECURE_ELEMENT_TYPE_UICC);
- net_nfc_service_se_set_se_mode(SECURE_ELEMENT_OFF_MODE);
-
- /*Init tapi api and return back response*/
- if (net_nfc_service_tapi_init() != true)
- {
- net_nfc_service_tapi_deinit();
- result = NET_NFC_INVALID_STATE;
- handle = NULL;
- }
- else
- {
- result = NET_NFC_OK;
- handle = (net_nfc_target_handle_s *)UICC_TARGET_HANDLE;
- }
- }
- else if (detail->se_type == SECURE_ELEMENT_TYPE_ESE)
- {
- /*Connect NFC-WI to ESE*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_WIRED_MODE, &result);
-
- /*off UICC*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
-
- net_nfc_service_se_set_se_type(SECURE_ELEMENT_TYPE_ESE);
- net_nfc_service_se_set_se_mode(SECURE_ELEMENT_WIRED_MODE);
- net_nfc_service_se_get_se_setting()->open_request_trans_param = detail->trans_param;
-
- result = NET_NFC_OK;
- handle = (net_nfc_target_handle_s *)1;
- }
- else
- {
- result = NET_NFC_INVALID_STATE;
- handle = NULL;
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_open_internal_se_t resp = { 0 };
-
- resp.length = sizeof(net_nfc_response_open_internal_se_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
- resp.result = result;
- resp.se_type = detail->se_type;
- resp.handle = handle;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_set_se_t), NULL);
- }
+ net_nfc_service_se_open_se(req_msg);
}
break;
case NET_NFC_MESSAGE_SET_SE :
{
- net_nfc_request_set_se_t *detail = (net_nfc_request_set_se_t *)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
- bool isTypeChange = false;
-
- if (detail->se_type != net_nfc_service_se_get_se_type())
- {
- result = net_nfc_service_se_change_se(detail->se_type);
- isTypeChange = true;
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_set_se_t resp = { 0 };
-
- resp.length = sizeof(net_nfc_response_set_se_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
- resp.se_type = detail->se_type;
- resp.result = result;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_set_se_t), NULL);
- }
-
- if (isTypeChange)
- {
- net_nfc_response_notify_t noti_se = { 0, };
-
- net_nfc_broadcast_response_msg(NET_NFC_MESSAGE_SE_TYPE_CHANGED, (void *)¬i_se, sizeof(net_nfc_response_notify_t), NULL);
- }
+ net_nfc_service_se_set_se(req_msg);
}
break;
case NET_NFC_MESSAGE_GET_SE :
{
- net_nfc_request_get_se_t *detail = (net_nfc_request_get_se_t *)req_msg;
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_get_se_t resp = { 0 };
-
- resp.length = sizeof(net_nfc_request_get_se_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
- resp.result = NET_NFC_OK;
- resp.se_type = net_nfc_service_se_get_se_type();
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_se_t), NULL);
- }
+ net_nfc_service_se_get_se(req_msg);
}
break;
case NET_NFC_MESSAGE_MAKE_READ_ONLY_NDEF :
{
- net_nfc_request_make_read_only_ndef_t *detail = (net_nfc_request_make_read_only_ndef_t *)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
-
- if (net_nfc_server_is_target_connected(detail->handle))
- {
- net_nfc_controller_make_read_only_ndef(detail->handle, &result);
- }
- else
- {
- result = NET_NFC_TARGET_IS_MOVED_AWAY;
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_make_read_only_ndef_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_make_read_only_ndef_t);
- resp.flags = detail->flags;
- resp.result = result;
- resp.trans_param = detail->trans_param;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
- }
+ net_nfc_service_tag_make_readonly(req_msg);
}
break;
case NET_NFC_MESSAGE_IS_TAG_CONNECTED :
{
- net_nfc_request_is_tag_connected_t *detail = (net_nfc_request_is_tag_connected_t *)req_msg;
- net_nfc_current_target_info_s* target_info = NULL;
-
- target_info = net_nfc_server_get_tag_info();
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_is_tag_connected_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_is_tag_connected_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
-
- if (target_info != NULL)
- {
- resp.result = NET_NFC_OK;
- resp.devType = target_info->devType;
- }
- else
- {
- resp.result = NET_NFC_NOT_CONNECTED;
- resp.devType = NET_NFC_UNKNOWN_TARGET;
- }
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_is_tag_connected_t), NULL);
- }
+ net_nfc_service_is_tag_connected(req_msg);
}
break;
case NET_NFC_MESSAGE_GET_CURRENT_TAG_INFO :
{
- net_nfc_response_get_current_tag_info_t resp = { 0, };
- net_nfc_request_get_current_tag_info_t *detail = (net_nfc_request_get_current_tag_info_t *)req_msg;
- net_nfc_current_target_info_s *target_info = NULL;
- net_nfc_error_e result = NET_NFC_OK;
-
- resp.length = sizeof(net_nfc_response_get_current_tag_info_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
-
- target_info = net_nfc_server_get_tag_info();
-
- if (target_info != NULL)
- {
- bool success = true;
- data_s* recv_data = NULL;
-
- if (target_info->devType != NET_NFC_NFCIP1_TARGET && target_info->devType != NET_NFC_NFCIP1_INITIATOR)
- {
-#ifdef BROADCAST_MESSAGE
- net_nfc_server_set_server_state(NET_NFC_TAG_CONNECTED);
-#endif
- DEBUG_SERVER_MSG("tag is connected");
-
- uint8_t ndef_card_state = 0;
- int max_data_size = 0;
- int real_data_size = 0;
-
- if (net_nfc_controller_check_ndef(target_info->handle, &ndef_card_state, &max_data_size, &real_data_size, &result) == true)
- {
- resp.ndefCardState = ndef_card_state;
- resp.maxDataSize = max_data_size;
- resp.actualDataSize = real_data_size;
- resp.is_ndef_supported = 1;
- }
-
- resp.devType = target_info->devType;
- resp.handle = target_info->handle;
- resp.number_of_keys = target_info->number_of_keys;
-
- net_nfc_util_duplicate_data(&resp.target_info_values, &target_info->target_info_values);
-
- if (resp.is_ndef_supported)
- {
- if (net_nfc_controller_read_ndef(target_info->handle, &recv_data, &(resp.result)) == true)
- {
- DEBUG_SERVER_MSG("net_nfc_controller_read_ndef is success");
-
- resp.raw_data.length = recv_data->length;
-
- success = net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
- (void *)(resp.target_info_values.buffer), resp.target_info_values.length,
- (void *)(recv_data->buffer), recv_data->length, NULL);
- }
- else
- {
- DEBUG_SERVER_MSG("net_nfc_controller_read_ndef is fail");
-
- resp.raw_data.length = 0;
-
- success = net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
- (void *)(resp.target_info_values.buffer), resp.target_info_values.length, NULL);
- }
- }
- else
- {
- resp.raw_data.length = 0;
-
- success = net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
- (void *)(resp.target_info_values.buffer), resp.target_info_values.length, NULL);
- }
-
- net_nfc_util_free_data(&resp.target_info_values);
- }
- }
- else
- {
- resp.result = NET_NFC_NOT_CONNECTED;
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t), NULL);
- }
+ net_nfc_service_get_current_tag_info(req_msg);
}
break;
case NET_NFC_MESSAGE_GET_CURRENT_TARGET_HANDLE :
{
- net_nfc_request_get_current_target_handle_t *detail = (net_nfc_request_get_current_target_handle_t *)req_msg;
- net_nfc_current_target_info_s *target_info = NULL;
-
- target_info = net_nfc_server_get_tag_info();
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_get_current_target_handle_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_get_current_target_handle_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
-
- if (target_info != NULL)
- {
- resp.handle = target_info->handle;
- resp.devType = target_info->devType;
- resp.result = NET_NFC_OK;
- }
- else
- {
- resp.result = NET_NFC_NOT_CONNECTED;
- }
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_target_handle_t), NULL);
- }
+ net_nfc_service_get_current_target_handle(req_msg);
}
break;
case NET_NFC_GET_SERVER_STATE :
{
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_get_server_state_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_get_server_state_t);
- resp.flags = req_msg->flags;
- resp.state = net_nfc_server_get_server_state();
- resp.result = NET_NFC_OK;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_server_state_t), NULL);
- }
+ net_nfc_service_get_server_state(req_msg);
}
break;
case NET_NFC_MESSAGE_READ_NDEF :
{
- net_nfc_request_read_ndef_t *detail = (net_nfc_request_read_ndef_t*)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
- data_s *data = NULL;
- bool success = false;
-
- if (net_nfc_server_is_target_connected(detail->handle))
- {
- success = net_nfc_controller_read_ndef(detail->handle, &data, &result);
- }
- else
- {
- result = NET_NFC_TARGET_IS_MOVED_AWAY;
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_read_ndef_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_read_ndef_t);
- resp.flags = detail->flags;
- resp.result = result;
- resp.trans_param = detail->trans_param;
-
- if (success)
- {
- resp.data.length = data->length;
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_read_ndef_t),
- data->buffer, data->length, NULL);
- }
- else
- {
- resp.data.length = 0;
- resp.data.buffer = NULL;
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_read_ndef_t), NULL);
- }
- }
-
- if (data != NULL)
- {
- net_nfc_util_free_data(data);
- _net_nfc_util_free_mem(data);
- }
+ net_nfc_service_tag_read_ndef(req_msg);
}
break;
case NET_NFC_MESSAGE_WRITE_NDEF :
{
- net_nfc_request_write_ndef_t *detail = (net_nfc_request_write_ndef_t *)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
-
- if (net_nfc_server_is_target_connected(detail->handle))
- {
- data_s data = { NULL, 0 };
-
- if (net_nfc_util_duplicate_data(&data, &detail->data) == true)
- {
- net_nfc_controller_write_ndef(detail->handle, &data, &result);
-
- net_nfc_util_free_data(&data);
- }
- else
- {
- result = NET_NFC_ALLOC_FAIL;
- }
- }
- else
- {
- result = NET_NFC_TARGET_IS_MOVED_AWAY;
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_write_ndef_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_write_ndef_t);
- resp.flags = detail->flags;
- resp.result = result;
- resp.trans_param = detail->trans_param;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
- }
+ net_nfc_service_tag_write_ndef(req_msg);
}
break;
case NET_NFC_MESSAGE_FORMAT_NDEF :
{
- net_nfc_request_format_ndef_t *detail = (net_nfc_request_format_ndef_t *)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
-
- if (net_nfc_server_is_target_connected(detail->handle))
- {
- data_s data = { NULL, 0 };
-
- if (net_nfc_util_duplicate_data(&data, &detail->key) == true)
- {
- net_nfc_controller_format_ndef(detail->handle, &data, &result);
- net_nfc_util_free_data(&data);
- }
- else
- {
- result = NET_NFC_ALLOC_FAIL;
- }
- }
- else
- {
- result = NET_NFC_TARGET_IS_MOVED_AWAY;
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_format_ndef_t resp = { 0 };
-
- resp.length = sizeof(net_nfc_response_format_ndef_t);
- resp.flags = detail->flags;
- resp.result = result;
- resp.trans_param = detail->trans_param;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_format_ndef_t), NULL);
- }
+ net_nfc_service_tag_format_ndef(req_msg);
}
break;
case NET_NFC_MESSAGE_SIM_TEST :
{
- net_nfc_request_test_t *detail = (net_nfc_request_test_t *)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
-
- if (net_nfc_controller_sim_test(&result) == true)
- {
- DEBUG_SERVER_MSG("net_nfc_controller_sim_test Result [SUCCESS]");
- }
- else
- {
- DEBUG_SERVER_MSG("net_nfc_controller_sim_test Result [ERROR1]");
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_test_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_test_t);
- resp.flags = detail->flags;
- resp.result = result;
- resp.trans_param = detail->trans_param;
-
- DEBUG_SERVER_MSG("SEND RESPONSE!!");
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
- }
+ net_nfc_service_test_sim_test(req_msg);
}
break;
case NET_NFC_MESSAGE_GET_FIRMWARE_VERSION :
{
- net_nfc_error_e result = NET_NFC_OK;
- data_s *data = NULL;
-
- if (net_nfc_controller_get_firmware_version(&data, &result) == true)
- {
- DEBUG_SERVER_MSG("net_nfc_controller_update_firmware Result [SUCCESS]");
-
- }
- else
- {
- DEBUG_ERR_MSG("net_nfc_controller_update_firmware Result [ERROR3]");
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_firmware_version_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_firmware_version_t);
- resp.flags = req_msg->flags;
- resp.result = result;
- resp.data.length = data->length;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_firmware_version_t), (void *)data->buffer, resp.data.length, NULL);
- }
-
- net_nfc_util_free_data(data);
+ net_nfc_service_test_get_firmware_version(req_msg);
}
break;
case NET_NFC_MESSAGE_PRBS_TEST :
{
- net_nfc_request_test_t *detail = (net_nfc_request_test_t *)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
- uint32_t local_tech = 0;
- uint32_t local_rate = 0;
-
- local_tech = detail->tech;
- local_rate = detail->rate;
-
- DEBUG_SERVER_MSG("NET_NFC_MESSAGE_PRBS_TEST local_tech [%d]\n", local_tech);
- DEBUG_SERVER_MSG("NET_NFC_MESSAGE_PRBS_TEST local_rate [%d]\n", local_rate);
-
- if (net_nfc_controller_prbs_test(&result, local_tech, local_rate) == true)
- {
- DEBUG_SERVER_MSG("net_nfc_controller_prbs_test Result [SUCCESS]");
- }
- else
- {
- DEBUG_ERR_MSG("net_nfc_controller_prbs_test Result [ERROR3]");
- }
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_test_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_test_t);
- resp.flags = detail->flags;
- resp.result = result;
- resp.trans_param = detail->trans_param;
-
- DEBUG_SERVER_MSG("SEND RESPONSE!!");
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
- }
+ net_nfc_service_test_prbs_test(req_msg);
}
break;
case NET_NFC_MESSAGE_SET_EEDATA :
{
- net_nfc_request_eedata_register_t *detail = (net_nfc_request_eedata_register_t *)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
- uint32_t local_mode = 0;
- uint32_t local_reg_id = 0;
- data_s data = { NULL, 0 };
-
- local_mode = detail->mode;
- local_reg_id = detail->reg_id;
-
- DEBUG_SERVER_MSG("NET_NFC_MESSAGE_SET_EEDATA local_mode [%d]\n", local_mode);
- DEBUG_SERVER_MSG("NET_NFC_MESSAGE_SET_EEDATA local_reg_id [%d]\n", local_reg_id);
-
- if (net_nfc_util_duplicate_data(&data, &detail->data) == true)
- {
- if (net_nfc_controller_eedata_register_set(&result, local_mode, local_reg_id, &data) == true)
- {
- DEBUG_SERVER_MSG("net_nfc_controller_eedata_register_set Result [SUCCESS]");
- }
- else
- {
- DEBUG_ERR_MSG("net_nfc_controller_eedata_register_set Result [ERROR3]");
- }
- net_nfc_util_free_data(&data);
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_test_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_test_t);
- resp.flags = detail->flags;
- resp.result = result;
- resp.trans_param = detail->trans_param;
-
- DEBUG_SERVER_MSG("SEND RESPONSE!!");
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
- }
- }
+ net_nfc_service_test_set_eedata(req_msg);
}
break;
case NET_NFC_MESSAGE_SERVICE_DEINIT :
{
- net_nfc_error_e result;
-
- result = net_nfc_service_se_change_se(SECURE_ELEMENT_TYPE_INVALID);
-
- /* release access control instance */
- net_nfc_util_access_control_release();
-
- net_nfc_server_free_current_tag_info();
-
- if (net_nfc_controller_deinit() == TRUE)
- {
- DEBUG_SERVER_MSG("net_nfc_controller_deinit success [%d]", result);
-
- /*vconf off*/
- if (vconf_set_bool(VCONFKEY_NFC_STATE, FALSE) != 0)
- {
- DEBUG_ERR_MSG("vconf_set_bool failed");
- }
-
- net_nfc_response_test_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_test_t);
- resp.flags = req_msg->flags;
- resp.result = NET_NFC_OK;
- resp.trans_param = (void *)req_msg->user_param;
-
- net_nfc_broadcast_response_msg(req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
- }
- else
- {
- DEBUG_SERVER_MSG("net_nfc_controller_deinit failed");
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_test_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_test_t);
- resp.flags = req_msg->flags;
- resp.result = NET_NFC_UNKNOWN_ERROR;
- resp.trans_param = (void *)req_msg->user_param;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
- }
- }
+ net_nfc_service_deinit(req_msg);
}
break;
case NET_NFC_MESSAGE_SERVICE_INIT :
{
- net_nfc_error_e result;
-
- if (net_nfc_controller_init(&result) == true)
- {
- net_nfc_llcp_config_info_s config = { 128, 1, 100, 0 };
-
- if (net_nfc_controller_register_listener(net_nfc_service_target_detected_cb, net_nfc_service_se_transaction_cb, net_nfc_service_llcp_event_cb, &result) == true)
- {
- DEBUG_SERVER_MSG("net_nfc_controller_register_listener Success!!");
- }
- else
- {
- DEBUG_ERR_MSG("net_nfc_controller_register_listener failed [%d]", result);
- }
-
- if (net_nfc_controller_llcp_config(&config, &result) == true)
- {
- /*We need to check the stack that supports the llcp or not.*/
- DEBUG_SERVER_MSG("llcp is enabled");
- }
- else
- {
- DEBUG_ERR_MSG("net_nfc_controller_llcp_config failed [%d]", result);
- }
-
- result = net_nfc_service_se_change_se(SECURE_ELEMENT_TYPE_UICC);
-
- if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG, NET_NFC_ALL_ENABLE, &result) == true)
- {
- DEBUG_SERVER_MSG("now, nfc is ready");
- }
- else
- {
- DEBUG_ERR_MSG("net_nfc_controller_confiure_discovery failed [%d]", result);
- }
-
- /* initialize access control instance */
- net_nfc_util_access_control_initialize();
-
- /*Send the Init Success Response Msg*/
- {
- net_nfc_response_test_t resp = { 0, };
-
- DEBUG_SERVER_MSG("net_nfc_controller_init success [%d]", result);
-
- resp.length = sizeof(net_nfc_response_test_t);
- resp.flags = req_msg->flags;
- resp.result = NET_NFC_OK;
- resp.trans_param = (void *)req_msg->user_param;
-
- /*vconf on*/
- if (vconf_set_bool(VCONFKEY_NFC_STATE, TRUE) != 0)
- {
- DEBUG_ERR_MSG("vconf_set_bool failed");
- }
-
- net_nfc_broadcast_response_msg(req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
- }
- }
- else
- {
- DEBUG_ERR_MSG("net_nfc_controller_init failed [%d]", result);
-
- if (net_nfc_server_check_client_is_running(req_msg->client_fd))
- {
- net_nfc_response_test_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_test_t);
- resp.flags = req_msg->flags;
- resp.result = result;
- resp.trans_param = (void *)req_msg->user_param;
-
- net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
- }
- }
+ net_nfc_service_init(req_msg);
}
break;
case NET_NFC_MESSAGE_SERVICE_RESTART_POLLING_LOOP :
{
- net_nfc_error_e result = NET_NFC_OK;
- int pm_state = 0;
- int set_config = 0;
- net_nfc_request_msg_t *discovery_req = (net_nfc_request_msg_t *)req_msg;
-
- pm_state = discovery_req->user_param;
-
- DEBUG_SERVER_MSG("NET_NFC_MESSAGE_SERVICE_RESTART_POLLING_LOOP PM State = [%d]", pm_state);
-
- if (pm_state == 1)
- {
- set_config = NET_NFC_ALL_ENABLE;
- }
- else if (pm_state == 3)
- {
- set_config = NET_NFC_ALL_DISABLE;
- }
- else
- {
- DEBUG_SERVER_MSG("Do not anything!!");
- }
-
- //if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_RESUME, NET_NFC_ALL_ENABLE, &result) == true)
- if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG, set_config, &result) == true)
- {
- DEBUG_SERVER_MSG("now, nfc polling loop is running again");
- }
+ net_nfc_service_restart_polling(req_msg);
}
break;
case NET_NFC_MESSAGE_SERVICE_SE :
{
- net_nfc_request_set_se_t *detail = (net_nfc_request_set_se_t *)req_msg;
- net_nfc_error_e result = NET_NFC_OK;
- int mode;
-
- mode = (int)detail->se_type;
-
- if (mode == NET_NFC_SE_CMD_UICC_ON)
- {
- /*turn on UICC*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_VIRTUAL_MODE, &result);
-
- /*turn off ESE*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
- }
- else if (mode == NET_NFC_SE_CMD_ESE_ON)
- {
- /*turn off UICC*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
-
- /*turn on ESE*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_VIRTUAL_MODE, &result);
- }
- else if (mode == NET_NFC_SE_CMD_ALL_OFF)
- {
- /*turn off both*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
-
- /*turn on ESE*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
- }
- else
- {
- /*turn off both*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_VIRTUAL_MODE, &result);
-
- /*turn on ESE*/
- net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_VIRTUAL_MODE, &result);
- }
+ net_nfc_service_se_set_se(req_msg);
}
break;
#include "vconf.h"
#ifdef SECURITY_SERVER
-#include <security-server.h>
+#include "security-server.h"
#endif
#include "net_nfc_typedef_private.h"
#include <pthread.h>
#include <malloc.h>
+#include "vconf.h"
+
#include "net_nfc_controller_private.h"
#include "net_nfc_util_private.h"
#include "net_nfc_typedef.h"
#include "net_nfc_util_ndef_message.h"
#include "net_nfc_util_ndef_record.h"
#include "net_nfc_util_access_control_private.h"
+#include "net_nfc_server_context_private.h"
/* static variable */
}
else
{
- DEBUG_ERR_MSG("net_nfc_controller_transceive is failed, [%d]", result);
+ DEBUG_ERR_MSG("net_nfc_controller_transceive is failed, [%d]", error);
}
return result;
bundle_free(kb);
}
+
+void net_nfc_service_is_tag_connected(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_is_tag_connected_t *detail = (net_nfc_request_is_tag_connected_t *)msg;
+ net_nfc_current_target_info_s *target_info;
+
+ target_info = net_nfc_server_get_tag_info();
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_is_tag_connected_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_is_tag_connected_t);
+ resp.flags = detail->flags;
+ resp.trans_param = detail->trans_param;
+
+ if (target_info != NULL)
+ {
+ resp.result = NET_NFC_OK;
+ resp.devType = target_info->devType;
+ }
+ else
+ {
+ resp.result = NET_NFC_NOT_CONNECTED;
+ resp.devType = NET_NFC_UNKNOWN_TARGET;
+ }
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_is_tag_connected_t), NULL);
+ }
+}
+
+void net_nfc_service_get_current_tag_info(net_nfc_request_msg_t *msg)
+{
+ net_nfc_response_get_current_tag_info_t resp = { 0, };
+ net_nfc_request_get_current_tag_info_t *detail = (net_nfc_request_get_current_tag_info_t *)msg;
+ net_nfc_current_target_info_s *target_info = NULL;
+ net_nfc_error_e result = NET_NFC_OK;
+
+ resp.length = sizeof(net_nfc_response_get_current_tag_info_t);
+ resp.flags = detail->flags;
+ resp.trans_param = detail->trans_param;
+
+ target_info = net_nfc_server_get_tag_info();
+ if (target_info != NULL)
+ {
+ bool success = true;
+ data_s *recv_data = NULL;
+
+ if (target_info->devType != NET_NFC_NFCIP1_TARGET && target_info->devType != NET_NFC_NFCIP1_INITIATOR)
+ {
+#ifdef BROADCAST_MESSAGE
+ net_nfc_server_set_server_state(NET_NFC_TAG_CONNECTED);
+#endif
+ DEBUG_SERVER_MSG("tag is connected");
+
+ uint8_t ndef_card_state = 0;
+ int max_data_size = 0;
+ int real_data_size = 0;
+
+ if (net_nfc_controller_check_ndef(target_info->handle,
+ &ndef_card_state, &max_data_size, &real_data_size, &result) == true)
+ {
+ resp.ndefCardState = ndef_card_state;
+ resp.maxDataSize = max_data_size;
+ resp.actualDataSize = real_data_size;
+ resp.is_ndef_supported = 1;
+ }
+
+ resp.devType = target_info->devType;
+ resp.handle = target_info->handle;
+ resp.number_of_keys = target_info->number_of_keys;
+
+ net_nfc_util_duplicate_data(&resp.target_info_values, &target_info->target_info_values);
+
+ if (resp.is_ndef_supported)
+ {
+ if (net_nfc_controller_read_ndef(target_info->handle, &recv_data, &(resp.result)) == true)
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_read_ndef is success");
+
+ resp.raw_data.length = recv_data->length;
+
+ success = net_nfc_send_response_msg(msg->client_fd, msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
+ (void *)(resp.target_info_values.buffer), resp.target_info_values.length,
+ (void *)(recv_data->buffer), recv_data->length, NULL);
+ }
+ else
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_read_ndef is fail");
+
+ resp.raw_data.length = 0;
+
+ success = net_nfc_send_response_msg(msg->client_fd, msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
+ (void *)(resp.target_info_values.buffer), resp.target_info_values.length, NULL);
+ }
+ }
+ else
+ {
+ resp.raw_data.length = 0;
+
+ success = net_nfc_send_response_msg(msg->client_fd, msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
+ (void *)(resp.target_info_values.buffer), resp.target_info_values.length, NULL);
+ }
+
+ net_nfc_util_free_data(&resp.target_info_values);
+ }
+ else
+ {
+ /* LLCP */
+ resp.result = NET_NFC_NOT_CONNECTED;
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t), NULL);
+ }
+ }
+ else
+ {
+ resp.result = NET_NFC_NOT_CONNECTED;
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t), NULL);
+ }
+}
+
+void net_nfc_service_get_current_target_handle(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_get_current_target_handle_t *detail = (net_nfc_request_get_current_target_handle_t *)msg;
+ net_nfc_current_target_info_s *target_info = NULL;
+
+ target_info = net_nfc_server_get_tag_info();
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_get_current_target_handle_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_get_current_target_handle_t);
+ resp.flags = detail->flags;
+ resp.trans_param = detail->trans_param;
+
+ if (target_info != NULL)
+ {
+ resp.handle = target_info->handle;
+ resp.devType = target_info->devType;
+ resp.result = NET_NFC_OK;
+ }
+ else
+ {
+ resp.result = NET_NFC_NOT_CONNECTED;
+ }
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_get_current_target_handle_t), NULL);
+ }
+}
+
+void net_nfc_service_deinit(net_nfc_request_msg_t *msg)
+{
+ net_nfc_error_e result;
+
+ result = net_nfc_service_se_change_se(SECURE_ELEMENT_TYPE_INVALID);
+
+ /* release access control instance */
+ net_nfc_util_access_control_release();
+
+ net_nfc_server_free_current_tag_info();
+
+ if (net_nfc_controller_deinit() == TRUE)
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_deinit success [%d]", result);
+
+ /*vconf off*/
+ if (vconf_set_bool(VCONFKEY_NFC_STATE, FALSE) != 0)
+ {
+ DEBUG_ERR_MSG("vconf_set_bool failed");
+ }
+
+ net_nfc_response_test_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_test_t);
+ resp.flags = msg->flags;
+ resp.result = NET_NFC_OK;
+ resp.trans_param = (void *)msg->user_param;
+
+ net_nfc_broadcast_response_msg(msg->request_type, (void *)&resp,
+ sizeof(net_nfc_response_test_t), NULL);
+ }
+ else
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_deinit failed");
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_test_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_test_t);
+ resp.flags = msg->flags;
+ resp.result = NET_NFC_UNKNOWN_ERROR;
+ resp.trans_param = (void *)msg->user_param;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+ }
+ }
+}
+
+void net_nfc_service_init(net_nfc_request_msg_t *msg)
+{
+ net_nfc_error_e result;
+
+ if (net_nfc_controller_init(&result) == true)
+ {
+ net_nfc_llcp_config_info_s config = { 128, 1, 100, 0 };
+
+ if (net_nfc_controller_register_listener(net_nfc_service_target_detected_cb,
+ net_nfc_service_se_transaction_cb, net_nfc_service_llcp_event_cb, &result) == true)
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_register_listener Success!!");
+ }
+ else
+ {
+ DEBUG_ERR_MSG("net_nfc_controller_register_listener failed [%d]", result);
+ }
+
+ if (net_nfc_controller_llcp_config(&config, &result) == true)
+ {
+ /*We need to check the stack that supports the llcp or not.*/
+ DEBUG_SERVER_MSG("llcp is enabled");
+ }
+ else
+ {
+ DEBUG_ERR_MSG("net_nfc_controller_llcp_config failed [%d]", result);
+ }
+
+ result = net_nfc_service_se_change_se(SECURE_ELEMENT_TYPE_UICC);
+
+ if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG,
+ NET_NFC_ALL_ENABLE, &result) == true)
+ {
+ DEBUG_SERVER_MSG("now, nfc is ready");
+ }
+ else
+ {
+ DEBUG_ERR_MSG("net_nfc_controller_confiure_discovery failed [%d]", result);
+ }
+
+ /* initialize access control instance */
+ net_nfc_util_access_control_initialize();
+
+ /*Send the Init Success Response Msg*/
+ {
+ net_nfc_response_test_t resp = { 0, };
+
+ DEBUG_SERVER_MSG("net_nfc_controller_init success [%d]", result);
+
+ resp.length = sizeof(net_nfc_response_test_t);
+ resp.flags = msg->flags;
+ resp.result = NET_NFC_OK;
+ resp.trans_param = (void *)msg->user_param;
+
+ /*vconf on*/
+ if (vconf_set_bool(VCONFKEY_NFC_STATE, TRUE) != 0)
+ {
+ DEBUG_ERR_MSG("vconf_set_bool failed");
+ }
+
+ net_nfc_broadcast_response_msg(msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+ }
+ }
+ else
+ {
+ DEBUG_ERR_MSG("net_nfc_controller_init failed [%d]", result);
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_test_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_test_t);
+ resp.flags = msg->flags;
+ resp.result = result;
+ resp.trans_param = (void *)msg->user_param;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+ }
+ }
+}
+
+void net_nfc_service_restart_polling(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_msg_t *discovery_req = (net_nfc_request_msg_t *)msg;
+ net_nfc_error_e result = NET_NFC_OK;
+ int pm_state = 0;
+ int set_config = 0;
+
+ pm_state = discovery_req->user_param;
+
+ DEBUG_SERVER_MSG("NET_NFC_MESSAGE_SERVICE_RESTART_POLLING_LOOP PM State = [%d]", pm_state);
+
+ if (pm_state == 1)
+ {
+ set_config = NET_NFC_ALL_ENABLE;
+ }
+ else if (pm_state == 3)
+ {
+ set_config = NET_NFC_ALL_DISABLE;
+ }
+ else
+ {
+ DEBUG_SERVER_MSG("Do not anything!!");
+ }
+
+ if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG, set_config, &result) == true)
+ {
+ DEBUG_SERVER_MSG("now, nfc polling loop is running again");
+ }
+}
+
+void net_nfc_service_get_server_state(net_nfc_request_msg_t *msg)
+{
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_get_server_state_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_get_server_state_t);
+ resp.flags = msg->flags;
+ resp.state = net_nfc_server_get_server_state();
+ resp.result = NET_NFC_OK;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_get_server_state_t), NULL);
+ }
+}
#include "net_nfc_server_ipc_private.h"
#include "net_nfc_server_dispatcher_private.h"
#include "net_nfc_service_se_private.h"
+#include "net_nfc_server_context_private.h"
/* define */
+
+/* static variable */
+static uint8_t g_se_prev_type = SECURE_ELEMENT_TYPE_INVALID;
+static uint8_t g_se_prev_mode = SECURE_ELEMENT_OFF_MODE;
+
/* For ESE*/
static net_nfc_se_setting_t g_se_setting;
DEBUG_SERVER_MSG("trans param = [%p]", resp.trans_param);
- net_nfc_send_response_msg(detail_msg->client_fd, NET_NFC_MESSAGE_OPEN_INTERNAL_SE, &resp, sizeof(net_nfc_response_open_internal_se_t), NULL);
+ net_nfc_send_response_msg(detail_msg->client_fd, NET_NFC_MESSAGE_OPEN_INTERNAL_SE,
+ &resp, sizeof(net_nfc_response_open_internal_se_t), NULL);
g_se_setting.open_request_trans_param = NULL;
}
if (g_se_setting.current_ese_handle != NULL)
{
- if (net_nfc_controller_disconnect(g_se_setting.current_ese_handle, &result) == false)
+ if (net_nfc_controller_secure_element_close(g_se_setting.current_ese_handle, &result) == false)
{
net_nfc_controller_exception_handler();
}
resp.data.length = apdu->apdu_resp_len;
DEBUG_MSG("send response send apdu msg");
- net_nfc_send_response_msg(param->client_fd, NET_NFC_MESSAGE_SEND_APDU_SE, (void *)&resp, sizeof(net_nfc_response_send_apdu_t), apdu->apdu_resp, apdu->apdu_resp_len, NULL);
+ net_nfc_send_response_msg(param->client_fd, NET_NFC_MESSAGE_SEND_APDU_SE,
+ (void *)&resp, sizeof(net_nfc_response_send_apdu_t), apdu->apdu_resp, apdu->apdu_resp_len, NULL);
}
else
{
DEBUG_MSG("send response send apdu msg");
- net_nfc_send_response_msg(param->client_fd, NET_NFC_MESSAGE_SEND_APDU_SE, (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
+ net_nfc_send_response_msg(param->client_fd, NET_NFC_MESSAGE_SEND_APDU_SE,
+ (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
}
_net_nfc_util_free_mem(param);
{
DEBUG_SERVER_MSG("launch se app");
- net_nfc_app_util_launch_se_transaction_app(se_event->aid.buffer, se_event->aid.length, se_event->param.buffer, se_event->param.length);
+ net_nfc_app_util_launch_se_transaction_app(se_event->aid.buffer,
+ se_event->aid.length, se_event->param.buffer, se_event->param.length);
DEBUG_SERVER_MSG("launch se app end");
}
return res;
}
+
+void net_nfc_service_se_send_apdu(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_send_apdu_t *detail = (net_nfc_request_send_apdu_t *)msg;
+
+ if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
+ {
+ data_s apdu_data = { NULL, 0 };
+
+ if (net_nfc_util_duplicate_data(&apdu_data, &detail->data) == false)
+ return;
+
+ net_nfc_service_transfer_apdu(msg->client_fd, &apdu_data, detail->trans_param);
+
+ net_nfc_util_free_data(&apdu_data);
+ }
+ else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
+ {
+ bool success;
+ data_s command;
+ data_s *response = NULL;
+ net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
+
+ if (net_nfc_util_duplicate_data(&command, &detail->data) == false)
+ {
+ DEBUG_ERR_MSG("alloc failed");
+ return;
+ }
+
+ if ((success = net_nfc_controller_secure_element_send_apdu(detail->handle, &command, &response, &result)) == true)
+ {
+ if (response != NULL)
+ {
+ DEBUG_SERVER_MSG("transceive data received, len [%d]", response->length);
+ }
+ }
+ else
+ {
+ DEBUG_ERR_MSG("transceive failed = [%d]", result);
+ }
+ net_nfc_util_free_data(&command);
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_send_apdu_t resp = { 0, };
+
+ DEBUG_SERVER_MSG("send response send_apdu");
+
+ resp.length = sizeof(net_nfc_response_send_apdu_t);
+ resp.flags = detail->flags;
+ resp.user_param = detail->user_param;
+ resp.trans_param = detail->trans_param;
+ resp.result = result;
+
+ if (response != NULL)
+ {
+ resp.data.length = response->length;
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_send_apdu_t),
+ response->buffer, response->length, NULL);
+ }
+ else
+ {
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
+ }
+ }
+ }
+ else
+ {
+ DEBUG_SERVER_MSG("invalid se handle");
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_send_apdu_t resp = { 0 };
+
+ resp.length = sizeof(net_nfc_response_send_apdu_t);
+ resp.flags = detail->flags;
+ resp.trans_param = detail->trans_param;
+ resp.result = NET_NFC_INVALID_PARAM;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
+ }
+ }
+}
+
+void net_nfc_service_se_get_atr(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_get_atr_t *detail = (net_nfc_request_get_atr_t *)msg;
+
+ if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
+ {
+ net_nfc_service_request_atr(msg->client_fd, (void *)detail->user_param);
+ }
+ else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
+ {
+ data_s *data = NULL;
+ net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
+
+ /* TODO : get atr */
+#if 0
+ net_nfc_transceive_info_s info;
+
+ info.dev_type = NET_NFC_ISO14443_A_PICC;
+ if (net_nfc_controller_transceive(detail->handle, &info, &data, &result) == true)
+ {
+ if (data != NULL)
+ {
+ DEBUG_SERVER_MSG("transceive data received [%d]", data->length);
+ }
+ }
+ else
+ {
+ DEBUG_SERVER_MSG("transceive is failed = [%d]", result);
+ }
+#endif
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_get_atr_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_get_atr_t);
+ resp.flags = detail->flags;
+ resp.user_param = detail->user_param;
+ resp.result = result;
+
+ if (data != NULL)
+ {
+ DEBUG_SERVER_MSG("send response send apdu msg");
+ resp.data.length = data->length;
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_get_atr_t),
+ data->buffer, data->length, NULL);
+ }
+ else
+ {
+ DEBUG_SERVER_MSG("send response send apdu msg");
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_get_atr_t), NULL);
+ }
+ }
+ }
+ else
+ {
+ DEBUG_SERVER_MSG("invalid se handle");
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_get_atr_t resp = { 0 };
+
+ resp.length = sizeof(net_nfc_response_get_atr_t);
+ resp.flags = detail->flags;
+ resp.user_param = detail->user_param;
+ resp.result = NET_NFC_INVALID_PARAM;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_get_atr_t), NULL);
+ }
+ }
+}
+
+void net_nfc_service_se_close_se(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_close_internal_se_t *detail = (net_nfc_request_close_internal_se_t *)msg;
+ net_nfc_error_e result = NET_NFC_OK;
+
+ if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
+ {
+ /*deinit TAPI*/
+ DEBUG_SERVER_MSG("UICC is current secure element");
+ net_nfc_service_tapi_deinit();
+
+ }
+ else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
+ {
+ result = net_nfc_service_se_close_ese();
+#ifdef BROADCAST_MESSAGE
+ net_nfc_server_unset_server_state(NET_NFC_SE_CONNECTED);
+#endif
+ }
+ else
+ {
+ DEBUG_ERR_MSG("invalid se handle received handle = [0x%p] and current handle = [0x%p]",
+ detail->handle, net_nfc_service_se_get_current_ese_handle());
+ }
+
+ if ((g_se_prev_type != net_nfc_service_se_get_se_type()) || (g_se_prev_mode != net_nfc_service_se_get_se_mode()))
+ {
+ /*return back se mode*/
+ net_nfc_controller_set_secure_element_mode(g_se_prev_type, g_se_prev_mode, &result);
+
+ net_nfc_service_se_set_se_type(g_se_prev_type);
+ net_nfc_service_se_set_se_mode(g_se_prev_mode);
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_close_internal_se_t resp = { 0 };
+
+ resp.length = sizeof(net_nfc_response_close_internal_se_t);
+ resp.flags = detail->flags;
+ resp.trans_param = detail->trans_param;
+ resp.result = result;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_close_internal_se_t), NULL);
+ }
+
+}
+
+void net_nfc_service_se_open_se(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_open_internal_se_t *detail = (net_nfc_request_open_internal_se_t *)msg;
+ net_nfc_target_handle_s *handle = NULL;
+ net_nfc_error_e result = NET_NFC_OK;
+
+ g_se_prev_type = net_nfc_service_se_get_se_type();
+ g_se_prev_mode = net_nfc_service_se_get_se_mode();
+
+ if (detail->se_type == SECURE_ELEMENT_TYPE_UICC)
+ {
+ /*off ESE*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
+
+ /*Off UICC. UICC SHOULD not be detected by external reader when being communicated in internal process*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
+
+ net_nfc_service_se_set_se_type(SECURE_ELEMENT_TYPE_UICC);
+ net_nfc_service_se_set_se_mode(SECURE_ELEMENT_OFF_MODE);
+
+ /*Init tapi api and return back response*/
+ if (net_nfc_service_tapi_init() != true)
+ {
+ net_nfc_service_tapi_deinit();
+ result = NET_NFC_INVALID_STATE;
+ handle = NULL;
+ }
+ else
+ {
+ result = NET_NFC_OK;
+ handle = (net_nfc_target_handle_s *)UICC_TARGET_HANDLE;
+ }
+ }
+ else if (detail->se_type == SECURE_ELEMENT_TYPE_ESE)
+ {
+ /*off UICC*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
+
+ if (net_nfc_controller_secure_element_open(SECURE_ELEMENT_TYPE_ESE, &handle, &result) == true)
+ {
+ net_nfc_service_se_set_se_type(SECURE_ELEMENT_TYPE_ESE);
+ net_nfc_service_se_set_se_mode(SECURE_ELEMENT_WIRED_MODE);
+
+ net_nfc_service_se_get_se_setting()->open_request_trans_param = detail->trans_param;
+ net_nfc_service_se_set_current_ese_handle(handle);
+
+ DEBUG_ERR_MSG("handle [%p]", handle);
+ }
+ else
+ {
+ DEBUG_ERR_MSG("net_nfc_controller_secure_element_open failed [%d]", result);
+ }
+ }
+ else
+ {
+ result = NET_NFC_INVALID_STATE;
+ handle = NULL;
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_open_internal_se_t resp = { 0 };
+
+ resp.length = sizeof(net_nfc_response_open_internal_se_t);
+ resp.flags = detail->flags;
+ resp.user_param = detail->user_param;
+ resp.trans_param = detail->trans_param;
+ resp.result = result;
+ resp.se_type = detail->se_type;
+ resp.handle = handle;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_open_internal_se_t), NULL);
+ }
+}
+
+void net_nfc_service_se_set_se(net_nfc_request_msg_t *msg)
+{
+#if 1
+ net_nfc_request_set_se_t *detail = (net_nfc_request_set_se_t *)msg;
+ net_nfc_error_e result = NET_NFC_OK;
+ bool isTypeChange = false;
+
+ if (detail->se_type != net_nfc_service_se_get_se_type())
+ {
+ result = net_nfc_service_se_change_se(detail->se_type);
+ isTypeChange = true;
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_set_se_t resp = { 0 };
+
+ resp.length = sizeof(net_nfc_response_set_se_t);
+ resp.flags = detail->flags;
+ resp.trans_param = detail->trans_param;
+ resp.se_type = detail->se_type;
+ resp.result = result;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_set_se_t), NULL);
+ }
+
+ if (isTypeChange)
+ {
+ net_nfc_response_notify_t noti_se = { 0, };
+
+ net_nfc_broadcast_response_msg(NET_NFC_MESSAGE_SE_TYPE_CHANGED,
+ (void *)¬i_se, sizeof(net_nfc_response_notify_t), NULL);
+ }
+
+#else
+ net_nfc_request_set_se_t *detail = (net_nfc_request_set_se_t *)msg;
+ net_nfc_error_e result = NET_NFC_OK;
+ int mode;
+
+ mode = (int)detail->se_type;
+
+ if (mode == NET_NFC_SE_CMD_UICC_ON)
+ {
+ /*turn on UICC*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+ SECURE_ELEMENT_VIRTUAL_MODE, &result);
+
+ /*turn off ESE*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+ SECURE_ELEMENT_OFF_MODE, &result);
+ }
+ else if (mode == NET_NFC_SE_CMD_ESE_ON)
+ {
+ /*turn off UICC*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+ SECURE_ELEMENT_OFF_MODE, &result);
+
+ /*turn on ESE*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+ SECURE_ELEMENT_VIRTUAL_MODE, &result);
+ }
+ else if (mode == NET_NFC_SE_CMD_ALL_OFF)
+ {
+ /*turn off both*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+ SECURE_ELEMENT_OFF_MODE, &result);
+
+ /*turn on ESE*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+ SECURE_ELEMENT_OFF_MODE, &result);
+ }
+ else
+ {
+ /*turn off both*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+ SECURE_ELEMENT_VIRTUAL_MODE, &result);
+
+ /*turn on ESE*/
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+ SECURE_ELEMENT_VIRTUAL_MODE, &result);
+ }
+#endif
+}
+
+void net_nfc_service_se_get_se(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_get_se_t *detail = (net_nfc_request_get_se_t *)msg;
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_get_se_t resp = { 0 };
+
+ resp.length = sizeof(net_nfc_request_get_se_t);
+ resp.flags = detail->flags;
+ resp.trans_param = detail->trans_param;
+ resp.result = NET_NFC_OK;
+ resp.se_type = net_nfc_service_se_get_se_type();
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_get_se_t), NULL);
+ }
+}
+
+void net_nfc_service_se_cleanup()
+{
+ DEBUG_SERVER_MSG("client is terminated abnormally");
+
+ if (g_se_prev_type == SECURE_ELEMENT_TYPE_ESE)
+ {
+ net_nfc_error_e result = NET_NFC_OK;
+ net_nfc_target_handle_s *ese_handle = net_nfc_service_se_get_current_ese_handle();
+
+ if (ese_handle != NULL)
+ {
+ DEBUG_SERVER_MSG("ese_handle was not freed and disconnected");
+
+ net_nfc_service_se_close_ese();
+#ifdef BROADCAST_MESSAGE
+ net_nfc_server_set_server_state(NET_NFC_SERVER_IDLE);
+#endif
+ }
+
+ if ((g_se_prev_type != net_nfc_service_se_get_se_type()) || (g_se_prev_mode != net_nfc_service_se_get_se_mode()))
+ {
+ net_nfc_controller_set_secure_element_mode(g_se_prev_type, g_se_prev_mode, &result);
+
+ net_nfc_service_se_set_se_type(g_se_prev_type);
+ net_nfc_service_se_set_se_mode(g_se_prev_mode);
+ }
+ }
+ else if (g_se_prev_type == SECURE_ELEMENT_TYPE_UICC)
+ {
+ net_nfc_service_tapi_deinit();
+ }
+ else
+ {
+ DEBUG_SERVER_MSG("SE type is not valid");
+ }
+}
#include "net_nfc_server_ipc_private.h"
#include "net_nfc_server_dispatcher_private.h"
#include "net_nfc_manager_util_private.h"
+#include "net_nfc_server_context_private.h"
/* define */
}
#endif
+
+void net_nfc_service_tag_make_readonly(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_make_read_only_ndef_t *detail = (net_nfc_request_make_read_only_ndef_t *)msg;
+ net_nfc_error_e result = NET_NFC_OK;
+
+ if (net_nfc_server_is_target_connected(detail->handle))
+ {
+ net_nfc_controller_make_read_only_ndef(detail->handle, &result);
+ }
+ else
+ {
+ result = NET_NFC_TARGET_IS_MOVED_AWAY;
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_make_read_only_ndef_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_make_read_only_ndef_t);
+ resp.flags = detail->flags;
+ resp.result = result;
+ resp.trans_param = detail->trans_param;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
+ }
+}
+
+void net_nfc_service_tag_read_ndef(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_read_ndef_t *detail = (net_nfc_request_read_ndef_t *)msg;
+ net_nfc_error_e result = NET_NFC_TARGET_IS_MOVED_AWAY;
+ data_s *data = NULL;
+
+ if (net_nfc_server_is_target_connected(detail->handle))
+ {
+ net_nfc_controller_read_ndef(detail->handle, &data, &result);
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_read_ndef_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_read_ndef_t);
+ resp.flags = detail->flags;
+ resp.result = result;
+ resp.trans_param = detail->trans_param;
+
+ if (data != NULL)
+ {
+ resp.data.length = data->length;
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_read_ndef_t),
+ data->buffer, data->length, NULL);
+ }
+ else
+ {
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_read_ndef_t), NULL);
+ }
+ }
+
+ if (data != NULL)
+ {
+ net_nfc_util_free_data(data);
+ _net_nfc_util_free_mem(data);
+ }
+}
+
+void net_nfc_service_tag_write_ndef(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_write_ndef_t *detail = (net_nfc_request_write_ndef_t *)msg;
+ net_nfc_error_e result = NET_NFC_TARGET_IS_MOVED_AWAY;
+
+ if (net_nfc_server_is_target_connected(detail->handle))
+ {
+ data_s data = { NULL, 0 };
+
+ if (net_nfc_util_duplicate_data(&data, &detail->data) == true)
+ {
+ net_nfc_controller_write_ndef(detail->handle, &data, &result);
+
+ net_nfc_util_free_data(&data);
+ }
+ else
+ {
+ result = NET_NFC_ALLOC_FAIL;
+ }
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_write_ndef_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_write_ndef_t);
+ resp.flags = detail->flags;
+ resp.result = result;
+ resp.trans_param = detail->trans_param;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
+ }
+}
+
+void net_nfc_service_tag_format_ndef(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_format_ndef_t *detail = (net_nfc_request_format_ndef_t *)msg;
+ net_nfc_error_e result = NET_NFC_TARGET_IS_MOVED_AWAY;
+
+ if (net_nfc_server_is_target_connected(detail->handle))
+ {
+ data_s data = { NULL, 0 };
+
+ if (net_nfc_util_duplicate_data(&data, &detail->key) == true)
+ {
+ net_nfc_controller_format_ndef(detail->handle, &data, &result);
+ net_nfc_util_free_data(&data);
+ }
+ else
+ {
+ result = NET_NFC_ALLOC_FAIL;
+ }
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_format_ndef_t resp = { 0 };
+
+ resp.length = sizeof(net_nfc_response_format_ndef_t);
+ resp.flags = detail->flags;
+ resp.result = result;
+ resp.trans_param = detail->trans_param;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_format_ndef_t), NULL);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "net_nfc_typedef.h"
+#include "net_nfc_debug_private.h"
+#include "net_nfc_util_private.h"
+#include "net_nfc_server_ipc_private.h"
+#include "net_nfc_controller_private.h"
+#include "net_nfc_service_test_private.h"
+#include "net_nfc_server_context_private.h"
+
+void net_nfc_service_test_sim_test(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_test_t *detail = (net_nfc_request_test_t *)msg;
+ net_nfc_error_e result = NET_NFC_OK;
+
+ if (net_nfc_controller_sim_test(&result) == true)
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_sim_test Result [SUCCESS]");
+ }
+ else
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_sim_test Result [ERROR1]");
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_test_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_test_t);
+ resp.flags = detail->flags;
+ resp.result = result;
+ resp.trans_param = detail->trans_param;
+
+ DEBUG_SERVER_MSG("SEND RESPONSE!!");
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+ }
+}
+
+void net_nfc_service_test_get_firmware_version(net_nfc_request_msg_t *msg)
+{
+ net_nfc_error_e result = NET_NFC_OK;
+ data_s *data = NULL;
+
+ if (net_nfc_controller_get_firmware_version(&data, &result) == true)
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_update_firmware Result [SUCCESS]");
+
+ }
+ else
+ {
+ DEBUG_ERR_MSG("net_nfc_controller_update_firmware Result [ERROR3]");
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_firmware_version_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_firmware_version_t);
+ resp.flags = msg->flags;
+ resp.result = result;
+ resp.data.length = data->length;
+
+ if (data != NULL)
+ {
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_firmware_version_t),
+ (void *)data->buffer, resp.data.length, NULL);
+ }
+ else
+ {
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_firmware_version_t), NULL);
+ }
+ }
+
+ if (data != NULL)
+ {
+ net_nfc_util_free_data(data);
+ _net_nfc_util_free_mem(data);
+ }
+}
+
+void net_nfc_service_test_prbs_test(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_test_t *detail = (net_nfc_request_test_t *)msg;
+ net_nfc_error_e result = NET_NFC_OK;
+ uint32_t local_tech = 0;
+ uint32_t local_rate = 0;
+
+ local_tech = detail->tech;
+ local_rate = detail->rate;
+
+ DEBUG_SERVER_MSG("local_tech [%d]\n", local_tech);
+ DEBUG_SERVER_MSG("local_rate [%d]\n", local_rate);
+
+ if (net_nfc_controller_prbs_test(&result, local_tech, local_rate) == true)
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_prbs_test Result [SUCCESS]");
+ }
+ else
+ {
+ DEBUG_ERR_MSG("net_nfc_controller_prbs_test Result [ERROR3]");
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_test_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_test_t);
+ resp.flags = detail->flags;
+ resp.result = result;
+ resp.trans_param = detail->trans_param;
+
+ DEBUG_SERVER_MSG("SEND RESPONSE!!");
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+ }
+}
+
+void net_nfc_service_test_set_eedata(net_nfc_request_msg_t *msg)
+{
+ net_nfc_request_eedata_register_t *detail = (net_nfc_request_eedata_register_t *)msg;
+ net_nfc_error_e result = NET_NFC_OK;
+ uint32_t local_mode = 0;
+ uint32_t local_reg_id = 0;
+ data_s data = { NULL, 0 };
+
+ local_mode = detail->mode;
+ local_reg_id = detail->reg_id;
+
+ DEBUG_SERVER_MSG("local_mode [%d]\n", local_mode);
+ DEBUG_SERVER_MSG("local_reg_id [%d]\n", local_reg_id);
+
+ if (net_nfc_util_duplicate_data(&data, &detail->data) == true)
+ {
+ if (net_nfc_controller_eedata_register_set(&result, local_mode,
+ local_reg_id, &data) == true)
+ {
+ DEBUG_SERVER_MSG("net_nfc_controller_eedata_register_set Result [SUCCESS]");
+ }
+ else
+ {
+ DEBUG_ERR_MSG("net_nfc_controller_eedata_register_set Result [ERROR3]");
+ }
+ net_nfc_util_free_data(&data);
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_test_t resp = { 0, };
+
+ resp.length = sizeof(net_nfc_response_test_t);
+ resp.flags = detail->flags;
+ resp.result = result;
+ resp.trans_param = detail->trans_param;
+
+ DEBUG_SERVER_MSG("SEND RESPONSE!!");
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+ }
+ }
+}
/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include <stdio.h>
#include <sys/time.h>
#include "package-manager.h"
+#include "pkgmgr-info.h"
#include "SEService.h"
#include "Reader.h"
#include "Session.h"
unsigned char aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 };
channel_h channel = NULL;
- channel = session_open_basic_channel_sync(session, aid, sizeof(aid));
+ channel = session_open_logical_channel_sync(session, aid, sizeof(aid));
if (channel != NULL)
{
result = gp_se_acl_create_instance(channel);
net_nfc_util_access_control_initialize();
{
pkgmgr_certinfo_h cert_info = NULL;
+ pkgmgrinfo_appinfo_h handle;
+ char *pkgid = NULL;
+
+ if(pkgmgrinfo_appinfo_get_appinfo(pkg_name, &handle) != PMINFO_R_OK)
+ {
+ DEBUG_ERR_MSG("pkgmgrinfo_appinfo_get_appinfo fail");
+ return result;
+ }
+
+ if(pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid) != PMINFO_R_OK)
+ {
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ DEBUG_ERR_MSG("pkgmgrinfo_appinfo_get_pkgid fail");
+ return result;
+ }
+ cert_info = _get_cert_info(pkgid);
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
- cert_info = _get_cert_info(pkg_name);
if (cert_info != NULL)
{
int i;