diff options
author | 2020-03-13 17:03:53 +0800 | |
---|---|---|
committer | 2020-03-16 12:39:27 +0000 | |
commit | 3cfed05891ca7791e9d8aa8c5ff584de741819f7 (patch) | |
tree | 7a5d8370f037ead9e8ec778647925cb6dbc4efd4 /src/plugins/tlspicotls/tls_picotls.h | |
parent | 7c0eb56f40b3ccf8acd8f04e208aa50231aebeba (diff) |
tls: refactor Picotls ctx_read function to reduce one time memory copy
Type: refactor
Signed-off-by: Simon Zhang <yuwei1.zhang@intel.com>
Change-Id: I7a952fd95e49468a0d1c763b3e289648c93539da
Diffstat (limited to 'src/plugins/tlspicotls/tls_picotls.h')
-rw-r--r-- | src/plugins/tlspicotls/tls_picotls.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/tlspicotls/tls_picotls.h b/src/plugins/tlspicotls/tls_picotls.h index 0fa19c538ad..92f7b0f9ed5 100644 --- a/src/plugins/tlspicotls/tls_picotls.h +++ b/src/plugins/tlspicotls/tls_picotls.h @@ -9,9 +9,13 @@ #define TLS_RX_LEN(x) ((x)->rx_content + (x)->rx_len) #define TLS_RX_OFFSET(x) ((x)->rx_content + (x)->rx_offset) -#define TLS_RX_IS_LEFT(x) ((x)->rx_len != (x)->rx_offset) +#define TLS_RX_IS_LEFT(x) ((x)->rx_len != 0 && (x)->rx_len != (x)->rx_offset) #define TLS_RX_LEFT_LEN(x) ((x)->rx_len - (x)->rx_offset) +#define TLS_READ_OFFSET(x) ((x)->read_buffer.base + (x)->read_buffer_offset) +#define TLS_READ_IS_LEFT(x) ((x)->read_buffer.off != 0 && (x)->read_buffer.off != (x)->read_buffer_offset) +#define TLS_READ_LEFT_LEN(x) ((x)->read_buffer.off - (x)->read_buffer_offset) + #define TLS_WRITE_OFFSET(x) ((x)->write_buffer.base + (x)->write_buffer_offset) #define TLS_WRITE_IS_LEFT(x) ((x)->write_buffer.off != 0 && (x)->write_buffer.off != (x)->write_buffer_offset) @@ -24,8 +28,10 @@ typedef struct tls_ctx_picotls_ u8 *rx_content; int rx_offset; int rx_len; + ptls_buffer_t read_buffer; ptls_buffer_t write_buffer; uint8_t *write_content; + int read_buffer_offset; int write_buffer_offset; } picotls_ctx_t; |