/* * Copyright (C) 2022 The Android Open Source Project * * 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. */ #include #include "../includes/common.h" #include #include #include #include #include #define DEFAULT_SAP 1 #define LENGTH 0 bool testInProgress = false; struct sigaction new_action, old_action; void sigsegv_handler(int signum, siginfo_t *info, void *context) { if (testInProgress && info->si_signo == SIGSEGV) { (*old_action.sa_sigaction)(signum, info, context); return; } exit(EXIT_FAILURE); } extern tLLCP_CB llcp_cb; extern tRW_CB rw_cb; extern tNFC_CB nfc_cb; void GKI_freebuf(void* x) { (void)x; } void GKI_start_timer(uint8_t, int32_t, bool) {} void GKI_stop_timer(uint8_t) {} void poc_cback(tRW_EVENT event, tRW_DATA* p_rw_data) { (void)event; (void)p_rw_data; } int32_t main() { sigemptyset(&new_action.sa_mask); new_action.sa_flags = SA_SIGINFO; new_action.sa_sigaction = sigsegv_handler; sigaction(SIGSEGV, &new_action, &old_action); tNFC_ACTIVATE_DEVT p_activate_params = {}; p_activate_params.protocol = NFC_PROTOCOL_ISO_DEP; p_activate_params.rf_tech_param.mode = NFC_DISCOVERY_TYPE_POLL_A; RW_SetActivatedTagType(&p_activate_params, &poc_cback); FAIL_CHECK(rw_cb.p_cback == &poc_cback); GKI_init(); llcp_init(); for (int32_t n = 0; n < LLCP_MAX_DATA_LINK; ++n) { llcp_cb.dlcb[n].state = LLCP_DLC_STATE_CONNECTED; llcp_cb.dlcb[n].local_sap = DEFAULT_SAP; llcp_cb.dlcb[n].remote_sap = DEFAULT_SAP; } testInProgress = true; llcp_dlc_proc_rx_pdu(DEFAULT_SAP, LLCP_PDU_RNR_TYPE, DEFAULT_SAP, LENGTH, nullptr); testInProgress = false; return EXIT_SUCCESS; }