rfcomm.h 1.5 KB

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