Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[+] Export SSL handler of HTTP/3 connection for ssl_protocol, ssl_cipher, etc. #310

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions include/xquic/xqc_http3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
lianglli marked this conversation as resolved.
Show resolved Hide resolved


/**
* @brief set user_data for http3 connection, user_data could be the application layer context of
* http3 connection
Expand Down
7 changes: 7 additions & 0 deletions include/xquic/xquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
2 changes: 2 additions & 0 deletions scripts/xquic.lds
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/http3/xqc_h3_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/tls/xqc_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


/**
* ============================================================================
Expand Down
4 changes: 4 additions & 0 deletions src/tls/xqc_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions src/transport/xqc_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down