3 * MCAP for BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef __MCAP_INTERNAL_H
24 #define __MCAP_INTERNAL_H
55 mcap_mdl_event_cb mdl_connected; /* Remote device has created a MDL */
56 mcap_mdl_event_cb mdl_closed; /* Remote device has closed a MDL */
57 mcap_mdl_event_cb mdl_deleted; /* Remote device requested deleting a MDL */
58 mcap_mdl_event_cb mdl_aborted; /* Remote device aborted the mdl creation */
59 mcap_remote_mdl_conn_req_cb mdl_conn_req; /* Remote device requested creating a MDL */
60 mcap_remote_mdl_reconn_req_cb mdl_reconn_req; /* Remote device requested reconnecting a MDL */
61 gpointer user_data; /* User data */
64 struct mcap_instance {
65 bdaddr_t src; /* Source address */
66 GIOChannel *ccio; /* Control Channel IO */
67 GIOChannel *dcio; /* Data Channel IO */
68 GSList *mcls; /* MCAP instance list */
69 GSList *cached; /* List with all cached MCLs (MAX_CACHED macro) */
70 BtIOSecLevel sec; /* Security level */
71 mcap_mcl_event_cb mcl_connected_cb; /* New MCL connected */
72 mcap_mcl_event_cb mcl_reconnected_cb; /* Old MCL has been reconnected */
73 mcap_mcl_event_cb mcl_disconnected_cb; /* MCL disconnected */
74 mcap_mcl_event_cb mcl_uncached_cb; /* MCL has been removed from MCAP cache */
75 mcap_info_ind_event_cb mcl_sync_infoind_cb; /* (CSP Master) Received info indication */
76 gpointer user_data; /* Data to be provided in callbacks */
77 gint ref; /* Reference counter */
79 gboolean csp_enabled; /* CSP: functionality enabled */
83 struct mcap_mdl_op_cb;
86 struct mcap_instance *mi; /* MCAP instance where this MCL belongs */
87 bdaddr_t addr; /* Device address */
88 GIOChannel *cc; /* MCAP Control Channel IO */
89 guint wid; /* MCL Watcher id */
90 GSList *mdls; /* List of Data Channels shorted by mdlid */
91 MCLState state; /* Current MCL State */
92 MCLRole role; /* Initiator or acceptor of this MCL */
93 MCAPCtrl req; /* Request control flag */
94 struct mcap_mdl_op_cb *priv_data; /* Temporal data to manage responses */
95 struct mcap_mdl_cb *cb; /* MDL callbacks */
96 guint tid; /* Timer id for waiting for a response */
97 uint8_t *lcmd; /* Last command sent */
98 gint ref; /* References counter */
99 uint8_t ctrl; /* MCL control flag */
100 uint16_t next_mdl; /* id used to create next MDL */
101 struct mcap_csp *csp; /* CSP control structure */
104 #define MCAP_CTRL_CACHED 0x01 /* MCL is cached */
105 #define MCAP_CTRL_STD_OP 0x02 /* Support for standard op codes */
106 #define MCAP_CTRL_SYNC_OP 0x04 /* Support for synchronization commands */
107 #define MCAP_CTRL_CONN 0x08 /* MCL is in connecting process */
108 #define MCAP_CTRL_FREE 0x10 /* MCL is marked as releasable */
109 #define MCAP_CTRL_NOCACHE 0x20 /* MCL is marked as not cacheable */
112 struct mcap_mcl *mcl; /* MCL where this MDL belongs */
113 GIOChannel *dc; /* MCAP Data Channel IO */
114 guint wid; /* MDL Watcher id */
115 uint16_t mdlid; /* MDL id */
116 uint8_t mdep_id; /* MCAP Data End Point */
117 MDLState state; /* MDL state */
118 gint ref; /* References counter */
121 struct sync_info_ind_data {
127 int mcap_send_data(int sock, const void *buf, uint32_t size);
129 void proc_sync_cmd(struct mcap_mcl *mcl, uint8_t *cmd, uint32_t len);
130 void mcap_sync_init(struct mcap_mcl *mcl);
131 void mcap_sync_stop(struct mcap_mcl *mcl);
137 #endif /* __MCAP_INTERNAL_H */