/**************************************************************************** Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT be copied by any method or incorporated into another program without the express written consent of Aerospace C.Power. This Information or any portion thereof remains the property of Aerospace C.Power. The Information contained herein is believed to be accurate and Aerospace C.Power assumes no responsibility or liability for its use in any way and conveys no license or title under any patent or copyright and makes no representation or warranty that this Information is free from patent or copyright infringement. ****************************************************************************/ #include "mac_avln.h" mac_avln_ctxt_t g_mac_avln_ctxt; uint32_t mac_avln_ctxt_init(uint8_t avln_num) { IOT_ASSERT(avln_num <= MAX_AVLN_NUM); g_mac_avln_ctxt.avln_num_allocated = avln_num; mac_avln_t * mac_avln_array = \ (mac_avln_t *)os_mem_malloc(PLC_MAC_KEY_MID, \ avln_num * sizeof(mac_avln_t)); IOT_ASSERT(mac_avln_array); os_mem_set((uint8_t *)mac_avln_array, 0, \ avln_num * sizeof(mac_avln_t)); g_mac_avln_ctxt.mac_avln_array = (mac_avln_t *)mac_avln_array; return 0; } /* avln init function * return 0 if successul, else failed. */ uint32_t mac_avln_init(uint8_t avln_idx, uint8_t key_tbl_num) { IOT_ASSERT((avln_idx <= MAX_AVLN_NUM) && \ (avln_idx <= g_mac_avln_ctxt.avln_num_allocated) && \ (key_tbl_num <= MAX_KEY_TABLE_NUM)); mac_avln_t *mac_avln_tmp = (g_mac_avln_ctxt.mac_avln_array + avln_idx); mac_avln_tmp->avln_idx = avln_idx; mac_avln_tmp->key_tbl_num = key_tbl_num; mac_key_table_t *key_tbl = \ (mac_key_table_t *)os_mem_malloc(PLC_MAC_KEY_MID, \ key_tbl_num * sizeof(mac_key_table_t)); IOT_ASSERT(key_tbl); os_mem_set((uint8_t *)key_tbl, 0, key_tbl_num * sizeof(mac_key_table_t)); mac_avln_tmp->key_tbl = (mac_key_table_t *)key_tbl; return 0; }