There is a confusion between the node default TTL (section 4.2.7) and the publish TTL (section 4.2.2.5): - The node default TTL can only take values 0x00, and 0x02 to 0x7f. The value 0xff is not prohibited. - The publish TTL can take values 0x00 to 0x7f, as well as 0xff which means use the node default TTL. Currently the default node TTL is set to 0xff (DEFAULT_TTL), and read_default_ttl() also allows such a value. This patch fixes that to use 0x7f (TTL_MASK) as the default value instead. Note that the code handling OP_CONFIG_DEFAULT_TTL_SET correctly use 0x7f (TTL_MASK) for the upper allowed limit. --- mesh/mesh-config-json.c | 2 +- mesh/node.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index b2cff6824..5ca2961b0 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -358,7 +358,7 @@ static bool read_default_ttl(json_object *jobj, uint8_t *ttl) if (!val && errno == EINVAL) return false; - if (val < 0 || val == 1 || val > DEFAULT_TTL) + if (val < 0 || val == 1 || val > TTL_MASK) return false; *ttl = (uint8_t) val; diff --git a/mesh/node.c b/mesh/node.c index e23f32dd1..5dcffe6f7 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -672,7 +672,7 @@ struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t node_default_ttl_get(struct mesh_node *node) { if (!node) - return DEFAULT_TTL; + return TTL_MASK; return node->ttl; } @@ -1352,7 +1352,7 @@ static void set_defaults(struct mesh_node *node) node->friend = MESH_MODE_UNSUPPORTED; node->beacon = MESH_MODE_DISABLED; node->relay.mode = MESH_MODE_DISABLED; - node->ttl = DEFAULT_TTL; + node->ttl = TTL_MASK; node->seq_number = DEFAULT_SEQUENCE_NUMBER; /* Add configuration server model on primary element */ -- 2.24.0