mesh: Check TTL max value on transport TX

Adds check for TTL max in the transport send functions, and moves
setting of default TTL to transport.

this is port of a2aad2b3f80e60415b1210ab0b3f487854ee6b26
This commit is contained in:
Krzysztof Kopyściński
2021-01-12 14:05:19 +01:00
committed by Łukasz Rymanowski
parent 011dbfda65
commit 2e41391890
4 changed files with 17 additions and 17 deletions
-2
View File
@@ -27,8 +27,6 @@
static struct ble_npl_callout hello_work;
static struct ble_npl_callout mesh_start_work;
struct bt_mesh_hb_cb hb_cb;
static void heartbeat(const struct bt_mesh_hb_sub *sub, uint8_t hops,
uint16_t feat)
{
-4
View File
@@ -456,10 +456,6 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct os_mbuf *buf,
BT_DBG("Payload len %u: %s", buf->om_len, bt_hex(buf->om_data, buf->om_len));
BT_DBG("Seq 0x%06x", bt_mesh.seq);
if (tx->ctx->send_ttl == BT_MESH_TTL_DEFAULT) {
tx->ctx->send_ttl = bt_mesh_default_ttl_get();
}
cred = net_tx_cred_get(tx);
err = net_header_encode(tx, cred->nid, buf);
if (err) {
+15 -5
View File
@@ -488,11 +488,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct os_mbuf *sdu,
tx->started = 0;
tx->ctl = !!ctl_op;
if (net_tx->ctx->send_ttl == BT_MESH_TTL_DEFAULT) {
tx->ttl = bt_mesh_default_ttl_get();
} else {
tx->ttl = net_tx->ctx->send_ttl;
}
tx->ttl = net_tx->ctx->send_ttl;
BT_DBG("SeqZero 0x%04x (segs: %u)",
(uint16_t)(tx->seq_auth & TRANS_SEQ_ZERO_MASK), tx->nack_count);
@@ -627,6 +623,13 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct os_mbuf *msg,
return -EINVAL;
}
if (tx->ctx->send_ttl == BT_MESH_TTL_DEFAULT) {
tx->ctx->send_ttl = bt_mesh_default_ttl_get();
} else if (tx->ctx->send_ttl > BT_MESH_TTL_MAX) {
BT_ERR("TTL too large (max 127)");
return -EINVAL;
}
if (msg->om_len > BT_MESH_SDU_UNSEG_MAX) {
tx->ctx->send_rel = 1;
tx->ctx->send_rel = true;
@@ -988,6 +991,13 @@ int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data,
net_buf_simple_init_with_data(buf, data, data_len);
if (tx->ctx->send_ttl == BT_MESH_TTL_DEFAULT) {
tx->ctx->send_ttl = bt_mesh_default_ttl_get();
} else if (tx->ctx->send_ttl > BT_MESH_TTL_MAX) {
BT_ERR("TTL too large (max 127)");
return -EINVAL;
}
if (data_len > BT_MESH_SDU_UNSEG_MAX) {
tx->ctx->send_rel = true;
}
+2 -6
View File
@@ -473,34 +473,30 @@ syscfg.defs:
Controls whether the Friend feature is enabled by default. Can be
changed through runtime configuration.
value: 1
restrictions: BLE_MESH_FRIEND
BLE_MESH_FRIEND_RECV_WIN:
description: >
Receive Window in milliseconds supported by the Friend node.
value: 255
restrictions: BLE_MESH_FRIEND
BLE_MESH_FRIEND_QUEUE_SIZE:
description: >
Minimum number of buffers available to be stored for each
local Friend Queue.
value: 16
restrictions: BLE_MESH_FRIEND
BLE_MESH_FRIEND_SUB_LIST_SIZE:
description: >
Size of the Subscription List that can be supported by a
Friend node for a Low Power node.
value: 3
restrictions: BLE_MESH_FRIEND
BLE_MESH_FRIEND_LPN_COUNT:
description: >
Number of Low Power Nodes the Friend can have a Friendship
with simultaneously.
value: 2
restrictions: BLE_MESH_FRIEND
BLE_MESH_FRIEND_SEG_RX:
description: >
@@ -509,7 +505,7 @@ syscfg.defs:
many elements we can simultaneously be receiving segmented
messages from when the messages are going into the Friend queue.
value: 1
restrictions: BLE_MESH_FRIEND
BLE_MESH_CFG_CLI:
description: >