Skip to content

Commit b0ea148

Browse files
author
Mika Leppänen
committed
Corrected key storage configuration setting
Settings can now be set by application before initialization.
1 parent be3c94e commit b0ea148

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

source/6LoWPAN/ws/ws_pae_key_storage.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ typedef struct {
8787
} key_storage_array_t;
8888

8989
typedef struct {
90+
uint8_t settings_set; /**< Settings set, do not use defaults */
9091
uint8_t storages_empty; /**< Number of empty i.e. to be allocated storages */
9192
uint16_t storage_default_size; /**< Default size for storages */
9293
uint16_t replace_index; /**< Index to replace when storages are full */
@@ -138,6 +139,7 @@ int8_t ws_pae_key_storage_memory_set(uint8_t key_storages_number, const uint16_t
138139

139140
int8_t ws_pae_key_storage_settings_set(uint8_t alloc_max_number, uint16_t alloc_size, uint16_t storing_interval)
140141
{
142+
key_storage_params.settings_set = true;
141143
key_storage_params.storages_empty = alloc_max_number;
142144
key_storage_params.storage_default_size = alloc_size;
143145
key_storage_params.store_timer = storing_interval;
@@ -148,12 +150,14 @@ int8_t ws_pae_key_storage_settings_set(uint8_t alloc_max_number, uint16_t alloc_
148150

149151
void ws_pae_key_storage_init(void)
150152
{
151-
key_storage_params.storages_empty = DEFAULT_NUMBER_OF_STORAGES;
152-
key_storage_params.storage_default_size = STORAGE_ARRAY_HEADER_LEN + (sizeof(sec_prot_keys_storage_t) * DEFAULT_NUMBER_OF_ENTRIES_IN_ONE_STORAGE);
153+
if (!key_storage_params.settings_set) {
154+
key_storage_params.storages_empty = DEFAULT_NUMBER_OF_STORAGES;
155+
key_storage_params.storage_default_size = STORAGE_ARRAY_HEADER_LEN + (sizeof(sec_prot_keys_storage_t) * DEFAULT_NUMBER_OF_ENTRIES_IN_ONE_STORAGE);
156+
key_storage_params.store_timer = DEFAULT_STORING_INTERVAL;
157+
key_storage_params.store_timer_timeout = DEFAULT_STORING_INTERVAL;
158+
}
153159
key_storage_params.replace_index = 0;
154160
key_storage_params.store_bitfield = 0,
155-
key_storage_params.store_timer_timeout = DEFAULT_STORING_INTERVAL;
156-
key_storage_params.store_timer = DEFAULT_STORING_INTERVAL;
157161
key_storage_params.restart_cnt = 0;
158162
}
159163

0 commit comments

Comments
 (0)