天嵌二次封装库使用手册  V1.0
bnep.h
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 
12 #ifndef __BNEP_H
13 #define __BNEP_H
14 
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19 
20 #include "bluetooth.h"
21 
22 #ifndef ETH_ALEN
23 #define ETH_ALEN 6 /* from <net/ethernet.h> */
24 #endif
25 
26 /* BNEP UUIDs */
27 #define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
28 #define BNEP_UUID16 0x02
29 #define BNEP_UUID32 0x04
30 #define BNEP_UUID128 0x16
31 
32 #define BNEP_SVC_PANU 0x1115
33 #define BNEP_SVC_NAP 0x1116
34 #define BNEP_SVC_GN 0x1117
35 
36 /* BNEP packet types */
37 #define BNEP_GENERAL 0x00
38 #define BNEP_CONTROL 0x01
39 #define BNEP_COMPRESSED 0x02
40 #define BNEP_COMPRESSED_SRC_ONLY 0x03
41 #define BNEP_COMPRESSED_DST_ONLY 0x04
42 
43 /* BNEP control types */
44 #define BNEP_CMD_NOT_UNDERSTOOD 0x00
45 #define BNEP_SETUP_CONN_REQ 0x01
46 #define BNEP_SETUP_CONN_RSP 0x02
47 #define BNEP_FILTER_NET_TYPE_SET 0x03
48 #define BNEP_FILTER_NET_TYPE_RSP 0x04
49 #define BNEP_FILTER_MULT_ADDR_SET 0x05
50 #define BNEP_FILTER_MULT_ADDR_RSP 0x06
51 
52 /* BNEP response messages */
53 #define BNEP_SUCCESS 0x00
54 
55 #define BNEP_CONN_INVALID_DST 0x01
56 #define BNEP_CONN_INVALID_SRC 0x02
57 #define BNEP_CONN_INVALID_SVC 0x03
58 #define BNEP_CONN_NOT_ALLOWED 0x04
59 
60 #define BNEP_FILTER_UNSUPPORTED_REQ 0x01
61 #define BNEP_FILTER_INVALID_RANGE 0x02
62 #define BNEP_FILTER_INVALID_MCADDR 0x02
63 #define BNEP_FILTER_LIMIT_REACHED 0x03
64 #define BNEP_FILTER_DENIED_SECURITY 0x04
65 
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 
72 #ifndef BNEP_PSM
73 #define BNEP_PSM 0x0f
74 #endif
75 
76 /* BNEP headers */
77 #define BNEP_TYPE_MASK 0x7f
78 #define BNEP_EXT_HEADER 0x80
79 
81  {
82  uint8_t type;
83  uint8_t ctrl;
84  uint8_t uuid_size;
85  uint8_t service[0];
86  } __attribute__((packed));
87 
89  {
90  uint8_t type;
91  uint8_t ctrl;
92  uint16_t len;
93  uint8_t list[0];
94  } __attribute__((packed));
95 
97  {
98  uint8_t type;
99  uint8_t ctrl;
100  uint8_t unkn_ctrl;
101  } __attribute__((packed));
102 
104  {
105  uint8_t type;
106  uint8_t ctrl;
107  uint16_t resp;
108  } __attribute__((packed));
109 
111  {
112  uint8_t type;
113  uint8_t len;
114  uint8_t data[0];
115  } __attribute__((packed));
116 
117 /* BNEP ioctl defines */
118 #define BNEPCONNADD _IOW('B', 200, int)
119 #define BNEPCONNDEL _IOW('B', 201, int)
120 #define BNEPGETCONNLIST _IOR('B', 210, int)
121 #define BNEPGETCONNINFO _IOR('B', 211, int)
122 #define BNEPGETSUPPFEAT _IOR('B', 212, int)
123 
124 #define BNEP_SETUP_RESPONSE 0
125 
127  {
128  int sock; /* Connected socket */
129  uint32_t flags;
130  uint16_t role;
131  char device[16]; /* Name of the Ethernet device */
132  };
133 
135  {
136  uint32_t flags;
137  uint8_t dst[ETH_ALEN];
138  };
139 
141  {
142  uint32_t flags;
143  uint16_t role;
144  uint16_t state;
145  uint8_t dst[ETH_ALEN];
146  char device[16];
147  };
148 
150  {
151  uint32_t cnum;
152  struct bnep_conninfo *ci;
153  };
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif /* __BNEP_H */
Definition: bnep.h:149
Definition: bnep.h:110
Definition: bnep.h:126
Definition: amp.h:35
Definition: bnep.h:88
Definition: bnep.h:80
Definition: bnep.h:140
Definition: bnep.h:134
Definition: bnep.h:103