Blame src/shared/btsnoop.h

Packit 34410b
/*
Packit 34410b
 *
Packit 34410b
 *  BlueZ - Bluetooth protocol stack for Linux
Packit 34410b
 *
Packit 34410b
 *  Copyright (C) 2012-2014  Intel Corporation. All rights reserved.
Packit 34410b
 *
Packit 34410b
 *
Packit 34410b
 *  This library is free software; you can redistribute it and/or
Packit 34410b
 *  modify it under the terms of the GNU Lesser General Public
Packit 34410b
 *  License as published by the Free Software Foundation; either
Packit 34410b
 *  version 2.1 of the License, or (at your option) any later version.
Packit 34410b
 *
Packit 34410b
 *  This library is distributed in the hope that it will be useful,
Packit 34410b
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 34410b
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 34410b
 *  Lesser General Public License for more details.
Packit 34410b
 *
Packit 34410b
 *  You should have received a copy of the GNU Lesser General Public
Packit 34410b
 *  License along with this library; if not, write to the Free Software
Packit 34410b
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
Packit 34410b
 *
Packit 34410b
 */
Packit 34410b
Packit 34410b
#include <stdint.h>
Packit 34410b
#include <stdbool.h>
Packit 34410b
#include <sys/time.h>
Packit 34410b
Packit 34410b
#define BTSNOOP_FORMAT_INVALID		0
Packit 34410b
#define BTSNOOP_FORMAT_HCI		1001
Packit 34410b
#define BTSNOOP_FORMAT_UART		1002
Packit 34410b
#define BTSNOOP_FORMAT_BCSP		1003
Packit 34410b
#define BTSNOOP_FORMAT_3WIRE		1004
Packit 34410b
#define BTSNOOP_FORMAT_MONITOR		2001
Packit 34410b
#define BTSNOOP_FORMAT_SIMULATOR	2002
Packit 34410b
Packit 34410b
#define BTSNOOP_FLAG_PKLG_SUPPORT	(1 << 0)
Packit 34410b
Packit 34410b
#define BTSNOOP_OPCODE_NEW_INDEX	0
Packit 34410b
#define BTSNOOP_OPCODE_DEL_INDEX	1
Packit 34410b
#define BTSNOOP_OPCODE_COMMAND_PKT	2
Packit 34410b
#define BTSNOOP_OPCODE_EVENT_PKT	3
Packit 34410b
#define BTSNOOP_OPCODE_ACL_TX_PKT	4
Packit 34410b
#define BTSNOOP_OPCODE_ACL_RX_PKT	5
Packit 34410b
#define BTSNOOP_OPCODE_SCO_TX_PKT	6
Packit 34410b
#define BTSNOOP_OPCODE_SCO_RX_PKT	7
Packit 34410b
#define BTSNOOP_OPCODE_OPEN_INDEX	8
Packit 34410b
#define BTSNOOP_OPCODE_CLOSE_INDEX	9
Packit 34410b
#define BTSNOOP_OPCODE_INDEX_INFO	10
Packit 34410b
#define BTSNOOP_OPCODE_VENDOR_DIAG	11
Packit 34410b
#define BTSNOOP_OPCODE_SYSTEM_NOTE	12
Packit 34410b
#define BTSNOOP_OPCODE_USER_LOGGING	13
Packit 34410b
#define BTSNOOP_OPCODE_CTRL_OPEN	14
Packit 34410b
#define BTSNOOP_OPCODE_CTRL_CLOSE	15
Packit 34410b
#define BTSNOOP_OPCODE_CTRL_COMMAND	16
Packit 34410b
#define BTSNOOP_OPCODE_CTRL_EVENT	17
Packit 34410b
Packit 34410b
#define BTSNOOP_MAX_PACKET_SIZE		(1486 + 4)
Packit 34410b
Packit 34410b
#define BTSNOOP_TYPE_PRIMARY	0
Packit 34410b
#define BTSNOOP_TYPE_AMP	1
Packit 34410b
Packit 34410b
#define BTSNOOP_BUS_VIRTUAL	0
Packit 34410b
#define BTSNOOP_BUS_USB		1
Packit 34410b
#define BTSNOOP_BUS_PCCARD	2
Packit 34410b
#define BTSNOOP_BUS_UART	3
Packit 34410b
#define BTSNOOP_BUS_RS232	4
Packit 34410b
#define BTSNOOP_BUS_PCI		5
Packit 34410b
#define BTSNOOP_BUS_SDIO	6
Packit 34410b
#define BTSNOOP_BUS_SPI		7
Packit 34410b
#define BTSNOOP_BUS_I2C		8
Packit 34410b
#define BTSNOOP_BUS_SMD		9
Packit 34410b
Packit 34410b
struct btsnoop_opcode_new_index {
Packit 34410b
	uint8_t  type;
Packit 34410b
	uint8_t  bus;
Packit 34410b
	uint8_t  bdaddr[6];
Packit 34410b
	char     name[8];
Packit 34410b
} __attribute__((packed));
Packit 34410b
Packit 34410b
struct btsnoop_opcode_index_info {
Packit 34410b
	uint8_t  bdaddr[6];
Packit 34410b
	uint16_t manufacturer;
Packit 34410b
} __attribute__((packed));
Packit 34410b
Packit 34410b
#define BTSNOOP_PRIORITY_EMERG		0
Packit 34410b
#define BTSNOOP_PRIORITY_ALERT		1
Packit 34410b
#define BTSNOOP_PRIORITY_CRIT		2
Packit 34410b
#define BTSNOOP_PRIORITY_ERR		3
Packit 34410b
#define BTSNOOP_PRIORITY_WARNING	4
Packit 34410b
#define BTSNOOP_PRIORITY_NOTICE		5
Packit 34410b
#define BTSNOOP_PRIORITY_INFO		6
Packit 34410b
#define BTSNOOP_PRIORITY_DEBUG		7
Packit 34410b
Packit 34410b
struct btsnoop_opcode_user_logging {
Packit 34410b
	uint8_t  priority;
Packit 34410b
	uint8_t  ident_len;
Packit 34410b
} __attribute__((packed));
Packit 34410b
Packit 34410b
struct btsnoop;
Packit 34410b
Packit 34410b
struct btsnoop *btsnoop_open(const char *path, unsigned long flags);
Packit 34410b
struct btsnoop *btsnoop_create(const char *path, size_t max_size,
Packit 34410b
				unsigned int max_count, uint32_t format);
Packit 34410b
Packit 34410b
struct btsnoop *btsnoop_ref(struct btsnoop *btsnoop);
Packit 34410b
void btsnoop_unref(struct btsnoop *btsnoop);
Packit 34410b
Packit 34410b
uint32_t btsnoop_get_format(struct btsnoop *btsnoop);
Packit 34410b
Packit 34410b
bool btsnoop_write(struct btsnoop *btsnoop, struct timeval *tv, uint32_t flags,
Packit 34410b
			uint32_t drops, const void *data, uint16_t size);
Packit 34410b
bool btsnoop_write_hci(struct btsnoop *btsnoop, struct timeval *tv,
Packit 34410b
			uint16_t index, uint16_t opcode, uint32_t drops,
Packit 34410b
			const void *data, uint16_t size);
Packit 34410b
bool btsnoop_write_phy(struct btsnoop *btsnoop, struct timeval *tv,
Packit 34410b
			uint16_t frequency, const void *data, uint16_t size);
Packit 34410b
Packit 34410b
bool btsnoop_read_hci(struct btsnoop *btsnoop, struct timeval *tv,
Packit 34410b
					uint16_t *index, uint16_t *opcode,
Packit 34410b
					void *data, uint16_t *size);
Packit 34410b
bool btsnoop_read_phy(struct btsnoop *btsnoop, struct timeval *tv,
Packit 34410b
			uint16_t *frequency, void *data, uint16_t *size);