Home | History | Annotate | Download | only in int
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2010-2012 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 (defined (NFA_SNEP_INCLUDED) && (NFA_SNEP_INCLUDED==TRUE))
     28 #include "llcp_api.h"
     29 #include "nfa_snep_api.h"
     30 
     31 /*****************************************************************************
     32 **  Constants and data types
     33 *****************************************************************************/
     34 #define NFA_SNEP_DEFAULT_SERVER_SAP     0x04    /* SNEP default server SAP   */
     35 #define NFA_SNEP_HEADER_SIZE            6       /* SNEP header size          */
     36 #define NFA_SNEP_ACCEPT_LEN_SIZE        4       /* SNEP Acceptable Length size */
     37 #define NFA_SNEP_CLIENT_TIMEOUT         1000    /* ms, waiting for response  */
     38 
     39 /* NFA SNEP events */
     40 enum
     41 {
     42     NFA_SNEP_API_START_DEFAULT_SERVER_EVT  = NFA_SYS_EVT_START (NFA_ID_SNEP),
     43     NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT,
     44     NFA_SNEP_API_REG_SERVER_EVT,
     45     NFA_SNEP_API_REG_CLIENT_EVT,
     46     NFA_SNEP_API_DEREG_EVT,
     47     NFA_SNEP_API_CONNECT_EVT,
     48     NFA_SNEP_API_GET_REQ_EVT,
     49     NFA_SNEP_API_PUT_REQ_EVT,
     50     NFA_SNEP_API_GET_RESP_EVT,
     51     NFA_SNEP_API_PUT_RESP_EVT,
     52     NFA_SNEP_API_DISCONNECT_EVT,
     53 
     54     NFA_SNEP_LAST_EVT
     55 };
     56 
     57 /* data type for NFA_SNEP_API_START_DEFAULT_SERVER_EVT */
     58 typedef struct
     59 {
     60     BT_HDR              hdr;
     61     tNFA_SNEP_CBACK     *p_cback;
     62 } tNFA_SNEP_API_START_DEFAULT_SERVER;
     63 
     64 /* data type for NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT */
     65 typedef struct
     66 {
     67     BT_HDR              hdr;
     68     tNFA_SNEP_CBACK     *p_cback;
     69 } tNFA_SNEP_API_STOP_DEFAULT_SERVER;
     70 
     71 /* data type for NFA_SNEP_API_REG_SERVER_EVT */
     72 typedef struct
     73 {
     74     BT_HDR              hdr;
     75     UINT8               server_sap;
     76     char                service_name[LLCP_MAX_SN_LEN + 1];
     77     tNFA_SNEP_CBACK     *p_cback;
     78 } tNFA_SNEP_API_REG_SERVER;
     79 
     80 /* data type for NFA_SNEP_API_REG_CLIENT_EVT */
     81 typedef struct
     82 {
     83     BT_HDR              hdr;
     84     tNFA_SNEP_CBACK     *p_cback;
     85 } tNFA_SNEP_API_REG_CLIENT;
     86 
     87 /* data type for NFA_SNEP_API_DEREG_EVT */
     88 typedef struct
     89 {
     90     BT_HDR              hdr;
     91     tNFA_HANDLE         reg_handle;     /* handle for registered server/client */
     92 } tNFA_SNEP_API_DEREG;
     93 
     94 /* data type for NFA_SNEP_API_CONNECT_EVT */
     95 typedef struct
     96 {
     97     BT_HDR              hdr;
     98     tNFA_HANDLE         client_handle;  /* handle for client                   */
     99     char                service_name[LLCP_MAX_SN_LEN + 1];
    100 } tNFA_SNEP_API_CONNECT;
    101 
    102 /* data type for NFA_SNEP_API_GET_REQ_EVT */
    103 typedef struct
    104 {
    105     BT_HDR              hdr;
    106     tNFA_HANDLE         conn_handle;    /* handle for data link connection      */
    107     UINT32              buff_length;    /* length of buffer; acceptable length  */
    108     UINT32              ndef_length;    /* length of current NDEF message       */
    109     UINT8               *p_ndef_buff;   /* buffer for NDEF message              */
    110 } tNFA_SNEP_API_GET_REQ;
    111 
    112 /* data type for NFA_SNEP_API_PUT_REQ_EVT */
    113 typedef struct
    114 {
    115     BT_HDR              hdr;
    116     tNFA_HANDLE         conn_handle;    /* handle for data link connection */
    117     UINT32              ndef_length;    /* length of NDEF message          */
    118     UINT8               *p_ndef_buff;   /* buffer for NDEF message         */
    119 } tNFA_SNEP_API_PUT_REQ;
    120 
    121 /* data type for NFA_SNEP_API_GET_RESP_EVT */
    122 typedef struct
    123 {
    124     BT_HDR              hdr;
    125     tNFA_HANDLE         conn_handle;    /* handle for data link connection */
    126     tNFA_SNEP_RESP_CODE resp_code;      /* response code                   */
    127     UINT32              ndef_length;    /* length of NDEF message          */
    128     UINT8               *p_ndef_buff;   /* buffer for NDEF message         */
    129 } tNFA_SNEP_API_GET_RESP;
    130 
    131 /* data type for NFA_SNEP_API_PUT_RESP_EVT */
    132 typedef struct
    133 {
    134     BT_HDR              hdr;
    135     tNFA_HANDLE         conn_handle;    /* handle for data link connection */
    136     tNFA_SNEP_RESP_CODE resp_code;      /* response code                   */
    137 } tNFA_SNEP_API_PUT_RESP;
    138 
    139 /* data type for NFA_SNEP_API_DISCONNECT_EVT */
    140 typedef struct
    141 {
    142     BT_HDR              hdr;
    143     tNFA_HANDLE         conn_handle;    /* response code                   */
    144     BOOLEAN             flush;          /* TRUE if discard pending data    */
    145 } tNFA_SNEP_API_DISCONNECT;
    146 
    147 /* union of all event data types */
    148 typedef union
    149 {
    150     BT_HDR                              hdr;
    151     tNFA_SNEP_API_START_DEFAULT_SERVER  api_start_default_server;   /* NFA_SNEP_API_START_DEFAULT_SERVER_EVT */
    152     tNFA_SNEP_API_STOP_DEFAULT_SERVER   api_stop_default_server;    /* NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT  */
    153     tNFA_SNEP_API_REG_SERVER            api_reg_server;             /* NFA_SNEP_API_REG_SERVER_EVT   */
    154     tNFA_SNEP_API_REG_CLIENT            api_reg_client;             /* NFA_SNEP_API_REG_CLIENT_EVT   */
    155     tNFA_SNEP_API_DEREG                 api_dereg;                  /* NFA_SNEP_API_DEREG_EVT        */
    156     tNFA_SNEP_API_CONNECT               api_connect;                /* NFA_SNEP_API_CONNECT_EVT      */
    157     tNFA_SNEP_API_GET_REQ               api_get_req;                /* NFA_SNEP_API_GET_REQ_EVT      */
    158     tNFA_SNEP_API_PUT_REQ               api_put_req;                /* NFA_SNEP_API_PUT_REQ_EVT      */
    159     tNFA_SNEP_API_GET_RESP              api_get_resp;               /* NFA_SNEP_API_GET_RESP_EVT     */
    160     tNFA_SNEP_API_PUT_RESP              api_put_resp;               /* NFA_SNEP_API_PUT_RESP_EVT     */
    161     tNFA_SNEP_API_DISCONNECT            api_disc;                   /* NFA_SNEP_API_DISCONNECT_EVT   */
    162 } tNFA_SNEP_MSG;
    163 
    164 /*****************************************************************************
    165 **  control block
    166 *****************************************************************************/
    167 
    168 /* NFA SNEP service control block */
    169 #define NFA_SNEP_FLAG_ANY               0x00   /* ignore flags while searching   */
    170 #define NFA_SNEP_FLAG_SERVER            0x01   /* server */
    171 #define NFA_SNEP_FLAG_CLIENT            0x02   /* client */
    172 #define NFA_SNEP_FLAG_CONNECTING        0x04   /* waiting for connection confirm */
    173 #define NFA_SNEP_FLAG_CONNECTED         0x08   /* data link connected            */
    174 #define NFA_SNEP_FLAG_W4_RESP_CONTINUE  0x10   /* Waiting for continue response  */
    175 #define NFA_SNEP_FLAG_W4_REQ_CONTINUE   0x20   /* Waiting for continue request   */
    176 
    177 typedef struct
    178 {
    179     UINT8               local_sap;      /* local SAP of service */
    180     UINT8               remote_sap;     /* local SAP of service */
    181     UINT8               flags;          /* internal flags       */
    182     tNFA_SNEP_CBACK    *p_cback;        /* callback for event   */
    183     TIMER_LIST_ENT      timer;          /* timer for client     */
    184 
    185     UINT16              tx_miu;         /* adjusted MIU for throughput              */
    186     BOOLEAN             congest;        /* TRUE if data link connection is congested */
    187     BOOLEAN             rx_fragments;   /* TRUE if waiting more fragments            */
    188 
    189     UINT8               tx_code;        /* transmitted code in request/response */
    190     UINT8               rx_code;        /* received code in request/response    */
    191 
    192     UINT32              acceptable_length;
    193     UINT32              buff_length;    /* size of buffer for NDEF message   */
    194     UINT32              ndef_length;    /* length of NDEF message            */
    195     UINT32              cur_length;     /* currently sent or received length */
    196     UINT8               *p_ndef_buff;   /* NDEF message buffer               */
    197 } tNFA_SNEP_CONN;
    198 
    199 /*
    200 ** NFA SNEP control block
    201 */
    202 typedef struct
    203 {
    204     tNFA_SNEP_CONN      conn[NFA_SNEP_MAX_CONN];
    205     BOOLEAN             listen_enabled;
    206     BOOLEAN             is_dta_mode;
    207     UINT8               trace_level;
    208 } tNFA_SNEP_CB;
    209 
    210 /*
    211 ** NFA SNEP default server control block
    212 */
    213 
    214 /* multiple data link connections for default server */
    215 typedef struct
    216 {
    217     tNFA_HANDLE         conn_handle;    /* connection handle for default server   */
    218     UINT8               *p_rx_ndef;     /* buffer to receive NDEF                 */
    219 } tNFA_SNEP_DEFAULT_CONN;
    220 
    221 #define NFA_SNEP_DEFAULT_MAX_CONN    3
    222 
    223 typedef struct
    224 {
    225 
    226     tNFA_HANDLE             server_handle;                  /* registered handle for default server   */
    227     tNFA_SNEP_DEFAULT_CONN  conn[NFA_SNEP_DEFAULT_MAX_CONN];/* connections for default server         */
    228 
    229 } tNFA_SNEP_DEFAULT_CB;
    230 
    231 /*****************************************************************************
    232 **  External variables
    233 *****************************************************************************/
    234 
    235 /* NFA SNEP control block */
    236 #if NFA_DYNAMIC_MEMORY == FALSE
    237 extern tNFA_SNEP_CB nfa_snep_cb;
    238 #else
    239 extern tNFA_SNEP_CB *nfa_snep_cb_ptr;
    240 #define nfa_snep_cb (*nfa_snep_cb_ptr)
    241 #endif
    242 
    243 /* NFA SNEP default server control block */
    244 #if NFA_DYNAMIC_MEMORY == FALSE
    245 extern tNFA_SNEP_DEFAULT_CB nfa_snep_default_cb;
    246 #else
    247 extern tNFA_SNEP_DEFAULT_CB *nfa_snep_default_cb_ptr;
    248 #define nfa_snep_default_cb (*nfa_snep_default_cb_ptr)
    249 #endif
    250 
    251 /*****************************************************************************
    252 **  External functions
    253 *****************************************************************************/
    254 /*
    255 **  nfa_snep_main.c
    256 */
    257 void nfa_snep_init (BOOLEAN is_dta_mode);
    258 /*
    259 **  nfa_snep_default.c
    260 */
    261 void nfa_snep_default_init (void);
    262 BOOLEAN nfa_snep_start_default_server (tNFA_SNEP_MSG *p_msg);
    263 BOOLEAN nfa_snep_stop_default_server (tNFA_SNEP_MSG *p_msg);
    264 /*
    265 **  nfa_snep_srv.c
    266 */
    267 UINT8 nfa_snep_allocate_cb (void);
    268 void nfa_snep_deallocate_cb (UINT8 xx);
    269 void nfa_snep_send_msg (UINT8 opcode, UINT8 dlink);
    270 
    271 void nfa_snep_llcp_cback (tLLCP_SAP_CBACK_DATA *p_data);
    272 void nfa_snep_proc_llcp_data_ind (tLLCP_SAP_CBACK_DATA  *p_data);
    273 void nfa_snep_proc_llcp_connect_ind (tLLCP_SAP_CBACK_DATA  *p_data);
    274 void nfa_snep_proc_llcp_connect_resp (tLLCP_SAP_CBACK_DATA  *p_data);
    275 void nfa_snep_proc_llcp_disconnect_ind (tLLCP_SAP_CBACK_DATA  *p_data);
    276 void nfa_snep_proc_llcp_disconnect_resp (tLLCP_SAP_CBACK_DATA  *p_data);
    277 void nfa_snep_proc_llcp_congest (tLLCP_SAP_CBACK_DATA  *p_data);
    278 void nfa_snep_proc_llcp_link_status (tLLCP_SAP_CBACK_DATA  *p_data);
    279 void nfa_snep_proc_llcp_tx_complete (tLLCP_SAP_CBACK_DATA  *p_data);
    280 
    281 BOOLEAN nfa_snep_reg_server (tNFA_SNEP_MSG *p_msg);
    282 BOOLEAN nfa_snep_reg_client (tNFA_SNEP_MSG *p_msg);
    283 BOOLEAN nfa_snep_dereg (tNFA_SNEP_MSG *p_msg);
    284 BOOLEAN nfa_snep_connect (tNFA_SNEP_MSG *p_msg);
    285 BOOLEAN nfa_snep_put_resp (tNFA_SNEP_MSG *p_msg);
    286 BOOLEAN nfa_snep_get_resp (tNFA_SNEP_MSG *p_msg);
    287 BOOLEAN nfa_snep_put_req (tNFA_SNEP_MSG *p_msg);
    288 BOOLEAN nfa_snep_get_req (tNFA_SNEP_MSG *p_msg);
    289 BOOLEAN nfa_snep_disconnect (tNFA_SNEP_MSG *p_msg);
    290 
    291 #endif /* (defined (NFA_SNEP_INCLUDED) && (NFA_SNEP_INCLUDED==TRUE)) */
    292 #endif /* NFA_SNEP_INT_H */
    293