| 2 |
raymond |
1 |
/*
|
|
|
2 |
Asynchronous TCP library for Espressif MCUs
|
|
|
3 |
|
|
|
4 |
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
|
|
5 |
This file is part of the esp8266 core for Arduino environment.
|
|
|
6 |
|
|
|
7 |
This library is free software; you can redistribute it and/or
|
|
|
8 |
modify it under the terms of the GNU Lesser General Public
|
|
|
9 |
License as published by the Free Software Foundation; either
|
|
|
10 |
version 2.1 of the License, or (at your option) any later version.
|
|
|
11 |
|
|
|
12 |
This library is distributed in the hope that it will be useful,
|
|
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
15 |
Lesser General Public License for more details.
|
|
|
16 |
|
|
|
17 |
You should have received a copy of the GNU Lesser General Public
|
|
|
18 |
License along with this library; if not, write to the Free Software
|
|
|
19 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
20 |
*/
|
|
|
21 |
/*
|
|
|
22 |
* Compatibility for AxTLS with LWIP raw tcp mode (http://lwip.wikia.com/wiki/Raw/TCP)
|
|
|
23 |
* Original Code and Inspiration: Slavey Karadzhov
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
#ifndef LWIPR_COMPAT_H
|
|
|
27 |
#define LWIPR_COMPAT_H
|
|
|
28 |
|
|
|
29 |
#include <async_config.h>
|
|
|
30 |
|
|
|
31 |
#if ASYNC_TCP_SSL_ENABLED
|
|
|
32 |
|
|
|
33 |
#include "lwipopts.h"
|
|
|
34 |
/*
|
|
|
35 |
* All those functions will run only if LWIP tcp raw mode is used
|
|
|
36 |
*/
|
|
|
37 |
#if LWIP_RAW==1
|
|
|
38 |
|
|
|
39 |
#ifdef __cplusplus
|
|
|
40 |
extern "C" {
|
|
|
41 |
#endif
|
|
|
42 |
|
|
|
43 |
#include <stdbool.h>
|
|
|
44 |
#include "include/ssl.h"
|
|
|
45 |
|
|
|
46 |
#define ERR_TCP_SSL_INVALID_SSL -101
|
|
|
47 |
#define ERR_TCP_SSL_INVALID_TCP -102
|
|
|
48 |
#define ERR_TCP_SSL_INVALID_CLIENTFD -103
|
|
|
49 |
#define ERR_TCP_SSL_INVALID_CLIENTFD_DATA -104
|
|
|
50 |
#define ERR_TCP_SSL_INVALID_DATA -105
|
|
|
51 |
|
|
|
52 |
#define TCP_SSL_TYPE_CLIENT 0
|
|
|
53 |
#define TCP_SSL_TYPE_SERVER 1
|
|
|
54 |
|
|
|
55 |
#define tcp_ssl_ssl_write(A, B, C) tcp_ssl_write(A, B, C)
|
|
|
56 |
#define tcp_ssl_ssl_read(A, B) tcp_ssl_read(A, B)
|
|
|
57 |
|
|
|
58 |
typedef void (* tcp_ssl_data_cb_t)(void *arg, struct tcp_pcb *tcp, uint8_t * data, size_t len);
|
|
|
59 |
typedef void (* tcp_ssl_handshake_cb_t)(void *arg, struct tcp_pcb *tcp, SSL *ssl);
|
|
|
60 |
typedef void (* tcp_ssl_error_cb_t)(void *arg, struct tcp_pcb *tcp, int8_t error);
|
|
|
61 |
typedef int (* tcp_ssl_file_cb_t)(void *arg, const char *filename, uint8_t **buf);
|
|
|
62 |
|
|
|
63 |
uint8_t tcp_ssl_has_client();
|
|
|
64 |
|
|
|
65 |
int tcp_ssl_new_client(struct tcp_pcb *tcp);
|
|
|
66 |
|
|
|
67 |
SSL_CTX * tcp_ssl_new_server_ctx(const char *cert, const char *private_key_file, const char *password);
|
|
|
68 |
int tcp_ssl_new_server(struct tcp_pcb *tcp, SSL_CTX* ssl_ctx);
|
|
|
69 |
int tcp_ssl_is_server(struct tcp_pcb *tcp);
|
|
|
70 |
|
|
|
71 |
int tcp_ssl_free(struct tcp_pcb *tcp);
|
|
|
72 |
int tcp_ssl_read(struct tcp_pcb *tcp, struct pbuf *p);
|
|
|
73 |
|
|
|
74 |
#ifdef AXTLS_2_0_0_SNDBUF
|
|
|
75 |
int tcp_ssl_sndbuf(struct tcp_pcb *tcp);
|
|
|
76 |
#endif
|
|
|
77 |
|
|
|
78 |
int tcp_ssl_write(struct tcp_pcb *tcp, uint8_t *data, size_t len);
|
|
|
79 |
|
|
|
80 |
void tcp_ssl_file(tcp_ssl_file_cb_t cb, void * arg);
|
|
|
81 |
|
|
|
82 |
void tcp_ssl_arg(struct tcp_pcb *tcp, void * arg);
|
|
|
83 |
void tcp_ssl_data(struct tcp_pcb *tcp, tcp_ssl_data_cb_t arg);
|
|
|
84 |
void tcp_ssl_handshake(struct tcp_pcb *tcp, tcp_ssl_handshake_cb_t arg);
|
|
|
85 |
void tcp_ssl_err(struct tcp_pcb *tcp, tcp_ssl_error_cb_t arg);
|
|
|
86 |
|
|
|
87 |
SSL * tcp_ssl_get_ssl(struct tcp_pcb *tcp);
|
|
|
88 |
bool tcp_ssl_has(struct tcp_pcb *tcp);
|
|
|
89 |
|
|
|
90 |
#ifdef __cplusplus
|
|
|
91 |
}
|
|
|
92 |
#endif
|
|
|
93 |
|
|
|
94 |
#endif /* LWIP_RAW==1 */
|
|
|
95 |
|
|
|
96 |
#endif /* ASYNC_TCP_SSL_ENABLED */
|
|
|
97 |
|
|
|
98 |
#endif /* LWIPR_COMPAT_H */
|