gatt-database: Add OCF service handling logic
[platform/upstream/bluez.git] / monitor / packet.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  *
4  *  BlueZ - Bluetooth protocol stack for Linux
5  *
6  *  Copyright (C) 2011-2014  Intel Corporation
7  *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
8  *
9  *
10  */
11
12 #include <stdint.h>
13 #include <stdbool.h>
14 #include <sys/time.h>
15 #include <sys/socket.h>
16
17 #define PACKET_FILTER_SHOW_INDEX        (1 << 0)
18 #define PACKET_FILTER_SHOW_DATE         (1 << 1)
19 #define PACKET_FILTER_SHOW_TIME         (1 << 2)
20 #define PACKET_FILTER_SHOW_TIME_OFFSET  (1 << 3)
21 #define PACKET_FILTER_SHOW_ACL_DATA     (1 << 4)
22 #define PACKET_FILTER_SHOW_SCO_DATA     (1 << 5)
23 #define PACKET_FILTER_SHOW_A2DP_STREAM  (1 << 6)
24 #define PACKET_FILTER_SHOW_MGMT_SOCKET  (1 << 7)
25
26 struct packet_conn_data {
27         uint16_t index;
28         uint8_t  src[6];
29         uint16_t handle;
30         uint8_t  type;
31         uint8_t  dst[6];
32         uint8_t  dst_type;
33         void     *data;
34         void     (*destroy)(void *data);
35 };
36
37 struct packet_conn_data *packet_get_conn_data(uint16_t handle);
38
39 bool packet_has_filter(unsigned long filter);
40 void packet_set_filter(unsigned long filter);
41 void packet_add_filter(unsigned long filter);
42 void packet_del_filter(unsigned long filter);
43
44 void packet_set_priority(const char *priority);
45 void packet_select_index(uint16_t index);
46 void packet_set_fallback_manufacturer(uint16_t manufacturer);
47 void packet_set_msft_evt_prefix(const uint8_t *prefix, uint8_t len);
48
49 void packet_hexdump(const unsigned char *buf, uint16_t len);
50 void packet_print_error(const char *label, uint8_t error);
51 void packet_print_version(const char *label, uint8_t version,
52                                 const char *sublabel, uint16_t subversion);
53 void packet_print_company(const char *label, uint16_t company);
54 void packet_print_addr(const char *label, const void *data, uint8_t type);
55 void packet_print_handle(uint16_t handle);
56 void packet_print_rssi(const char *label, int8_t rssi);
57 void packet_print_ad(const void *data, uint8_t size);
58 void packet_print_features_lmp(const uint8_t *features, uint8_t page);
59 void packet_print_features_ll(const uint8_t *features);
60 void packet_print_features_msft(const uint8_t *features);
61 void packet_print_channel_map_lmp(const uint8_t *map);
62 void packet_print_channel_map_ll(const uint8_t *map);
63 void packet_print_io_capability(uint8_t capability);
64 void packet_print_io_authentication(uint8_t authentication);
65 void packet_print_codec_id(const char *label, uint8_t codec);
66
67 #define LTV_DEC(_type, _func) \
68 { \
69         .type = _type, \
70         .func = _func, \
71 }
72
73 struct packet_ltv_decoder {
74         uint8_t  type;
75         void (*func)(const uint8_t *data, uint8_t len);
76 };
77
78 void packet_print_ltv(const char *label, const uint8_t *data, uint8_t len,
79                         struct packet_ltv_decoder *decoder, size_t num);
80
81 void packet_control(struct timeval *tv, struct ucred *cred,
82                                         uint16_t index, uint16_t opcode,
83                                         const void *data, uint16_t size);
84 void packet_monitor(struct timeval *tv, struct ucred *cred,
85                                         uint16_t index, uint16_t opcode,
86                                         const void *data, uint16_t size);
87 void packet_simulator(struct timeval *tv, uint16_t frequency,
88                                         const void *data, uint16_t size);
89
90 void packet_new_index(struct timeval *tv, uint16_t index, const char *label,
91                                 uint8_t type, uint8_t bus, const char *name);
92 void packet_del_index(struct timeval *tv, uint16_t index, const char *label);
93 void packet_open_index(struct timeval *tv, uint16_t index, const char *label);
94 void packet_close_index(struct timeval *tv, uint16_t index, const char *label);
95 void packet_index_info(struct timeval *tv, uint16_t index, const char *label,
96                                                         uint16_t manufacturer);
97 void packet_vendor_diag(struct timeval *tv, uint16_t index,
98                                         uint16_t manufacturer,
99                                         const void *data, uint16_t size);
100 void packet_system_note(struct timeval *tv, struct ucred *cred,
101                                         uint16_t index, const void *message);
102 void packet_user_logging(struct timeval *tv, struct ucred *cred,
103                                         uint16_t index, uint8_t priority,
104                                         const char *ident, const void *data,
105                                         uint16_t size);
106
107 void packet_hci_command(struct timeval *tv, struct ucred *cred, uint16_t index,
108                                         const void *data, uint16_t size);
109 void packet_hci_event(struct timeval *tv, struct ucred *cred, uint16_t index,
110                                         const void *data, uint16_t size);
111 void packet_hci_acldata(struct timeval *tv, struct ucred *cred, uint16_t index,
112                                 bool in, const void *data, uint16_t size);
113 void packet_hci_scodata(struct timeval *tv, struct ucred *cred, uint16_t index,
114                                 bool in, const void *data, uint16_t size);
115 void packet_hci_isodata(struct timeval *tv, struct ucred *cred, uint16_t index,
116                                 bool in, const void *data, uint16_t size);
117
118 void packet_ctrl_open(struct timeval *tv, struct ucred *cred, uint16_t index,
119                                         const void *data, uint16_t size);
120 void packet_ctrl_close(struct timeval *tv, struct ucred *cred, uint16_t index,
121                                         const void *data, uint16_t size);
122 void packet_ctrl_command(struct timeval *tv, struct ucred *cred, uint16_t index,
123                                         const void *data, uint16_t size);
124 void packet_ctrl_event(struct timeval *tv, struct ucred *cred, uint16_t index,
125                                         const void *data, uint16_t size);
126
127 void packet_todo(void);
128
129 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
130 void print_le_set_adv_parameters_cmd(const void *data, uint8_t size);
131 void print_le_set_random_address_cmd(const void *data, uint8_t size);
132 void print_le_set_adv_data_cmd(const void *data, uint8_t size);
133 void print_le_set_scan_rsp_data_cmd(const void *data, uint8_t size);
134 void print_le_set_adv_enable_cmd(const void *data, uint8_t size);
135 #endif