• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
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 
19 /******************************************************************************
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 
27 #if (NFA_SNEP_INCLUDED == TRUE)
28 #include "llcp_api.h"
29 #include "nfa_snep_api.h"
30 
31 /*****************************************************************************
32 **  Constants and data types
33 *****************************************************************************/
34 /* SNEP Acceptable Length size */
35 
36 /* NFA SNEP events */
37 enum {
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,
48   NFA_SNEP_API_DISCONNECT_EVT
49 
50 };
51 
52 /* data type for NFA_SNEP_API_START_DEFAULT_SERVER_EVT */
53 typedef struct {
54   NFC_HDR hdr;
55   tNFA_SNEP_CBACK* p_cback;
56 } tNFA_SNEP_API_START_DEFAULT_SERVER;
57 
58 /* data type for NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT */
59 typedef struct {
60   NFC_HDR hdr;
61   tNFA_SNEP_CBACK* p_cback;
62 } tNFA_SNEP_API_STOP_DEFAULT_SERVER;
63 
64 /* data type for NFA_SNEP_API_REG_SERVER_EVT */
65 typedef 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;
70 } tNFA_SNEP_API_REG_SERVER;
71 
72 /* data type for NFA_SNEP_API_REG_CLIENT_EVT */
73 typedef struct {
74   NFC_HDR hdr;
75   tNFA_SNEP_CBACK* p_cback;
76 } tNFA_SNEP_API_REG_CLIENT;
77 
78 /* data type for NFA_SNEP_API_DEREG_EVT */
79 typedef struct {
80   NFC_HDR hdr;
81   tNFA_HANDLE reg_handle; /* handle for registered server/client */
82 } tNFA_SNEP_API_DEREG;
83 
84 /* data type for NFA_SNEP_API_CONNECT_EVT */
85 typedef struct {
86   NFC_HDR hdr;
87   tNFA_HANDLE client_handle; /* handle for client                   */
88   char service_name[LLCP_MAX_SN_LEN + 1];
89 } tNFA_SNEP_API_CONNECT;
90 
91 /* data type for NFA_SNEP_API_GET_REQ_EVT */
92 typedef 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              */
98 } tNFA_SNEP_API_GET_REQ;
99 
100 /* data type for NFA_SNEP_API_PUT_REQ_EVT */
101 typedef 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         */
106 } tNFA_SNEP_API_PUT_REQ;
107 
108 /* data type for NFA_SNEP_API_GET_RESP_EVT */
109 typedef 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         */
115 } tNFA_SNEP_API_GET_RESP;
116 
117 /* data type for NFA_SNEP_API_PUT_RESP_EVT */
118 typedef struct {
119   NFC_HDR hdr;
120   tNFA_HANDLE conn_handle;       /* handle for data link connection */
121   tNFA_SNEP_RESP_CODE resp_code; /* response code                   */
122 } tNFA_SNEP_API_PUT_RESP;
123 
124 /* data type for NFA_SNEP_API_DISCONNECT_EVT */
125 typedef struct {
126   NFC_HDR hdr;
127   tNFA_HANDLE conn_handle; /* response code                   */
128   bool flush;              /* TRUE if discard pending data    */
129 } tNFA_SNEP_API_DISCONNECT;
130 
131 /* union of all event data types */
132 typedef 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   */
147 } tNFA_SNEP_MSG;
148 
149 /*****************************************************************************
150 **  control block
151 *****************************************************************************/
152 
153 /* NFA SNEP service control block */
154 /* ignore flags while searching   */
155 /* waiting for connection confirm */
156 /* data link connected            */
157 /* Waiting for continue response  */
158 /* Waiting for continue request   */
159 
160 typedef 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     */
166 
167   uint16_t tx_miu;   /* adjusted MIU for throughput              */
168   bool congest;      /* TRUE if data link connection is congested */
169   bool rx_fragments; /* TRUE if waiting more fragments            */
170 
171   uint8_t tx_code; /* transmitted code in request/response */
172   uint8_t rx_code; /* received code in request/response    */
173 
174   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               */
179 } tNFA_SNEP_CONN;
180 
181 /*
182 ** NFA SNEP control block
183 */
184 typedef struct {
185   tNFA_SNEP_CONN conn[NFA_SNEP_MAX_CONN];
186   bool listen_enabled;
187   bool is_dta_mode;
188 } tNFA_SNEP_CB;
189 
190 /*
191 ** NFA SNEP default server control block
192 */
193 
194 /* multiple data link connections for default server */
195 typedef struct {
196   tNFA_HANDLE conn_handle; /* connection handle for default server   */
197   uint8_t* p_rx_ndef;      /* buffer to receive NDEF                 */
198 } tNFA_SNEP_DEFAULT_CONN;
199 
200 #define NFA_SNEP_DEFAULT_MAX_CONN 3
201 
202 typedef 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 */
206 
207 } tNFA_SNEP_DEFAULT_CB;
208 
209 /*****************************************************************************
210 **  External variables
211 *****************************************************************************/
212 
213 /* NFA SNEP control block */
214 extern tNFA_SNEP_CB nfa_snep_cb;
215 
216 /* NFA SNEP default server control block */
217 extern tNFA_SNEP_DEFAULT_CB nfa_snep_default_cb;
218 
219 /*****************************************************************************
220 **  External functions
221 *****************************************************************************/
222 /*
223 **  nfa_snep_main.c
224 */
225 void nfa_snep_init(bool is_dta_mode);
226 
227 #endif /* (NFA_SNEP_INCLUDED == TRUE) */
228 #endif /* NFA_SNEP_INT_H */
229