1 /* 2 * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 */ 4 5 #if !defined(DM_MESSAGE_CACHE_DISABLED) 6 #ifndef _DM_MESSAGE_CACHE_H_ 7 #define _DM_MESSAGE_CACHE_H_ 8 9 #include "iotx_dm_internal.h" 10 11 #define DM_MSG_CACHE_TIMEOUT_MS_DEFAULT (10000) 12 13 typedef struct { 14 int msgid; 15 int devid; 16 iotx_dm_event_types_t response_type; 17 char *data; 18 uint64_t ctime; 19 struct list_head linked_list; 20 } dm_msg_cache_node_t; 21 22 typedef struct { 23 void *mutex; 24 int dmc_list_size; 25 struct list_head dmc_list; 26 } dm_msg_cache_ctx_t; 27 28 int dm_msg_cache_init(void); 29 int dm_msg_cache_deinit(void); 30 int dm_msg_cache_insert(int msg_id, int devid, iotx_dm_event_types_t type, 31 char *data); 32 int dm_msg_cache_search(_IN_ int msg_id, _OU_ dm_msg_cache_node_t **node); 33 int dm_msg_cache_remove(int msg_id); 34 void dm_msg_cache_tick(void); 35 36 #endif 37 #endif 38