bnep.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
  7. * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
  8. *
  9. *
  10. */
  11. #ifndef __BNEP_H
  12. #define __BNEP_H
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #include <bluetooth/bluetooth.h>
  17. #ifndef ETH_ALEN
  18. #define ETH_ALEN 6 /* from <net/ethernet.h> */
  19. #endif
  20. /* BNEP UUIDs */
  21. #define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
  22. #define BNEP_UUID16 0x02
  23. #define BNEP_UUID32 0x04
  24. #define BNEP_UUID128 0x16
  25. #define BNEP_SVC_PANU 0x1115
  26. #define BNEP_SVC_NAP 0x1116
  27. #define BNEP_SVC_GN 0x1117
  28. /* BNEP packet types */
  29. #define BNEP_GENERAL 0x00
  30. #define BNEP_CONTROL 0x01
  31. #define BNEP_COMPRESSED 0x02
  32. #define BNEP_COMPRESSED_SRC_ONLY 0x03
  33. #define BNEP_COMPRESSED_DST_ONLY 0x04
  34. /* BNEP control types */
  35. #define BNEP_CMD_NOT_UNDERSTOOD 0x00
  36. #define BNEP_SETUP_CONN_REQ 0x01
  37. #define BNEP_SETUP_CONN_RSP 0x02
  38. #define BNEP_FILTER_NET_TYPE_SET 0x03
  39. #define BNEP_FILTER_NET_TYPE_RSP 0x04
  40. #define BNEP_FILTER_MULT_ADDR_SET 0x05
  41. #define BNEP_FILTER_MULT_ADDR_RSP 0x06
  42. /* BNEP response messages */
  43. #define BNEP_SUCCESS 0x00
  44. #define BNEP_CONN_INVALID_DST 0x01
  45. #define BNEP_CONN_INVALID_SRC 0x02
  46. #define BNEP_CONN_INVALID_SVC 0x03
  47. #define BNEP_CONN_NOT_ALLOWED 0x04
  48. #define BNEP_FILTER_UNSUPPORTED_REQ 0x01
  49. #define BNEP_FILTER_INVALID_RANGE 0x02
  50. #define BNEP_FILTER_INVALID_MCADDR 0x02
  51. #define BNEP_FILTER_LIMIT_REACHED 0x03
  52. #define BNEP_FILTER_DENIED_SECURITY 0x04
  53. /* L2CAP settings */
  54. #define BNEP_MTU 1691
  55. #define BNEP_FLUSH_TO 0xffff
  56. #define BNEP_CONNECT_TO 15
  57. #define BNEP_FILTER_TO 15
  58. #ifndef BNEP_PSM
  59. #define BNEP_PSM 0x0f
  60. #endif
  61. /* BNEP headers */
  62. #define BNEP_TYPE_MASK 0x7f
  63. #define BNEP_EXT_HEADER 0x80
  64. struct bnep_setup_conn_req {
  65. uint8_t type;
  66. uint8_t ctrl;
  67. uint8_t uuid_size;
  68. uint8_t service[0];
  69. } __attribute__((packed));
  70. struct bnep_set_filter_req {
  71. uint8_t type;
  72. uint8_t ctrl;
  73. uint16_t len;
  74. uint8_t list[0];
  75. } __attribute__((packed));
  76. struct bnep_ctrl_cmd_not_understood_cmd {
  77. uint8_t type;
  78. uint8_t ctrl;
  79. uint8_t unkn_ctrl;
  80. } __attribute__((packed));
  81. struct bnep_control_rsp {
  82. uint8_t type;
  83. uint8_t ctrl;
  84. uint16_t resp;
  85. } __attribute__((packed));
  86. struct bnep_ext_hdr {
  87. uint8_t type;
  88. uint8_t len;
  89. uint8_t data[0];
  90. } __attribute__((packed));
  91. /* BNEP ioctl defines */
  92. #define BNEPCONNADD _IOW('B', 200, int)
  93. #define BNEPCONNDEL _IOW('B', 201, int)
  94. #define BNEPGETCONNLIST _IOR('B', 210, int)
  95. #define BNEPGETCONNINFO _IOR('B', 211, int)
  96. #define BNEPGETSUPPFEAT _IOR('B', 212, int)
  97. #define BNEP_SETUP_RESPONSE 0
  98. struct bnep_connadd_req {
  99. int sock; /* Connected socket */
  100. uint32_t flags;
  101. uint16_t role;
  102. char device[16]; /* Name of the Ethernet device */
  103. };
  104. struct bnep_conndel_req {
  105. uint32_t flags;
  106. uint8_t dst[ETH_ALEN];
  107. };
  108. struct bnep_conninfo {
  109. uint32_t flags;
  110. uint16_t role;
  111. uint16_t state;
  112. uint8_t dst[ETH_ALEN];
  113. char device[16];
  114. };
  115. struct bnep_connlist_req {
  116. uint32_t cnum;
  117. struct bnep_conninfo *ci;
  118. };
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif /* __BNEP_H */