liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | #ifndef MBTK_SOCK_INTERNAL_INCLUDE |
| 2 | #define MBTK_SOCK_INTERNAL_INCLUDE |
| 3 | #include "mbtk_sock2.h" |
| 4 | //#include <openssl/ssl.h> |
| 5 | |
| 6 | #define MBTK_HANDLE_MAX_NUM 5 |
| 7 | #define MBTK_SOCK_MAX_NUM 10 |
| 8 | |
| 9 | typedef struct { |
| 10 | int fd; |
b.liu | 8181e14 | 2023-09-26 10:31:10 +0800 | [diff] [blame] | 11 | mbtk_sock_type type; // socket type:TCP or UDP |
b.liu | 9a8e82b | 2023-10-10 16:09:50 +0800 | [diff] [blame] | 12 | #ifdef MBTK_POLARSSL_SUPPORT |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 13 | entropy_context* entropy; |
| 14 | ctr_drbg_context* ctr_drbg; |
| 15 | ssl_context *ssl; |
| 16 | ssl_session *saved_session; |
| 17 | x509_crt *cacert; |
| 18 | x509_crt *clicert; |
| 19 | pk_context* pkey; |
luojin | 8fbb343 | 2023-10-18 09:47:46 +0800 | [diff] [blame] | 20 | #else |
| 21 | SSL_CTX *ctx; |
| 22 | SSL *ssl; |
b.liu | 9a8e82b | 2023-10-10 16:09:50 +0800 | [diff] [blame] | 23 | #endif |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 24 | } mbtk_sock_inter_info_s; |
| 25 | |
| 26 | typedef struct { |
| 27 | mbtk_init_info init_info; |
| 28 | int sock_num; |
| 29 | mbtk_sock_inter_info_s inter_infos[MBTK_SOCK_MAX_NUM]; |
| 30 | mbtk_sock_info infos[MBTK_SOCK_MAX_NUM]; |
| 31 | } mbtk_sock_s; |
| 32 | struct options |
| 33 | { |
| 34 | const char *server_name; /* hostname of the server (client only) */ |
| 35 | const char *server_addr; /* address of the server (client only) */ |
| 36 | int server_port; /* port on which the ssl service runs */ |
| 37 | int debug_level; /* level of debugging */ |
| 38 | int nbio; /* should I/O be blocking? */ |
| 39 | const char *request_page; /* page on server to request */ |
| 40 | int request_size; /* pad request with header to requested size */ |
| 41 | const char *ca_file; /* the file with the CA certificate(s) */ |
| 42 | const char *ca_path; /* the path with the CA certificate(s) reside */ |
| 43 | const char *crt_file; /* the file with the client certificate */ |
| 44 | const char *key_file; /* the file with the client key */ |
| 45 | const char *psk; /* the pre-shared key */ |
| 46 | const char *psk_identity; /* the pre-shared key identity */ |
| 47 | int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */ |
| 48 | int renegotiation; /* enable / disable renegotiation */ |
| 49 | int allow_legacy; /* allow legacy renegotiation */ |
| 50 | int renegotiate; /* attempt renegotiation? */ |
| 51 | int renego_delay; /* delay before enforcing renegotiation */ |
| 52 | int exchanges; /* number of data exchanges */ |
| 53 | int min_version; /* minimum protocol version accepted */ |
| 54 | int max_version; /* maximum protocol version accepted */ |
| 55 | int auth_mode; /* verify mode for connection */ |
| 56 | unsigned char mfl_code; /* code for maximum fragment length */ |
| 57 | int trunc_hmac; /* negotiate truncated hmac or not */ |
| 58 | int reconnect; /* attempt to resume session */ |
| 59 | int reco_delay; /* delay in seconds before resuming session */ |
| 60 | int tickets; /* enable / disable session tickets */ |
| 61 | const char *alpn_string; /* ALPN supported protocols */ |
| 62 | } opt; |
| 63 | |
luojin | 8fbb343 | 2023-10-18 09:47:46 +0800 | [diff] [blame] | 64 | #endif /* MBTK_SOCK_INTERNAL_INCLUDE */ |