bowen liu
/
mbed-os-example-blinky
ex
Fork of mbed-os-example-mbed5-blinky by
Embed:
(wiki syntax)
Show/hide line numbers
baidu_ca_transport.h
00001 // Copyright 2017 Baidu Inc. All Rights Reserved. 00002 // Author: Su Hao (suhao@baidu.com) 00003 // 00004 // Description: Define the adapter for networks. 00005 00006 #ifndef BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SOURCE_BAIDU_CA_TRANSPORT_H 00007 #define BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SOURCE_BAIDU_CA_TRANSPORT_H 00008 00009 #include "baidu_ca_types.h" 00010 #include "baidu_ca.h" 00011 00012 #define BCA_READ_FOREVER ((bca_u32_t)-1) 00013 00014 /* 00015 * The handler operate transfer. 00016 */ 00017 typedef void* bca_trans_handler; 00018 00019 typedef struct _bca_trans_s { 00020 bca_socket_t ctx; 00021 bca_context secure; 00022 bca_context soc_context; 00023 void* cert; 00024 bca_size_t cert_len; 00025 bca_u32_t read_timeout; 00026 bca_addr_t addr; 00027 } bca_trans_t, *bca_trans_ptr; 00028 00029 /* 00030 * Acquire the handler. 00031 * 00032 * @Param hdlr, in, the global context for baidu ca 00033 * @Param flag, in, the flag mark the transport properties, see in ${link bca_trans_flag_e} 00034 * @Param ctx, in, the socket context for user 00035 * @Return bca_trans_handler, the transport context 00036 */ 00037 BCA_INT bca_trans_handler bca_trans_acquire(bca_context ctx); 00038 00039 /* 00040 * Set the public key or certificate. 00041 * 00042 * @Param hdlr, in, the context for the transport 00043 * @Param data, in, the content of the public key or certificate 00044 * @Param size, in, the size of the data 00045 * @Return bca_status_t, the operation result 00046 */ 00047 BCA_INT bca_status_t bca_trans_set_pk(bca_trans_handler hdlr, 00048 const void* data, 00049 bca_size_t size); 00050 00051 /* 00052 * Set the timeout for receiving data. 00053 * 00054 * @Param hdlr, in, the context for the transport 00055 * @Param timeout, in, the recv data timeout interval 00056 * @Return bca_status_t, the operation result 00057 */ 00058 BCA_INT bca_status_t bca_trans_set_read_timeout(bca_trans_handler hdlr, 00059 bca_u32_t timeout); 00060 00061 /* 00062 * Connect to the host. 00063 * 00064 * @Param hdlr, in, the context for the transport 00065 * @Param addr, in, the target address infomations 00066 * @Return bca_status_t, the operation result 00067 */ 00068 BCA_INT bca_status_t bca_trans_connect(bca_trans_handler hdlr, 00069 const bca_addr_t* addr); 00070 00071 /* 00072 * Send data. 00073 * 00074 * @Param hdlr, in, the context for the transport 00075 * @Param data, in, the data will be sent 00076 * @Param size, in, the data size 00077 * @Param addr, in, the target address infomations 00078 * @Return bca_status_t, the operation result 00079 */ 00080 BCA_INT bca_status_t bca_trans_send(bca_trans_handler hdlr, 00081 const void* data, 00082 bca_size_t size, 00083 const bca_addr_t* addr); 00084 00085 /* 00086 * Receive data. 00087 * 00088 * @Param hdlr, in, the context for the transport 00089 * @Param data, out, the data will be read 00090 * @Param size, in, the data size 00091 * @Param addr, out, the target address infomations 00092 * @Return bca_status_t, the operation result 00093 */ 00094 BCA_INT bca_status_t bca_trans_recv(bca_trans_handler hdlr, 00095 void* data, 00096 bca_size_t size, 00097 bca_addr_t* addr); 00098 00099 /* 00100 * Disconnect from the remote host. 00101 * 00102 * @Param hdlr, in, the context for the transport 00103 * @Return bca_status_t, the operation result 00104 */ 00105 BCA_INT bca_status_t bca_trans_close(bca_trans_handler hdlr); 00106 00107 /* 00108 * Release the handler. 00109 * 00110 * @Param hdlr, in, the context for the transport 00111 * @Return bca_status_t, the operation result 00112 */ 00113 BCA_INT bca_status_t bca_trans_release(bca_trans_handler hdlr); 00114 00115 #endif // BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SOURCE_BAIDU_CA_TRANSPORT_H
Generated on Tue Jul 12 2022 16:28:52 by 1.7.2