Blob: att.h

Blob id: 53a3f7a2ae98da48184a1c712be80cd4b4ebee1c

Size: 4.0 KB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 *
 *  BlueZ - Bluetooth protocol stack for Linux
 *
 *  Copyright (C) 2014  Google Inc.
 *
 *
 */

#include <stdbool.h>
#include <stdint.h>

#include "src/shared/att-types.h"

#define BT_ATT_DEBUG		0x00
#define BT_ATT_DEBUG_VERBOSE	0x01
#define BT_ATT_DEBUG_HEXDUMP	0x02

struct bt_att;
struct bt_att_chan;

struct bt_att *bt_att_new(int fd, bool ext_signed);

struct bt_att *bt_att_ref(struct bt_att *att);
void bt_att_unref(struct bt_att *att);

bool bt_att_set_close_on_unref(struct bt_att *att, bool do_close);

int bt_att_get_fd(struct bt_att *att);

int bt_att_attach_fd(struct bt_att *att, int fd);

int bt_att_get_channels(struct bt_att *att);

typedef void (*bt_att_response_func_t)(uint8_t opcode, const void *pdu,
					uint16_t length, void *user_data);
typedef void (*bt_att_notify_func_t)(struct bt_att_chan *chan, uint16_t mtu,
					uint8_t opcode, const void *pdu,
					uint16_t length, void *user_data);
typedef void (*bt_att_destroy_func_t)(void *user_data);
typedef void (*bt_att_debug_func_t)(const char *str, void *user_data);
typedef void (*bt_att_timeout_func_t)(unsigned int id, uint8_t opcode,
							void *user_data);
typedef void (*bt_att_disconnect_func_t)(int err, void *user_data);
typedef void (*bt_att_exchange_func_t)(uint16_t mtu, void *user_data);
typedef bool (*bt_att_counter_func_t)(uint32_t *sign_cnt, void *user_data);

bool bt_att_set_debug(struct bt_att *att, uint8_t level,
			bt_att_debug_func_t callback, void *user_data,
			bt_att_destroy_func_t destroy);

uint16_t bt_att_get_mtu(struct bt_att *att);
bool bt_att_set_mtu(struct bt_att *att, uint16_t mtu);
uint8_t bt_att_get_link_type(struct bt_att *att);

bool bt_att_set_timeout_cb(struct bt_att *att, bt_att_timeout_func_t callback,
						void *user_data,
						bt_att_destroy_func_t destroy);

unsigned int bt_att_send(struct bt_att *att, uint8_t opcode,
					const void *pdu, uint16_t length,
					bt_att_response_func_t callback,
					void *user_data,
					bt_att_destroy_func_t destroy);
int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
					const void *pdu, uint16_t length,
					bt_att_response_func_t callback,
					void *user_data,
					bt_att_destroy_func_t destroy);
unsigned int bt_att_chan_send(struct bt_att_chan *chan, uint8_t opcode,
					const void *pdu, uint16_t len,
					bt_att_response_func_t callback,
					void *user_data,
					bt_att_destroy_func_t destroy);
#define bt_att_chan_send_rsp(chan, opcode, pdu, len) \
	bt_att_chan_send(chan, opcode, pdu, len, NULL, NULL, NULL)
bool bt_att_chan_cancel(struct bt_att_chan *chan, unsigned int id);
bool bt_att_cancel(struct bt_att *att, unsigned int id);
bool bt_att_cancel_all(struct bt_att *att);

int bt_att_chan_send_error_rsp(struct bt_att_chan *chan, uint8_t opcode,
						uint16_t handle, int error);

unsigned int bt_att_register(struct bt_att *att, uint8_t opcode,
						bt_att_notify_func_t callback,
						void *user_data,
						bt_att_destroy_func_t destroy);
bool bt_att_unregister(struct bt_att *att, unsigned int id);

unsigned int bt_att_register_disconnect(struct bt_att *att,
					bt_att_disconnect_func_t callback,
					void *user_data,
					bt_att_destroy_func_t destroy);
bool bt_att_unregister_disconnect(struct bt_att *att, unsigned int id);

unsigned int bt_att_register_exchange(struct bt_att *att,
					bt_att_exchange_func_t callback,
					void *user_data,
					bt_att_destroy_func_t destroy);
bool bt_att_unregister_exchange(struct bt_att *att, unsigned int id);
bool bt_att_unregister_all(struct bt_att *att);

int bt_att_get_security(struct bt_att *att, uint8_t *enc_size);
bool bt_att_set_security(struct bt_att *att, int level);
void bt_att_set_enc_key_size(struct bt_att *att, uint8_t enc_size);

bool bt_att_set_local_key(struct bt_att *att, uint8_t sign_key[16],
			bt_att_counter_func_t func, void *user_data);
bool bt_att_set_remote_key(struct bt_att *att, uint8_t sign_key[16],
			bt_att_counter_func_t func, void *user_data);
bool bt_att_has_crypto(struct bt_att *att);
bool bt_att_set_retry(struct bt_att *att, unsigned int id, bool retry);