1 /* 2 * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 */ 4 5 6 7 8 #ifndef __COAP_RESOURCE_H__ 9 #define __COAP_RESOURCE_H__ 10 11 #include <stdint.h> 12 #include "iotx_coap_internal.h" 13 #include "CoAPExport.h" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif /* __cplusplus */ 18 19 #define COAP_MAX_PATH_CHECKSUM_LEN (5) 20 21 typedef struct { 22 unsigned short permission; 23 CoAPRecvMsgHandler callback; 24 unsigned int ctype; 25 unsigned int maxage; 26 struct list_head reslist; 27 char path[COAP_MAX_PATH_CHECKSUM_LEN]; 28 char *filter_path; 29 path_type_t path_type; 30 } CoAPResource; 31 32 int CoAPResource_init(CoAPContext *context, int res_maxcount); 33 34 int CoAPPathMD5_sum(const char *path, int len, char outbuf[], int outlen); 35 36 int CoAPResource_register(CoAPContext *context, const char *path, 37 unsigned short permission, unsigned int ctype, 38 unsigned int maxage, CoAPRecvMsgHandler callback); 39 40 CoAPResource *CoAPResourceByPath_get(CoAPContext *context, const char *path); 41 42 int CoAPResource_deinit(CoAPContext *context); 43 44 int CoAPResource_topicFilterMatch(const char *filter, const char *topic); 45 #ifdef __cplusplus 46 } 47 #endif /* __cplusplus */ 48 49 #endif 50