device: Set disconnect timer to zero for fast disconnection
[platform/upstream/bluez.git] / monitor / rfcomm.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 #define RFCOMM_SABM     0x2f
13 #define RFCOMM_DISC     0x43
14 #define RFCOMM_UA       0x63
15 #define RFCOMM_DM       0x0f
16 #define RFCOMM_UIH      0xef
17
18 #define RFCOMM_GET_TYPE(control)        ((control) & 0xef)
19 #define RFCOMM_GET_DLCI(address)        ((address & 0xfc) >> 2)
20 #define RFCOMM_GET_CHANNEL(address)     ((address & 0xf8) >> 3)
21 #define RFCOMM_GET_DIR(address)         ((address & 0x04) >> 2)
22 #define RFCOMM_TEST_EA(length)          ((length & 0x01))
23
24 struct rfcomm_hdr {
25         uint8_t address;
26         uint8_t control;
27         uint8_t length;
28 } __attribute__((packed));
29
30 struct rfcomm_cmd {
31         uint8_t address;
32         uint8_t control;
33         uint8_t length;
34         uint8_t fcs;
35 } __attribute__((packed));
36
37 #define RFCOMM_TEST    0x08
38 #define RFCOMM_FCON    0x28
39 #define RFCOMM_FCOFF   0x18
40 #define RFCOMM_MSC     0x38
41 #define RFCOMM_RPN     0x24
42 #define RFCOMM_RLS     0x14
43 #define RFCOMM_PN      0x20
44 #define RFCOMM_NSC     0x04
45
46 #define RFCOMM_TEST_CR(type)            ((type & 0x02))
47 #define RFCOMM_GET_MCC_TYPE(type)       ((type & 0xfc) >> 2)
48
49 struct rfcomm_mcc {
50         uint8_t type;
51         uint8_t length;
52 } __attribute__((packed));
53
54 struct rfcomm_msc {
55         uint8_t dlci;
56         uint8_t v24_sig;
57 } __attribute__((packed));
58
59 struct rfcomm_pn {
60         uint8_t  dlci;
61         uint8_t  flow_ctrl;
62         uint8_t  priority;
63         uint8_t  ack_timer;
64         uint16_t mtu;
65         uint8_t  max_retrans;
66         uint8_t  credits;
67 } __attribute__((packed));