Fix build break for rpm
[framework/connectivity/bluez.git] / health / mcap_internal.h
1 /*
2  *
3  *  MCAP for BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
6  *
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.
11  *
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.
16  *
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
20  *
21  */
22
23 #ifndef __MCAP_INTERNAL_H
24 #define __MCAP_INTERNAL_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 typedef enum {
31         MCL_CONNECTED,
32         MCL_PENDING,
33         MCL_ACTIVE,
34         MCL_IDLE
35 } MCLState;
36
37 typedef enum {
38         MCL_ACCEPTOR,
39         MCL_INITIATOR
40 } MCLRole;
41
42 typedef enum {
43         MCL_AVAILABLE,
44         MCL_WAITING_RSP
45 } MCAPCtrl;
46
47 typedef enum {
48         MDL_WAITING,
49         MDL_CONNECTED,
50         MDL_DELETING,
51         MDL_CLOSED
52 } MDLState;
53
54 struct mcap_mdl_cb {
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 */
62 };
63
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 */
78
79         gboolean                csp_enabled;            /* CSP: functionality enabled */
80 };
81
82 struct mcap_csp;
83 struct mcap_mdl_op_cb;
84
85 struct mcap_mcl {
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 */
102 };
103
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 */
110
111 struct mcap_mdl {
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 */
119 };
120
121 struct sync_info_ind_data {
122         uint32_t        btclock;
123         uint64_t        timestamp;
124         uint16_t        accuracy;
125 };
126
127 int mcap_send_data(int sock, const void *buf, uint32_t size);
128
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);
132
133 #ifdef __cplusplus
134 }
135 #endif
136
137 #endif /* __MCAP_INTERNAL_H */