blob: 83f6cb5b69feb996c4d609c13677938ba22cfeea [file] [log] [blame]
nxpandroidc7611652015-09-23 16:42:05 +05301/******************************************************************************
2 *
3 * Copyright (C) 2010-2014 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
nxpandroidc7611652015-09-23 16:42:05 +053019/******************************************************************************
20 *
21 * This is the private interface file for the NFA SNEP.
22 *
23 ******************************************************************************/
24#ifndef NFA_SNEP_INT_H
25#define NFA_SNEP_INT_H
26
nxf24591c1cbeab2018-02-21 17:32:26 +053027#if (NFA_SNEP_INCLUDED == TRUE)
nxpandroidc7611652015-09-23 16:42:05 +053028#include "llcp_api.h"
29#include "nfa_snep_api.h"
30
31/*****************************************************************************
32** Constants and data types
33*****************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +053034/* SNEP Acceptable Length size */
nxpandroidc7611652015-09-23 16:42:05 +053035
36/* NFA SNEP events */
nxpandroid8f6d0532017-07-12 18:25:30 +053037enum {
38 NFA_SNEP_API_START_DEFAULT_SERVER_EVT = NFA_SYS_EVT_START(NFA_ID_SNEP),
39 NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT,
40 NFA_SNEP_API_REG_SERVER_EVT,
41 NFA_SNEP_API_REG_CLIENT_EVT,
42 NFA_SNEP_API_DEREG_EVT,
43 NFA_SNEP_API_CONNECT_EVT,
44 NFA_SNEP_API_GET_REQ_EVT,
45 NFA_SNEP_API_PUT_REQ_EVT,
46 NFA_SNEP_API_GET_RESP_EVT,
47 NFA_SNEP_API_PUT_RESP_EVT,
nxf24591c1cbeab2018-02-21 17:32:26 +053048 NFA_SNEP_API_DISCONNECT_EVT
nxpandroidc7611652015-09-23 16:42:05 +053049
nxpandroidc7611652015-09-23 16:42:05 +053050};
51
52/* data type for NFA_SNEP_API_START_DEFAULT_SERVER_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053053typedef struct {
54 NFC_HDR hdr;
55 tNFA_SNEP_CBACK* p_cback;
nxpandroidc7611652015-09-23 16:42:05 +053056} tNFA_SNEP_API_START_DEFAULT_SERVER;
57
58/* data type for NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053059typedef struct {
60 NFC_HDR hdr;
61 tNFA_SNEP_CBACK* p_cback;
nxpandroidc7611652015-09-23 16:42:05 +053062} tNFA_SNEP_API_STOP_DEFAULT_SERVER;
63
64/* data type for NFA_SNEP_API_REG_SERVER_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053065typedef struct {
66 NFC_HDR hdr;
67 uint8_t server_sap;
68 char service_name[LLCP_MAX_SN_LEN + 1];
69 tNFA_SNEP_CBACK* p_cback;
nxpandroidc7611652015-09-23 16:42:05 +053070} tNFA_SNEP_API_REG_SERVER;
71
72/* data type for NFA_SNEP_API_REG_CLIENT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053073typedef struct {
74 NFC_HDR hdr;
75 tNFA_SNEP_CBACK* p_cback;
nxpandroidc7611652015-09-23 16:42:05 +053076} tNFA_SNEP_API_REG_CLIENT;
77
78/* data type for NFA_SNEP_API_DEREG_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053079typedef struct {
80 NFC_HDR hdr;
81 tNFA_HANDLE reg_handle; /* handle for registered server/client */
nxpandroidc7611652015-09-23 16:42:05 +053082} tNFA_SNEP_API_DEREG;
83
84/* data type for NFA_SNEP_API_CONNECT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053085typedef struct {
86 NFC_HDR hdr;
87 tNFA_HANDLE client_handle; /* handle for client */
88 char service_name[LLCP_MAX_SN_LEN + 1];
nxpandroidc7611652015-09-23 16:42:05 +053089} tNFA_SNEP_API_CONNECT;
90
91/* data type for NFA_SNEP_API_GET_REQ_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053092typedef struct {
93 NFC_HDR hdr;
94 tNFA_HANDLE conn_handle; /* handle for data link connection */
95 uint32_t buff_length; /* length of buffer; acceptable length */
96 uint32_t ndef_length; /* length of current NDEF message */
97 uint8_t* p_ndef_buff; /* buffer for NDEF message */
nxpandroidc7611652015-09-23 16:42:05 +053098} tNFA_SNEP_API_GET_REQ;
99
100/* data type for NFA_SNEP_API_PUT_REQ_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530101typedef struct {
102 NFC_HDR hdr;
103 tNFA_HANDLE conn_handle; /* handle for data link connection */
104 uint32_t ndef_length; /* length of NDEF message */
105 uint8_t* p_ndef_buff; /* buffer for NDEF message */
nxpandroidc7611652015-09-23 16:42:05 +0530106} tNFA_SNEP_API_PUT_REQ;
107
108/* data type for NFA_SNEP_API_GET_RESP_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530109typedef struct {
110 NFC_HDR hdr;
111 tNFA_HANDLE conn_handle; /* handle for data link connection */
112 tNFA_SNEP_RESP_CODE resp_code; /* response code */
113 uint32_t ndef_length; /* length of NDEF message */
114 uint8_t* p_ndef_buff; /* buffer for NDEF message */
nxpandroidc7611652015-09-23 16:42:05 +0530115} tNFA_SNEP_API_GET_RESP;
116
117/* data type for NFA_SNEP_API_PUT_RESP_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530118typedef struct {
119 NFC_HDR hdr;
120 tNFA_HANDLE conn_handle; /* handle for data link connection */
121 tNFA_SNEP_RESP_CODE resp_code; /* response code */
nxpandroidc7611652015-09-23 16:42:05 +0530122} tNFA_SNEP_API_PUT_RESP;
123
124/* data type for NFA_SNEP_API_DISCONNECT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530125typedef struct {
126 NFC_HDR hdr;
127 tNFA_HANDLE conn_handle; /* response code */
nxf24591c1cbeab2018-02-21 17:32:26 +0530128 bool flush; /* TRUE if discard pending data */
nxpandroidc7611652015-09-23 16:42:05 +0530129} tNFA_SNEP_API_DISCONNECT;
130
131/* union of all event data types */
nxpandroid8f6d0532017-07-12 18:25:30 +0530132typedef union {
133 NFC_HDR hdr;
134 tNFA_SNEP_API_START_DEFAULT_SERVER
135 api_start_default_server; /* NFA_SNEP_API_START_DEFAULT_SERVER_EVT */
136 tNFA_SNEP_API_STOP_DEFAULT_SERVER
137 api_stop_default_server; /* NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT */
138 tNFA_SNEP_API_REG_SERVER api_reg_server; /* NFA_SNEP_API_REG_SERVER_EVT */
139 tNFA_SNEP_API_REG_CLIENT api_reg_client; /* NFA_SNEP_API_REG_CLIENT_EVT */
140 tNFA_SNEP_API_DEREG api_dereg; /* NFA_SNEP_API_DEREG_EVT */
141 tNFA_SNEP_API_CONNECT api_connect; /* NFA_SNEP_API_CONNECT_EVT */
142 tNFA_SNEP_API_GET_REQ api_get_req; /* NFA_SNEP_API_GET_REQ_EVT */
143 tNFA_SNEP_API_PUT_REQ api_put_req; /* NFA_SNEP_API_PUT_REQ_EVT */
144 tNFA_SNEP_API_GET_RESP api_get_resp; /* NFA_SNEP_API_GET_RESP_EVT */
145 tNFA_SNEP_API_PUT_RESP api_put_resp; /* NFA_SNEP_API_PUT_RESP_EVT */
146 tNFA_SNEP_API_DISCONNECT api_disc; /* NFA_SNEP_API_DISCONNECT_EVT */
nxpandroidc7611652015-09-23 16:42:05 +0530147} tNFA_SNEP_MSG;
148
149/*****************************************************************************
150** control block
151*****************************************************************************/
152
153/* NFA SNEP service control block */
nxpandroid8f6d0532017-07-12 18:25:30 +0530154/* ignore flags while searching */
nxpandroid8f6d0532017-07-12 18:25:30 +0530155/* waiting for connection confirm */
nxpandroid8f6d0532017-07-12 18:25:30 +0530156/* data link connected */
nxpandroid8f6d0532017-07-12 18:25:30 +0530157/* Waiting for continue response */
nxpandroid8f6d0532017-07-12 18:25:30 +0530158/* Waiting for continue request */
nxpandroidc7611652015-09-23 16:42:05 +0530159
nxpandroid8f6d0532017-07-12 18:25:30 +0530160typedef struct {
161 uint8_t local_sap; /* local SAP of service */
162 uint8_t remote_sap; /* local SAP of service */
163 uint8_t flags; /* internal flags */
164 tNFA_SNEP_CBACK* p_cback; /* callback for event */
165 TIMER_LIST_ENT timer; /* timer for client */
nxpandroidc7611652015-09-23 16:42:05 +0530166
nxpandroid8f6d0532017-07-12 18:25:30 +0530167 uint16_t tx_miu; /* adjusted MIU for throughput */
nxf24591c1cbeab2018-02-21 17:32:26 +0530168 bool congest; /* TRUE if data link connection is congested */
169 bool rx_fragments; /* TRUE if waiting more fragments */
nxpandroidc7611652015-09-23 16:42:05 +0530170
nxpandroid8f6d0532017-07-12 18:25:30 +0530171 uint8_t tx_code; /* transmitted code in request/response */
172 uint8_t rx_code; /* received code in request/response */
nxpandroidc7611652015-09-23 16:42:05 +0530173
nxpandroid8f6d0532017-07-12 18:25:30 +0530174 uint32_t acceptable_length;
175 uint32_t buff_length; /* size of buffer for NDEF message */
176 uint32_t ndef_length; /* length of NDEF message */
177 uint32_t cur_length; /* currently sent or received length */
178 uint8_t* p_ndef_buff; /* NDEF message buffer */
nxpandroidc7611652015-09-23 16:42:05 +0530179} tNFA_SNEP_CONN;
180
181/*
182** NFA SNEP control block
183*/
nxpandroid8f6d0532017-07-12 18:25:30 +0530184typedef struct {
185 tNFA_SNEP_CONN conn[NFA_SNEP_MAX_CONN];
186 bool listen_enabled;
187 bool is_dta_mode;
nxpandroidc7611652015-09-23 16:42:05 +0530188} tNFA_SNEP_CB;
189
190/*
191** NFA SNEP default server control block
192*/
193
194/* multiple data link connections for default server */
nxpandroid8f6d0532017-07-12 18:25:30 +0530195typedef struct {
196 tNFA_HANDLE conn_handle; /* connection handle for default server */
197 uint8_t* p_rx_ndef; /* buffer to receive NDEF */
nxpandroidc7611652015-09-23 16:42:05 +0530198} tNFA_SNEP_DEFAULT_CONN;
199
nxpandroid8f6d0532017-07-12 18:25:30 +0530200#define NFA_SNEP_DEFAULT_MAX_CONN 3
nxpandroidc7611652015-09-23 16:42:05 +0530201
nxpandroid8f6d0532017-07-12 18:25:30 +0530202typedef struct {
203 tNFA_HANDLE server_handle; /* registered handle for default server */
204 tNFA_SNEP_DEFAULT_CONN
205 conn[NFA_SNEP_DEFAULT_MAX_CONN]; /* connections for default server */
nxpandroidc7611652015-09-23 16:42:05 +0530206
207} tNFA_SNEP_DEFAULT_CB;
208
209/*****************************************************************************
210** External variables
211*****************************************************************************/
212
213/* NFA SNEP control block */
nxpandroidc7611652015-09-23 16:42:05 +0530214extern tNFA_SNEP_CB nfa_snep_cb;
nxpandroidc7611652015-09-23 16:42:05 +0530215
216/* NFA SNEP default server control block */
nxpandroidc7611652015-09-23 16:42:05 +0530217extern tNFA_SNEP_DEFAULT_CB nfa_snep_default_cb;
nxpandroidc7611652015-09-23 16:42:05 +0530218
219/*****************************************************************************
220** External functions
221*****************************************************************************/
222/*
223** nfa_snep_main.c
224*/
nxpandroid8f6d0532017-07-12 18:25:30 +0530225void nfa_snep_init(bool is_dta_mode);
nxpandroidc7611652015-09-23 16:42:05 +0530226
nxf24591c1cbeab2018-02-21 17:32:26 +0530227#endif /* (NFA_SNEP_INCLUDED == TRUE) */
nxpandroidc7611652015-09-23 16:42:05 +0530228#endif /* NFA_SNEP_INT_H */