* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-#include <pthread.h>
-#include <time.h>
-#include <sys/time.h>
-#include <dirent.h>
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+#include <dirent.h>
#include <fcntl.h>
-#include <malloc.h>
-#include <vconf.h>
-
-#include <pwd.h>
#include <grp.h>
+#include <pthread.h>
+#include <pwd.h>
+#include <stdbool.h>
+#include <sys/stat.h>
#include <sys/epoll.h>
-
-#ifdef USE_GLIB_MAIN_LOOP
-#include <glib.h>
-#endif
+#include <vconf.h>
#include <net_nfc_oem_controller.h>
-#include "net_nfc_typedef.h"
+#include <net_nfc_typedef.h>
+#include <net_nfc_util_internal.h>
+#include <net_nfc_util_ndef_message.h>
+#include <net_nfc_util_ndef_record.h>
#include "nfc_debug_private.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_ndef_message.h"
-#include "net_nfc_util_ndef_record.h"
-
-#include <netinet/in.h>
-
-/*************************** STRUCTURE DEFINE START ***************************************/
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
typedef enum {
EMUL_NFC_TAG_DISCOVERED = 100,
typedef struct _socket_info_s {
net_nfc_llcp_socket_t socket_handle;
bool isValid;
- void* user_context;
+ void *user_context;
} socket_info_s;
typedef struct _net_nfc_oem_llcp_state_t {
llcp_state_e state;
net_nfc_llcp_socket_t socket;
uint16_t max_capability;
- net_nfc_target_handle_s * handle;
+ net_nfc_target_handle_s *handle;
net_nfc_error_e prev_result;
net_nfc_llcp_socket_t incomming_socket;
ndef_message_s *requester;
ndef_message_s *selector;
bool low_power;
- void * user_data;
- void * payload;
+ void *user_data;
+ void *payload;
llcp_app_protocol_e type_app_protocol;
net_nfc_conn_handover_carrier_type_e type;
emul_message_id message_id;
emul_target_type target_type;
int record_count;
- uint8_t* file_data;
+ uint8_t *file_data;
} emulMsg_s;
-typedef void * (*emul_Nfc_thread_handler_t) (void * pParam);
-
-/*************************** STRUCTURE DEFINE START ***************************************/
+typedef void* (*emul_Nfc_thread_handler_t)(void *pParam);
#define __USE_EPOLL_FOR_FILE__ 1
-
-/****************************** DEFINE START *******************************************/
-
/* for emulator management */
#define NET_NFC_EMUL_DATA_PATH "/dev"
#define NET_NFC_EMUL_MESSAGE_FILE_NAME "nfc0"
#define WRITE_BUFFER_LENGTH_MAX BUFFER_LENGTH_MAX
#define NET_NFC_MAX_LLCP_SOCKET_BUFFER BUFFER_LENGTH_MAX
-/****************************** DEFINE END *******************************************/
-
-
-
-/****************************** VARIABLE START *******************************************/
-
/* listener callback */
-static target_detection_listener_cb g_emul_controller_target_cb ;
-static se_transaction_listener_cb g_emul_controller_se_cb ;
-static llcp_event_listener_cb g_emul_controller_llcp_cb ;
-static hce_apdu_listener_cb g_emul_controller_hce_cb ;
+static target_detection_listener_cb g_emul_controller_target_cb;
+static se_transaction_listener_cb g_emul_controller_se_cb;
+static llcp_event_listener_cb g_emul_controller_llcp_cb;
+static hce_apdu_listener_cb g_emul_controller_hce_cb;
/* for emulator management */
-pthread_t gEmulThread;
+pthread_t gEmulThread;
/* for stack management */
-static net_nfc_target_handle_s * current_working_handle = NULL;
+static net_nfc_target_handle_s *current_working_handle = NULL;
static bool g_stack_init_successful = 0;
static bool g_tag_attached = 0;
static bool g_p2p_attached = 0;
socket_info_s socket_info_array[LLCP_NB_SOCKET_MAX] = { {0, } };
-snep_msg_s* Snep_Server_msg;
-data_s* llcp_server_data = NULL;
+snep_msg_s *Snep_Server_msg;
+data_s *llcp_server_data = NULL;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-/****************************** VARIABLE END *******************************************/
-
-
-
-/*************************** STATIC FUNCTION DECLARE START ***************************************/
-
-/*************************** INTERFACE START ***************************************/
-
-static bool net_nfc_emul_controller_init(net_nfc_error_e* result);
-static bool net_nfc_emul_controller_deinit(void);
-static bool net_nfc_emul_controller_register_listener(
- target_detection_listener_cb target_detection_listener,
- se_transaction_listener_cb se_transaction_listener,
- llcp_event_listener_cb llcp_event_listener,
- hce_apdu_listener_cb hce_apdu_listener,
- net_nfc_error_e* result);
-static bool net_nfc_emul_controller_unregister_listener();
-static bool net_nfc_emul_controller_get_firmware_version(data_s **data, net_nfc_error_e *result);
-static bool net_nfc_emul_controller_check_firmware_version(net_nfc_error_e* result);
-static bool net_nfc_emul_controller_update_firmware(net_nfc_error_e* result);
-static bool net_nfc_emul_controller_get_stack_information(net_nfc_stack_information_s* stack_info, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_configure_discovery(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_get_secure_element_list(net_nfc_secure_element_info_s* list, int* count, net_nfc_error_e* result);
-static bool net_nfc_emul_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);
-static bool net_nfc_emul_controller_connect(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_disconnect(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
-static bool net_nfc_emul_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);
-static bool net_nfc_emul_controller_check_target_presence(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_read_ndef(net_nfc_target_handle_s* handle, data_s** data, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_write_ndef(net_nfc_target_handle_s* handle, data_s* data, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_make_read_only_ndef(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_transceive(net_nfc_target_handle_s* handle, net_nfc_transceive_info_s* info, data_s** data, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_format_ndef(net_nfc_target_handle_s* handle, data_s* secure_key, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_exception_handler(void);
-static bool net_nfc_emul_controller_is_ready(net_nfc_error_e* error);
-
-static bool net_nfc_emul_controller_llcp_config(net_nfc_llcp_config_info_s * config, net_nfc_error_e * result);
-static bool net_nfc_emul_controller_llcp_check_llcp(net_nfc_target_handle_s * handle, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_llcp_activate_llcp(net_nfc_target_handle_s * handle, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_llcp_create_socket(net_nfc_llcp_socket_t* socket, net_nfc_socket_type_e socketType, uint16_t miu, uint8_t rw, net_nfc_error_e* result, void * user_param);
-static bool net_nfc_emul_controller_llcp_bind(net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_llcp_listen(net_nfc_target_handle_s* handle, uint8_t* service_access_name, net_nfc_llcp_socket_t socket, net_nfc_error_e* result, void * user_param);
-static bool net_nfc_emul_controller_llcp_accept(net_nfc_llcp_socket_t socket, net_nfc_error_e* result, void *user_param);
-static bool net_nfc_emul_controller_llcp_connect_by_url(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, uint8_t* service_access_name, net_nfc_error_e* result, void * user_param);
-static bool net_nfc_emul_controller_llcp_connect(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e* result, void * user_param);
-static bool net_nfc_emul_controller_llcp_reject(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_llcp_disconnect(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, net_nfc_error_e* result, void * user_param);
-static bool net_nfc_emul_controller_llcp_socket_close(net_nfc_llcp_socket_t socket, net_nfc_error_e* result);
-static bool net_nfc_emul_controller_llcp_recv(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, data_s* data, net_nfc_error_e* result, void * user_param);
-static bool net_nfc_emul_controller_llcp_send(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, data_s* data, net_nfc_error_e* result, void * user_param);
-static bool net_nfc_emul_controller_llcp_recv_from(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, data_s * data, net_nfc_error_e* result, void * user_param);
-static bool net_nfc_emul_controller_llcp_send_to(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, data_s* data, uint8_t service_access_point, net_nfc_error_e* result, void * user_param);
-static bool net_nfc_emul_controller_llcp_get_remote_config(net_nfc_target_handle_s* handle, net_nfc_llcp_config_info_s *config, net_nfc_error_e* result);
-static bool net_nfc_emul_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);
-
-static bool net_nfc_emul_controller_support_nfc(net_nfc_error_e *result);
-static bool net_nfc_emul_controller_secure_element_open(net_nfc_secure_element_type_e element_type,
- net_nfc_target_handle_s **handle, net_nfc_error_e *result);
-static bool net_nfc_emul_controller_secure_element_get_atr(net_nfc_target_handle_s *handle,
- data_s **atr, net_nfc_error_e *result);
-static bool net_nfc_emul_controller_secure_element_send_apdu(net_nfc_target_handle_s *handle,
- data_s *command, data_s **response, net_nfc_error_e *result);
-static bool net_nfc_emul_controller_secure_element_close(net_nfc_target_handle_s *handle,
- net_nfc_error_e *result);
-
-
-/*************************** INTERFACE END ***************************************/
-
-
-
-/*************************** ETC Function ***************************************/
/* Memory utils */
/* free memory, after free given memory it set NULL. Before proceed free, this function also check NULL */
-void __nfc_emul_util_free_mem(void** mem, char * filename, unsigned int line);
+static void __nfc_emul_util_free_mem(void **mem, char *filename, unsigned int line);
/* allocation memory */
-void __nfc_emul_util_alloc_mem(void** mem, int size, char * filename, unsigned int line);
-#define _nfc_emul_util_alloc_mem(mem, size) __nfc_emul_util_alloc_mem((void **)&mem, size, __FILE__, __LINE__)
-#define _nfc_emul_util_free_mem(mem) __nfc_emul_util_free_mem((void **)&mem, __FILE__, __LINE__)
-
+static void __nfc_emul_util_alloc_mem(void **mem, int size, char *filename, unsigned int line);
+#define _nfc_emul_util_alloc_mem(mem, size) __nfc_emul_util_alloc_mem((void**)&mem, size, __FILE__, __LINE__)
+#define _nfc_emul_util_free_mem(mem) __nfc_emul_util_free_mem((void**)&mem, __FILE__, __LINE__)
-static bool __net_nfc_is_valide_target_handle(net_nfc_target_handle_s * handle);
-static void __net_nfc_make_valid_target_handle(net_nfc_target_handle_s ** handle);
-static void __net_nfc_make_invalid_target_handle();
-/*************************** STATIC FUNCTION DECLARE END ***************************************/
-
-
-
-void __nfc_emul_util_free_mem(void** mem, char * filename, unsigned int line)
+static void __nfc_emul_util_free_mem(void **mem, char *filename, unsigned int line)
{
if (mem == NULL || *mem == NULL) {
LOGE("FILE: %s, LINE:%d, Invalid parameter in mem free util (pinter is NULL)", filename, line);
*mem = NULL;
}
-void __nfc_emul_util_alloc_mem(void** mem, int size, char * filename, unsigned int line)
+static void __nfc_emul_util_alloc_mem(void **mem, int size, char *filename, unsigned int line)
{
if (mem == NULL || size <= 0) {
LOGE("FILE: %s, LINE:%d, Invalid parameter in mem alloc util", filename, line);
LOGE("FILE: %s, LINE:%d, Allocation is failed", filename, line);
}
-static bool __net_nfc_is_valide_target_handle(net_nfc_target_handle_s * handle)
+static bool __net_nfc_is_valide_target_handle(net_nfc_target_handle_s *handle)
{
bool result = (current_working_handle == handle);
if (!result)
return result;
}
-static void __net_nfc_make_valid_target_handle(net_nfc_target_handle_s ** handle)
+
+static void __net_nfc_make_valid_target_handle(net_nfc_target_handle_s **handle)
{
if (current_working_handle != NULL)
DEBUG_MSG("[WARNING]: HANDLE WAS ALLOCATED ALREADY!");
if (*handle != NULL)
current_working_handle = *handle;
}
+
static void __net_nfc_make_invalid_target_handle()
{
if (current_working_handle != NULL) {
}
}
-static socket_info_s * _net_nfc_get_available_socket_slot()
+static socket_info_s* _net_nfc_get_available_socket_slot()
{
int idx = 0;
for (; idx < LLCP_NB_SOCKET_MAX; idx++) {
}
}
-static socket_info_s * _net_nfc_find_server_socket(net_nfc_llcp_socket_t socket)
+static socket_info_s* _net_nfc_find_server_socket(net_nfc_llcp_socket_t socket)
{
int idx = 0;
for (; idx < LLCP_NB_SOCKET_MAX; idx++) {
return NULL;
}
-////////////// INTERFACE START //////////
-
-NET_NFC_EXPORT_API bool onload(net_nfc_oem_interface_s * emul_interfaces)
-{
- DEBUG_EMUL_BEGIN();
-
- emul_interfaces->init = net_nfc_emul_controller_init;
- emul_interfaces->deinit = net_nfc_emul_controller_deinit;
- emul_interfaces->register_listener = net_nfc_emul_controller_register_listener;
- emul_interfaces->unregister_listener = net_nfc_emul_controller_unregister_listener;
- emul_interfaces->get_firmware_version = net_nfc_emul_controller_get_firmware_version;
- emul_interfaces->check_firmware_version = net_nfc_emul_controller_check_firmware_version;
- emul_interfaces->update_firmeware = net_nfc_emul_controller_update_firmware;
- emul_interfaces->get_stack_information = net_nfc_emul_controller_get_stack_information;
- emul_interfaces->configure_discovery = net_nfc_emul_controller_configure_discovery;
- emul_interfaces->get_secure_element_list = net_nfc_emul_controller_get_secure_element_list;
- emul_interfaces->set_secure_element_mode = net_nfc_emul_controller_set_secure_element_mode;
- emul_interfaces->connect = net_nfc_emul_controller_connect;
- emul_interfaces->disconnect = net_nfc_emul_controller_disconnect;
- emul_interfaces->check_ndef = net_nfc_emul_controller_check_ndef;
- emul_interfaces->check_presence = net_nfc_emul_controller_check_target_presence;
- emul_interfaces->read_ndef = net_nfc_emul_controller_read_ndef;
- emul_interfaces->write_ndef = net_nfc_emul_controller_write_ndef;
- emul_interfaces->make_read_only_ndef = net_nfc_emul_controller_make_read_only_ndef;
- emul_interfaces->transceive = net_nfc_emul_controller_transceive;
- emul_interfaces->format_ndef = net_nfc_emul_controller_format_ndef;
- emul_interfaces->exception_handler = net_nfc_emul_controller_exception_handler;
- emul_interfaces->is_ready = net_nfc_emul_controller_is_ready;
-
- emul_interfaces->config_llcp = net_nfc_emul_controller_llcp_config;
- emul_interfaces->check_llcp_status = net_nfc_emul_controller_llcp_check_llcp;
- emul_interfaces->activate_llcp = net_nfc_emul_controller_llcp_activate_llcp;
- emul_interfaces->create_llcp_socket = net_nfc_emul_controller_llcp_create_socket;
- emul_interfaces->bind_llcp_socket = net_nfc_emul_controller_llcp_bind;
- emul_interfaces->listen_llcp_socket = net_nfc_emul_controller_llcp_listen;
- emul_interfaces->accept_llcp_socket = net_nfc_emul_controller_llcp_accept;
- emul_interfaces->connect_llcp_by_url = net_nfc_emul_controller_llcp_connect_by_url;
- emul_interfaces->connect_llcp = net_nfc_emul_controller_llcp_connect;
- emul_interfaces->disconnect_llcp = net_nfc_emul_controller_llcp_disconnect;
- emul_interfaces->close_llcp_socket = net_nfc_emul_controller_llcp_socket_close;
- emul_interfaces->recv_llcp = net_nfc_emul_controller_llcp_recv;
- emul_interfaces->send_llcp = net_nfc_emul_controller_llcp_send;
- emul_interfaces->recv_from_llcp = net_nfc_emul_controller_llcp_recv_from;
- emul_interfaces->send_to_llcp = net_nfc_emul_controller_llcp_send_to;
- emul_interfaces->reject_llcp = net_nfc_emul_controller_llcp_reject;
- emul_interfaces->get_remote_config = net_nfc_emul_controller_llcp_get_remote_config;
- emul_interfaces->get_remote_socket_info = net_nfc_emul_controller_llcp_get_remote_socket_info;
-
- emul_interfaces->support_nfc = net_nfc_emul_controller_support_nfc;
-
- emul_interfaces->secure_element_open = net_nfc_emul_controller_secure_element_open;
- emul_interfaces->secure_element_get_atr = net_nfc_emul_controller_secure_element_get_atr;
- emul_interfaces->secure_element_send_apdu = net_nfc_emul_controller_secure_element_send_apdu;
- emul_interfaces->secure_element_close = net_nfc_emul_controller_secure_element_close;
-
- emul_interfaces->hce_response_apdu = NULL;
- emul_interfaces->route_aid = NULL;
- emul_interfaces->unroute_aid = NULL;
- emul_interfaces->commit_routing = NULL;
- emul_interfaces->set_default_route = NULL;
- emul_interfaces->clear_aid_table = NULL;
- emul_interfaces->get_aid_tablesize = NULL;
-
- DEBUG_EMUL_END();
-
- return true;
-}
-
static void _net_nfc_initialize_llcp(void)
{
DEBUG_EMUL_BEGIN();
if (Snep_Server_msg == NULL) {
- Snep_Server_msg = (snep_msg_s *)calloc(1, sizeof(snep_msg_s));
+ Snep_Server_msg = calloc(1, sizeof(snep_msg_s));
if (Snep_Server_msg == NULL)
return;
- Snep_Server_msg->data = (data_s *)calloc(1, sizeof(data_s));
+ Snep_Server_msg->data = calloc(1, sizeof(data_s));
if (Snep_Server_msg->data == NULL)
return;
- Snep_Server_msg->data->buffer = (uint8_t *)calloc(1, sizeof(uint8_t) * BUFFER_LENGTH_MAX);
+ Snep_Server_msg->data->buffer = calloc(1, sizeof(uint8_t) * BUFFER_LENGTH_MAX);
}
DEBUG_EMUL_END();
int index;
int create_record_count = 0;
- char emulMsg[BUFFER_LENGTH_MAX] = { 0, };
+ char emulMsg[BUFFER_LENGTH_MAX] = {0};
- memcpy(emulMsg, emul_msg->file_data, sizeof(emulMsg)-1);
+ memcpy(emulMsg, emul_msg->file_data, sizeof(emulMsg) - 1);
/* parsing data and create record to record structure */
- for (index = 0; index < record_count ; index++) {
+ for (index = 0; index < record_count; index++) {
char *name_format;
char *type_name;
char *record_id;
char *record_payload;
- emulMsg_data_s record = { 0, };
- data_s filePayload = { NULL, 0 };
+ emulMsg_data_s record = {0};
+ data_s filePayload = {NULL, 0};
/* parse string */
if (index == 0)
- name_format = strtok((char *) emulMsg, NET_NFC_EMUL_MSG_RECORD_SEPERATOR);
+ name_format = strtok((char *)emulMsg, NET_NFC_EMUL_MSG_RECORD_SEPERATOR);
else
name_format = strtok(NULL, NET_NFC_EMUL_MSG_RECORD_SEPERATOR);
type_name = strtok(NULL, NET_NFC_EMUL_MSG_RECORD_SEPERATOR);
record_id = strtok(NULL, NET_NFC_EMUL_MSG_RECORD_SEPERATOR);
- if (index == record_count-1) {
+ if (index == record_count - 1) {
/* the last payload : we have to read sentence fully */
record_payload = strtok(NULL, "\n");
} else {
{
char *buffer = NULL;
size_t buffer_len = 0;
- struct passwd pwd = { 0, };
+ struct passwd pwd = {0};
struct passwd *pw_inhouse = NULL;
- struct group grp = { 0, };
+ struct group grp = {0};
struct group *gr_inhouse = NULL;
if (file == NULL)
static void _net_nfc_store_ndef_message(data_s *data)
{
- char file_name[1024] = { 0, };
+ char file_name[1024] = {0};
FILE *fp = NULL;
if (data == NULL)
static net_nfc_error_e _net_nfc_retrieve_ndef_message(data_s *data)
{
- char file_name[1024] = { 0, };
+ char file_name[1024] = {0};
FILE *fp = NULL;
net_nfc_error_e result = NET_NFC_OK;
int retval = true;
net_nfc_error_e result = NET_NFC_OK;
- data_s rawdata = { NULL, 0 };
+ data_s rawdata = {NULL, 0};
- int record_count = emul_msg->record_count;
+ int record_count = emul_msg->record_count;
if (record_count == 0)
return false;
ndef_message_h ndef_message = NULL;
int ndef_length = 0;
- if ((result = net_nfc_util_create_ndef_message((ndef_message_s **) &ndef_message)) != NET_NFC_OK)
+ if ((result = net_nfc_util_create_ndef_message((ndef_message_s **)&ndef_message)) != NET_NFC_OK)
DEBUG_MSG("failed to create ndef message [%d]", result);
/* create records and append it to ndef_msg*/
- emul_msg->record_count = _net_nfc_create_records_from_emulMsg(emul_msg, (ndef_message_s **) &ndef_message, record_count);
+ emul_msg->record_count = _net_nfc_create_records_from_emulMsg(emul_msg, (ndef_message_s **)&ndef_message, record_count);
/* convert ndef msg to raw data */
- ndef_length = net_nfc_util_get_ndef_message_length((ndef_message_s *) ndef_message);
+ ndef_length = net_nfc_util_get_ndef_message_length((ndef_message_s *)ndef_message);
if (!ndef_length)
DEBUG_MSG("ndef_message size is zero!");
return retval;
}
-static bool _net_nfc_create_emulMsg(emulMsg_s **emul_msg, uint8_t * data, long int size)
+static bool _net_nfc_create_emulMsg(emulMsg_s **emul_msg, uint8_t *data, long int size)
{
DEBUG_EMUL_BEGIN();
char *emulMsgID;
char *emulMsgData;
- *emul_msg = (emulMsg_s *)calloc(1, sizeof(emulMsg_s));
+ *emul_msg = calloc(1, sizeof(emulMsg_s));
if (*emul_msg == NULL)
return false;
/* emulData => ID : MSG ex) 100:1,1,1,U,samsung,http://www.naver.com */
emulMsgID = strtok((char *)data, NET_NFC_EMUL_MSG_ID_SEPERATOR);
if (emulMsgID != NULL)
- (*emul_msg)->message_id = (emul_message_id) (atoi(emulMsgID));
+ (*emul_msg)->message_id = (emul_message_id)(atoi(emulMsgID));
DEBUG_MSG("emul_msg->message_id >>>>[%d]", (*emul_msg)->message_id);
{
/* get message : Tag Type, Record Count, Records */
int target_type = -1;
- char file_data[BUFFER_LENGTH_MAX] = {0, };
+ char file_data[BUFFER_LENGTH_MAX] = {0};
int length = 0;
sscanf(emulMsgData, NET_NFC_EMUL_TAG_DISCOVERED_DATA_FORMAT, &target_type, &((*emul_msg)->record_count), file_data);
- (*emul_msg)->target_type = (emul_target_type) target_type;
+ (*emul_msg)->target_type = (emul_target_type)target_type;
- length = strlen(file_data)+1;
+ length = strlen(file_data) + 1;
_nfc_emul_util_alloc_mem((*emul_msg)->file_data, length);
memcpy((*emul_msg)->file_data, file_data, length);
DEBUG_EMUL_BEGIN();
/* make handle */
- net_nfc_target_handle_s* handle = NULL;
+ net_nfc_target_handle_s *handle = NULL;
int length = 0;
__net_nfc_make_valid_target_handle(&handle);
return;
/* make msg */
- net_nfc_request_target_detected_t* target_detected = NULL;
- uint8_t device_info[] = { 0x03, 0x55, 0x49, 0x44, 0x07, 0x04, 0x93, 0xB7, 0xD9, 0x5B, 0x02, 0x80, \
+ net_nfc_request_target_detected_t *target_detected = NULL;
+ uint8_t device_info[] = {0x03, 0x55, 0x49, 0x44, 0x07, 0x04, 0x93, 0xB7, 0xD9, 0x5B, 0x02, 0x80, \
0x08, 0x41, 0x50, 0x50, 0x5F, 0x44, 0x41, 0x54, 0x41, 0x00, 0x03, 0x53, 0x41, 0x4B, \
0x01, 0x00, 0x04, 0x41, 0x54, 0x51, 0x41, 0x02, 0x44, 0x00, 0x0D, 0x4D, 0x41, 0x58, \
0x5F, 0x44, 0x41, 0x54, 0x41, 0x5F, 0x52, 0x41, 0x54, 0x45, 0x01, 0x00, 0x08, 0x46, \
0x57, 0x49, 0x5F, 0x53, 0x46, 0x47, 0x54, 0x01, 0x03, 0x49, 0x44, 0x6D, 0x07, 0x04, \
- 0x93, 0xB7, 0xD9, 0x5B, 0x02, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ 0x93, 0xB7, 0xD9, 0x5B, 0x02, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
length = sizeof(net_nfc_request_target_detected_t) + sizeof(device_info);
target_detected->handle->connection_id = current_connection_id++;
if (target_detected->devType == NET_NFC_NFCIP1_TARGET) {
- DEBUG_MSG("set llcp connection type. remote device is target");
+ DEBUG_MSG("set llcp connection type. remote device is target");
handle->connection_type = NET_NFC_P2P_CONNECTION_TARGET;
_net_nfc_emul_set_is_p2p_attached(true);
} else if (target_detected->devType == NET_NFC_NFCIP1_INITIATOR) {
- DEBUG_MSG("set llcp connection type. remote device is initiator");
+ DEBUG_MSG("set llcp connection type. remote device is initiator");
handle->connection_type = NET_NFC_P2P_CONNECTION_INITIATOR;
_net_nfc_emul_set_is_p2p_attached(true);
} else {
}
}
-static void _net_nfc_llcp_data_receive_cb(void* pContext)
+static void _net_nfc_llcp_data_receive_cb(void *pContext)
{
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
}
-static void _net_nfc_llcp_data_receive_from_cb(void* pContext)
+static void _net_nfc_llcp_data_receive_from_cb(void *pContext)
{
DEBUG_EMUL_BEGIN();
{
DEBUG_EMUL_BEGIN();
- uint8_t* temp = Snep_Server_msg->data->buffer;
+ uint8_t *temp = Snep_Server_msg->data->buffer;
uint8_t response = (uint8_t)resp_field;
uint8_t version = 0;
uint32_t length_field = 0;
- data_s rawdata = { NULL, 0 };
+ data_s rawdata = {NULL, 0};
version = SNEP_MAJOR_VER;
version = (((version << 4) & 0xf0) | (SNEP_MINOR_VER & 0x0f));
DEBUG_EMUL_END();
}
-static llcp_state_e _net_nfc_get_llcp_state(void* pContext)
+static llcp_state_e _net_nfc_get_llcp_state(void *pContext)
{
DEBUG_EMUL_BEGIN();
llcp_state_e state;
static bool _net_nfc_make_llcp_data(emulMsg_s *emul_msg)
{
DEBUG_EMUL_BEGIN();
- data_s rawdata = { NULL, 0 };
+ data_s rawdata = {NULL, 0};
_net_nfc_retrieve_ndef_message(&rawdata);
_nfc_emul_util_free_mem(rawdata.buffer);
DEBUG_EMUL_END();
}
-static void _net_nfc_process_emulMsg(uint8_t * data, long int size)
+static void _net_nfc_process_emulMsg(uint8_t *data, long int size)
{
DEBUG_EMUL_BEGIN();
}
#ifdef __USE_EPOLL_FOR_FILE__
-static void emul_ReaderThread(void * pArg)
+static void emul_ReaderThread(void *pArg)
{
DEBUG_MSG("emul_ReaderThread START >>>>");
- char file_name[1024] = { 0, };
+ char file_name[1024] = {0};
bool condition = true;
int emulMsg_file_fd = -1;
LOGE("file path : %s", file_name);
/* open file for poll */
- emulMsg_file_fd = open(file_name, O_RDONLY|O_NONBLOCK);
+ emulMsg_file_fd = open(file_name, O_RDONLY | O_NONBLOCK);
if (emulMsg_file_fd < 0) {
DEBUG_MSG("file open error !!!!");
return;
return;
}
- if ((emulMsg_poll_events = (struct epoll_event *)calloc(1, sizeof(struct epoll_event) * EPOLL_SIZE)) == NULL) {
+ if ((emulMsg_poll_events = calloc(1, sizeof(struct epoll_event) * EPOLL_SIZE)) == NULL) {
DEBUG_MSG("calloc is occured");
close(emulMsg_file_fd);
return;
#else
-static void emul_ReaderThread(void * pArg)
+static void emul_ReaderThread(void *pArg)
{
DEBUG_MSG("emul_ReaderThread START >>>>");
FILE *fp = NULL;
- char file_name[1024] = { 0, };
+ char file_name[1024] = {0};
char readBuffer[READ_BUFFER_LENGTH_MAX];
LOGE("file path : %s", file_name);
time(&curTime);
- DEBUG_MSG("Start Current Time [%ld]", (unsigned long) curTime);
+ DEBUG_MSG("Start Current Time [%ld]", (unsigned long)curTime);
/* polling 500 ms */
} else {
/* get the modified time of the file */
if (stat(file_name, &st) == 0) {
- if ((unsigned long) st.st_mtime <= (unsigned long) curTime) {
+ if ((unsigned long)st.st_mtime <= (unsigned long)curTime) {
fclose(fp);
continue;
} else {
- DEBUG_MSG("FILE Modified Time [%ld]", (unsigned long) st.st_mtime);
+ DEBUG_MSG("FILE Modified Time [%ld]", (unsigned long)st.st_mtime);
/* update current time */
time(&curTime);
- DEBUG_MSG("Get New Current Time [%ld]", (unsigned long) curTime);
+ DEBUG_MSG("Get New Current Time [%ld]", (unsigned long)curTime);
}
} else {
DEBUG_MSG("get DATA >>>> readBuffer [%s]", readBuffer);
/* process message */
- _net_nfc_process_emulMsg((uint8_t *) readBuffer, (long int) strlen(readBuffer));
+ _net_nfc_process_emulMsg((uint8_t *)readBuffer, (long int)strlen(readBuffer));
fclose(fp);
}
DEBUG_EMUL_BEGIN();
- ret = pthread_create(&gEmulThread, NULL, (emul_Nfc_thread_handler_t)emul_ReaderThread, (void*) "emul_read_thread");
+ ret = pthread_create(&gEmulThread, NULL, (emul_Nfc_thread_handler_t)emul_ReaderThread, (void*)"emul_read_thread");
if (ret != 0)
return false;
DEBUG_EMUL_END();
}
-static bool net_nfc_emul_controller_init(net_nfc_error_e* result)
+static bool net_nfc_emul_controller_init(net_nfc_error_e *result)
{
bool ret = true;
se_transaction_listener_cb se_transaction_listener,
llcp_event_listener_cb llcp_event_listener,
hce_apdu_listener_cb hce_apdu_listener,
- net_nfc_error_e* result)
+ net_nfc_error_e *result)
{
if (result == NULL)
return false;
DEBUG_EMUL_BEGIN();
- *data = (data_s *)calloc(1, sizeof(data_s));
+ *data = calloc(1, sizeof(data_s));
if (*data == NULL)
return false;
(*data)->length = 10;
- (*data)->buffer = (uint8_t *)calloc(1, (*data)->length);
+ (*data)->buffer = calloc(1, (*data)->length);
if ((*data)->buffer == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_check_firmware_version(net_nfc_error_e* result)
+static bool net_nfc_emul_controller_check_firmware_version(net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_update_firmware(net_nfc_error_e* result)
+static bool net_nfc_emul_controller_update_firmware(net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_get_stack_information(net_nfc_stack_information_s* stack_info, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_get_stack_information(net_nfc_stack_information_s *stack_info, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_configure_discovery(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_configure_discovery(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e *result)
{
int idx;
bool ret = true;
/* reset socket_info */
for (idx = 0; idx < LLCP_NB_SOCKET_MAX; idx++)
- _net_nfc_remove_socket_slot((net_nfc_llcp_socket_t) idx);
+ _net_nfc_remove_socket_slot((net_nfc_llcp_socket_t)idx);
DEBUG_MSG("Kill Thread");
return ret;
}
-static bool net_nfc_emul_controller_get_secure_element_list(net_nfc_secure_element_info_s* list, int* count, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_get_secure_element_list(net_nfc_secure_element_info_s *list, int *count, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_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)
+static bool net_nfc_emul_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)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_check_target_presence(net_nfc_target_handle_s* handle, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_check_target_presence(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
{
if (result == NULL)
return false;
*result = NET_NFC_OK;
- usleep(300*1000);
+ usleep(300 * 1000);
if (_net_nfc_emul_get_is_tag_attached()) {
return true;
}
}
-static bool net_nfc_emul_controller_connect(net_nfc_target_handle_s* handle, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_connect(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_disconnect(net_nfc_target_handle_s* handle, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_disconnect(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
{
if (result == NULL)
return false;
/* reset socket_info */
int idx = 0;
for (; idx < LLCP_NB_SOCKET_MAX; idx++)
- _net_nfc_remove_socket_slot((net_nfc_llcp_socket_t) idx);
+ _net_nfc_remove_socket_slot((net_nfc_llcp_socket_t)idx);
DEBUG_EMUL_END();
return true;
}
-static bool net_nfc_emul_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)
+static bool net_nfc_emul_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)
{
- data_s rawdata = { NULL, 0 };
+ data_s rawdata = {NULL, 0};
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_make_read_only_ndef(net_nfc_target_handle_s* handle, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_make_read_only_ndef(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_read_ndef(net_nfc_target_handle_s* handle, data_s** data, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_read_ndef(net_nfc_target_handle_s *handle, data_s **data, net_nfc_error_e *result)
{
int real_data_size = 0;
- data_s rawdata = { NULL, 0 };
+ data_s rawdata = {NULL, 0};
DEBUG_EMUL_BEGIN();
return false;
}
- *data = (data_s*) calloc(1, sizeof(data_s));
+ *data = calloc(1, sizeof(data_s));
if (*data == NULL) {
*result = NET_NFC_ALLOC_FAIL;
}
(*data)->length = real_data_size;
- (*data)->buffer = (uint8_t *)calloc(1, real_data_size);
+ (*data)->buffer = calloc(1, real_data_size);
if ((*data)->buffer == NULL) {
free(*data);
return true;
}
-static bool net_nfc_emul_controller_write_ndef(net_nfc_target_handle_s* handle, data_s* data, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_write_ndef(net_nfc_target_handle_s *handle, data_s *data, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return ret;
}
-static bool net_nfc_emul_controller_format_ndef(net_nfc_target_handle_s* handle, data_s* secure_key, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_format_ndef(net_nfc_target_handle_s *handle, data_s *secure_key, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_is_ready(net_nfc_error_e* result)
+static bool net_nfc_emul_controller_is_ready(net_nfc_error_e *result)
{
if (result == NULL)
return false;
* LLCP definition *
********************/
-static bool net_nfc_emul_controller_llcp_config(net_nfc_llcp_config_info_s * config, net_nfc_error_e * result)
+static bool net_nfc_emul_controller_llcp_config(net_nfc_llcp_config_info_s *config, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_check_llcp(net_nfc_target_handle_s* handle, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_llcp_check_llcp(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_activate_llcp(net_nfc_target_handle_s* handle, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_llcp_activate_llcp(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_create_socket(net_nfc_llcp_socket_t* socket, net_nfc_socket_type_e socketType, uint16_t miu, uint8_t rw, net_nfc_error_e* result, void * user_param)
+static bool net_nfc_emul_controller_llcp_create_socket(net_nfc_llcp_socket_t *socket, net_nfc_socket_type_e socketType, uint16_t miu, uint8_t rw, net_nfc_error_e *result, void *user_param)
{
if (result == NULL)
return false;
DEBUG_EMUL_BEGIN();
/* get available socket */
- socket_info_s* socket_info = _net_nfc_get_available_socket_slot();
+ socket_info_s *socket_info = _net_nfc_get_available_socket_slot();
if (socket_info == NULL) {
DEBUG_ERR_MSG("The available socket is nothing!!");
return false;
} else if (llcp_state == NET_NFC_STATE_EXCHANGER_SERVER_NPP) {
DEBUG_MSG("NET_NFC_STATE_EXCHANGER_SERVER_NPP");
- *socket = NET_NFC_EMUL_NPP_SERVER_SOCKET_NUMBER;
+ *socket = NET_NFC_EMUL_NPP_SERVER_SOCKET_NUMBER;
} else if (llcp_state == NET_NFC_STATE_EXCHANGER_CLIENT) {
DEBUG_MSG("NET_NFC_STATE_EXCHANGER_CLIENT");
- *socket = NET_NFC_EMUL_CLIENT_SOCKET_NUMBER;
+ *socket = NET_NFC_EMUL_CLIENT_SOCKET_NUMBER;
} else if (llcp_state == NET_NFC_STATE_CONN_HANDOVER_REQUEST) {
DEBUG_MSG("NET_NFC_STATE_CONN_HANDOVER_REQUEST");
- *socket = NET_NFC_EMUL_HANDOVER_REQUEST_SOCKET_NUMBER;
+ *socket = NET_NFC_EMUL_HANDOVER_REQUEST_SOCKET_NUMBER;
} else if (llcp_state == NET_NFC_STATE_CONN_HANDOVER_SELECT) {
DEBUG_MSG("NET_NFC_STATE_CONN_HANDOVER_SELECT");
- *socket = NET_NFC_EMUL_HANDOVER_SELECT_SOCKET_NUMBER;
+ *socket = NET_NFC_EMUL_HANDOVER_SELECT_SOCKET_NUMBER;
} else {
DEBUG_MSG("we doesn't support..");
DEBUG_MSG("socket is created = [0x%x]", *socket);
socket_info->socket_handle = *socket;
- socket_info->user_context = (void *) user_param;
+ socket_info->user_context = (void *)user_param;
DEBUG_EMUL_END();
return true;
}
-static bool net_nfc_emul_controller_llcp_bind(net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_llcp_bind(net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_listen(net_nfc_target_handle_s* handle, uint8_t* service_access_name, net_nfc_llcp_socket_t socket, net_nfc_error_e* result, void * user_param)
+static bool net_nfc_emul_controller_llcp_listen(net_nfc_target_handle_s *handle, uint8_t *service_access_name, net_nfc_llcp_socket_t socket, net_nfc_error_e *result, void *user_param)
{
if (result == NULL)
return false;
}
/* below accept function does not used. */
-static bool net_nfc_emul_controller_llcp_accept(net_nfc_llcp_socket_t socket, net_nfc_error_e* result, void *user_param)
+static bool net_nfc_emul_controller_llcp_accept(net_nfc_llcp_socket_t socket, net_nfc_error_e *result, void *user_param)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_connect(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e* result, void * user_param)
+static bool net_nfc_emul_controller_llcp_connect(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e *result, void *user_param)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_connect_by_url(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, uint8_t* service_access_name, net_nfc_error_e* result, void * user_param)
+static bool net_nfc_emul_controller_llcp_connect_by_url(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, uint8_t *service_access_name, net_nfc_error_e *result, void *user_param)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_send(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, data_s* data, net_nfc_error_e* result, void * user_param)
+static bool net_nfc_emul_controller_llcp_send(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, data_s *data, net_nfc_error_e *result, void *user_param)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_send_to(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, data_s* data, uint8_t service_access_point, net_nfc_error_e* result, void * user_param)
+static bool net_nfc_emul_controller_llcp_send_to(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, data_s *data, uint8_t service_access_point, net_nfc_error_e *result, void *user_param)
{
if (result == NULL)
return false;
}
-static bool net_nfc_emul_controller_llcp_recv(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, data_s * data, net_nfc_error_e* result, void * user_param)
+static bool net_nfc_emul_controller_llcp_recv(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, data_s *data, net_nfc_error_e *result, void *user_param)
{
if (result == NULL || data == NULL)
return false;
DEBUG_MSG("send last segment >>>");
llcp_server_data->length = remained_size;
- memcpy(llcp_server_data->buffer, Snep_Server_msg->data->buffer+Snep_Server_msg->offset , remained_size);
+ memcpy(llcp_server_data->buffer, Snep_Server_msg->data->buffer + Snep_Server_msg->offset, remained_size);
Snep_Server_msg->isSegment = false;
} else {
DEBUG_MSG("send continue segment >>>");
llcp_server_data->length = SNEP_MAX_BUFFER;
- memcpy(llcp_server_data->buffer, Snep_Server_msg->data->buffer+Snep_Server_msg->offset, SNEP_MAX_BUFFER);
+ memcpy(llcp_server_data->buffer, Snep_Server_msg->data->buffer + Snep_Server_msg->offset, SNEP_MAX_BUFFER);
Snep_Server_msg->offset += SNEP_MAX_BUFFER;
}
return true;
}
-static bool net_nfc_emul_controller_llcp_recv_from(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, data_s * data, net_nfc_error_e* result, void * user_param)
+static bool net_nfc_emul_controller_llcp_recv_from(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, data_s *data, net_nfc_error_e *result, void *user_param)
{
if (result == NULL)
return false;
DEBUG_MSG("send last segment >>>");
llcp_server_data->length = remained_size;
- memcpy(llcp_server_data->buffer, Snep_Server_msg->data->buffer+Snep_Server_msg->offset , remained_size);
+ memcpy(llcp_server_data->buffer, Snep_Server_msg->data->buffer + Snep_Server_msg->offset, remained_size);
Snep_Server_msg->isSegment = false;
} else {
DEBUG_MSG("send continue segment >>>");
llcp_server_data->length = SNEP_MAX_BUFFER;
- memcpy(llcp_server_data->buffer, Snep_Server_msg->data->buffer+Snep_Server_msg->offset, SNEP_MAX_BUFFER);
+ memcpy(llcp_server_data->buffer, Snep_Server_msg->data->buffer + Snep_Server_msg->offset, SNEP_MAX_BUFFER);
Snep_Server_msg->offset += SNEP_MAX_BUFFER;
}
return true;
}
-static bool net_nfc_emul_controller_llcp_disconnect(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, net_nfc_error_e* result, void * user_param)
+static bool net_nfc_emul_controller_llcp_disconnect(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_error_e *result, void *user_param)
{
if (result == NULL)
return false;
}
/* reset socket_info */
- _net_nfc_remove_socket_slot((net_nfc_llcp_socket_t) socket);
+ _net_nfc_remove_socket_slot((net_nfc_llcp_socket_t)socket);
DEBUG_EMUL_END();
return true;
}
-static bool net_nfc_emul_controller_llcp_socket_close(net_nfc_llcp_socket_t socket, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_llcp_socket_close(net_nfc_llcp_socket_t socket,
+ net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_reject(net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_llcp_reject(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_error_e *result)
{
if (result == NULL)
return false;
return true;
}
-static bool net_nfc_emul_controller_llcp_get_remote_config(net_nfc_target_handle_s* handle, net_nfc_llcp_config_info_s *config, net_nfc_error_e* result)
+static bool net_nfc_emul_controller_llcp_get_remote_config(net_nfc_target_handle_s *handle, net_nfc_llcp_config_info_s *config, net_nfc_error_e *result)
{
/* In llcp specification ver 1.1, default miu size is 128 */
const uint16_t default_miu = 128;
return true;
}
-static bool net_nfc_emul_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)
+static bool net_nfc_emul_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)
{
/* In llcp specification ver 1.1, default miu size is 128 */
const uint16_t default_miu = 128;
static bool net_nfc_emul_controller_support_nfc(net_nfc_error_e *result)
{
bool ret = false;
- struct stat st = { 0, };
+ struct stat st = {0};
if (stat("/dev/nfc0", &st) == -1) {
if (result)
return true;
}
static bool net_nfc_emul_controller_secure_element_get_atr(net_nfc_target_handle_s *handle,
- data_s **atr, net_nfc_error_e *result)
+ data_s **atr, net_nfc_error_e *result)
{
bool ret = true;
char buffer[1024];
strncpy(buffer, "getatr", sizeof(buffer));
- temp = (data_s *)calloc(1, sizeof(*temp));
+ temp = calloc(1, sizeof(*temp));
if (temp != NULL) {
- temp->buffer = (uint8_t *)calloc(1, length);
+ temp->buffer = calloc(1, length);
if (temp->buffer != NULL) {
memcpy(temp->buffer, buffer, length);
temp->length = length;
return ret;
}
static bool net_nfc_emul_controller_secure_element_send_apdu(net_nfc_target_handle_s *handle,
- data_s *command, data_s **response, net_nfc_error_e *result)
+ data_s *command, data_s **response, net_nfc_error_e *result)
{
bool ret = true;
char buffer[1024];
length = strlen(buffer);
- temp = (data_s *)calloc(1, sizeof(*temp));
+ temp = calloc(1, sizeof(*temp));
if (temp != NULL) {
- temp->buffer = (uint8_t *)calloc(1, length + 1);
+ temp->buffer = calloc(1, length + 1);
if (temp->buffer != NULL) {
memcpy(temp->buffer, buffer, sizeof(temp->buffer) - 1);
temp->length = length;
ret = false;
}
} else {
- *result = NET_NFC_ALLOC_FAIL;
- ret = false;
+ *result = NET_NFC_ALLOC_FAIL;
+ ret = false;
}
DEBUG_ERR_MSG("se send apdu end");
return ret;
}
static bool net_nfc_emul_controller_secure_element_close(net_nfc_target_handle_s *handle,
- net_nfc_error_e *result)
+ net_nfc_error_e *result)
{
DEBUG_ERR_MSG("se close start");
*result = NET_NFC_OK;
DEBUG_ERR_MSG("se close end");
}
-////////////// INTERFACE END //////////
+__attribute__((visibility("default"))) bool onload(net_nfc_oem_interface_s *emul_interfaces)
+{
+ DEBUG_EMUL_BEGIN();
+
+ emul_interfaces->init = net_nfc_emul_controller_init;
+ emul_interfaces->deinit = net_nfc_emul_controller_deinit;
+ emul_interfaces->register_listener = net_nfc_emul_controller_register_listener;
+ emul_interfaces->unregister_listener = net_nfc_emul_controller_unregister_listener;
+ emul_interfaces->get_firmware_version = net_nfc_emul_controller_get_firmware_version;
+ emul_interfaces->check_firmware_version = net_nfc_emul_controller_check_firmware_version;
+ emul_interfaces->update_firmeware = net_nfc_emul_controller_update_firmware;
+ emul_interfaces->get_stack_information = net_nfc_emul_controller_get_stack_information;
+ emul_interfaces->configure_discovery = net_nfc_emul_controller_configure_discovery;
+ emul_interfaces->get_secure_element_list = net_nfc_emul_controller_get_secure_element_list;
+ emul_interfaces->set_secure_element_mode = net_nfc_emul_controller_set_secure_element_mode;
+ emul_interfaces->connect = net_nfc_emul_controller_connect;
+ emul_interfaces->disconnect = net_nfc_emul_controller_disconnect;
+ emul_interfaces->check_ndef = net_nfc_emul_controller_check_ndef;
+ emul_interfaces->check_presence = net_nfc_emul_controller_check_target_presence;
+ emul_interfaces->read_ndef = net_nfc_emul_controller_read_ndef;
+ emul_interfaces->write_ndef = net_nfc_emul_controller_write_ndef;
+ emul_interfaces->make_read_only_ndef = net_nfc_emul_controller_make_read_only_ndef;
+ emul_interfaces->transceive = net_nfc_emul_controller_transceive;
+ emul_interfaces->format_ndef = net_nfc_emul_controller_format_ndef;
+ emul_interfaces->exception_handler = net_nfc_emul_controller_exception_handler;
+ emul_interfaces->is_ready = net_nfc_emul_controller_is_ready;
+
+ emul_interfaces->config_llcp = net_nfc_emul_controller_llcp_config;
+ emul_interfaces->check_llcp_status = net_nfc_emul_controller_llcp_check_llcp;
+ emul_interfaces->activate_llcp = net_nfc_emul_controller_llcp_activate_llcp;
+ emul_interfaces->create_llcp_socket = net_nfc_emul_controller_llcp_create_socket;
+ emul_interfaces->bind_llcp_socket = net_nfc_emul_controller_llcp_bind;
+ emul_interfaces->listen_llcp_socket = net_nfc_emul_controller_llcp_listen;
+ emul_interfaces->accept_llcp_socket = net_nfc_emul_controller_llcp_accept;
+ emul_interfaces->connect_llcp_by_url = net_nfc_emul_controller_llcp_connect_by_url;
+ emul_interfaces->connect_llcp = net_nfc_emul_controller_llcp_connect;
+ emul_interfaces->disconnect_llcp = net_nfc_emul_controller_llcp_disconnect;
+ emul_interfaces->close_llcp_socket = net_nfc_emul_controller_llcp_socket_close;
+ emul_interfaces->recv_llcp = net_nfc_emul_controller_llcp_recv;
+ emul_interfaces->send_llcp = net_nfc_emul_controller_llcp_send;
+ emul_interfaces->recv_from_llcp = net_nfc_emul_controller_llcp_recv_from;
+ emul_interfaces->send_to_llcp = net_nfc_emul_controller_llcp_send_to;
+ emul_interfaces->reject_llcp = net_nfc_emul_controller_llcp_reject;
+ emul_interfaces->get_remote_config = net_nfc_emul_controller_llcp_get_remote_config;
+ emul_interfaces->get_remote_socket_info = net_nfc_emul_controller_llcp_get_remote_socket_info;
+
+ emul_interfaces->support_nfc = net_nfc_emul_controller_support_nfc;
+
+ emul_interfaces->secure_element_open = net_nfc_emul_controller_secure_element_open;
+ emul_interfaces->secure_element_get_atr = net_nfc_emul_controller_secure_element_get_atr;
+ emul_interfaces->secure_element_send_apdu = net_nfc_emul_controller_secure_element_send_apdu;
+ emul_interfaces->secure_element_close = net_nfc_emul_controller_secure_element_close;
+
+ emul_interfaces->hce_response_apdu = NULL;
+ emul_interfaces->route_aid = NULL;
+ emul_interfaces->unroute_aid = NULL;
+ emul_interfaces->commit_routing = NULL;
+ emul_interfaces->set_default_route = NULL;
+ emul_interfaces->clear_aid_table = NULL;
+ emul_interfaces->get_aid_tablesize = NULL;
+
+ DEBUG_EMUL_END();
+
+ return true;
+}