#define SAR_KEY(src, seq0) ((((uint32_t)(seq0)) << 16) | (src))
+#define FAST_CACHE_SIZE 8
+
enum _relay_advice {
RELAY_NONE, /* Relay not enabled in node */
RELAY_ALLOWED, /* Relay enabled, msg not to node's unicast */
uint16_t ref_cnt;
};
-struct msg_rx {
- const uint8_t *data;
- uint32_t iv_index;
- uint32_t seq;
- uint16_t src;
- uint16_t dst;
- uint16_t size;
- uint8_t tc;
- bool done;
- bool szmic;
- union {
- struct {
- uint16_t app_idx;
- uint8_t key_aid;
- } m;
- struct {
- uint16_t seq0;
- } a;
- struct {
- uint8_t opcode;
- } c;
- } u;
-};
-
struct net_decode {
struct mesh_net *net;
struct mesh_friend *frnd;
bool processed;
};
-#define FAST_CACHE_SIZE 8
static struct l_queue *fast_cache;
static struct l_queue *nets;
struct mesh_net_heartbeat *hb = &net->heartbeat;
l_debug("%s: %4.4x --> %d", __func__, feature, in_use);
+
if (in_use) {
if (net->heartbeat.features & feature)
return; /* no change */
subnet = get_primary_subnet(net);
/* TODO: the primary key must be present, do we need to add check?. */
- frnd->net_key_cur = net_key_frnd_add(subnet->net_key_cur,
- dst, net->src_addr,
- lp_cnt, fn_cnt);
+ frnd->net_key_cur = net_key_frnd_add(subnet->net_key_cur, dst,
+ net->src_addr, lp_cnt, fn_cnt);
if (!subnet->net_key_upd)
return frnd;
frnd->net_idx = subnet->idx;
- frnd->net_key_upd = net_key_frnd_add(subnet->net_key_upd,
- dst, net->src_addr,
- lp_cnt, fn_cnt);
+ frnd->net_key_upd = net_key_frnd_add(subnet->net_key_upd, dst,
+ net->src_addr, lp_cnt, fn_cnt);
return frnd;
}
}
void mesh_friend_sub_add(struct mesh_net *net, uint16_t lpn, uint8_t ele_cnt,
- uint8_t grp_cnt,
- const uint8_t *list)
+ uint8_t grp_cnt, const uint8_t *list)
{
uint16_t *new_list;
uint16_t *grp_list;
frnd->u.active.grp_cnt += grp_cnt;
}
-void mesh_friend_sub_del(struct mesh_net *net, uint16_t lpn,
- uint8_t cnt,
- const uint8_t *del_list)
+void mesh_friend_sub_del(struct mesh_net *net, uint16_t lpn, uint8_t cnt,
+ const uint8_t *del_list)
{
uint16_t *grp_list;
int16_t i, grp_cnt;
size_t cnt16 = cnt * sizeof(uint16_t);
- struct mesh_friend *frnd = l_queue_find(net->friends,
- match_by_friend,
+ struct mesh_friend *frnd = l_queue_find(net->friends, match_by_friend,
L_UINT_TO_PTR(lpn));
if (!frnd)
return;
return true;
}
-uint8_t mesh_net_get_num_ele(struct mesh_net *net)
-{
- if (!net)
- return 0;
-
- return net->last_addr - net->src_addr + 1;
-}
-
bool mesh_net_set_proxy_mode(struct mesh_net *net, bool enable)
{
if (!net)
if (net->relay.enable)
features |= FEATURE_RELAY;
+
if (net->proxy_enable)
features |= FEATURE_PROXY;
+
if (net->friend_enable)
features |= FEATURE_FRIEND;
l_debug("Ignoring replayed packet");
return true;
}
- }
+ } else if (l_queue_length(net->replay_cache) >= crpl) {
+ /* SRC not in Replay Cache... see if there is space for it */
- /* SRC not in Replay Cache... see if there is space for it */
- else if (l_queue_length(net->replay_cache) >= crpl) {
int ret = l_queue_foreach_remove(net->replay_cache,
clean_old_iv_index, L_UINT_TO_PTR(iv_index));
uint16_t mesh_net_get_address(struct mesh_net *net);
bool mesh_net_register_unicast(struct mesh_net *net,
uint16_t unicast, uint8_t num_ele);
-uint8_t mesh_net_get_num_ele(struct mesh_net *net);
void net_local_beacon(uint32_t key_id, uint8_t *beacon);
bool mesh_net_set_beacon_mode(struct mesh_net *net, bool enable);
bool mesh_net_set_proxy_mode(struct mesh_net *net, bool enable);
uint16_t seqZero, uint32_t ack_flags);
int mesh_net_get_identity_mode(struct mesh_net *net, uint16_t idx,
uint8_t *mode);
-char *mesh_net_id_name(struct mesh_net *net);
bool mesh_net_dst_reg(struct mesh_net *net, uint16_t dst);
bool mesh_net_dst_unreg(struct mesh_net *net, uint16_t dst);
struct mesh_friend *mesh_friend_new(struct mesh_net *net, uint16_t dst,