bnep.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. *
  3. * BlueZ - Bluetooth protocol stack for Linux
  4. *
  5. * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
  6. * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. */
  24. #ifndef __BNEP_H
  25. #define __BNEP_H
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #include <bluetooth/bluetooth.h>
  30. #ifndef ETH_ALEN
  31. #define ETH_ALEN 6 /* from <net/ethernet.h> */
  32. #endif
  33. /* BNEP UUIDs */
  34. #define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
  35. #define BNEP_UUID16 0x02
  36. #define BNEP_UUID32 0x04
  37. #define BNEP_UUID128 0x16
  38. #define BNEP_SVC_PANU 0x1115
  39. #define BNEP_SVC_NAP 0x1116
  40. #define BNEP_SVC_GN 0x1117
  41. /* BNEP packet types */
  42. #define BNEP_GENERAL 0x00
  43. #define BNEP_CONTROL 0x01
  44. #define BNEP_COMPRESSED 0x02
  45. #define BNEP_COMPRESSED_SRC_ONLY 0x03
  46. #define BNEP_COMPRESSED_DST_ONLY 0x04
  47. /* BNEP control types */
  48. #define BNEP_CMD_NOT_UNDERSTOOD 0x00
  49. #define BNEP_SETUP_CONN_REQ 0x01
  50. #define BNEP_SETUP_CONN_RSP 0x02
  51. #define BNEP_FILTER_NET_TYPE_SET 0x03
  52. #define BNEP_FILTER_NET_TYPE_RSP 0x04
  53. #define BNEP_FILTER_MULT_ADDR_SET 0x05
  54. #define BNEP_FILTER_MULT_ADDR_RSP 0x06
  55. /* BNEP response messages */
  56. #define BNEP_SUCCESS 0x00
  57. #define BNEP_CONN_INVALID_DST 0x01
  58. #define BNEP_CONN_INVALID_SRC 0x02
  59. #define BNEP_CONN_INVALID_SVC 0x03
  60. #define BNEP_CONN_NOT_ALLOWED 0x04
  61. #define BNEP_FILTER_UNSUPPORTED_REQ 0x01
  62. #define BNEP_FILTER_INVALID_RANGE 0x02
  63. #define BNEP_FILTER_INVALID_MCADDR 0x02
  64. #define BNEP_FILTER_LIMIT_REACHED 0x03
  65. #define BNEP_FILTER_DENIED_SECURITY 0x04
  66. /* L2CAP settings */
  67. #define BNEP_MTU 1691
  68. #define BNEP_FLUSH_TO 0xffff
  69. #define BNEP_CONNECT_TO 15
  70. #define BNEP_FILTER_TO 15
  71. #ifndef BNEP_PSM
  72. #define BNEP_PSM 0x0f
  73. #endif
  74. /* BNEP headers */
  75. #define BNEP_TYPE_MASK 0x7f
  76. #define BNEP_EXT_HEADER 0x80
  77. struct bnep_setup_conn_req {
  78. uint8_t type;
  79. uint8_t ctrl;
  80. uint8_t uuid_size;
  81. uint8_t service[0];
  82. } __attribute__((packed));
  83. struct bnep_set_filter_req {
  84. uint8_t type;
  85. uint8_t ctrl;
  86. uint16_t len;
  87. uint8_t list[0];
  88. } __attribute__((packed));
  89. struct bnep_ctrl_cmd_not_understood_cmd {
  90. uint8_t type;
  91. uint8_t ctrl;
  92. uint8_t unkn_ctrl;
  93. } __attribute__((packed));
  94. struct bnep_control_rsp {
  95. uint8_t type;
  96. uint8_t ctrl;
  97. uint16_t resp;
  98. } __attribute__((packed));
  99. struct bnep_ext_hdr {
  100. uint8_t type;
  101. uint8_t len;
  102. uint8_t data[0];
  103. } __attribute__((packed));
  104. /* BNEP ioctl defines */
  105. #define BNEPCONNADD _IOW('B', 200, int)
  106. #define BNEPCONNDEL _IOW('B', 201, int)
  107. #define BNEPGETCONNLIST _IOR('B', 210, int)
  108. #define BNEPGETCONNINFO _IOR('B', 211, int)
  109. #define BNEPGETSUPPFEAT _IOR('B', 212, int)
  110. #define BNEP_SETUP_RESPONSE 0
  111. struct bnep_connadd_req {
  112. int sock; /* Connected socket */
  113. uint32_t flags;
  114. uint16_t role;
  115. char device[16]; /* Name of the Ethernet device */
  116. };
  117. struct bnep_conndel_req {
  118. uint32_t flags;
  119. uint8_t dst[ETH_ALEN];
  120. };
  121. struct bnep_conninfo {
  122. uint32_t flags;
  123. uint16_t role;
  124. uint16_t state;
  125. uint8_t dst[ETH_ALEN];
  126. char device[16];
  127. };
  128. struct bnep_connlist_req {
  129. uint32_t cnum;
  130. struct bnep_conninfo *ci;
  131. };
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif /* __BNEP_H */