summaryrefslogtreecommitdiff
path: root/src/shared/csip.h
blob: 0f8acb1cae8236f03801bb143a9133f34a549557 (plain)
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
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 *
 *  BlueZ - Bluetooth protocol stack for Linux
 *
 *  Copyright (C) 2022  Intel Corporation. All rights reserved.
 *
 */

#include <stdbool.h>
#include <inttypes.h>

#include "src/shared/io.h"

#ifndef __packed
#define __packed __attribute__((packed))
#endif

struct bt_csip;

enum {
	BT_CSIP_SIRK_ENCRYPT = 0x00,
	BT_CSIP_SIRK_CLEARTEXT = 0x01
};

typedef void (*bt_csip_ready_func_t)(struct bt_csip *csip, void *user_data);
typedef void (*bt_csip_destroy_func_t)(void *user_data);
typedef void (*bt_csip_debug_func_t)(const char *str, void *user_data);
typedef void (*bt_csip_func_t)(struct bt_csip *csip, void *user_data);
typedef bool (*bt_csip_ltk_func_t)(struct bt_csip *csip, uint8_t k[16],
							void *user_data);
typedef bool (*bt_csip_sirk_func_t)(struct bt_csip *csip, uint8_t type,
				    uint8_t k[16], uint8_t size, uint8_t rank,
				    void *user_data);

struct bt_csip *bt_csip_ref(struct bt_csip *csip);
void bt_csip_unref(struct bt_csip *csip);

void bt_csip_add_db(struct gatt_db *db);

bool bt_csip_attach(struct bt_csip *csip, struct bt_gatt_client *client);
void bt_csip_detach(struct bt_csip *csip);

bool bt_csip_set_debug(struct bt_csip *csip, bt_csip_debug_func_t func,
			void *user_data, bt_csip_destroy_func_t destroy);

struct bt_att *bt_csip_get_att(struct bt_csip *csip);

bool bt_csip_set_user_data(struct bt_csip *csip, void *user_data);

/* Session related function */
unsigned int bt_csip_register(bt_csip_func_t added, bt_csip_func_t removed,
							void *user_data);
bool bt_csip_unregister(unsigned int id);
struct bt_csip *bt_csip_new(struct gatt_db *ldb, struct gatt_db *rdb);

bool bt_csip_set_sirk(struct bt_csip *csip, bool encrypt,
				uint8_t k[16], uint8_t size, uint8_t rank,
				bt_csip_ltk_func_t func, void *user_data);

bool bt_csip_get_sirk(struct bt_csip *csip, uint8_t *type,
				uint8_t k[16], uint8_t *size, uint8_t *rank);

unsigned int bt_csip_ready_register(struct bt_csip *csip,
				bt_csip_ready_func_t func, void *user_data,
				bt_csip_destroy_func_t destroy);
bool bt_csip_ready_unregister(struct bt_csip *csip, unsigned int id);