Fix Managment API names to be consistent with the kernel

This commit is contained in:
Johan Hedberg 2010-11-07 19:12:30 +02:00
parent ff489b4fe3
commit 9a404a4e6b
2 changed files with 33 additions and 45 deletions

View File

@ -32,85 +32,73 @@ struct mgmt_hdr {
#define MGMT_HDR_SIZE 4
#define MGMT_OP_READ_VERSION 0x0001
struct mgmt_read_version_rp {
struct mgmt_rp_read_version {
uint8_t version;
uint16_t revision;
} __packed;
#define MGMT_READ_VERSION_RP_SIZE 3
#define MGMT_OP_READ_FEATURES 0x0002
struct mgmt_read_features_rp {
struct mgmt_rp_read_features {
uint8_t features[8];
} __packed;
#define MGMT_READ_FEATURES_RP_SIZE 8
#define MGMT_OP_READ_INDEX_LIST 0x0003
struct mgmt_read_index_list_rp {
struct mgmt_rp_read_index_list {
uint16_t num_controllers;
uint16_t index[0];
} __packed;
#define MGMT_READ_INDEX_LIST_RP_SIZE 2
#define MGMT_OP_READ_INFO 0x0004
struct mgmt_read_info_cp {
struct mgmt_cp_read_info {
uint16_t index;
} __packed;
#define MGMT_READ_INFO_CP_SIZE 2
struct mgmt_read_info_rp {
struct mgmt_rp_read_info {
uint8_t status;
uint16_t index;
uint8_t type;
bdaddr_t bdaddr;
uint8_t features[8];
} __packed;
#define MGMT_READ_INFO_RP_SIZE 18
#define MGMT_OP_READ_STATISTICS 0x0005
#define MGMT_OP_READ_MODE 0x0006
struct mgmt_read_mode_cp {
struct mgmt_cp_read_mode {
uint16_t index;
} __packed;
#define MGMT_READ_MODE_CP_SIZE 2
struct mgmt_read_mode_rp {
struct mgmt_rp_read_mode {
uint8_t status;
uint16_t index;
uint8_t enabled;
uint8_t mode;
} __packed;
#define MGMT_READ_MODE_RP_SIZE 5
#define MGMT_OP_WRITE_MODE 0x0007
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_cmd_complete_ev {
struct mgmt_ev_cmd_complete {
uint16_t opcode;
uint8_t data[0];
} __packed;
#define MGMT_CMD_COMPLETE_SIZE 2
#define MGMT_EV_CMD_STATUS 0x0002
struct mgmt_cmd_status_ev {
struct mgmt_ev_cmd_status {
uint8_t status;
uint16_t opcode;
} __packed;
#define MGMT_CMD_STATUS_SIZE 3
#define MGMT_EV_CONTROLLER_ERROR 0x0003
struct mgmt_controller_error_ev {
struct mgmt_ev_controller_error {
uint16_t index;
uint8_t error_code;
} __packed;
#define MGMT_CONTROLLER_ERROR_SIZE 3
#define MGMT_EV_INDEX_ADDED 0x0004
struct mgmt_index_added_ev {
struct mgmt_ev_index_added {
uint16_t index;
} __packed;
#define MGMT_INDEX_ADDED_SIZE 2
#define MGMT_EV_INDEX_REMOVED 0x0005
struct mgmt_index_removed_ev {
struct mgmt_ev_index_removed {
uint16_t index;
} __packed;
#define MGMT_INDEX_REMOVED_SIZE 2

View File

@ -68,9 +68,9 @@ static uint16_t mgmt_revision = 0;
static void read_version_complete(int sk, void *buf, size_t len)
{
struct mgmt_hdr hdr;
struct mgmt_read_version_rp *rp = buf;
struct mgmt_rp_read_version *rp = buf;
if (len < MGMT_READ_VERSION_RP_SIZE) {
if (len < sizeof(*rp)) {
error("Too small read version complete event");
return;
}
@ -104,9 +104,9 @@ static void add_controller(uint16_t index)
static void read_info(int sk, uint16_t index)
{
char buf[MGMT_HDR_SIZE + MGMT_READ_INFO_CP_SIZE];
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_read_info)];
struct mgmt_hdr *hdr = (void *) buf;
struct mgmt_read_info_cp *cp = (void *) &buf[sizeof(*hdr)];
struct mgmt_cp_read_info *cp = (void *) &buf[sizeof(*hdr)];
memset(buf, 0, sizeof(buf));
hdr->opcode = MGMT_OP_READ_INFO;
@ -121,10 +121,10 @@ static void read_info(int sk, uint16_t index)
static void mgmt_index_added(int sk, void *buf, size_t len)
{
struct mgmt_index_added_ev *ev = buf;
struct mgmt_ev_index_added *ev = buf;
uint16_t index;
if (len < MGMT_INDEX_ADDED_SIZE) {
if (len < sizeof(*ev)) {
error("Too small index added event");
return;
}
@ -152,10 +152,10 @@ static void remove_controller(uint16_t index)
static void mgmt_index_removed(int sk, void *buf, size_t len)
{
struct mgmt_index_removed_ev *ev = buf;
struct mgmt_ev_index_removed *ev = buf;
uint16_t index;
if (len < MGMT_INDEX_REMOVED_SIZE) {
if (len < sizeof(*ev)) {
error("Too small index removed event");
return;
}
@ -167,9 +167,9 @@ static void mgmt_index_removed(int sk, void *buf, size_t len)
static void read_mode(int sk, uint16_t index)
{
char buf[MGMT_HDR_SIZE + MGMT_READ_MODE_CP_SIZE];
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_read_mode)];
struct mgmt_hdr *hdr = (void *) buf;
struct mgmt_read_mode_cp *cp = (void *) &buf[sizeof(*hdr)];
struct mgmt_cp_read_mode *cp = (void *) &buf[sizeof(*hdr)];
memset(buf, 0, sizeof(buf));
hdr->opcode = MGMT_OP_READ_MODE;
@ -184,18 +184,18 @@ static void read_mode(int sk, uint16_t index)
static void read_index_list_complete(int sk, void *buf, size_t len)
{
struct mgmt_read_index_list_rp *rp = buf;
struct mgmt_rp_read_index_list *rp = buf;
uint16_t num;
int i;
if (len < MGMT_READ_INDEX_LIST_RP_SIZE) {
if (len < sizeof(*rp)) {
error("Too small read index list complete event");
return;
}
num = btohs(bt_get_unaligned(&rp->num_controllers));
if (num * sizeof(uint16_t) + MGMT_READ_INDEX_LIST_RP_SIZE != len) {
if (num * sizeof(uint16_t) + sizeof(*rp) != len) {
error("Incorrect packet size for index list event");
return;
}
@ -212,12 +212,12 @@ static void read_index_list_complete(int sk, void *buf, size_t len)
static void read_info_complete(int sk, void *buf, size_t len)
{
struct mgmt_read_info_rp *rp = buf;
struct mgmt_rp_read_info *rp = buf;
struct controller_info *info;
uint16_t index;
char addr[18];
if (len < MGMT_READ_INFO_RP_SIZE) {
if (len < sizeof(*rp)) {
error("Too small read info complete event");
return;
}
@ -247,13 +247,13 @@ static void read_info_complete(int sk, void *buf, size_t len)
static void read_mode_complete(int sk, void *buf, size_t len)
{
struct mgmt_read_mode_rp *rp = buf;
struct mgmt_rp_read_mode *rp = buf;
struct controller_info *info;
uint16_t index;
if (len < MGMT_READ_MODE_RP_SIZE) {
if (len < sizeof(*rp)) {
error("Too small read mode complete event (%zu != %d)",
len, MGMT_READ_MODE_RP_SIZE);
len, sizeof(*rp));
return;
}
@ -280,7 +280,7 @@ static void read_mode_complete(int sk, void *buf, size_t len)
static void mgmt_cmd_complete(int sk, void *buf, size_t len)
{
struct mgmt_cmd_complete_ev *ev = buf;
struct mgmt_ev_cmd_complete *ev = buf;
uint16_t opcode;
DBG("");
@ -313,7 +313,7 @@ static void mgmt_cmd_complete(int sk, void *buf, size_t len)
static void mgmt_cmd_status(int sk, void *buf, size_t len)
{
struct mgmt_cmd_status_ev *ev = buf;
struct mgmt_ev_cmd_status *ev = buf;
uint16_t opcode;
if (len < sizeof(*ev)) {
@ -328,7 +328,7 @@ static void mgmt_cmd_status(int sk, void *buf, size_t len)
static void mgmt_controller_error(int sk, void *buf, size_t len)
{
struct mgmt_controller_error_ev *ev = buf;
struct mgmt_ev_controller_error *ev = buf;
uint16_t index;
if (len < sizeof(*ev)) {