mgmt.h revision 6964bd2dd54d5cce7ce2588b0dcd0a3530e6fba9
112d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg/*
212d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  BlueZ - Bluetooth protocol stack for Linux
312d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *
412d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  Copyright (C) 2010  Nokia Corporation
512d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  Copyright (C) 2010  Marcel Holtmann <marcel@holtmann.org>
612d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *
712d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *
812d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  This program is free software; you can redistribute it and/or modify
912d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  it under the terms of the GNU General Public License as published by
1012d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  the Free Software Foundation; either version 2 of the License, or
1112d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  (at your option) any later version.
1212d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *
1312d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  This program is distributed in the hope that it will be useful,
1412d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  but WITHOUT ANY WARRANTY; without even the implied warranty of
1512d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1612d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  GNU General Public License for more details.
1712d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *
1812d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  You should have received a copy of the GNU General Public License
1912d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  along with this program; if not, write to the Free Software
2012d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
2112d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg *
2212d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg */
2312d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg
24b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg#ifndef __packed
25b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg#define __packed __attribute__((packed))
26b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg#endif
27b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg
28fb91c88916485512033b8437686a5f2405d19a92Johan Hedbergstruct mgmt_hdr {
2912d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg	uint16_t opcode;
3012d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg	uint16_t len;
3112d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg} __packed;
32fb91c88916485512033b8437686a5f2405d19a92Johan Hedberg#define MGMT_HDR_SIZE	4
3312d02e7f2283d0b1511fc7be08579b3037f5c9a9Johan Hedberg
34fb91c88916485512033b8437686a5f2405d19a92Johan Hedberg#define MGMT_OP_READ_VERSION		0x0001
359a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_rp_read_version {
36b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg	uint8_t version;
37b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg	uint16_t revision;
38b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg} __packed;
39b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg
40fb91c88916485512033b8437686a5f2405d19a92Johan Hedberg#define MGMT_OP_READ_FEATURES		0x0002
419a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_rp_read_features {
4258e6c539e644ab0d85890a0369dcc0c3d06a99b1Johan Hedberg	uint8_t features[8];
4358e6c539e644ab0d85890a0369dcc0c3d06a99b1Johan Hedberg} __packed;
44c0882114c2f9008762f2b298dd511d349627b490Johan Hedberg
45fb91c88916485512033b8437686a5f2405d19a92Johan Hedberg#define MGMT_OP_READ_INDEX_LIST		0x0003
469a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_rp_read_index_list {
47c0882114c2f9008762f2b298dd511d349627b490Johan Hedberg	uint16_t num_controllers;
48c0882114c2f9008762f2b298dd511d349627b490Johan Hedberg	uint16_t index[0];
49c0882114c2f9008762f2b298dd511d349627b490Johan Hedberg} __packed;
50c0882114c2f9008762f2b298dd511d349627b490Johan Hedberg
51fb91c88916485512033b8437686a5f2405d19a92Johan Hedberg#define MGMT_OP_READ_INFO		0x0004
529a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_cp_read_info {
5358e6c539e644ab0d85890a0369dcc0c3d06a99b1Johan Hedberg	uint16_t index;
5458e6c539e644ab0d85890a0369dcc0c3d06a99b1Johan Hedberg} __packed;
559a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_rp_read_info {
5658e6c539e644ab0d85890a0369dcc0c3d06a99b1Johan Hedberg	uint16_t index;
5758e6c539e644ab0d85890a0369dcc0c3d06a99b1Johan Hedberg	uint8_t type;
5824a34a8b1f8615ad79199efdb6fea479509464b4Johan Hedberg	uint8_t powered;
5914655825c95fd065afc41bfc1c810987bfb1a2c6Johan Hedberg	uint8_t connectable;
6024a34a8b1f8615ad79199efdb6fea479509464b4Johan Hedberg	uint8_t discoverable;
6124a34a8b1f8615ad79199efdb6fea479509464b4Johan Hedberg	uint8_t pairable;
6224a34a8b1f8615ad79199efdb6fea479509464b4Johan Hedberg	uint8_t sec_mode;
63b67a8a42e6ea9c2d2b0877ac3832de75ec4e00e5Johan Hedberg	bdaddr_t bdaddr;
6424a34a8b1f8615ad79199efdb6fea479509464b4Johan Hedberg	uint8_t dev_class[3];
6558e6c539e644ab0d85890a0369dcc0c3d06a99b1Johan Hedberg	uint8_t features[8];
668c442fd677490441b64b3509c1264460668d9367Johan Hedberg	uint16_t manufacturer;
678c442fd677490441b64b3509c1264460668d9367Johan Hedberg	uint8_t hci_ver;
688c442fd677490441b64b3509c1264460668d9367Johan Hedberg	uint16_t hci_rev;
6958e6c539e644ab0d85890a0369dcc0c3d06a99b1Johan Hedberg} __packed;
7058e6c539e644ab0d85890a0369dcc0c3d06a99b1Johan Hedberg
71fb88bd2992dc0e3d90a9aabacaefcfcfc3f9aba9Johan Hedbergstruct mgmt_mode {
7227a311476a53c72ac06d6cdc3cffbef14a0caba7Johan Hedberg	uint16_t index;
73fb88bd2992dc0e3d90a9aabacaefcfcfc3f9aba9Johan Hedberg	uint8_t val;
7407481cab563a0db441075f7e786d442e0c576c32Johan Hedberg} __packed;
75fdd43acc2a2a151e380de5f02c291d804ec05419Johan Hedberg
76fb88bd2992dc0e3d90a9aabacaefcfcfc3f9aba9Johan Hedberg#define MGMT_OP_SET_POWERED		0x0005
77fb88bd2992dc0e3d90a9aabacaefcfcfc3f9aba9Johan Hedberg
78528432cc7aad7601c3d98157c9472e6a089232f8Johan Hedberg#define MGMT_OP_SET_DISCOVERABLE	0x0006
79528432cc7aad7601c3d98157c9472e6a089232f8Johan Hedberg
8014655825c95fd065afc41bfc1c810987bfb1a2c6Johan Hedberg#define MGMT_OP_SET_CONNECTABLE		0x0007
8114655825c95fd065afc41bfc1c810987bfb1a2c6Johan Hedberg
826964bd2dd54d5cce7ce2588b0dcd0a3530e6fba9Johan Hedberg#define MGMT_OP_SET_PAIRABLE		0x0008
836964bd2dd54d5cce7ce2588b0dcd0a3530e6fba9Johan Hedberg
84fb91c88916485512033b8437686a5f2405d19a92Johan Hedberg#define MGMT_EV_CMD_COMPLETE		0x0001
859a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_ev_cmd_complete {
86b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg	uint16_t opcode;
87b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg	uint8_t data[0];
88b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg} __packed;
89b02a68367321b323db81823f43d7332e35ce96faJohan Hedberg
90fb91c88916485512033b8437686a5f2405d19a92Johan Hedberg#define MGMT_EV_CMD_STATUS		0x0002
919a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_ev_cmd_status {
92ff489b4fe36d7de4f438df38cb446c7b3477ebdeJohan Hedberg	uint8_t status;
93ff489b4fe36d7de4f438df38cb446c7b3477ebdeJohan Hedberg	uint16_t opcode;
94ff489b4fe36d7de4f438df38cb446c7b3477ebdeJohan Hedberg} __packed;
95ff489b4fe36d7de4f438df38cb446c7b3477ebdeJohan Hedberg
96fb91c88916485512033b8437686a5f2405d19a92Johan Hedberg#define MGMT_EV_CONTROLLER_ERROR	0x0003
979a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_ev_controller_error {
98ff489b4fe36d7de4f438df38cb446c7b3477ebdeJohan Hedberg	uint16_t index;
99ff489b4fe36d7de4f438df38cb446c7b3477ebdeJohan Hedberg	uint8_t error_code;
100ff489b4fe36d7de4f438df38cb446c7b3477ebdeJohan Hedberg} __packed;
10149bedc0b8c58cac7a8198a7247fb6dfb37e29c42Johan Hedberg
10249bedc0b8c58cac7a8198a7247fb6dfb37e29c42Johan Hedberg#define MGMT_EV_INDEX_ADDED		0x0004
1039a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_ev_index_added {
10449bedc0b8c58cac7a8198a7247fb6dfb37e29c42Johan Hedberg	uint16_t index;
10549bedc0b8c58cac7a8198a7247fb6dfb37e29c42Johan Hedberg} __packed;
10649bedc0b8c58cac7a8198a7247fb6dfb37e29c42Johan Hedberg
10749bedc0b8c58cac7a8198a7247fb6dfb37e29c42Johan Hedberg#define MGMT_EV_INDEX_REMOVED		0x0005
1089a404a4e6bc03afcd78f02ef5cd77e50f77cd012Johan Hedbergstruct mgmt_ev_index_removed {
10949bedc0b8c58cac7a8198a7247fb6dfb37e29c42Johan Hedberg	uint16_t index;
11049bedc0b8c58cac7a8198a7247fb6dfb37e29c42Johan Hedberg} __packed;
1118582b8e4cdf85425a40696c2839c44417c798687Johan Hedberg
1128582b8e4cdf85425a40696c2839c44417c798687Johan Hedberg#define MGMT_EV_POWERED			0x0006
113528432cc7aad7601c3d98157c9472e6a089232f8Johan Hedberg
114528432cc7aad7601c3d98157c9472e6a089232f8Johan Hedberg#define MGMT_EV_DISCOVERABLE		0x0007
11514655825c95fd065afc41bfc1c810987bfb1a2c6Johan Hedberg
11614655825c95fd065afc41bfc1c810987bfb1a2c6Johan Hedberg#define MGMT_EV_CONNECTABLE		0x0008
1176964bd2dd54d5cce7ce2588b0dcd0a3530e6fba9Johan Hedberg
1186964bd2dd54d5cce7ce2588b0dcd0a3530e6fba9Johan Hedberg#define MGMT_EV_PAIRABLE		0x0009
119