mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
TLS: add an internal function isc__nmhandle_get_selected_alpn()
The added function provides the interface for getting an ALPN tag negotiated during TLS connection establishment. The new function can be used by higher level transports.
This commit is contained in:
@@ -1399,8 +1399,7 @@ transport_connect_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
|
|||||||
|
|
||||||
INSIST(transp_sock->type == isc_nm_tlssocket);
|
INSIST(transp_sock->type == isc_nm_tlssocket);
|
||||||
|
|
||||||
isc_tls_get_selected_alpn(transp_sock->tlsstream.tls, &alpn,
|
isc__nmhandle_get_selected_alpn(handle, &alpn, &alpnlen);
|
||||||
&alpnlen);
|
|
||||||
if (alpn == NULL || alpnlen != NGHTTP2_PROTO_VERSION_ID_LEN ||
|
if (alpn == NULL || alpnlen != NGHTTP2_PROTO_VERSION_ID_LEN ||
|
||||||
memcmp(NGHTTP2_PROTO_VERSION_ID, alpn,
|
memcmp(NGHTTP2_PROTO_VERSION_ID, alpn,
|
||||||
NGHTTP2_PROTO_VERSION_ID_LEN) != 0)
|
NGHTTP2_PROTO_VERSION_ID_LEN) != 0)
|
||||||
|
@@ -1603,6 +1603,11 @@ void
|
|||||||
isc__nm_tls_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result,
|
isc__nm_tls_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result,
|
||||||
bool async);
|
bool async);
|
||||||
|
|
||||||
|
void
|
||||||
|
isc__nmhandle_tls_get_selected_alpn(isc_nmhandle_t *handle,
|
||||||
|
const unsigned char **alpn,
|
||||||
|
unsigned int *alpnlen);
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__nm_http_stoplistening(isc_nmsocket_t *sock);
|
isc__nm_http_stoplistening(isc_nmsocket_t *sock);
|
||||||
|
|
||||||
@@ -2022,3 +2027,15 @@ isc__nmhandle_set_manual_timer(isc_nmhandle_t *handle, const bool manual);
|
|||||||
* Set manual read timer control mode - so that it will not get reset
|
* Set manual read timer control mode - so that it will not get reset
|
||||||
* automatically on read nor get started when read is initiated.
|
* automatically on read nor get started when read is initiated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
isc__nmhandle_get_selected_alpn(isc_nmhandle_t *handle,
|
||||||
|
const unsigned char **alpn,
|
||||||
|
unsigned int *alpnlen);
|
||||||
|
/*
|
||||||
|
* Returns a non zero terminated ALPN identifier via 'alpn'. The
|
||||||
|
* length of the identifier is returned via 'alpnlen'. If after the
|
||||||
|
* call either 'alpn == NULL' or 'alpnlen == 0', then identifier was
|
||||||
|
* not negotiated of the underlying protocol of the connection
|
||||||
|
* represented via the given handle does not support ALPN.
|
||||||
|
*/
|
||||||
|
@@ -2922,6 +2922,27 @@ isc__nmhandle_set_manual_timer(isc_nmhandle_t *handle, const bool manual) {
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
isc__nmhandle_get_selected_alpn(isc_nmhandle_t *handle,
|
||||||
|
const unsigned char **alpn,
|
||||||
|
unsigned int *alpnlen) {
|
||||||
|
isc_nmsocket_t *sock;
|
||||||
|
|
||||||
|
REQUIRE(VALID_NMHANDLE(handle));
|
||||||
|
sock = handle->sock;
|
||||||
|
REQUIRE(VALID_NMSOCK(sock));
|
||||||
|
|
||||||
|
switch (sock->type) {
|
||||||
|
#if HAVE_LIBNGHTTP2
|
||||||
|
case isc_nm_tlssocket:
|
||||||
|
isc__nmhandle_tls_get_selected_alpn(handle, alpn, alpnlen);
|
||||||
|
return;
|
||||||
|
#endif /* HAVE_LIBNGHTTP2 */
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef NETMGR_TRACE
|
#ifdef NETMGR_TRACE
|
||||||
/*
|
/*
|
||||||
* Dump all active sockets in netmgr. We output to stderr
|
* Dump all active sockets in netmgr. We output to stderr
|
||||||
|
@@ -1402,3 +1402,18 @@ isc__nmhandle_tls_set_manual_timer(isc_nmhandle_t *handle, const bool manual) {
|
|||||||
|
|
||||||
sock->manual_read_timer = manual;
|
sock->manual_read_timer = manual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
isc__nmhandle_tls_get_selected_alpn(isc_nmhandle_t *handle,
|
||||||
|
const unsigned char **alpn,
|
||||||
|
unsigned int *alpnlen) {
|
||||||
|
isc_nmsocket_t *sock;
|
||||||
|
|
||||||
|
REQUIRE(VALID_NMHANDLE(handle));
|
||||||
|
sock = handle->sock;
|
||||||
|
REQUIRE(VALID_NMSOCK(sock));
|
||||||
|
REQUIRE(sock->type == isc_nm_tlssocket);
|
||||||
|
REQUIRE(sock->tid == isc_tid());
|
||||||
|
|
||||||
|
isc_tls_get_selected_alpn(sock->tlsstream.tls, alpn, alpnlen);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user