switchlink_db_status_t switchlink_db_bridge_add(uint32_t ifindex, switchlink_db_bridge_info_t *bridge) { switchlink_db_bridge_obj_t * obj = switchlink_malloc(sizeof(switchlink_db_bridge_obj_t), 1); obj->ifindex = ifindex; memcpy(&(obj->bridge), bridge, sizeof(switchlink_db_bridge_info_t)); tommy_trie_inplace_insert(&switchlink_db_bridge_obj_map, &obj->ifindex_node, obj, obj->ifindex); tommy_trie_inplace_insert(&switchlink_db_handle_obj_map, &obj->handle_node, obj, obj->bridge.bridge_h); return SWITCHLINK_DB_STATUS_SUCCESS; }
switchlink_db_status_t switchlink_db_ecmp_add(switchlink_db_ecmp_info_t *ecmp_info) { assert(ecmp_info->num_nhops < SWITCHLINK_ECMP_NUM_MEMBERS_MAX); switchlink_db_ecmp_obj_t * obj = switchlink_malloc(sizeof(switchlink_db_ecmp_obj_t), 1); memcpy(&(obj->ecmp_info), ecmp_info, sizeof(switchlink_db_ecmp_info_t)); obj->ref_count = 0; tommy_list_insert_tail(&switchlink_db_ecmp_obj_list, &obj->list_node, obj); tommy_trie_inplace_insert(&switchlink_db_handle_obj_map, &obj->handle_node, obj, obj->ecmp_info.ecmp_h); return SWITCHLINK_DB_STATUS_SUCCESS; }
switchlink_db_status_t switchlink_db_oifl_add(switchlink_db_oifl_info_t *oifl_info) { static switchlink_handle_t s_oifl_h = 1; assert(oifl_info->num_intfs < SWITCHLINK_OIFL_NUM_MEMBERS_MAX); switchlink_db_oifl_obj_t * obj = switchlink_malloc(sizeof(switchlink_db_oifl_obj_t), 1); oifl_info->oifl_h = (s_oifl_h++ & ~SWITCHLINK_HANDLE_TYPE_OIFL) | SWITCHLINK_HANDLE_TYPE_OIFL; memcpy(&(obj->oifl_info), oifl_info, sizeof(switchlink_db_oifl_info_t)); obj->ref_count = 0; tommy_list_insert_tail(&switchlink_db_oifl_obj_list, &obj->list_node, obj); tommy_trie_inplace_insert(&switchlink_db_handle_obj_map, &obj->handle_node, obj, obj->oifl_info.oifl_h); return SWITCHLINK_DB_STATUS_SUCCESS; }