Commit 636ef51b authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Fix compile error with -Wunused-function

parent 400934e5
...@@ -345,6 +345,7 @@ static void setup_nghttp2_callbacks(nghttp2_session_callbacks *callbacks) { ...@@ -345,6 +345,7 @@ static void setup_nghttp2_callbacks(nghttp2_session_callbacks *callbacks) {
callbacks, on_data_chunk_recv_callback); callbacks, on_data_chunk_recv_callback);
} }
#ifndef OPENSSL_NO_NEXTPROTONEG
/* /*
* Callback function for TLS NPN. Since this program only supports * Callback function for TLS NPN. Since this program only supports
* HTTP/2 protocol, if server does not offer HTTP/2 the nghttp2 * HTTP/2 protocol, if server does not offer HTTP/2 the nghttp2
...@@ -365,6 +366,7 @@ static int select_next_proto_cb(SSL *ssl, unsigned char **out, ...@@ -365,6 +366,7 @@ static int select_next_proto_cb(SSL *ssl, unsigned char **out,
} }
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
#endif /* !OPENSSL_NO_NEXTPROTONEG */
/* /*
* Setup SSL/TLS context. * Setup SSL/TLS context.
......
...@@ -308,6 +308,7 @@ static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id, ...@@ -308,6 +308,7 @@ static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
return 0; return 0;
} }
#ifndef OPENSSL_NO_NEXTPROTONEG
/* NPN TLS extension client callback. We check that server advertised /* NPN TLS extension client callback. We check that server advertised
the HTTP/2 protocol the nghttp2 library supports. If not, exit the HTTP/2 protocol the nghttp2 library supports. If not, exit
the program. */ the program. */
...@@ -322,6 +323,7 @@ static int select_next_proto_cb(SSL *ssl, unsigned char **out, ...@@ -322,6 +323,7 @@ static int select_next_proto_cb(SSL *ssl, unsigned char **out,
} }
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
#endif /* !OPENSSL_NO_NEXTPROTONEG */
/* Create SSL_CTX. */ /* Create SSL_CTX. */
static SSL_CTX *create_ssl_ctx(void) { static SSL_CTX *create_ssl_ctx(void) {
......
...@@ -109,6 +109,7 @@ struct app_context { ...@@ -109,6 +109,7 @@ struct app_context {
static unsigned char next_proto_list[256]; static unsigned char next_proto_list[256];
static size_t next_proto_list_len; static size_t next_proto_list_len;
#ifndef OPENSSL_NO_NEXTPROTONEG
static int next_proto_cb(SSL *ssl, const unsigned char **data, static int next_proto_cb(SSL *ssl, const unsigned char **data,
unsigned int *len, void *arg) { unsigned int *len, void *arg) {
(void)ssl; (void)ssl;
...@@ -118,6 +119,7 @@ static int next_proto_cb(SSL *ssl, const unsigned char **data, ...@@ -118,6 +119,7 @@ static int next_proto_cb(SSL *ssl, const unsigned char **data,
*len = (unsigned int)next_proto_list_len; *len = (unsigned int)next_proto_list_len;
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
#endif /* !OPENSSL_NO_NEXTPROTONEG */
#if OPENSSL_VERSION_NUMBER >= 0x10002000L #if OPENSSL_VERSION_NUMBER >= 0x10002000L
static int alpn_select_proto_cb(SSL *ssl, const unsigned char **out, static int alpn_select_proto_cb(SSL *ssl, const unsigned char **out,
......
...@@ -1984,6 +1984,7 @@ HttpServer::HttpServer(const Config *config) : config_(config) { ...@@ -1984,6 +1984,7 @@ HttpServer::HttpServer(const Config *config) : config_(config) {
}; };
} }
#ifndef OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len, int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
void *arg) { void *arg) {
...@@ -1993,6 +1994,7 @@ int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len, ...@@ -1993,6 +1994,7 @@ int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
} // namespace } // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) { int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) {
......
...@@ -35,6 +35,7 @@ namespace nghttp2 { ...@@ -35,6 +35,7 @@ namespace nghttp2 {
namespace asio_http2 { namespace asio_http2 {
namespace client { namespace client {
#ifndef OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
int client_select_next_proto_cb(SSL *ssl, unsigned char **out, int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
unsigned char *outlen, const unsigned char *in, unsigned char *outlen, const unsigned char *in,
...@@ -46,6 +47,7 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out, ...@@ -46,6 +47,7 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
} // namespace } // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG
boost::system::error_code boost::system::error_code
configure_tls_context(boost::system::error_code &ec, configure_tls_context(boost::system::error_code &ec,
...@@ -54,7 +56,9 @@ configure_tls_context(boost::system::error_code &ec, ...@@ -54,7 +56,9 @@ configure_tls_context(boost::system::error_code &ec,
auto ctx = tls_ctx.native_handle(); auto ctx = tls_ctx.native_handle();
#ifndef OPENSSL_NO_NEXTPROTONEG
SSL_CTX_set_next_proto_select_cb(ctx, client_select_next_proto_cb, nullptr); SSL_CTX_set_next_proto_select_cb(ctx, client_select_next_proto_cb, nullptr);
#endif // !OPENSSL_NO_NEXTPROTONEG
#if OPENSSL_VERSION_NUMBER >= 0x10002000L #if OPENSSL_VERSION_NUMBER >= 0x10002000L
auto proto_list = util::get_default_alpn(); auto proto_list = util::get_default_alpn();
......
...@@ -35,12 +35,14 @@ namespace nghttp2 { ...@@ -35,12 +35,14 @@ namespace nghttp2 {
namespace asio_http2 { namespace asio_http2 {
namespace server { namespace server {
#ifndef OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
std::vector<unsigned char> &get_alpn_token() { std::vector<unsigned char> &get_alpn_token() {
static auto alpn_token = util::get_default_alpn(); static auto alpn_token = util::get_default_alpn();
return alpn_token; return alpn_token;
} }
} // namespace } // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG
#if OPENSSL_VERSION_NUMBER >= 0x10002000L #if OPENSSL_VERSION_NUMBER >= 0x10002000L
namespace { namespace {
...@@ -82,6 +84,7 @@ configure_tls_context_easy(boost::system::error_code &ec, ...@@ -82,6 +84,7 @@ configure_tls_context_easy(boost::system::error_code &ec,
} }
#endif /* OPENSSL_NO_EC */ #endif /* OPENSSL_NO_EC */
#ifndef OPENSSL_NO_NEXTPROTONEG
SSL_CTX_set_next_protos_advertised_cb( SSL_CTX_set_next_protos_advertised_cb(
ctx, ctx,
[](SSL *s, const unsigned char **data, unsigned int *len, void *arg) { [](SSL *s, const unsigned char **data, unsigned int *len, void *arg) {
...@@ -93,6 +96,7 @@ configure_tls_context_easy(boost::system::error_code &ec, ...@@ -93,6 +96,7 @@ configure_tls_context_easy(boost::system::error_code &ec,
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
}, },
nullptr); nullptr);
#endif // !OPENSSL_NO_NEXTPROTONEG
#if OPENSSL_VERSION_NUMBER >= 0x10002000L #if OPENSSL_VERSION_NUMBER >= 0x10002000L
// ALPN selection callback // ALPN selection callback
......
...@@ -1565,6 +1565,7 @@ std::string get_reqline(const char *uri, const http_parser_url &u) { ...@@ -1565,6 +1565,7 @@ std::string get_reqline(const char *uri, const http_parser_url &u) {
} }
} // namespace } // namespace
#ifndef OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
int client_select_next_proto_cb(SSL *ssl, unsigned char **out, int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
unsigned char *outlen, const unsigned char *in, unsigned char *outlen, const unsigned char *in,
...@@ -1579,6 +1580,7 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out, ...@@ -1579,6 +1580,7 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
return SSL_TLSEXT_ERR_NOACK; return SSL_TLSEXT_ERR_NOACK;
} }
} // namespace } // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
constexpr char UNIX_PATH_PREFIX[] = "unix:"; constexpr char UNIX_PATH_PREFIX[] = "unix:";
......
...@@ -2222,6 +2222,7 @@ id responseEnd requestStart process code size request path)" ...@@ -2222,6 +2222,7 @@ id responseEnd requestStart process code size request path)"
} }
} // namespace } // namespace
#ifndef OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
int client_select_next_proto_cb(SSL *ssl, unsigned char **out, int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
unsigned char *outlen, const unsigned char *in, unsigned char *outlen, const unsigned char *in,
...@@ -2245,6 +2246,7 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out, ...@@ -2245,6 +2246,7 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
} // namespace } // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
int communicate( int communicate(
......
...@@ -80,6 +80,7 @@ const unsigned char *ASN1_STRING_get0_data(ASN1_STRING *x) { ...@@ -80,6 +80,7 @@ const unsigned char *ASN1_STRING_get0_data(ASN1_STRING *x) {
} // namespace } // namespace
#endif // !OPENSSL_1_1_API #endif // !OPENSSL_1_1_API
#ifndef OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len, int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
void *arg) { void *arg) {
...@@ -89,6 +90,7 @@ int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len, ...@@ -89,6 +90,7 @@ int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
} // namespace } // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG
namespace { namespace {
int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) { int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment