diff --git a/docs/API.md b/docs/API.md index 31346b329..2281b818d 100644 --- a/docs/API.md +++ b/docs/API.md @@ -464,6 +464,13 @@ xqc_int_t xqc_conn_get_errno(xqc_connection_t *conn); Get error code of specified connection. +#### xqc_conn_get_ssl +``` +void *xqc_conn_get_ssl(xqc_connection_t *conn); +``` +Get ssl handler of specified connection. + + #### xqc_conn_set_transport_user_data ``` void xqc_conn_set_transport_user_data(xqc_connection_t *conn, void *user_data); @@ -839,6 +846,13 @@ xqc_int_t xqc_h3_conn_get_errno(xqc_h3_conn_t *h3c); Get connection error code. +#### xqc_h3_conn_get_ssl +``` +void *xqc_h3_conn_get_ssl(xqc_h3_conn_t *h3c); +``` +Get ssl handler of http3 connection. + + #### xqc_h3_conn_set_user_data ``` void xqc_h3_conn_set_user_data(xqc_h3_conn_t *h3c, void *user_data); diff --git a/include/xquic/xqc_http3.h b/include/xquic/xqc_http3.h index cbe94fe8a..604339b63 100644 --- a/include/xquic/xqc_http3.h +++ b/include/xquic/xqc_http3.h @@ -461,6 +461,16 @@ XQC_EXPORT_PUBLIC_API xqc_int_t xqc_h3_conn_get_errno(xqc_h3_conn_t *h3c); +/** + * @brief get ssl handler of http3 connection + * + * @param h3c handler of http3 connection + * @return ssl handler of http3 connection + */ +XQC_EXPORT_PUBLIC_API +void *xqc_h3_conn_get_ssl(xqc_h3_conn_t *h3c); + + /** * @brief set user_data for http3 connection, user_data could be the application layer context of * http3 connection @@ -480,7 +490,7 @@ void xqc_h3_conn_set_user_data(xqc_h3_conn_t *h3c, void *user_data); * @return user_data */ XQC_EXPORT_PUBLIC_API -void* xqc_h3_conn_get_user_data(xqc_h3_conn_t *h3_conn); +void *xqc_h3_conn_get_user_data(xqc_h3_conn_t *h3_conn); /** @@ -742,7 +752,7 @@ void xqc_h3_ext_bytestream_set_user_data(xqc_h3_ext_bytestream_t *h3_ext_bs, * @return the pointer of user data */ XQC_EXPORT_PUBLIC_API -void* xqc_h3_ext_bytestream_get_user_data(xqc_h3_ext_bytestream_t *h3_ext_bs); +void *xqc_h3_ext_bytestream_get_user_data(xqc_h3_ext_bytestream_t *h3_ext_bs); /** * @brief get statistics of a bytestream @@ -809,7 +819,7 @@ void xqc_h3_ext_datagram_set_user_data(xqc_h3_conn_t *conn, void *user_data); * @return the user_data of all datagram callbacks */ XQC_EXPORT_PUBLIC_API -void* xqc_h3_ext_datagram_get_user_data(xqc_h3_conn_t *conn); +void *xqc_h3_ext_datagram_get_user_data(xqc_h3_conn_t *conn); /** diff --git a/include/xquic/xquic.h b/include/xquic/xquic.h index b9649cf87..109852a3d 100644 --- a/include/xquic/xquic.h +++ b/include/xquic/xquic.h @@ -1427,6 +1427,13 @@ XQC_EXPORT_PUBLIC_API xqc_int_t xqc_conn_get_errno(xqc_connection_t *conn); +/** + * Get ssl handler of specified connection + */ +XQC_EXPORT_PUBLIC_API +void *xqc_conn_get_ssl(xqc_connection_t *conn); + + /** * @brief get latest rtt sample of the initial path * @@ -1613,7 +1620,7 @@ void xqc_datagram_set_user_data(xqc_connection_t *conn, void *dgram_data); * @dgram_data: the user_data of all datagram callbacks */ XQC_EXPORT_PUBLIC_API -void* xqc_datagram_get_user_data(xqc_connection_t *conn); +void *xqc_datagram_get_user_data(xqc_connection_t *conn); /** * @brief the API to send a datagram over the QUIC connection diff --git a/scripts/xquic.lds b/scripts/xquic.lds index 2b031158f..fc3897f92 100644 --- a/scripts/xquic.lds +++ b/scripts/xquic.lds @@ -8,6 +8,7 @@ XQUIC_VERS_1.0 { xqc_h3_conn_close; xqc_scid_str; xqc_h3_conn_get_errno; + xqc_h3_conn_get_ssl; xqc_h3_conn_set_user_data; xqc_h3_conn_get_peer_addr; xqc_h3_conn_get_local_addr; @@ -34,6 +35,7 @@ XQUIC_VERS_1.0 { xqc_connect; xqc_conn_close; xqc_conn_get_errno; + xqc_conn_get_ssl; xqc_conn_set_transport_user_data; xqc_conn_get_peer_addr; xqc_conn_get_local_addr; diff --git a/src/http3/xqc_h3_conn.c b/src/http3/xqc_h3_conn.c index d2a20cf5b..79f201855 100644 --- a/src/http3/xqc_h3_conn.c +++ b/src/http3/xqc_h3_conn.c @@ -146,6 +146,17 @@ xqc_h3_conn_get_errno(xqc_h3_conn_t *h3_conn) } +void * +xqc_h3_conn_get_ssl(xqc_h3_conn_t *h3_conn) +{ + if (h3_conn->conn) { + return xqc_conn_get_ssl(h3_conn->conn); + } + + return NULL; +} + + void xqc_h3_conn_set_user_data(xqc_h3_conn_t *h3_conn, void *user_data) diff --git a/src/http3/xqc_h3_ext_bytestream.c b/src/http3/xqc_h3_ext_bytestream.c index 1770b66c9..ebd99f947 100644 --- a/src/http3/xqc_h3_ext_bytestream.c +++ b/src/http3/xqc_h3_ext_bytestream.c @@ -388,7 +388,7 @@ xqc_h3_ext_bytestream_set_user_data(xqc_h3_ext_bytestream_t *h3_ext_bs, -void* +void * xqc_h3_ext_bytestream_get_user_data(xqc_h3_ext_bytestream_t *h3_ext_bs) { return h3_ext_bs->user_data; diff --git a/src/http3/xqc_h3_ext_dgram.c b/src/http3/xqc_h3_ext_dgram.c index 5f8ad537a..bc8e6b50f 100644 --- a/src/http3/xqc_h3_ext_dgram.c +++ b/src/http3/xqc_h3_ext_dgram.c @@ -82,7 +82,7 @@ xqc_h3_ext_datagram_set_user_data(xqc_h3_conn_t *conn, void *user_data) xqc_datagram_set_user_data(conn->conn, user_data); } -void* +void * xqc_h3_ext_datagram_get_user_data(xqc_h3_conn_t *conn) { return xqc_datagram_get_user_data(conn->conn); diff --git a/src/tls/babassl/xqc_crypto.c b/src/tls/babassl/xqc_crypto.c index 99c51ee1a..7147d196d 100644 --- a/src/tls/babassl/xqc_crypto.c +++ b/src/tls/babassl/xqc_crypto.c @@ -7,7 +7,7 @@ #include #include -void* +void * xqc_aead_ctx_new(const xqc_pkt_protect_aead_t *pp_aead, xqc_key_type_t type, const uint8_t *key, size_t noncelen) { @@ -176,7 +176,7 @@ xqc_ossl_aead_decrypt(const xqc_pkt_protect_aead_t *pp_aead, void *aead_ctx, return -XQC_TLS_DECRYPT_DATA_ERROR; } -void* +void * xqc_hp_ctx_new(const xqc_hdr_protect_cipher_t *hp_cipher, const uint8_t *key) { EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); diff --git a/src/tls/boringssl/xqc_crypto.c b/src/tls/boringssl/xqc_crypto.c index f0c4c3545..5cf382043 100644 --- a/src/tls/boringssl/xqc_crypto.c +++ b/src/tls/boringssl/xqc_crypto.c @@ -6,7 +6,7 @@ #include -void* +void * xqc_aead_ctx_new(const xqc_pkt_protect_aead_t *pp_aead, xqc_key_type_t type, const uint8_t *key, size_t noncelen) { @@ -86,7 +86,7 @@ xqc_bssl_aead_decrypt(const xqc_pkt_protect_aead_t *pp_aead, void *aead_ctx, } -void* +void * xqc_hp_ctx_new(const xqc_hdr_protect_cipher_t *hp_cipher, const uint8_t *key) { EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); diff --git a/src/tls/xqc_tls.c b/src/tls/xqc_tls.c index 3713ca90f..52ff46779 100644 --- a/src/tls/xqc_tls.c +++ b/src/tls/xqc_tls.c @@ -1124,6 +1124,16 @@ xqc_tls_get_selected_alpn(xqc_tls_t *tls, const char **out_alpn, (unsigned *)out_len); } +void * +xqc_tls_get_ssl(xqc_tls_t *tls) +{ + if (!tls) { + return NULL; + } + + return tls->ssl; +} + /** * ============================================================================ diff --git a/src/tls/xqc_tls.h b/src/tls/xqc_tls.h index 53f9ff672..b3f7a4dc0 100644 --- a/src/tls/xqc_tls.h +++ b/src/tls/xqc_tls.h @@ -200,6 +200,10 @@ void xqc_tls_get_selected_alpn(xqc_tls_t *tls, const char **out_alpn, xqc_int_t xqc_tls_update_tp(xqc_tls_t *tls, uint8_t *tp_buf, size_t tp_len); +/** + * @brief get SSL handler + */ +void *xqc_tls_get_ssl(xqc_tls_t *tls); #endif diff --git a/src/transport/xqc_conn.c b/src/transport/xqc_conn.c index 7d273faec..4f73cb16b 100644 --- a/src/transport/xqc_conn.c +++ b/src/transport/xqc_conn.c @@ -2156,6 +2156,16 @@ xqc_conn_get_errno(xqc_connection_t *conn) return conn->conn_err; } +void * +xqc_conn_get_ssl(xqc_connection_t *conn) +{ + if (conn->tls) { + return xqc_tls_get_ssl(conn->tls); + } + + return NULL; +} + xqc_int_t xqc_conn_immediate_close(xqc_connection_t *conn) { diff --git a/src/transport/xqc_datagram.c b/src/transport/xqc_datagram.c index fd8c37ad5..dd8017162 100644 --- a/src/transport/xqc_datagram.c +++ b/src/transport/xqc_datagram.c @@ -493,7 +493,7 @@ xqc_datagram_set_user_data(xqc_connection_t *conn, void *dgram_data) conn->dgram_data = dgram_data; } -void* +void * xqc_datagram_get_user_data(xqc_connection_t *conn) { return conn->dgram_data;