1 #ifndef _WRAPPERS_DEFS_H_ 2 #define _WRAPPERS_DEFS_H_ 3 4 #include <stdio.h> 5 #include "linkkit/infra/infra_types.h" 6 #include "linkkit/infra/infra_defs.h" 7 8 #define PLATFORM_WAIT_INFINITE (~0) 9 10 typedef struct { 11 void *(*malloc)(uint32_t size); 12 void (*free)(void *ptr); 13 } ssl_hooks_t; 14 15 typedef enum { 16 os_thread_priority_idle = -3, /* priority: idle (lowest) */ 17 os_thread_priority_low = -2, /* priority: low */ 18 os_thread_priority_belowNormal = -1, /* priority: below normal */ 19 os_thread_priority_normal = 0, /* priority: normal (default) */ 20 os_thread_priority_aboveNormal = 1, /* priority: above normal */ 21 os_thread_priority_high = 2, /* priority: high */ 22 os_thread_priority_realtime = 3, /* priority: realtime (highest) */ 23 os_thread_priority_error = 0x84, /* system cannot determine priority or 24 thread has illegal priority */ 25 } hal_os_thread_priority_t; 26 27 typedef struct _hal_os_thread { 28 hal_os_thread_priority_t priority; /*initial thread priority */ 29 void *stack_addr; /* thread stack address malloced by caller, use system 30 stack by . */ 31 int stack_size; /* stack size requirements in bytes; 0 is default stack size 32 */ 33 int detach_state; /* 0: not detached state; otherwise: detached state. */ 34 char *name; /* thread name. */ 35 } hal_os_thread_param_t; 36 37 #define DTLS_ERROR_BASE (1 << 24) 38 #define DTLS_SUCCESS (0) 39 #define DTLS_INVALID_PARAM (DTLS_ERROR_BASE | 1) 40 #define DTLS_INVALID_CA_CERTIFICATE (DTLS_ERROR_BASE | 2) 41 #define DTLS_HANDSHAKE_IN_PROGRESS (DTLS_ERROR_BASE | 3) 42 #define DTLS_HANDSHAKE_FAILED (DTLS_ERROR_BASE | 4) 43 #define DTLS_FATAL_ALERT_MESSAGE (DTLS_ERROR_BASE | 5) 44 #define DTLS_PEER_CLOSE_NOTIFY (DTLS_ERROR_BASE | 6) 45 #define DTLS_SESSION_CREATE_FAILED (DTLS_ERROR_BASE | 7) 46 #define DTLS_READ_DATA_FAILED (DTLS_ERROR_BASE | 8) 47 48 typedef struct { 49 unsigned char *p_ca_cert_pem; 50 char *p_host; 51 unsigned short port; 52 } coap_dtls_options_t; 53 54 typedef enum { 55 HAL_SEEK_SET, 56 HAL_SEEK_CUR, 57 HAL_SEEK_END 58 } hal_fs_seek_type_t; 59 60 typedef void DTLSContext; 61 62 /* link type */ 63 enum AWSS_LINK_TYPE { 64 /* rtos HAL choose this type */ 65 AWSS_LINK_TYPE_NONE, 66 67 /* linux HAL may choose the following type */ 68 AWSS_LINK_TYPE_PRISM, 69 AWSS_LINK_TYPE_80211_RADIO, 70 AWSS_LINK_TYPE_80211_RADIO_AVS, 71 AWSS_LINK_TYPE_HT40_CTRL /* for espressif HAL, see struct ht40_ctrl */ 72 }; 73 74 typedef int (*awss_recv_80211_frame_cb_t)(char *buf, int length, 75 enum AWSS_LINK_TYPE link_type, 76 int with_fcs, signed char rssi); 77 78 typedef void (*awss_wifi_mgmt_frame_cb_t)(_IN_ uint8_t *buffer, _IN_ int len, 79 _IN_ signed char rssi_dbm, 80 _IN_ int buffer_type); 81 82 struct HAL_Ht40_Ctrl { 83 uint16_t length; 84 uint8_t filter; 85 signed char rssi; 86 }; 87 88 /* encryt type */ 89 enum AWSS_ENC_TYPE { 90 AWSS_ENC_TYPE_NONE, 91 AWSS_ENC_TYPE_WEP, 92 AWSS_ENC_TYPE_TKIP, 93 AWSS_ENC_TYPE_AES, 94 AWSS_ENC_TYPE_TKIPAES, 95 AWSS_ENC_TYPE_MAX = AWSS_ENC_TYPE_TKIPAES, 96 AWSS_ENC_TYPE_INVALID = 0xff, 97 }; 98 /* auth type */ 99 enum AWSS_AUTH_TYPE { 100 AWSS_AUTH_TYPE_OPEN, 101 AWSS_AUTH_TYPE_SHARED, 102 AWSS_AUTH_TYPE_WPAPSK, 103 AWSS_AUTH_TYPE_WPA8021X, 104 AWSS_AUTH_TYPE_WPA2PSK, 105 AWSS_AUTH_TYPE_WPA28021X, 106 AWSS_AUTH_TYPE_WPAPSKWPA2PSK, 107 AWSS_AUTH_TYPE_MAX = AWSS_AUTH_TYPE_WPAPSKWPA2PSK, 108 AWSS_AUTH_TYPE_INVALID = 0xff, 109 }; 110 111 /* 80211 frame type */ 112 typedef enum HAL_Awss_Frame_Type { 113 FRAME_ACTION, 114 FRAME_BEACON, 115 FRAME_PROBE_REQ, 116 FRAME_PROBE_RESPONSE, 117 FRAME_DATA 118 } HAL_Awss_Frame_Type_t; 119 120 #if defined(AT_PARSER_ENABLED) 121 /* 122 * UART data width 123 */ 124 typedef enum { 125 DATA_WIDTH_5BIT, 126 DATA_WIDTH_6BIT, 127 DATA_WIDTH_7BIT, 128 DATA_WIDTH_8BIT, 129 DATA_WIDTH_9BIT 130 } hal_uart_data_width_t; 131 132 /* 133 * UART stop bits 134 */ 135 typedef enum { 136 STOP_BITS_1, 137 STOP_BITS_2 138 } hal_uart_stop_bits_t; 139 140 /* 141 * UART flow control 142 */ 143 typedef enum { 144 FLOW_CONTROL_DISABLED, 145 FLOW_CONTROL_CTS, 146 FLOW_CONTROL_RTS, 147 FLOW_CONTROL_CTS_RTS 148 } hal_uart_flow_control_t; 149 150 /* 151 * UART parity 152 */ 153 typedef enum { 154 NO_PARITY, 155 ODD_PARITY, 156 EVEN_PARITY 157 } hal_uart_parity_t; 158 159 /* 160 * UART mode 161 */ 162 typedef enum { 163 MODE_TX, 164 MODE_RX, 165 MODE_TX_RX 166 } hal_uart_mode_t; 167 168 /* 169 * UART configuration 170 */ 171 typedef struct { 172 uint32_t baud_rate; 173 hal_uart_data_width_t data_width; 174 hal_uart_parity_t parity; 175 hal_uart_stop_bits_t stop_bits; 176 hal_uart_flow_control_t flow_control; 177 hal_uart_mode_t mode; 178 } at_uart_config_t; 179 180 typedef struct { 181 uint8_t port; /* uart port */ 182 at_uart_config_t config; /* uart config */ 183 void *priv; /* priv data */ 184 } uart_dev_t; 185 #endif 186 187 #if defined(AT_TCP_ENABLED) 188 typedef enum { 189 /* WiFi */ 190 TCP_SERVER, 191 TCP_CLIENT, 192 SSL_CLIENT, 193 UDP_BROADCAST, 194 UDP_UNICAST, 195 /*WiFi end */ 196 /* Add others hereafter */ 197 } CONN_TYPE; 198 199 #if defined(AT_SSL_ENABLED) 200 typedef enum { 201 ROOT_CERT, 202 CLIENT_CERT, 203 /* add other type */ 204 } CERT_TYPE; 205 206 typedef struct { 207 int cert_len; 208 char *cert_data; 209 CERT_TYPE cert_type; 210 } cert_info_t; 211 #endif 212 213 /* Fill necessary fileds according to the socket type. */ 214 typedef struct { 215 int fd; /* fd that are used in socket level */ 216 CONN_TYPE type; 217 char *addr; /* remote ip or domain */ 218 int32_t r_port; /* remote port (set to -1 if not used) */ 219 int32_t l_port; /* local port (set to -1 if not used) */ 220 uint32_t tcp_keep_alive; /* tcp keep alive value (set to 0 if not used) */ 221 void *param; 222 } at_conn_t; 223 224 struct at_conn_input { 225 int fd; 226 void *data; 227 uint32_t datalen; 228 char *remote_ip; 229 uint16_t remote_port; 230 }; 231 232 #endif 233 234 #endif 235