Skip to content

Commit

Permalink
Fix compile error with -Wunused-function
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Apr 3, 2018
1 parent 400934e commit 636ef51
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ static void setup_nghttp2_callbacks(nghttp2_session_callbacks *callbacks) {
callbacks, on_data_chunk_recv_callback);
}

#ifndef OPENSSL_NO_NEXTPROTONEG
/*
* Callback function for TLS NPN. Since this program only supports
* HTTP/2 protocol, if server does not offer HTTP/2 the nghttp2
Expand All @@ -365,6 +366,7 @@ static int select_next_proto_cb(SSL *ssl, unsigned char **out,
}
return SSL_TLSEXT_ERR_OK;
}
#endif /* !OPENSSL_NO_NEXTPROTONEG */

/*
* Setup SSL/TLS context.
Expand Down
2 changes: 2 additions & 0 deletions examples/libevent-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
return 0;
}

#ifndef OPENSSL_NO_NEXTPROTONEG
/* NPN TLS extension client callback. We check that server advertised
the HTTP/2 protocol the nghttp2 library supports. If not, exit
the program. */
Expand All @@ -322,6 +323,7 @@ static int select_next_proto_cb(SSL *ssl, unsigned char **out,
}
return SSL_TLSEXT_ERR_OK;
}
#endif /* !OPENSSL_NO_NEXTPROTONEG */

/* Create SSL_CTX. */
static SSL_CTX *create_ssl_ctx(void) {
Expand Down
2 changes: 2 additions & 0 deletions examples/libevent-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ struct app_context {
static unsigned char next_proto_list[256];
static size_t next_proto_list_len;

#ifndef OPENSSL_NO_NEXTPROTONEG
static int next_proto_cb(SSL *ssl, const unsigned char **data,
unsigned int *len, void *arg) {
(void)ssl;
Expand All @@ -118,6 +119,7 @@ static int next_proto_cb(SSL *ssl, const unsigned char **data,
*len = (unsigned int)next_proto_list_len;
return SSL_TLSEXT_ERR_OK;
}
#endif /* !OPENSSL_NO_NEXTPROTONEG */

#if OPENSSL_VERSION_NUMBER >= 0x10002000L
static int alpn_select_proto_cb(SSL *ssl, const unsigned char **out,
Expand Down
2 changes: 2 additions & 0 deletions src/HttpServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,7 @@ HttpServer::HttpServer(const Config *config) : config_(config) {
};
}

#ifndef OPENSSL_NO_NEXTPROTONEG
namespace {
int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
void *arg) {
Expand All @@ -1993,6 +1994,7 @@ int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
return SSL_TLSEXT_ERR_OK;
}
} // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG

namespace {
int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) {
Expand Down
4 changes: 4 additions & 0 deletions src/asio_client_tls_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace nghttp2 {
namespace asio_http2 {
namespace client {

#ifndef OPENSSL_NO_NEXTPROTONEG
namespace {
int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
unsigned char *outlen, const unsigned char *in,
Expand All @@ -46,6 +47,7 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
return SSL_TLSEXT_ERR_OK;
}
} // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG

boost::system::error_code
configure_tls_context(boost::system::error_code &ec,
Expand All @@ -54,7 +56,9 @@ configure_tls_context(boost::system::error_code &ec,

auto ctx = tls_ctx.native_handle();

#ifndef OPENSSL_NO_NEXTPROTONEG
SSL_CTX_set_next_proto_select_cb(ctx, client_select_next_proto_cb, nullptr);
#endif // !OPENSSL_NO_NEXTPROTONEG

#if OPENSSL_VERSION_NUMBER >= 0x10002000L
auto proto_list = util::get_default_alpn();
Expand Down
4 changes: 4 additions & 0 deletions src/asio_server_tls_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ namespace nghttp2 {
namespace asio_http2 {
namespace server {

#ifndef OPENSSL_NO_NEXTPROTONEG
namespace {
std::vector<unsigned char> &get_alpn_token() {
static auto alpn_token = util::get_default_alpn();
return alpn_token;
}
} // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG

#if OPENSSL_VERSION_NUMBER >= 0x10002000L
namespace {
Expand Down Expand Up @@ -82,6 +84,7 @@ configure_tls_context_easy(boost::system::error_code &ec,
}
#endif /* OPENSSL_NO_EC */

#ifndef OPENSSL_NO_NEXTPROTONEG
SSL_CTX_set_next_protos_advertised_cb(
ctx,
[](SSL *s, const unsigned char **data, unsigned int *len, void *arg) {
Expand All @@ -93,6 +96,7 @@ configure_tls_context_easy(boost::system::error_code &ec,
return SSL_TLSEXT_ERR_OK;
},
nullptr);
#endif // !OPENSSL_NO_NEXTPROTONEG

#if OPENSSL_VERSION_NUMBER >= 0x10002000L
// ALPN selection callback
Expand Down
2 changes: 2 additions & 0 deletions src/h2load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,7 @@ std::string get_reqline(const char *uri, const http_parser_url &u) {
}
} // namespace

#ifndef OPENSSL_NO_NEXTPROTONEG
namespace {
int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
unsigned char *outlen, const unsigned char *in,
Expand All @@ -1579,6 +1580,7 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
return SSL_TLSEXT_ERR_NOACK;
}
} // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG

namespace {
constexpr char UNIX_PATH_PREFIX[] = "unix:";
Expand Down
2 changes: 2 additions & 0 deletions src/nghttp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,7 @@ id responseEnd requestStart process code size request path)"
}
} // namespace

#ifndef OPENSSL_NO_NEXTPROTONEG
namespace {
int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
unsigned char *outlen, const unsigned char *in,
Expand All @@ -2245,6 +2246,7 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
return SSL_TLSEXT_ERR_OK;
}
} // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG

namespace {
int communicate(
Expand Down
2 changes: 2 additions & 0 deletions src/shrpx_tls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const unsigned char *ASN1_STRING_get0_data(ASN1_STRING *x) {
} // namespace
#endif // !OPENSSL_1_1_API

#ifndef OPENSSL_NO_NEXTPROTONEG
namespace {
int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
void *arg) {
Expand All @@ -89,6 +90,7 @@ int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
return SSL_TLSEXT_ERR_OK;
}
} // namespace
#endif // !OPENSSL_NO_NEXTPROTONEG

namespace {
int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) {
Expand Down

0 comments on commit 636ef51

Please sign in to comment.