diff --git a/mesh/manager.c b/mesh/manager.c
index 3786f7a..b698663 100644
--- a/mesh/manager.c
+++ b/mesh/manager.c
#define _GNU_SOURCE
#include <ell/ell.h>
+#include "src/shared/ad.h"
+
#include "mesh/mesh-defs.h"
#include "mesh/dbus.h"
#include "mesh/error.h"
static struct l_queue *scans;
static struct prov_remote_data *prov_pending;
-static const uint8_t prvb[2] = {MESH_AD_TYPE_BEACON, 0x00};
+static const uint8_t prvb[2] = {BT_AD_MESH_BEACON, 0x00};
static bool by_scan(const void *a, const void *b)
{
diff --git a/mesh/mesh-defs.h b/mesh/mesh-defs.h
index a12acaf..5b0403d 100644
--- a/mesh/mesh-defs.h
+++ b/mesh/mesh-defs.h
*
*/
-#define MESH_AD_TYPE_PROVISION 0x29
-#define MESH_AD_TYPE_NETWORK 0x2A
-#define MESH_AD_TYPE_BEACON 0x2B
-
/*
* MshPRT_v1.1, section 3.3.1 / Core_v5.3, section 2.3.1.3
* Maximum length of AdvData without 'Length' field (30)
diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c
index 0875a35..f65de9d 100644
--- a/mesh/mesh-io-generic.c
+++ b/mesh/mesh-io-generic.c
/* Mesh specific AD types do *not* require active scanning,
* so do not turn on Active Scanning on their account.
*/
- if (rx_reg->filter[0] < MESH_AD_TYPE_PROVISION ||
- rx_reg->filter[0] > MESH_AD_TYPE_BEACON)
+ if (rx_reg->filter[0] < BT_AD_MESH_PROV ||
+ rx_reg->filter[0] > BT_AD_MESH_BEACON)
return true;
return false;
diff --git a/mesh/mesh-io-mgmt.c b/mesh/mesh-io-mgmt.c
index 065067f..30d3981 100644
--- a/mesh/mesh-io-mgmt.c
+++ b/mesh/mesh-io-mgmt.c
if (!addr)
addr = zero_addr;
- if (adv[1] == MESH_AD_TYPE_PROVISION) {
+ if (adv[1] == BT_AD_MESH_PROV) {
filter = l_queue_find(pvt->dup_filters, find_by_adv, adv);
if (!filter && addr != zero_addr)
};
/* Accept all traffic except beacons from any controller */
- if (index != pvt->send_idx && data[0] == MESH_AD_TYPE_BEACON)
+ if (index != pvt->send_idx && data[0] == BT_AD_MESH_BEACON)
return;
print_packet("RX", data, len);
if (len > adv_len)
break;
- if (adv[1] >= MESH_AD_TYPE_PROVISION &&
- adv[1] <= MESH_AD_TYPE_BEACON)
+ if (adv[1] >= BT_AD_MESH_PROV && adv[1] <= BT_AD_MESH_BEACON)
process_rx(index, pvt, ev->rssi, instant, addr,
adv + 1, adv[0]);
/* Mesh specific AD types do *not* require active scanning,
* so do not turn on Active Scanning on their account.
*/
- if (rx_reg->filter[0] < MESH_AD_TYPE_PROVISION ||
- rx_reg->filter[0] > MESH_AD_TYPE_BEACON)
+ if (rx_reg->filter[0] < BT_AD_MESH_PROV ||
+ rx_reg->filter[0] > BT_AD_MESH_BEACON)
return true;
return false;
int index = L_PTR_TO_UINT(user_data);
uint16_t len;
struct mgmt_cp_set_mesh *mesh;
- uint8_t mesh_ad_types[] = { MESH_AD_TYPE_NETWORK,
- MESH_AD_TYPE_BEACON, MESH_AD_TYPE_PROVISION };
+ uint8_t mesh_ad_types[] = { BT_AD_MESH_DATA, BT_AD_MESH_BEACON,
+ BT_AD_MESH_PROV };
l_debug("HCI%d is up status: %d", index, status);
if (status)
memcpy(send->adv_data + 1, tx->pkt, tx->len);
/* Filter looped back Provision packets */
- if (tx->pkt[0] == MESH_AD_TYPE_PROVISION)
+ if (tx->pkt[0] == BT_AD_MESH_PROV)
filter_dups(NULL, send->adv_data, get_instant());
mesh_mgmt_send(MGMT_OP_MESH_SEND, index,
diff --git a/mesh/mesh-io.c b/mesh/mesh-io.c
index 99c7c20..ec5feb9 100644
--- a/mesh/mesh-io.c
+++ b/mesh/mesh-io.c
#include "lib/bluetooth.h"
#include "lib/mgmt.h"
+#include "src/shared/ad.h"
#include "src/shared/mgmt.h"
#include "mesh/mesh-defs.h"
{MESH_IO_TYPE_UNIT_TEST, &mesh_io_unit},
};
-static const uint8_t unprv_filter[] = { MESH_AD_TYPE_BEACON, 0 };
+static const uint8_t unprv_filter[] = { BT_AD_MESH_BEACON, 0 };
static struct mesh_io *default_io;
static struct l_timeout *loop_adv_to;
diff --git a/mesh/mesh.c b/mesh/mesh.c
index 01a1607..db77602 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
#define _GNU_SOURCE
#include <ell/ell.h>
+#include "src/shared/ad.h"
+
#include "mesh/mesh-io.h"
#include "mesh/node.h"
#include "mesh/net.h"
bool mesh_reg_prov_rx(prov_rx_cb_t cb, void *user_data)
{
- uint8_t prov_filter[] = {MESH_AD_TYPE_PROVISION};
+ uint8_t prov_filter[] = {BT_AD_MESH_PROV};
if (mesh.prov_rx && mesh.prov_rx != cb)
return false;
void mesh_unreg_prov_rx(prov_rx_cb_t cb)
{
- uint8_t prov_filter[] = {MESH_AD_TYPE_PROVISION};
+ uint8_t prov_filter[] = {BT_AD_MESH_PROV};
if (mesh.prov_rx != cb)
return;
diff --git a/mesh/net-keys.c b/mesh/net-keys.c
index 9b11bb7..338d287 100644
--- a/mesh/net-keys.c
+++ b/mesh/net-keys.c
b_data, 5, b_data, NULL, 8))
return false;
- key->mpb[0] = MESH_AD_TYPE_BEACON;
+ key->mpb[0] = BT_AD_MESH_BEACON;
key->mpb[1] = BEACON_TYPE_MPB;
memcpy(key->mpb + 2, random, 13);
memcpy(key->mpb + 15, b_data, 13);
return false;
}
- key->snb[0] = MESH_AD_TYPE_BEACON;
+ key->snb[0] = BT_AD_MESH_BEACON;
key->snb[1] = BEACON_TYPE_SNB;
key->snb[2] = 0;
diff --git a/mesh/net.c b/mesh/net.c
index cf4f337..b6ff11f 100644
--- a/mesh/net.c
+++ b/mesh/net.c
.u.gen.max_delay = DEFAULT_MAX_DELAY
};
- packet[0] = MESH_AD_TYPE_NETWORK;
+ packet[0] = BT_AD_MESH_DATA;
memcpy(packet + 1, data, size);
mesh_io_send(io, &info, packet, size + 1);
return;
}
- tx->packet[0] = MESH_AD_TYPE_NETWORK;
+ tx->packet[0] = BT_AD_MESH_DATA;
info.type = MESH_IO_TIMING_TYPE_GENERAL;
info.u.gen.interval = tx->interval;
info.u.gen.cnt = tx->cnt;
first = l_queue_isempty(nets);
if (first) {
- const uint8_t snb[] = {MESH_AD_TYPE_BEACON, 1};
- const uint8_t mpb[] = {MESH_AD_TYPE_BEACON, 2};
- const uint8_t pkt[] = {MESH_AD_TYPE_NETWORK};
+ const uint8_t snb[] = {BT_AD_MESH_BEACON, 1};
+ const uint8_t mpb[] = {BT_AD_MESH_BEACON, 2};
+ const uint8_t pkt[] = {BT_AD_MESH_DATA};
if (!nets)
nets = l_queue_new();
struct mesh_io *mesh_net_detach(struct mesh_net *net)
{
- const uint8_t snb[] = {MESH_AD_TYPE_BEACON, 1};
- const uint8_t mpb[] = {MESH_AD_TYPE_BEACON, 2};
- const uint8_t pkt[] = {MESH_AD_TYPE_NETWORK};
+ const uint8_t snb[] = {BT_AD_MESH_BEACON, 1};
+ const uint8_t mpb[] = {BT_AD_MESH_BEACON, 2};
+ const uint8_t pkt[] = {BT_AD_MESH_DATA};
struct mesh_io *io;
uint8_t type = 0;
diff --git a/mesh/pb-adv.c b/mesh/pb-adv.c
index 0b1fd7d..1b80b97 100644
--- a/mesh/pb-adv.c
+++ b/mesh/pb-adv.c
#include <ell/ell.h>
+#include "src/shared/ad.h"
+
#include "mesh/mesh-defs.h"
#include "mesh/crypto.h"
#include "mesh/net.h"
static struct l_queue *pb_sessions = NULL;
-static const uint8_t filter[1] = { MESH_AD_TYPE_PROVISION };
+static const uint8_t filter[1] = { BT_AD_MESH_PROV };
static void pb_adv_packet(void *user_data, const uint8_t *pkt, uint16_t len);
uint16_t size)
{
uint16_t init_size;
- uint8_t buf[PB_ADV_MTU + 6] = { MESH_AD_TYPE_PROVISION };
+ uint8_t buf[PB_ADV_MTU + 6] = { BT_AD_MESH_PROV };
uint8_t max_seg;
uint8_t consumed;
int i;
static void send_open_req(struct pb_adv_session *session)
{
- struct pb_open_req open_req = { MESH_AD_TYPE_PROVISION };
+ struct pb_open_req open_req = { BT_AD_MESH_PROV };
l_put_be32(session->link_id, &open_req.link_id);
open_req.trans_num = 0;
static void send_open_cfm(struct pb_adv_session *session)
{
- struct pb_open_cfm open_cfm = { MESH_AD_TYPE_PROVISION };
+ struct pb_open_cfm open_cfm = { BT_AD_MESH_PROV };
l_put_be32(session->link_id, &open_cfm.link_id);
open_cfm.trans_num = 0;
static void send_ack(struct pb_adv_session *session, uint8_t trans_num)
{
- struct pb_ack ack = { MESH_AD_TYPE_PROVISION };
+ struct pb_ack ack = { BT_AD_MESH_PROV };
if (!l_queue_find(pb_sessions, session_match, session))
return;
static void send_close_ind(struct pb_adv_session *session, uint8_t reason)
{
- struct pb_close_ind close_ind = { MESH_AD_TYPE_PROVISION };
+ struct pb_close_ind close_ind = { BT_AD_MESH_PROV };
if (!l_queue_find(pb_sessions, session_match, session))
return;
diff --git a/mesh/prov-acceptor.c b/mesh/prov-acceptor.c
index 650309b..0cedc22 100644
--- a/mesh/prov-acceptor.c
+++ b/mesh/prov-acceptor.c
#include <ell/ell.h>
+#include "src/shared/ad.h"
#include "src/shared/ecc.h"
#include "mesh/mesh-defs.h"
uint8_t cmd[];
};
-static const uint8_t pkt_filter = MESH_AD_TYPE_PROVISION;
-static const uint8_t bec_filter[] = {MESH_AD_TYPE_BEACON,
+static const uint8_t pkt_filter = BT_AD_MESH_PROV;
+static const uint8_t bec_filter[] = {BT_AD_MESH_BEACON,
BEACON_TYPE_UNPROVISIONED};
#define MAT_REMOTE_PUBLIC 0x01
void *caller_data)
{
struct mesh_agent_prov_caps *caps;
- uint8_t beacon[24] = {MESH_AD_TYPE_BEACON,
- BEACON_TYPE_UNPROVISIONED};
+ uint8_t beacon[24] = {BT_AD_MESH_BEACON, BEACON_TYPE_UNPROVISIONED};
uint8_t len = sizeof(beacon) - sizeof(uint32_t);
bool result;
diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c
index dc19d1e..c0d2de4 100644
--- a/mesh/prov-initiator.c
+++ b/mesh/prov-initiator.c
#include <ell/ell.h>
+#include "src/shared/ad.h"
#include "src/shared/ecc.h"
#include "mesh/mesh-defs.h"
#define BEACON_TYPE_UNPROVISIONED 0x00
-static const uint8_t pkt_filter = MESH_AD_TYPE_PROVISION;
+static const uint8_t pkt_filter = BT_AD_MESH_PROV;
enum int_state {
INT_PROV_IDLE = 0,