aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-12-01 08:48:22 -0800
committerGravatar Mark D. Roth <roth@google.com>2016-12-01 08:48:22 -0800
commita5617850522ed729eb79ad040e87811ab6925484 (patch)
tree84e11b7a42a30ff4ce60b4cacebb943530bcbda9 /src
parent9b3f1b7ab1c925695412d7dd6febed8ca31b493c (diff)
clang-format
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.c8
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.h6
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.c11
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2.c48
-rw-r--r--src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c50
-rw-r--r--src/core/lib/http/httpcli_security_connector.c6
-rw-r--r--src/core/lib/security/transport/security_connector.c31
-rw-r--r--src/core/lib/security/transport/security_connector.h12
-rw-r--r--src/core/lib/security/transport/security_handshaker.c102
-rw-r--r--src/core/lib/security/transport/security_handshaker.h7
10 files changed, 137 insertions, 144 deletions
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.c b/src/core/ext/transport/chttp2/client/chttp2_connector.c
index 2af6b1e14d..213395c20f 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.c
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.c
@@ -41,9 +41,9 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
+#include "src/core/ext/client_channel/connector.h"
#include "src/core/ext/client_channel/http_connect_handshaker.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
-#include "src/core/ext/client_channel/connector.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/iomgr/tcp_client.h"
@@ -144,7 +144,7 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
c->handshake_mgr = NULL;
gpr_mu_unlock(&c->mu);
- chttp2_connector_unref(exec_ctx, (grpc_connector*)c);
+ chttp2_connector_unref(exec_ctx, (grpc_connector *)c);
}
static void start_handshake_locked(grpc_exec_ctx *exec_ctx,
@@ -246,9 +246,9 @@ static const grpc_connector_vtable chttp2_connector_vtable = {
chttp2_connector_connect};
grpc_connector *grpc_chttp2_connector_create(
- grpc_exec_ctx *exec_ctx, const char* server_name,
+ grpc_exec_ctx *exec_ctx, const char *server_name,
grpc_chttp2_create_handshakers_func create_handshakers,
- void* create_handshakers_user_data) {
+ void *create_handshakers_user_data) {
chttp2_connector *c = gpr_malloc(sizeof(*c));
memset(c, 0, sizeof(*c));
c->base.vtable = &chttp2_connector_vtable;
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.h b/src/core/ext/transport/chttp2/client/chttp2_connector.h
index 46401c34de..6c34ce1af1 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.h
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.h
@@ -35,8 +35,8 @@
#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H
#include "src/core/ext/client_channel/connector.h"
-#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/channel/handshaker.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
typedef void (*grpc_chttp2_create_handshakers_func)(
grpc_exec_ctx* exec_ctx, void* user_data,
@@ -44,8 +44,8 @@ typedef void (*grpc_chttp2_create_handshakers_func)(
/// If \a create_handshakers is non-NULL, it will be called with
/// \a create_handshakers_user_data to add handshakers.
-grpc_connector *grpc_chttp2_connector_create(
- grpc_exec_ctx *exec_ctx, const char* server_name,
+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);
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
index 10a84630ce..35e1e1f716 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
@@ -69,9 +69,9 @@ static void client_channel_factory_unref(
}
}
-static void create_handshakers(grpc_exec_ctx* exec_ctx,
- void* security_connector,
- grpc_handshake_manager* handshake_mgr) {
+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);
}
@@ -80,9 +80,8 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
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);
+ grpc_connector *connector = grpc_chttp2_connector_create(
+ exec_ctx, args->server_name, create_handshakers, f->security_connector);
grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args);
grpc_connector_unref(exec_ctx, connector);
return s;
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
index bdf10de49e..a4d7fc5f70 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
@@ -50,7 +50,7 @@
#include "src/core/lib/surface/server.h"
typedef struct pending_handshake_manager_node {
- grpc_handshake_manager* handshake_mgr;
+ grpc_handshake_manager *handshake_mgr;
struct pending_handshake_manager_node *next;
} pending_handshake_manager_node;
@@ -72,17 +72,17 @@ typedef struct {
} server_connection_state;
static void pending_handshake_manager_add_locked(
- server_state* state, grpc_handshake_manager* handshake_mgr) {
- pending_handshake_manager_node* node = gpr_malloc(sizeof(*node));
+ server_state *state, grpc_handshake_manager *handshake_mgr) {
+ pending_handshake_manager_node *node = gpr_malloc(sizeof(*node));
node->handshake_mgr = handshake_mgr;
node->next = state->pending_handshake_mgrs;
state->pending_handshake_mgrs = node;
}
static void pending_handshake_manager_remove_locked(
- server_state* state, grpc_handshake_manager* handshake_mgr) {
- pending_handshake_manager_node** prev_node = &state->pending_handshake_mgrs;
- for (pending_handshake_manager_node* node = state->pending_handshake_mgrs;
+ server_state *state, grpc_handshake_manager *handshake_mgr) {
+ pending_handshake_manager_node **prev_node = &state->pending_handshake_mgrs;
+ for (pending_handshake_manager_node *node = state->pending_handshake_mgrs;
node != NULL; node = node->next) {
if (node->handshake_mgr == handshake_mgr) {
*prev_node = node->next;
@@ -93,10 +93,10 @@ static void pending_handshake_manager_remove_locked(
}
}
-static void pending_handshake_manager_shutdown_locked(
- grpc_exec_ctx* exec_ctx, server_state* state) {
- pending_handshake_manager_node* prev_node = NULL;
- for (pending_handshake_manager_node* node = state->pending_handshake_mgrs;
+static void pending_handshake_manager_shutdown_locked(grpc_exec_ctx *exec_ctx,
+ server_state *state) {
+ pending_handshake_manager_node *prev_node = NULL;
+ for (pending_handshake_manager_node *node = state->pending_handshake_mgrs;
node != NULL; node = node->next) {
grpc_handshake_manager_shutdown(exec_ctx, node->handshake_mgr);
gpr_free(prev_node);
@@ -135,8 +135,7 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
exec_ctx, connection_state->server_state->server, transport,
connection_state->accepting_pollset,
grpc_server_get_channel_args(connection_state->server_state->server));
- grpc_chttp2_transport_start_reading(exec_ctx, transport,
- args->read_buffer);
+ grpc_chttp2_transport_start_reading(exec_ctx, transport, args->read_buffer);
grpc_channel_args_destroy(args->args);
}
pending_handshake_manager_remove_locked(connection_state->server_state,
@@ -150,14 +149,14 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
grpc_pollset *accepting_pollset,
grpc_tcp_server_acceptor *acceptor) {
- server_state* state = arg;
+ server_state *state = arg;
gpr_mu_lock(&state->mu);
if (state->shutdown) {
gpr_mu_unlock(&state->mu);
grpc_endpoint_destroy(exec_ctx, tcp);
return;
}
- grpc_handshake_manager* handshake_mgr = grpc_handshake_manager_create();
+ grpc_handshake_manager *handshake_mgr = grpc_handshake_manager_create();
pending_handshake_manager_add_locked(state, handshake_mgr);
gpr_mu_unlock(&state->mu);
grpc_tcp_server_ref(state->tcp_server);
@@ -173,8 +172,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(120, GPR_TIMESPAN));
grpc_handshake_manager_do_handshake(
exec_ctx, connection_state->handshake_mgr, tcp,
- grpc_server_get_channel_args(state->server),
- deadline, acceptor, on_handshake_done, connection_state);
+ grpc_server_get_channel_args(state->server), deadline, acceptor,
+ on_handshake_done, connection_state);
}
/* Server callback: start listening on our ports */
@@ -239,14 +238,13 @@ int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr) {
if (err != GRPC_ERROR_NONE) {
goto error;
}
- server_state* state = gpr_malloc(sizeof(*state));
+ server_state *state = gpr_malloc(sizeof(*state));
memset(state, 0, sizeof(*state));
grpc_closure_init(&state->tcp_server_shutdown_complete,
tcp_server_shutdown_complete, state);
- err = grpc_tcp_server_create(&exec_ctx,
- &state->tcp_server_shutdown_complete,
- grpc_server_get_channel_args(server),
- &tcp_server);
+ err =
+ grpc_tcp_server_create(&exec_ctx, &state->tcp_server_shutdown_complete,
+ grpc_server_get_channel_args(server), &tcp_server);
if (err != GRPC_ERROR_NONE) {
goto error;
}
@@ -259,8 +257,8 @@ int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr) {
const size_t naddrs = resolved->naddrs;
errors = gpr_malloc(sizeof(*errors) * naddrs);
for (i = 0; i < naddrs; i++) {
- errors[i] = grpc_tcp_server_add_port(tcp_server, &resolved->addrs[i],
- &port_temp);
+ errors[i] =
+ grpc_tcp_server_add_port(tcp_server, &resolved->addrs[i], &port_temp);
if (errors[i] == GRPC_ERROR_NONE) {
if (port_num == -1) {
port_num = port_temp;
@@ -293,8 +291,8 @@ int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr) {
grpc_resolved_addresses_destroy(resolved);
/* Register with the server only upon success */
- grpc_server_add_listener(&exec_ctx, server, state,
- server_start_listener, server_destroy_listener);
+ grpc_server_add_listener(&exec_ctx, server, state, server_start_listener,
+ server_destroy_listener);
goto done;
/* Error path: cleanup and return */
diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c
index 19aa22c7c4..8d2371c917 100644
--- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c
+++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c
@@ -55,7 +55,7 @@
#include "src/core/lib/surface/server.h"
typedef struct pending_handshake_manager_node {
- grpc_handshake_manager* handshake_mgr;
+ grpc_handshake_manager *handshake_mgr;
struct pending_handshake_manager_node *next;
} pending_handshake_manager_node;
@@ -79,17 +79,17 @@ typedef struct server_secure_connection_state {
} server_secure_connection_state;
static void pending_handshake_manager_add_locked(
- server_secure_state* state, grpc_handshake_manager* handshake_mgr) {
- pending_handshake_manager_node* node = gpr_malloc(sizeof(*node));
+ server_secure_state *state, grpc_handshake_manager *handshake_mgr) {
+ pending_handshake_manager_node *node = gpr_malloc(sizeof(*node));
node->handshake_mgr = handshake_mgr;
node->next = state->pending_handshake_mgrs;
state->pending_handshake_mgrs = node;
}
static void pending_handshake_manager_remove_locked(
- server_secure_state* state, grpc_handshake_manager* handshake_mgr) {
- pending_handshake_manager_node** prev_node = &state->pending_handshake_mgrs;
- for (pending_handshake_manager_node* node = state->pending_handshake_mgrs;
+ server_secure_state *state, grpc_handshake_manager *handshake_mgr) {
+ pending_handshake_manager_node **prev_node = &state->pending_handshake_mgrs;
+ for (pending_handshake_manager_node *node = state->pending_handshake_mgrs;
node != NULL; node = node->next) {
if (node->handshake_mgr == handshake_mgr) {
*prev_node = node->next;
@@ -101,9 +101,9 @@ static void pending_handshake_manager_remove_locked(
}
static void pending_handshake_manager_shutdown_locked(
- grpc_exec_ctx* exec_ctx, server_secure_state* state) {
- pending_handshake_manager_node* prev_node = NULL;
- for (pending_handshake_manager_node* node = state->pending_handshake_mgrs;
+ grpc_exec_ctx *exec_ctx, server_secure_state *state) {
+ pending_handshake_manager_node *prev_node = NULL;
+ for (pending_handshake_manager_node *node = state->pending_handshake_mgrs;
node != NULL; node = node->next) {
grpc_handshake_manager_shutdown(exec_ctx, node->handshake_mgr);
gpr_free(prev_node);
@@ -136,19 +136,18 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
gpr_free(args->read_buffer);
}
} else {
- grpc_arg channel_arg = grpc_server_credentials_to_arg(
- connection_state->server_state->creds);
+ grpc_arg channel_arg =
+ grpc_server_credentials_to_arg(connection_state->server_state->creds);
grpc_channel_args *args_copy =
- grpc_channel_args_copy_and_add(args->args, &channel_arg, 1);
+ grpc_channel_args_copy_and_add(args->args, &channel_arg, 1);
grpc_channel_args_destroy(args->args);
grpc_transport *transport =
- grpc_create_chttp2_transport(exec_ctx, args_copy, args->endpoint, 0);
+ grpc_create_chttp2_transport(exec_ctx, args_copy, args->endpoint, 0);
grpc_server_setup_transport(
- exec_ctx, connection_state->server_state->server, transport,
- connection_state->accepting_pollset, args_copy);
+ exec_ctx, connection_state->server_state->server, transport,
+ connection_state->accepting_pollset, args_copy);
grpc_channel_args_destroy(args_copy);
- grpc_chttp2_transport_start_reading(exec_ctx, transport,
- args->read_buffer);
+ grpc_chttp2_transport_start_reading(exec_ctx, transport, args->read_buffer);
}
pending_handshake_manager_remove_locked(connection_state->server_state,
connection_state->handshake_mgr);
@@ -168,7 +167,7 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
grpc_endpoint_destroy(exec_ctx, tcp);
return;
}
- grpc_handshake_manager* handshake_mgr = grpc_handshake_manager_create();
+ grpc_handshake_manager *handshake_mgr = grpc_handshake_manager_create();
pending_handshake_manager_add_locked(state, handshake_mgr);
gpr_mu_unlock(&state->mu);
grpc_tcp_server_ref(state->tcp_server);
@@ -186,8 +185,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(120, GPR_TIMESPAN));
grpc_handshake_manager_do_handshake(
exec_ctx, connection_state->handshake_mgr, tcp,
- grpc_server_get_channel_args(state->server),
- deadline, acceptor, on_handshake_done, connection_state);
+ grpc_server_get_channel_args(state->server), deadline, acceptor,
+ on_handshake_done, connection_state);
}
/* Server callback: start listening on our ports */
@@ -283,10 +282,9 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
memset(state, 0, sizeof(*state));
grpc_closure_init(&state->tcp_server_shutdown_complete,
tcp_server_shutdown_complete, state);
- err = grpc_tcp_server_create(&exec_ctx,
- &state->tcp_server_shutdown_complete,
- grpc_server_get_channel_args(server),
- &tcp_server);
+ err =
+ grpc_tcp_server_create(&exec_ctx, &state->tcp_server_shutdown_complete,
+ grpc_server_get_channel_args(server), &tcp_server);
if (err != GRPC_ERROR_NONE) {
goto error;
}
@@ -340,8 +338,8 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
grpc_resolved_addresses_destroy(resolved);
/* Register with the server only upon success */
- grpc_server_add_listener(&exec_ctx, server, state,
- server_start_listener, server_destroy_listener);
+ grpc_server_add_listener(&exec_ctx, server, state, server_start_listener,
+ server_destroy_listener);
grpc_exec_ctx_finish(&exec_ctx);
return port_num;
diff --git a/src/core/lib/http/httpcli_security_connector.c b/src/core/lib/http/httpcli_security_connector.c
index 1a6d31a75d..5fc1893554 100644
--- a/src/core/lib/http/httpcli_security_connector.c
+++ b/src/core/lib/http/httpcli_security_connector.c
@@ -162,7 +162,7 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
grpc_slice_buffer_destroy(args->read_buffer);
gpr_free(args->read_buffer);
if (error != GRPC_ERROR_NONE) {
- const char* msg = grpc_error_string(error);
+ const char *msg = grpc_error_string(error);
gpr_log(GPR_ERROR, "Secure transport setup failed: %s", msg);
grpc_error_free_string(msg);
c->func(exec_ctx, c->arg, NULL);
@@ -198,8 +198,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_httpcli_ssl_channel_security_connector* httpcli_connector =
- (grpc_httpcli_ssl_channel_security_connector*)sc;
+ grpc_httpcli_ssl_channel_security_connector *httpcli_connector =
+ (grpc_httpcli_ssl_channel_security_connector *)sc;
grpc_channel_security_connector_create_handshakers(
exec_ctx, sc, httpcli_connector->handshake_mgr);
grpc_handshake_manager_do_handshake(
diff --git a/src/core/lib/security/transport/security_connector.c b/src/core/lib/security/transport/security_connector.c
index cb2e8a2d9a..a2e0c7c7c7 100644
--- a/src/core/lib/security/transport/security_connector.c
+++ b/src/core/lib/security/transport/security_connector.c
@@ -238,9 +238,7 @@ static void fake_channel_destroy(grpc_security_connector *sc) {
gpr_free(sc);
}
-static void fake_server_destroy(grpc_security_connector *sc) {
- gpr_free(sc);
-}
+static void fake_server_destroy(grpc_security_connector *sc) { gpr_free(sc); }
static void fake_check_peer(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, tsi_peer peer,
@@ -387,15 +385,15 @@ static grpc_security_status ssl_create_handshaker(
static void ssl_channel_create_handshakers(
grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
grpc_handshake_manager *handshake_mgr) {
- grpc_ssl_channel_security_connector* c =
- (grpc_ssl_channel_security_connector*)sc;
+ grpc_ssl_channel_security_connector *c =
+ (grpc_ssl_channel_security_connector *)sc;
// Instantiate TSI handshaker.
tsi_handshaker *tsi_hs = NULL;
- ssl_create_handshaker(
- c->handshaker_factory, true /* is_client */,
- c->overridden_target_name != NULL ? c->overridden_target_name
- : c->target_name,
- &tsi_hs);
+ ssl_create_handshaker(c->handshaker_factory, true /* is_client */,
+ c->overridden_target_name != NULL
+ ? c->overridden_target_name
+ : c->target_name,
+ &tsi_hs);
// Create handshakers.
grpc_security_create_handshakers(exec_ctx, tsi_hs, &sc->base, handshake_mgr);
}
@@ -403,13 +401,12 @@ static void ssl_channel_create_handshakers(
static void ssl_server_create_handshakers(
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc,
grpc_handshake_manager *handshake_mgr) {
- grpc_ssl_server_security_connector* c =
- (grpc_ssl_server_security_connector*)sc;
+ grpc_ssl_server_security_connector *c =
+ (grpc_ssl_server_security_connector *)sc;
// Instantiate TSI handshaker.
tsi_handshaker *tsi_hs = NULL;
- ssl_create_handshaker(
- c->handshaker_factory, false /* is_client */, NULL /* peer_name */,
- &tsi_hs);
+ 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);
}
@@ -475,8 +472,8 @@ static grpc_error *ssl_check_peer(grpc_security_connector *sc,
const tsi_peer_property *p =
tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
if (p == NULL) {
- return GRPC_ERROR_CREATE("Cannot check peer: "
- "missing selected ALPN property.");
+ return GRPC_ERROR_CREATE(
+ "Cannot check peer: missing selected ALPN property.");
}
if (!grpc_chttp2_is_alpn_version_supported(p->value.data, p->value.length)) {
return GRPC_ERROR_CREATE("Cannot check peer: invalid ALPN value.");
diff --git a/src/core/lib/security/transport/security_connector.h b/src/core/lib/security/transport/security_connector.h
index 0e4e0aa720..696db0e02e 100644
--- a/src/core/lib/security/transport/security_connector.h
+++ b/src/core/lib/security/transport/security_connector.h
@@ -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 (*create_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. */
@@ -158,9 +158,9 @@ 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 (*create_handshakers)(grpc_exec_ctx *exec_ctx,
+ grpc_server_security_connector *sc,
+ grpc_handshake_manager *handshake_mgr);
};
void grpc_server_security_connector_create_handshakers(
diff --git a/src/core/lib/security/transport/security_handshaker.c b/src/core/lib/security/transport/security_handshaker.c
index 61144bf436..65982bbc85 100644
--- a/src/core/lib/security/transport/security_handshaker.c
+++ b/src/core/lib/security/transport/security_handshaker.c
@@ -64,8 +64,8 @@ typedef struct {
grpc_slice_buffer *read_buffer_to_destroy;
// State saved while performing the handshake.
- grpc_handshaker_args* args;
- grpc_closure* on_handshake_done;
+ grpc_handshaker_args *args;
+ grpc_closure *on_handshake_done;
unsigned char *handshake_buffer;
size_t handshake_buffer_size;
@@ -156,9 +156,8 @@ static void on_peer_checked(grpc_exec_ctx *exec_ctx, void *arg,
}
// Success.
// Create secure endpoint.
- h->args->endpoint =
- grpc_secure_endpoint_create(protector, h->args->endpoint,
- h->left_overs.slices, h->left_overs.count);
+ h->args->endpoint = grpc_secure_endpoint_create(
+ protector, h->args->endpoint, h->left_overs.slices, h->left_overs.count);
h->left_overs.count = 0;
h->left_overs.length = 0;
// Clear out the read buffer before it gets passed to the transport,
@@ -166,7 +165,7 @@ static void on_peer_checked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_slice_buffer_reset_and_unref(h->args->read_buffer);
// Add auth context to channel args.
grpc_arg auth_context_arg = grpc_auth_context_to_arg(h->auth_context);
- grpc_channel_args* tmp_args = h->args->args;
+ grpc_channel_args *tmp_args = h->args->args;
h->args->args =
grpc_channel_args_copy_and_add(tmp_args, &auth_context_arg, 1);
grpc_channel_args_destroy(tmp_args);
@@ -180,7 +179,7 @@ done:
security_handshaker_unref(exec_ctx, h);
}
-static grpc_error* check_peer_locked(grpc_exec_ctx *exec_ctx,
+static grpc_error *check_peer_locked(grpc_exec_ctx *exec_ctx,
security_handshaker *h) {
tsi_peer peer;
tsi_result result = tsi_handshaker_extract_peer(h->handshaker, &peer);
@@ -193,7 +192,7 @@ static grpc_error* check_peer_locked(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* send_handshake_bytes_to_peer_locked(grpc_exec_ctx *exec_ctx,
+static grpc_error *send_handshake_bytes_to_peer_locked(grpc_exec_ctx *exec_ctx,
security_handshaker *h) {
// Get data to send.
tsi_result result = TSI_OK;
@@ -265,9 +264,8 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
}
if (result != TSI_OK) {
security_handshake_failed_locked(
- exec_ctx, h,
- grpc_set_tsi_error_result(GRPC_ERROR_CREATE("Handshake failed"),
- result));
+ exec_ctx, h, grpc_set_tsi_error_result(
+ GRPC_ERROR_CREATE("Handshake failed"), result));
gpr_mu_unlock(&h->mu);
security_handshaker_unref(exec_ctx, h);
return;
@@ -276,16 +274,15 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
bool has_left_overs_in_current_slice =
(consumed_slice_size <
GRPC_SLICE_LENGTH(h->args->read_buffer->slices[i]));
- size_t num_left_overs =
- (has_left_overs_in_current_slice ? 1 : 0)
- + h->args->read_buffer->count - i - 1;
+ size_t num_left_overs = (has_left_overs_in_current_slice ? 1 : 0) +
+ h->args->read_buffer->count - i - 1;
if (num_left_overs > 0) {
/* Put the leftovers in our buffer (ownership transfered). */
if (has_left_overs_in_current_slice) {
grpc_slice_buffer_add(
&h->left_overs,
grpc_slice_split_tail(&h->args->read_buffer->slices[i],
- consumed_slice_size));
+ consumed_slice_size));
/* split_tail above increments refcount. */
grpc_slice_unref(h->args->read_buffer->slices[i]);
}
@@ -305,8 +302,8 @@ done:
gpr_mu_unlock(&h->mu);
}
-static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error) {
+static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx, void *arg,
+ grpc_error *error) {
security_handshaker *h = arg;
gpr_mu_lock(&h->mu);
if (error != GRPC_ERROR_NONE || h->shutdown) {
@@ -337,15 +334,15 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx,
// public handshaker API
//
-static void security_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {
- security_handshaker* h = (security_handshaker*)handshaker;
+static void security_handshaker_destroy(grpc_exec_ctx *exec_ctx,
+ grpc_handshaker *handshaker) {
+ security_handshaker *h = (security_handshaker *)handshaker;
security_handshaker_unref(exec_ctx, h);
}
-static void security_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {
- security_handshaker *h = (security_handshaker*)handshaker;
+static void security_handshaker_shutdown(grpc_exec_ctx *exec_ctx,
+ grpc_handshaker *handshaker) {
+ security_handshaker *h = (security_handshaker *)handshaker;
gpr_mu_lock(&h->mu);
if (!h->shutdown) {
h->shutdown = true;
@@ -355,16 +352,17 @@ static void security_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&h->mu);
}
-static void security_handshaker_do_handshake(
- grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker,
- grpc_tcp_server_acceptor* acceptor, grpc_closure* on_handshake_done,
- grpc_handshaker_args* args) {
- security_handshaker* h = (security_handshaker*)handshaker;
+static void security_handshaker_do_handshake(grpc_exec_ctx *exec_ctx,
+ grpc_handshaker *handshaker,
+ grpc_tcp_server_acceptor *acceptor,
+ grpc_closure *on_handshake_done,
+ grpc_handshaker_args *args) {
+ security_handshaker *h = (security_handshaker *)handshaker;
gpr_mu_lock(&h->mu);
h->args = args;
h->on_handshake_done = on_handshake_done;
gpr_ref(&h->refs);
- grpc_error* error = send_handshake_bytes_to_peer_locked(exec_ctx, h);
+ grpc_error *error = send_handshake_bytes_to_peer_locked(exec_ctx, h);
if (error != GRPC_ERROR_NONE) {
security_handshake_failed_locked(exec_ctx, h, error);
gpr_mu_unlock(&h->mu);
@@ -375,10 +373,10 @@ static void security_handshaker_do_handshake(
}
static const grpc_handshaker_vtable security_handshaker_vtable = {
- security_handshaker_destroy, security_handshaker_shutdown,
- security_handshaker_do_handshake};
+ security_handshaker_destroy, security_handshaker_shutdown,
+ security_handshaker_do_handshake};
-static grpc_handshaker* security_handshaker_create(
+static grpc_handshaker *security_handshaker_create(
grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker,
grpc_security_connector *connector) {
security_handshaker *h = gpr_malloc(sizeof(security_handshaker));
@@ -404,29 +402,30 @@ static grpc_handshaker* security_handshaker_create(
// fail_handshaker
//
-static void fail_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {
+static void fail_handshaker_destroy(grpc_exec_ctx *exec_ctx,
+ grpc_handshaker *handshaker) {
gpr_free(handshaker);
}
-static void fail_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {}
-
-static void fail_handshaker_do_handshake(
- grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker,
- grpc_tcp_server_acceptor* acceptor, grpc_closure* on_handshake_done,
- grpc_handshaker_args* args) {
- grpc_exec_ctx_sched(
- exec_ctx, on_handshake_done,
- GRPC_ERROR_CREATE("Failed to create security handshaker"), NULL);
+static void fail_handshaker_shutdown(grpc_exec_ctx *exec_ctx,
+ grpc_handshaker *handshaker) {}
+
+static void fail_handshaker_do_handshake(grpc_exec_ctx *exec_ctx,
+ grpc_handshaker *handshaker,
+ grpc_tcp_server_acceptor *acceptor,
+ grpc_closure *on_handshake_done,
+ grpc_handshaker_args *args) {
+ grpc_exec_ctx_sched(exec_ctx, on_handshake_done,
+ GRPC_ERROR_CREATE("Failed to create security handshaker"),
+ NULL);
}
static const grpc_handshaker_vtable fail_handshaker_vtable = {
- fail_handshaker_destroy, fail_handshaker_shutdown,
- fail_handshaker_do_handshake};
+ fail_handshaker_destroy, fail_handshaker_shutdown,
+ fail_handshaker_do_handshake};
-static grpc_handshaker* fail_handshaker_create() {
- grpc_handshaker* h = gpr_malloc(sizeof(*h));
+static grpc_handshaker *fail_handshaker_create() {
+ grpc_handshaker *h = gpr_malloc(sizeof(*h));
grpc_handshaker_init(&fail_handshaker_vtable, h);
return h;
}
@@ -435,9 +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_create_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) {
diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h
index 9d4157e869..f71f43a359 100644
--- a/src/core/lib/security/transport/security_handshaker.h
+++ b/src/core/lib/security/transport/security_handshaker.h
@@ -39,8 +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_create_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 */