• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "fuzz_cmn.h"
2 #include "rw_int.h"
3 
4 // These are the functions implemented elsewhere in the NFC code. Our fuzzing
5 // doesn't need them. To avoid pulling into more source code we simply stub
6 // them out.
7 
8 tNFA_PROPRIETARY_CFG nfa_proprietary_cfg = {
9     0x80, /* NCI_PROTOCOL_18092_ACTIVE */
10     0x81, /* NCI_PROTOCOL_B_PRIME */
11     0x82, /* NCI_PROTOCOL_DUAL */
12     0x83, /* NCI_PROTOCOL_15693 */
13     0x8A, /* NCI_PROTOCOL_KOVIO */
14     0xFF, /* NCI_PROTOCOL_MIFARE */
15     0x77, /* NCI_DISCOVERY_TYPE_POLL_KOVIO */
16     0x74, /* NCI_DISCOVERY_TYPE_POLL_B_PRIME */
17     0xF4, /* NCI_DISCOVERY_TYPE_LISTEN_B_PRIME */
18 };
19 
20 tRW_CB rw_cb = {};
21 
22 tNFA_PROPRIETARY_CFG* p_nfa_proprietary_cfg =
23     (tNFA_PROPRIETARY_CFG*)&nfa_proprietary_cfg;
24 
nfc_start_quick_timer(TIMER_LIST_ENT *,uint16_t,uint32_t)25 void nfc_start_quick_timer(TIMER_LIST_ENT*, uint16_t, uint32_t) {}
nfc_stop_timer(TIMER_LIST_ENT *)26 void nfc_stop_timer(TIMER_LIST_ENT*) {}
nfc_stop_quick_timer(TIMER_LIST_ENT *)27 void nfc_stop_quick_timer(TIMER_LIST_ENT*) {}
NFC_GetNCIVersion()28 uint8_t NFC_GetNCIVersion() { return NCI_VERSION_2_0; }
29 
NFC_SendData(uint8_t conn_id,NFC_HDR * p_data)30 tNFC_STATUS NFC_SendData(uint8_t conn_id, NFC_HDR* p_data) {
31   uint8_t* p = (uint8_t*)(p_data + 1) + p_data->offset;
32   uint8_t len = (uint8_t)p_data->len;
33 
34   FUZZLOG("conn_id=%d, data=%s", conn_id, BytesToHex(p, len).c_str());
35   GKI_freebuf(p_data);
36   return NFC_STATUS_OK;
37 }
38 
nci_snd_t3t_polling(uint16_t system_code,uint8_t rc,uint8_t tsn)39 uint8_t nci_snd_t3t_polling(uint16_t system_code, uint8_t rc, uint8_t tsn) {
40   FUZZLOG("sc=%04X, rc=%02X, tsn=%02X", system_code, rc, tsn);
41   return NFC_STATUS_OK;
42 }
43 
44 tNFC_CONN_CBACK* rf_cback = nullptr;
NFC_SetStaticRfCback(tNFC_CONN_CBACK * p_cback)45 void NFC_SetStaticRfCback(tNFC_CONN_CBACK* p_cback) { rf_cback = p_cback; }
46 
NFC_ISODEPNakPresCheck()47 tNFC_STATUS NFC_ISODEPNakPresCheck() { return NFC_STATUS_OK; }
48 
NFC_GetStatusName(tNFC_STATUS status)49 std::string NFC_GetStatusName(tNFC_STATUS status) {
50   switch (status) {
51     case NFC_STATUS_OK:
52       return "OK";
53     case NFC_STATUS_REJECTED:
54       return "REJECTED";
55     case NFC_STATUS_MSG_CORRUPTED:
56       return "CORRUPTED";
57     case NFC_STATUS_BUFFER_FULL:
58       return "BUFFER_FULL";
59     case NFC_STATUS_FAILED:
60       return "FAILED";
61     case NFC_STATUS_NOT_INITIALIZED:
62       return "NOT_INITIALIZED";
63     case NFC_STATUS_SYNTAX_ERROR:
64       return "SYNTAX_ERROR";
65     case NFC_STATUS_SEMANTIC_ERROR:
66       return "SEMANTIC_ERROR";
67     case NFC_STATUS_UNKNOWN_GID:
68       return "UNKNOWN_GID";
69     case NFC_STATUS_UNKNOWN_OID:
70       return "UNKNOWN_OID";
71     case NFC_STATUS_INVALID_PARAM:
72       return "INVALID_PARAM";
73     case NFC_STATUS_MSG_SIZE_TOO_BIG:
74       return "MSG_SIZE_TOO_BIG";
75     case NFC_STATUS_ALREADY_STARTED:
76       return "ALREADY_STARTED";
77     case NFC_STATUS_ACTIVATION_FAILED:
78       return "ACTIVATION_FAILED";
79     case NFC_STATUS_TEAR_DOWN:
80       return "TEAR_DOWN";
81     case NFC_STATUS_RF_TRANSMISSION_ERR:
82       return "RF_TRANSMISSION_ERR";
83     case NFC_STATUS_RF_PROTOCOL_ERR:
84       return "RF_PROTOCOL_ERR";
85     case NFC_STATUS_TIMEOUT:
86       return "TIMEOUT";
87     case NFC_STATUS_EE_INTF_ACTIVE_FAIL:
88       return "EE_INTF_ACTIVE_FAIL";
89     case NFC_STATUS_EE_TRANSMISSION_ERR:
90       return "EE_TRANSMISSION_ERR";
91     case NFC_STATUS_EE_PROTOCOL_ERR:
92       return "EE_PROTOCOL_ERR";
93     case NFC_STATUS_EE_TIMEOUT:
94       return "EE_TIMEOUT";
95     case NFC_STATUS_CMD_STARTED:
96       return "CMD_STARTED";
97     case NFC_STATUS_HW_TIMEOUT:
98       return "HW_TIMEOUT";
99     case NFC_STATUS_CONTINUE:
100       return "CONTINUE";
101     case NFC_STATUS_REFUSED:
102       return "REFUSED";
103     case NFC_STATUS_BAD_RESP:
104       return "BAD_RESP";
105     case NFC_STATUS_CMD_NOT_CMPLTD:
106       return "CMD_NOT_CMPLTD";
107     case NFC_STATUS_NO_BUFFERS:
108       return "NO_BUFFERS";
109     case NFC_STATUS_WRONG_PROTOCOL:
110       return "WRONG_PROTOCOL";
111     case NFC_STATUS_BUSY:
112       return "BUSY";
113     case NFC_STATUS_LINK_LOSS:
114       return "LINK_LOSS";
115     case NFC_STATUS_BAD_LENGTH:
116       return "BAD_LENGTH";
117     case NFC_STATUS_BAD_HANDLE:
118       return "BAD_HANDLE";
119     case NFC_STATUS_CONGESTED:
120       return "CONGESTED";
121     default:
122       return "UNKNOWN";
123   }
124 }