The folllowing functionsa are not being used anywhere in the code and have been removed: mesh_net_flush() mesh_net_prov_caps_get() mesh_net_priv_key_get() mesh_net_priv_key_set() mesh_net_prov_rand() mesh_net_prov_uni() mesh_net_id_uuid_set() mesh_net_test_addr() mesh_net_test_mode() mesh_net_uni_range_set() mesh_net_uni_range_get() mesh_net_set_window_accuracy() --- mesh/net.c | 149 ++--------------------------------------------------- mesh/net.h | 21 -------- 2 files changed, 4 insertions(+), 166 deletions(-) diff --git a/mesh/net.c b/mesh/net.c index af891e5a9..07813eec4 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -124,7 +124,6 @@ struct mesh_net { uint8_t chan; /* Channel of recent Rx */ uint8_t default_ttl; uint8_t tid; - uint8_t window_accuracy; struct { bool enable; @@ -144,21 +143,6 @@ struct mesh_net { struct l_queue *friends; struct l_queue *negotiations; struct l_queue *destinations; - - uint8_t prov_priv_key[32]; - - /* Unprovisioned Identity */ - char id_name[20]; - uint8_t id_uuid[16]; - - /* Provisioner: unicast address range */ - struct mesh_net_addr_range prov_uni_addr; - - /* Test Data */ - uint8_t prov_rand[16]; - uint8_t test_bd_addr[6]; - struct mesh_net_prov_caps prov_caps; - bool test_mode; }; struct mesh_msg { @@ -648,9 +632,6 @@ struct mesh_net *mesh_net_new(struct mesh_node *node) net->seq_num = DEFAULT_SEQUENCE_NUMBER; net->default_ttl = TTL_MASK; - memset(&net->prov_caps, 0, sizeof(net->prov_caps)); - net->prov_caps.algorithms = 1; - net->tx_cnt = DEFAULT_TRANSMIT_COUNT; net->tx_interval = DEFAULT_TRANSMIT_INTERVAL; @@ -829,93 +810,6 @@ bool mesh_net_set_relay_mode(struct mesh_net *net, bool enable, return true; } -struct mesh_net_prov_caps *mesh_net_prov_caps_get(struct mesh_net *net) -{ - if (net) - return &net->prov_caps; - - return NULL; -} - -char *mesh_net_id_name(struct mesh_net *net) -{ - if (net && net->id_name[0]) - return net->id_name; - - return NULL; -} - -bool mesh_net_id_uuid_set(struct mesh_net *net, uint8_t uuid[16]) -{ - if (!net) - return false; - - memcpy(net->id_uuid, uuid, 16); - - return true; -} - -uint8_t *mesh_net_priv_key_get(struct mesh_net *net) -{ - if (net) - return net->prov_priv_key; - - return NULL; -} - -bool mesh_net_priv_key_set(struct mesh_net *net, uint8_t key[32]) -{ - if (!net) - return false; - - memcpy(net->prov_priv_key, key, 32); - return true; -} - -uint8_t *mesh_net_test_addr(struct mesh_net *net) -{ - const uint8_t zero_addr[] = {0, 0, 0, 0, 0, 0}; - - if (net && memcmp(net->test_bd_addr, zero_addr, 6)) - return net->test_bd_addr; - - return NULL; -} - -uint8_t *mesh_net_prov_rand(struct mesh_net *net) -{ - if (net) - return net->prov_rand; - - return NULL; -} - -uint16_t mesh_net_prov_uni(struct mesh_net *net, uint8_t ele_cnt) -{ - uint16_t uni; - uint16_t next; - - if (!net) - return 0; - - next = net->prov_uni_addr.next + ele_cnt; - if (next > 0x8000 || next > net->prov_uni_addr.high) - return UNASSIGNED_ADDRESS; - - uni = net->prov_uni_addr.next; - net->prov_uni_addr.next = next; - - return uni; -} - -bool mesh_net_test_mode(struct mesh_net *net) -{ - if (net) - return net->test_mode; - - return false; -} - int mesh_net_get_identity_mode(struct mesh_net *net, uint16_t idx, uint8_t *mode) { @@ -1026,11 +920,6 @@ int mesh_net_add_key(struct mesh_net *net, uint16_t idx, const uint8_t *value) return MESH_STATUS_SUCCESS; } -void mesh_net_flush_msg_queues(struct mesh_net *net) -{ - l_queue_clear(net->msg_cache, l_free); -} - uint32_t mesh_net_get_iv_index(struct mesh_net *net) { if (!net) @@ -2543,7 +2432,7 @@ static void iv_upd_to(struct l_timeout *upd_timeout, void *user_data) net->iv_index, false); l_queue_foreach(net->subnets, refresh_beacon, net); queue_friend_update(net); - mesh_net_flush_msg_queues(net); + l_queue_clear(net->msg_cache, l_free); break; case IV_UPD_INIT: @@ -2937,7 +2826,7 @@ bool mesh_net_iv_index_update(struct mesh_net *net) return false; l_debug("iv_upd_state = IV_UPD_UPDATING"); - mesh_net_flush_msg_queues(net); + l_queue_clear(net->msg_cache, l_free); if (!mesh_config_write_iv_index(node_config_get(net->node), net->iv_index + 1, true)) @@ -2999,15 +2888,6 @@ bool mesh_net_dst_unreg(struct mesh_net *net, uint16_t dst) return true; } -bool mesh_net_flush(struct mesh_net *net) -{ - if (!net) - return false; - - /* TODO mesh-io Flush */ - return true; -} - static bool send_seg(struct mesh_net *net, struct mesh_sar *msg, uint8_t segO) { struct mesh_subnet *subnet; @@ -3430,7 +3310,7 @@ int mesh_net_update_key(struct mesh_net *net, uint16_t idx, return MESH_STATUS_SUCCESS; } -uint16_t mesh_net_get_features(struct mesh_net *net) +static uint16_t get_features(struct mesh_net *net) { uint16_t features = 0; @@ -3473,20 +3353,7 @@ void mesh_net_heartbeat_init(struct mesh_net *net) memset(hb, 0, sizeof(struct mesh_net_heartbeat)); hb->sub_min_hops = 0xff; - hb->features = mesh_net_get_features(net); -} - -void mesh_net_uni_range_set(struct mesh_net *net, - struct mesh_net_addr_range *range) -{ - net->prov_uni_addr.low = range->low; - net->prov_uni_addr.high = range->high; - net->prov_uni_addr.next = range->next; -} - -struct mesh_net_addr_range mesh_net_uni_range_get(struct mesh_net *net) -{ - return net->prov_uni_addr; + hb->features = get_features(net); } void mesh_net_set_iv_index(struct mesh_net *net, uint32_t index, bool update) @@ -3582,14 +3449,6 @@ bool mesh_net_is_local_address(struct mesh_net *net, uint16_t src, (last >= net->src_addr && last <= net->last_addr); } -void mesh_net_set_window_accuracy(struct mesh_net *net, uint8_t accuracy) -{ - if (!net) - return; - - net->window_accuracy = accuracy; -} - void mesh_net_transmit_params_set(struct mesh_net *net, uint8_t count, uint16_t interval) { diff --git a/mesh/net.h b/mesh/net.h index 12808ce38..84e7c1545 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -120,12 +120,6 @@ struct mesh_node; #define DEFAULT_MIN_DELAY 0 #define DEFAULT_MAX_DELAY 25 -struct mesh_net_addr_range { - uint16_t low; - uint16_t high; - uint16_t next; -}; - struct mesh_net_prov_caps { uint8_t num_ele; uint16_t algorithms; @@ -264,7 +258,6 @@ typedef void (*mesh_status_func_t)(void *user_data, bool result); struct mesh_net *mesh_net_new(struct mesh_node *node); void mesh_net_free(void *net); void mesh_net_cleanup(void); -void mesh_net_flush_msg_queues(struct mesh_net *net); void mesh_net_set_iv_index(struct mesh_net *net, uint32_t index, bool update); bool mesh_net_iv_index_update(struct mesh_net *net); bool mesh_net_set_seq_num(struct mesh_net *net, uint32_t number); @@ -300,7 +293,6 @@ bool mesh_net_attach(struct mesh_net *net, struct mesh_io *io); struct mesh_io *mesh_net_detach(struct mesh_net *net); struct l_queue *mesh_net_get_app_keys(struct mesh_net *net); -bool mesh_net_flush(struct mesh_net *net); void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, uint16_t net_idx, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, @@ -316,17 +308,9 @@ void mesh_net_ack_send(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, bool rly, uint16_t seqZero, uint32_t ack_flags); -struct mesh_net_prov_caps *mesh_net_prov_caps_get(struct mesh_net *net); -uint8_t *mesh_net_priv_key_get(struct mesh_net *net); -bool mesh_net_priv_key_set(struct mesh_net *net, uint8_t key[32]); -uint8_t *mesh_net_prov_rand(struct mesh_net *net); -uint16_t mesh_net_prov_uni(struct mesh_net *net, uint8_t ele_cnt); -bool mesh_net_id_uuid_set(struct mesh_net *net, uint8_t uuid[16]); -uint8_t *mesh_net_test_addr(struct mesh_net *net); 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_test_mode(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, @@ -348,13 +332,9 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, uint32_t hdr, const void *seg, uint16_t seg_len); -uint16_t mesh_net_get_features(struct mesh_net *net); struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net); void mesh_net_heartbeat_init(struct mesh_net *net); void mesh_net_heartbeat_send(struct mesh_net *net); -void mesh_net_uni_range_set(struct mesh_net *net, - struct mesh_net_addr_range *range); -struct mesh_net_addr_range mesh_net_uni_range_get(struct mesh_net *net); void mesh_net_provisioner_mode_set(struct mesh_net *net, bool mode); bool mesh_net_provisioner_mode_get(struct mesh_net *net); bool mesh_net_key_list_get(struct mesh_net *net, uint8_t *buf, uint16_t *count); @@ -365,7 +345,6 @@ struct mesh_node *mesh_net_node_get(struct mesh_net *net); bool mesh_net_have_key(struct mesh_net *net, uint16_t net_idx); bool mesh_net_is_local_address(struct mesh_net *net, uint16_t src, uint16_t count); -void mesh_net_set_window_accuracy(struct mesh_net *net, uint8_t accuracy); void mesh_net_transmit_params_set(struct mesh_net *net, uint8_t count, uint16_t interval); void mesh_net_transmit_params_get(struct mesh_net *net, uint8_t *count, -- 2.26.2