Rename *_create_handshakers() to *_add_handshakers().

pull/8979/head
Mark D. Roth 8 years ago
parent bc4403ad74
commit 65b79c8dda
  1. 18
      src/core/ext/transport/chttp2/client/chttp2_connector.c
  2. 10
      src/core/ext/transport/chttp2/client/chttp2_connector.h
  3. 2
      src/core/ext/transport/chttp2/client/insecure/channel_create.c
  4. 12
      src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
  5. 8
      src/core/ext/transport/chttp2/server/chttp2_server.c
  6. 4
      src/core/ext/transport/chttp2/server/chttp2_server.h
  7. 6
      src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c
  8. 11
      src/core/lib/http/httpcli_security_connector.c
  9. 32
      src/core/lib/security/transport/security_connector.c
  10. 16
      src/core/lib/security/transport/security_connector.h
  11. 8
      src/core/lib/security/transport/security_handshaker.c
  12. 8
      src/core/lib/security/transport/security_handshaker.h

@ -59,8 +59,8 @@ typedef struct {
bool connecting;
char *server_name;
grpc_chttp2_create_handshakers_func create_handshakers;
void *create_handshakers_user_data;
grpc_chttp2_add_handshakers_func add_handshakers;
void *add_handshakers_user_data;
grpc_closure *notify;
grpc_connect_in_args args;
@ -160,9 +160,9 @@ static void start_handshake_locked(grpc_exec_ctx *exec_ctx,
grpc_http_connect_handshaker_create(proxy_name, c->server_name));
gpr_free(proxy_name);
}
if (c->create_handshakers != NULL) {
c->create_handshakers(exec_ctx, c->create_handshakers_user_data,
c->handshake_mgr);
if (c->add_handshakers != NULL) {
c->add_handshakers(exec_ctx, c->add_handshakers_user_data,
c->handshake_mgr);
}
grpc_handshake_manager_do_handshake(
exec_ctx, c->handshake_mgr, c->endpoint, c->args.channel_args,
@ -255,15 +255,15 @@ static const grpc_connector_vtable chttp2_connector_vtable = {
grpc_connector *grpc_chttp2_connector_create(
grpc_exec_ctx *exec_ctx, const char *server_name,
grpc_chttp2_create_handshakers_func create_handshakers,
void *create_handshakers_user_data) {
grpc_chttp2_add_handshakers_func add_handshakers,
void *add_handshakers_user_data) {
chttp2_connector *c = gpr_malloc(sizeof(*c));
memset(c, 0, sizeof(*c));
c->base.vtable = &chttp2_connector_vtable;
gpr_mu_init(&c->mu);
gpr_ref_init(&c->refs, 1);
c->server_name = gpr_strdup(server_name);
c->create_handshakers = create_handshakers;
c->create_handshakers_user_data = create_handshakers_user_data;
c->add_handshakers = add_handshakers;
c->add_handshakers_user_data = add_handshakers_user_data;
return &c->base;
}

@ -38,15 +38,15 @@
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/iomgr/exec_ctx.h"
typedef void (*grpc_chttp2_create_handshakers_func)(
typedef void (*grpc_chttp2_add_handshakers_func)(
grpc_exec_ctx* exec_ctx, void* user_data,
grpc_handshake_manager* handshake_mgr);
/// If \a create_handshakers is non-NULL, it will be called with
/// \a create_handshakers_user_data to add handshakers.
/// If \a add_handshakers is non-NULL, it will be called with
/// \a add_handshakers_user_data to add handshakers.
grpc_connector* grpc_chttp2_connector_create(
grpc_exec_ctx* exec_ctx, const char* server_name,
grpc_chttp2_create_handshakers_func create_handshakers,
void* create_handshakers_user_data);
grpc_chttp2_add_handshakers_func add_handshakers,
void* add_handshakers_user_data);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H */

@ -54,7 +54,7 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
const grpc_subchannel_args *args) {
grpc_connector *connector = grpc_chttp2_connector_create(
exec_ctx, args->server_name, NULL /* create_handshakers */,
exec_ctx, args->server_name, NULL /* add_handshakers */,
NULL /* user_data */);
grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args);
grpc_connector_unref(exec_ctx, connector);

@ -69,11 +69,11 @@ static void client_channel_factory_unref(
}
}
static void create_handshakers(grpc_exec_ctx *exec_ctx,
void *security_connector,
grpc_handshake_manager *handshake_mgr) {
grpc_channel_security_connector_create_handshakers(
exec_ctx, security_connector, handshake_mgr);
static void add_handshakers(grpc_exec_ctx *exec_ctx,
void *security_connector,
grpc_handshake_manager *handshake_mgr) {
grpc_channel_security_connector_add_handshakers(exec_ctx, security_connector,
handshake_mgr);
}
static grpc_subchannel *client_channel_factory_create_subchannel(
@ -81,7 +81,7 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
const grpc_subchannel_args *args) {
client_channel_factory *f = (client_channel_factory *)cc_factory;
grpc_connector *connector = grpc_chttp2_connector_create(
exec_ctx, args->server_name, create_handshakers, f->security_connector);
exec_ctx, args->server_name, add_handshakers, f->security_connector);
grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args);
grpc_connector_unref(exec_ctx, connector);
return s;

@ -53,13 +53,13 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/server.h"
void grpc_chttp2_server_handshaker_factory_create_handshakers(
void grpc_chttp2_server_handshaker_factory_add_handshakers(
grpc_exec_ctx *exec_ctx,
grpc_chttp2_server_handshaker_factory *handshaker_factory,
grpc_handshake_manager *handshake_mgr) {
if (handshaker_factory != NULL) {
handshaker_factory->vtable->create_handshakers(exec_ctx, handshaker_factory,
handshake_mgr);
handshaker_factory->vtable->add_handshakers(exec_ctx, handshaker_factory,
handshake_mgr);
}
}
@ -189,7 +189,7 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
connection_state->accepting_pollset = accepting_pollset;
connection_state->acceptor = acceptor;
connection_state->handshake_mgr = handshake_mgr;
grpc_chttp2_server_handshaker_factory_create_handshakers(
grpc_chttp2_server_handshaker_factory_add_handshakers(
exec_ctx, state->handshaker_factory, connection_state->handshake_mgr);
// TODO(roth): We should really get this timeout value from channel
// args instead of hard-coding it.

@ -45,7 +45,7 @@ typedef struct grpc_chttp2_server_handshaker_factory
grpc_chttp2_server_handshaker_factory;
typedef struct {
void (*create_handshakers)(
void (*add_handshakers)(
grpc_exec_ctx *exec_ctx,
grpc_chttp2_server_handshaker_factory *handshaker_factory,
grpc_handshake_manager *handshake_mgr);
@ -57,7 +57,7 @@ struct grpc_chttp2_server_handshaker_factory {
const grpc_chttp2_server_handshaker_factory_vtable *vtable;
};
void grpc_chttp2_server_handshaker_factory_create_handshakers(
void grpc_chttp2_server_handshaker_factory_add_handshakers(
grpc_exec_ctx *exec_ctx,
grpc_chttp2_server_handshaker_factory *handshaker_factory,
grpc_handshake_manager *handshake_mgr);

@ -54,12 +54,12 @@ typedef struct {
grpc_server_security_connector *security_connector;
} server_security_handshaker_factory;
static void server_security_handshaker_factory_create_handshakers(
static void server_security_handshaker_factory_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_chttp2_server_handshaker_factory *hf,
grpc_handshake_manager *handshake_mgr) {
server_security_handshaker_factory *handshaker_factory =
(server_security_handshaker_factory *)hf;
grpc_server_security_connector_create_handshakers(
grpc_server_security_connector_add_handshakers(
exec_ctx, handshaker_factory->security_connector, handshake_mgr);
}
@ -74,7 +74,7 @@ static void server_security_handshaker_factory_destroy(
static const grpc_chttp2_server_handshaker_factory_vtable
server_security_handshaker_factory_vtable = {
server_security_handshaker_factory_create_handshakers,
server_security_handshaker_factory_add_handshakers,
server_security_handshaker_factory_destroy};
int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,

@ -60,7 +60,7 @@ static void httpcli_ssl_destroy(grpc_security_connector *sc) {
gpr_free(sc);
}
static void httpcli_ssl_create_handshakers(
static void httpcli_ssl_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
grpc_handshake_manager *handshake_mgr) {
grpc_httpcli_ssl_channel_security_connector *c =
@ -74,8 +74,7 @@ static void httpcli_ssl_create_handshakers(
tsi_result_to_string(result));
}
}
grpc_security_create_handshakers(exec_ctx, handshaker, &sc->base,
handshake_mgr);
grpc_security_add_handshakers(exec_ctx, handshaker, &sc->base, handshake_mgr);
}
static void httpcli_ssl_check_peer(grpc_exec_ctx *exec_ctx,
@ -132,7 +131,7 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
*sc = NULL;
return GRPC_SECURITY_ERROR;
}
c->base.create_handshakers = httpcli_ssl_create_handshakers;
c->base.add_handshakers = httpcli_ssl_add_handshakers;
*sc = &c->base;
return GRPC_SECURITY_OK;
}
@ -185,8 +184,8 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg,
GPR_ASSERT(httpcli_ssl_channel_security_connector_create(
pem_root_certs, pem_root_certs_size, host, &sc) ==
GRPC_SECURITY_OK);
grpc_channel_security_connector_create_handshakers(exec_ctx, sc,
c->handshake_mgr);
grpc_channel_security_connector_add_handshakers(exec_ctx, sc,
c->handshake_mgr);
grpc_handshake_manager_do_handshake(
exec_ctx, c->handshake_mgr, tcp, NULL /* channel_args */, deadline,
NULL /* acceptor */, on_handshake_done, c /* user_data */);

@ -111,19 +111,19 @@ const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer,
return NULL;
}
void grpc_channel_security_connector_create_handshakers(
void grpc_channel_security_connector_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *connector,
grpc_handshake_manager *handshake_mgr) {
if (connector != NULL) {
connector->create_handshakers(exec_ctx, connector, handshake_mgr);
connector->add_handshakers(exec_ctx, connector, handshake_mgr);
}
}
void grpc_server_security_connector_create_handshakers(
void grpc_server_security_connector_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *connector,
grpc_handshake_manager *handshake_mgr) {
if (connector != NULL) {
connector->create_handshakers(exec_ctx, connector, handshake_mgr);
connector->add_handshakers(exec_ctx, connector, handshake_mgr);
}
}
@ -285,18 +285,18 @@ static void fake_channel_check_call_host(grpc_exec_ctx *exec_ctx,
cb(exec_ctx, user_data, GRPC_SECURITY_OK);
}
static void fake_channel_create_handshakers(
static void fake_channel_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
grpc_handshake_manager *handshake_mgr) {
grpc_security_create_handshakers(
grpc_security_add_handshakers(
exec_ctx, tsi_create_fake_handshaker(true /* is_client */), &sc->base,
handshake_mgr);
}
static void fake_server_create_handshakers(
static void fake_server_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc,
grpc_handshake_manager *handshake_mgr) {
grpc_security_create_handshakers(
grpc_security_add_handshakers(
exec_ctx, tsi_create_fake_handshaker(false /* is_client */), &sc->base,
handshake_mgr);
}
@ -316,7 +316,7 @@ grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
c->base.vtable = &fake_channel_vtable;
c->request_metadata_creds = grpc_call_credentials_ref(request_metadata_creds);
c->check_call_host = fake_channel_check_call_host;
c->create_handshakers = fake_channel_create_handshakers;
c->add_handshakers = fake_channel_add_handshakers;
return c;
}
@ -328,7 +328,7 @@ grpc_server_security_connector *grpc_fake_server_security_connector_create(
gpr_ref_init(&c->base.refcount, 1);
c->base.vtable = &fake_server_vtable;
c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
c->create_handshakers = fake_server_create_handshakers;
c->add_handshakers = fake_server_add_handshakers;
return c;
}
@ -382,7 +382,7 @@ static grpc_security_status ssl_create_handshaker(
return GRPC_SECURITY_OK;
}
static void ssl_channel_create_handshakers(
static void ssl_channel_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
grpc_handshake_manager *handshake_mgr) {
grpc_ssl_channel_security_connector *c =
@ -395,10 +395,10 @@ static void ssl_channel_create_handshakers(
: c->target_name,
&tsi_hs);
// Create handshakers.
grpc_security_create_handshakers(exec_ctx, tsi_hs, &sc->base, handshake_mgr);
grpc_security_add_handshakers(exec_ctx, tsi_hs, &sc->base, handshake_mgr);
}
static void ssl_server_create_handshakers(
static void ssl_server_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc,
grpc_handshake_manager *handshake_mgr) {
grpc_ssl_server_security_connector *c =
@ -408,7 +408,7 @@ static void ssl_server_create_handshakers(
ssl_create_handshaker(c->handshaker_factory, false /* is_client */,
NULL /* peer_name */, &tsi_hs);
// Create handshakers.
grpc_security_create_handshakers(exec_ctx, tsi_hs, &sc->base, handshake_mgr);
grpc_security_add_handshakers(exec_ctx, tsi_hs, &sc->base, handshake_mgr);
}
static int ssl_host_matches_name(const tsi_peer *peer, const char *peer_name) {
@ -708,7 +708,7 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
c->base.request_metadata_creds =
grpc_call_credentials_ref(request_metadata_creds);
c->base.check_call_host = ssl_channel_check_call_host;
c->base.create_handshakers = ssl_channel_create_handshakers;
c->base.add_handshakers = ssl_channel_add_handshakers;
gpr_split_host_port(target_name, &c->target_name, &port);
gpr_free(port);
if (overridden_target_name != NULL) {
@ -783,7 +783,7 @@ grpc_security_status grpc_ssl_server_security_connector_create(
*sc = NULL;
goto error;
}
c->base.create_handshakers = ssl_server_create_handshakers;
c->base.add_handshakers = ssl_server_add_handshakers;
*sc = &c->base;
gpr_free((void *)alpn_protocol_strings);
gpr_free(alpn_protocol_string_lengths);

@ -133,9 +133,9 @@ struct grpc_channel_security_connector {
grpc_channel_security_connector *sc, const char *host,
grpc_auth_context *auth_context,
grpc_security_call_host_check_cb cb, void *user_data);
void (*create_handshakers)(grpc_exec_ctx *exec_ctx,
grpc_channel_security_connector *sc,
grpc_handshake_manager *handshake_mgr);
void (*add_handshakers)(grpc_exec_ctx *exec_ctx,
grpc_channel_security_connector *sc,
grpc_handshake_manager *handshake_mgr);
};
/* Checks that the host that will be set for a call is acceptable. */
@ -145,7 +145,7 @@ void grpc_channel_security_connector_check_call_host(
grpc_security_call_host_check_cb cb, void *user_data);
/* Registers handshakers with \a handshake_mgr. */
void grpc_channel_security_connector_create_handshakers(
void grpc_channel_security_connector_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *connector,
grpc_handshake_manager *handshake_mgr);
@ -158,12 +158,12 @@ typedef struct grpc_server_security_connector grpc_server_security_connector;
struct grpc_server_security_connector {
grpc_security_connector base;
void (*create_handshakers)(grpc_exec_ctx *exec_ctx,
grpc_server_security_connector *sc,
grpc_handshake_manager *handshake_mgr);
void (*add_handshakers)(grpc_exec_ctx *exec_ctx,
grpc_server_security_connector *sc,
grpc_handshake_manager *handshake_mgr);
};
void grpc_server_security_connector_create_handshakers(
void grpc_server_security_connector_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc,
grpc_handshake_manager *handshake_mgr);

@ -434,10 +434,10 @@ static grpc_handshaker *fail_handshaker_create() {
// exported functions
//
void grpc_security_create_handshakers(grpc_exec_ctx *exec_ctx,
tsi_handshaker *handshaker,
grpc_security_connector *connector,
grpc_handshake_manager *handshake_mgr) {
void grpc_security_add_handshakers(grpc_exec_ctx *exec_ctx,
tsi_handshaker *handshaker,
grpc_security_connector *connector,
grpc_handshake_manager *handshake_mgr) {
// If no TSI handshaker was created, add a handshaker that always fails.
// Otherwise, add a real security handshaker.
if (handshaker == NULL) {

@ -39,9 +39,9 @@
/// Creates any necessary security handshakers and adds them to
/// \a handshake_mgr.
void grpc_security_create_handshakers(grpc_exec_ctx *exec_ctx,
tsi_handshaker *handshaker,
grpc_security_connector *connector,
grpc_handshake_manager *handshake_mgr);
void grpc_security_add_handshakers(grpc_exec_ctx *exec_ctx,
tsi_handshaker *handshaker,
grpc_security_connector *connector,
grpc_handshake_manager *handshake_mgr);
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */

Loading…
Cancel
Save