1 /*
2  * Copyright (C) 2015-2018 Alibaba Group Holding Limited
3  */
4 
5 #include <stdint.h>
6 
7 #ifndef COAP_TRANSPORT_H__
8 #define COAP_TRANSPORT_H__
9 
10 typedef enum {
11     COAP_ENDPOINT_NOSEC = 0,
12     COAP_ENDPOINT_DTLS,
13     COAP_ENDPOINT_PSK,
14 } coap_endpoint_type;
15 
16 typedef struct {
17     DTLSContext *context;
18 } coap_remote_session_t;
19 
20 typedef struct {
21     int socket_id;
22     coap_endpoint_type ep_type;
23     void *context;
24 } coap_network_t;
25 
26 typedef struct {
27     coap_endpoint_type ep_type;
28     unsigned char *p_ca_cert_pem;
29     char *p_host;
30     unsigned short port;
31 } coap_network_init_t;
32 
33 unsigned int Cloud_CoAPNetwork_init(const coap_network_init_t *p_param,
34                                     coap_network_t *p_network);
35 
36 unsigned int Cloud_CoAPNetwork_write(coap_network_t *p_network,
37                                      const unsigned char *p_data,
38                                      unsigned int datalen);
39 
40 int Cloud_CoAPNetwork_read(coap_network_t *network, unsigned char *data,
41                            unsigned int datalen, unsigned int timeout);
42 
43 unsigned int Cloud_CoAPNetwork_deinit(coap_network_t *p_network);
44 
45 #endif
46