1 /* 2 * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __CoAPNETWORK_H__ 6 #define __CoAPNETWORK_H__ 7 #include <stdint.h> 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif /* __cplusplus */ 12 13 typedef enum { 14 COAP_NETWORK_NOSEC = 0, 15 COAP_NETWORK_DTLS, 16 } CoAPNetworkType; 17 18 typedef struct { 19 CoAPNetworkType type; 20 unsigned short port; 21 intptr_t fd; 22 } NetworkConf; 23 24 typedef void NetworkContext; 25 26 typedef struct { 27 CoAPNetworkType type; 28 char *group; 29 unsigned short port; 30 #ifdef COAP_DTLS_SUPPORT 31 /* TODO: */ 32 #endif 33 } NetworkInit; 34 35 NetworkContext *CoAPNetwork_init(const NetworkInit *p_param); 36 37 int CoAPNetwork_write(NetworkContext *p_context, NetworkAddr *p_remote, 38 const unsigned char *p_data, unsigned int datalen, 39 unsigned int timeout); 40 41 int CoAPNetwork_read(NetworkContext *p_context, NetworkAddr *p_remote, 42 unsigned char *p_data, unsigned int datalen, 43 unsigned int timeout); 44 45 void CoAPNetwork_deinit(NetworkContext *p_context); 46 47 #ifdef __cplusplus 48 } 49 #endif /* __cplusplus */ 50 51 #endif 52