mesh: Delete unused structures/functions
authorInga Stotland <inga.stotland@intel.com>
Thu, 11 Jun 2020 18:30:38 +0000 (11:30 -0700)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 28 Dec 2020 06:20:04 +0000 (11:50 +0530)
This deletes unused functions and structures in net.c & net.h.
Plus, some style cleanup.

Change-Id: Ic03ac2b38811c404579f904c311aba47dec982a1
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
mesh/net.c
mesh/net.h

index 2b11e52..0e4a352 100644 (file)
@@ -57,6 +57,8 @@
 
 #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 */
@@ -177,30 +179,6 @@ struct mesh_destination {
        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;
@@ -239,7 +217,6 @@ struct net_beacon_data {
        bool processed;
 };
 
-#define FAST_CACHE_SIZE 8
 static struct l_queue *fast_cache;
 static struct l_queue *nets;
 
@@ -287,6 +264,7 @@ static void trigger_heartbeat(struct mesh_net *net, uint16_t feature,
        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 */
@@ -400,17 +378,15 @@ struct mesh_friend *mesh_friend_new(struct mesh_net *net, uint16_t dst,
        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;
 }
@@ -434,8 +410,7 @@ bool mesh_friend_clear(struct mesh_net *net, struct mesh_friend *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;
@@ -461,15 +436,13 @@ void mesh_friend_sub_add(struct mesh_net *net, uint16_t lpn, uint8_t ele_cnt,
        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;
@@ -747,14 +720,6 @@ bool mesh_net_register_unicast(struct mesh_net *net,
        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)
@@ -3313,8 +3278,10 @@ static uint16_t get_features(struct mesh_net *net)
 
        if (net->relay.enable)
                features |= FEATURE_RELAY;
+
        if (net->proxy_enable)
                features |= FEATURE_PROXY;
+
        if (net->friend_enable)
                features |= FEATURE_FRIEND;
 
@@ -3551,10 +3518,9 @@ bool net_msg_check_replay_cache(struct mesh_net *net, uint16_t src,
                        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));
 
index f7fe3f1..7117f1a 100644 (file)
@@ -270,7 +270,6 @@ void mesh_net_set_frnd_seq(struct mesh_net *net, bool seq);
 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);
@@ -310,7 +309,6 @@ void mesh_net_ack_send(struct mesh_net *net, uint32_t key_id,
                                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,