aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/tsi/fake_transport_security.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/tsi/fake_transport_security.cc')
-rw-r--r--src/core/tsi/fake_transport_security.cc216
1 files changed, 109 insertions, 107 deletions
diff --git a/src/core/tsi/fake_transport_security.cc b/src/core/tsi/fake_transport_security.cc
index 349dcf5cb8..b12dde31fb 100644
--- a/src/core/tsi/fake_transport_security.cc
+++ b/src/core/tsi/fake_transport_security.cc
@@ -41,7 +41,7 @@
where the size field value is the size of the size field plus the size of
the data encoded in little endian on 4 bytes. */
typedef struct {
- unsigned char *data;
+ unsigned char* data;
size_t size;
size_t allocated_size;
size_t offset;
@@ -63,7 +63,7 @@ typedef struct {
int needs_incoming_message;
tsi_fake_frame incoming_frame;
tsi_fake_frame outgoing_frame;
- unsigned char *outgoing_bytes_buffer;
+ unsigned char* outgoing_bytes_buffer;
size_t outgoing_bytes_buffer_size;
tsi_result result;
} tsi_fake_handshaker;
@@ -85,10 +85,10 @@ typedef struct {
/* --- Utils. ---*/
-static const char *tsi_fake_handshake_message_strings[] = {
+static const char* tsi_fake_handshake_message_strings[] = {
"CLIENT_INIT", "SERVER_INIT", "CLIENT_FINISHED", "SERVER_FINISHED"};
-static const char *tsi_fake_handshake_message_to_string(int msg) {
+static const char* tsi_fake_handshake_message_to_string(int msg) {
if (msg < 0 || msg >= TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
gpr_log(GPR_ERROR, "Invalid message %d", msg);
return "UNKNOWN";
@@ -97,7 +97,7 @@ static const char *tsi_fake_handshake_message_to_string(int msg) {
}
static tsi_result tsi_fake_handshake_message_from_string(
- const char *msg_string, tsi_fake_handshake_message *msg) {
+ const char* msg_string, tsi_fake_handshake_message* msg) {
for (int i = 0; i < TSI_FAKE_HANDSHAKE_MESSAGE_MAX; i++) {
if (strncmp(msg_string, tsi_fake_handshake_message_strings[i],
strlen(tsi_fake_handshake_message_strings[i])) == 0) {
@@ -109,22 +109,22 @@ static tsi_result tsi_fake_handshake_message_from_string(
return TSI_DATA_CORRUPTED;
}
-static uint32_t load32_little_endian(const unsigned char *buf) {
+static uint32_t load32_little_endian(const unsigned char* buf) {
return ((uint32_t)(buf[0]) | (uint32_t)(buf[1] << 8) |
(uint32_t)(buf[2] << 16) | (uint32_t)(buf[3] << 24));
}
-static void store32_little_endian(uint32_t value, unsigned char *buf) {
+static void store32_little_endian(uint32_t value, unsigned char* buf) {
buf[3] = (unsigned char)((value >> 24) & 0xFF);
buf[2] = (unsigned char)((value >> 16) & 0xFF);
buf[1] = (unsigned char)((value >> 8) & 0xFF);
buf[0] = (unsigned char)((value)&0xFF);
}
-static uint32_t read_frame_size(const grpc_slice_buffer *sb) {
+static uint32_t read_frame_size(const grpc_slice_buffer* sb) {
GPR_ASSERT(sb != NULL && sb->length >= TSI_FAKE_FRAME_HEADER_SIZE);
uint8_t frame_size_buffer[TSI_FAKE_FRAME_HEADER_SIZE];
- uint8_t *buf = frame_size_buffer;
+ uint8_t* buf = frame_size_buffer;
/* Copies the first 4 bytes to a temporary buffer. */
size_t remaining = TSI_FAKE_FRAME_HEADER_SIZE;
for (size_t i = 0; i < sb->count; i++) {
@@ -143,7 +143,7 @@ static uint32_t read_frame_size(const grpc_slice_buffer *sb) {
return load32_little_endian(frame_size_buffer);
}
-static void tsi_fake_frame_reset(tsi_fake_frame *frame, int needs_draining) {
+static void tsi_fake_frame_reset(tsi_fake_frame* frame, int needs_draining) {
frame->offset = 0;
frame->needs_draining = needs_draining;
if (!needs_draining) frame->size = 0;
@@ -151,13 +151,13 @@ static void tsi_fake_frame_reset(tsi_fake_frame *frame, int needs_draining) {
/* Checks if the frame's allocated size is at least frame->size, and reallocs
* more memory if necessary. */
-static void tsi_fake_frame_ensure_size(tsi_fake_frame *frame) {
+static void tsi_fake_frame_ensure_size(tsi_fake_frame* frame) {
if (frame->data == NULL) {
frame->allocated_size = frame->size;
- frame->data = (unsigned char *)gpr_malloc(frame->allocated_size);
+ frame->data = (unsigned char*)gpr_malloc(frame->allocated_size);
} else if (frame->size > frame->allocated_size) {
- unsigned char *new_data =
- (unsigned char *)gpr_realloc(frame->data, frame->size);
+ unsigned char* new_data =
+ (unsigned char*)gpr_realloc(frame->data, frame->size);
frame->data = new_data;
frame->allocated_size = frame->size;
}
@@ -166,17 +166,17 @@ static void tsi_fake_frame_ensure_size(tsi_fake_frame *frame) {
/* Decodes the serialized fake frame contained in incoming_bytes, and fills
* frame with the contents of the decoded frame.
* This method should not be called if frame->needs_framing is not 0. */
-static tsi_result tsi_fake_frame_decode(const unsigned char *incoming_bytes,
- size_t *incoming_bytes_size,
- tsi_fake_frame *frame) {
+static tsi_result tsi_fake_frame_decode(const unsigned char* incoming_bytes,
+ size_t* incoming_bytes_size,
+ tsi_fake_frame* frame) {
size_t available_size = *incoming_bytes_size;
size_t to_read_size = 0;
- const unsigned char *bytes_cursor = incoming_bytes;
+ const unsigned char* bytes_cursor = incoming_bytes;
if (frame->needs_draining) return TSI_INTERNAL_ERROR;
if (frame->data == NULL) {
frame->allocated_size = TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE;
- frame->data = (unsigned char *)gpr_malloc(frame->allocated_size);
+ frame->data = (unsigned char*)gpr_malloc(frame->allocated_size);
}
if (frame->offset < TSI_FAKE_FRAME_HEADER_SIZE) {
@@ -215,9 +215,9 @@ static tsi_result tsi_fake_frame_decode(const unsigned char *incoming_bytes,
/* Encodes a fake frame into its wire format and places the result in
* outgoing_bytes. outgoing_bytes_size indicates the size of the encoded frame.
* This method should not be called if frame->needs_framing is 0. */
-static tsi_result tsi_fake_frame_encode(unsigned char *outgoing_bytes,
- size_t *outgoing_bytes_size,
- tsi_fake_frame *frame) {
+static tsi_result tsi_fake_frame_encode(unsigned char* outgoing_bytes,
+ size_t* outgoing_bytes_size,
+ tsi_fake_frame* frame) {
size_t to_write_size = frame->size - frame->offset;
if (!frame->needs_draining) return TSI_INTERNAL_ERROR;
if (*outgoing_bytes_size < to_write_size) {
@@ -233,8 +233,8 @@ static tsi_result tsi_fake_frame_encode(unsigned char *outgoing_bytes,
/* Sets the payload of a fake frame to contain the given data blob, where
* data_size indicates the size of data. */
-static tsi_result tsi_fake_frame_set_data(unsigned char *data, size_t data_size,
- tsi_fake_frame *frame) {
+static tsi_result tsi_fake_frame_set_data(unsigned char* data, size_t data_size,
+ tsi_fake_frame* frame) {
frame->offset = 0;
frame->size = data_size + TSI_FAKE_FRAME_HEADER_SIZE;
tsi_fake_frame_ensure_size(frame);
@@ -245,24 +245,24 @@ static tsi_result tsi_fake_frame_set_data(unsigned char *data, size_t data_size,
}
/* Destroys the contents of a fake frame. */
-static void tsi_fake_frame_destruct(tsi_fake_frame *frame) {
+static void tsi_fake_frame_destruct(tsi_fake_frame* frame) {
if (frame->data != NULL) gpr_free(frame->data);
}
/* --- tsi_frame_protector methods implementation. ---*/
-static tsi_result fake_protector_protect(tsi_frame_protector *self,
- const unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size,
- unsigned char *protected_output_frames,
- size_t *protected_output_frames_size) {
+static tsi_result fake_protector_protect(tsi_frame_protector* self,
+ const unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size,
+ unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size) {
tsi_result result = TSI_OK;
- tsi_fake_frame_protector *impl = (tsi_fake_frame_protector *)self;
+ tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self;
unsigned char frame_header[TSI_FAKE_FRAME_HEADER_SIZE];
- tsi_fake_frame *frame = &impl->protect_frame;
+ tsi_fake_frame* frame = &impl->protect_frame;
size_t saved_output_size = *protected_output_frames_size;
size_t drained_size = 0;
- size_t *num_bytes_written = protected_output_frames_size;
+ size_t* num_bytes_written = protected_output_frames_size;
*num_bytes_written = 0;
/* Try to drain first. */
@@ -313,11 +313,11 @@ static tsi_result fake_protector_protect(tsi_frame_protector *self,
}
static tsi_result fake_protector_protect_flush(
- tsi_frame_protector *self, unsigned char *protected_output_frames,
- size_t *protected_output_frames_size, size_t *still_pending_size) {
+ tsi_frame_protector* self, unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size, size_t* still_pending_size) {
tsi_result result = TSI_OK;
- tsi_fake_frame_protector *impl = (tsi_fake_frame_protector *)self;
- tsi_fake_frame *frame = &impl->protect_frame;
+ tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self;
+ tsi_fake_frame* frame = &impl->protect_frame;
if (!frame->needs_draining) {
/* Create a short frame. */
frame->size = frame->offset;
@@ -334,15 +334,15 @@ static tsi_result fake_protector_protect_flush(
}
static tsi_result fake_protector_unprotect(
- tsi_frame_protector *self, const unsigned char *protected_frames_bytes,
- size_t *protected_frames_bytes_size, unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size) {
+ tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
+ size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size) {
tsi_result result = TSI_OK;
- tsi_fake_frame_protector *impl = (tsi_fake_frame_protector *)self;
- tsi_fake_frame *frame = &impl->unprotect_frame;
+ tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self;
+ tsi_fake_frame* frame = &impl->unprotect_frame;
size_t saved_output_size = *unprotected_bytes_size;
size_t drained_size = 0;
- size_t *num_bytes_written = unprotected_bytes_size;
+ size_t* num_bytes_written = unprotected_bytes_size;
*num_bytes_written = 0;
/* Try to drain first. */
@@ -382,29 +382,31 @@ static tsi_result fake_protector_unprotect(
return result;
}
-static void fake_protector_destroy(tsi_frame_protector *self) {
- tsi_fake_frame_protector *impl = (tsi_fake_frame_protector *)self;
+static void fake_protector_destroy(tsi_frame_protector* self) {
+ tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self;
tsi_fake_frame_destruct(&impl->protect_frame);
tsi_fake_frame_destruct(&impl->unprotect_frame);
gpr_free(self);
}
static const tsi_frame_protector_vtable frame_protector_vtable = {
- fake_protector_protect, fake_protector_protect_flush,
- fake_protector_unprotect, fake_protector_destroy,
+ fake_protector_protect,
+ fake_protector_protect_flush,
+ fake_protector_unprotect,
+ fake_protector_destroy,
};
/* --- tsi_zero_copy_grpc_protector methods implementation. ---*/
static tsi_result fake_zero_copy_grpc_protector_protect(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *unprotected_slices,
- grpc_slice_buffer *protected_slices) {
+ grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self,
+ grpc_slice_buffer* unprotected_slices,
+ grpc_slice_buffer* protected_slices) {
if (self == NULL || unprotected_slices == NULL || protected_slices == NULL) {
return TSI_INVALID_ARGUMENT;
}
- tsi_fake_zero_copy_grpc_protector *impl =
- (tsi_fake_zero_copy_grpc_protector *)self;
+ tsi_fake_zero_copy_grpc_protector* impl =
+ (tsi_fake_zero_copy_grpc_protector*)self;
/* Protects each frame. */
while (unprotected_slices->length > 0) {
size_t frame_length =
@@ -421,14 +423,14 @@ static tsi_result fake_zero_copy_grpc_protector_protect(
}
static tsi_result fake_zero_copy_grpc_protector_unprotect(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *protected_slices,
- grpc_slice_buffer *unprotected_slices) {
+ grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self,
+ grpc_slice_buffer* protected_slices,
+ grpc_slice_buffer* unprotected_slices) {
if (self == NULL || unprotected_slices == NULL || protected_slices == NULL) {
return TSI_INVALID_ARGUMENT;
}
- tsi_fake_zero_copy_grpc_protector *impl =
- (tsi_fake_zero_copy_grpc_protector *)self;
+ tsi_fake_zero_copy_grpc_protector* impl =
+ (tsi_fake_zero_copy_grpc_protector*)self;
grpc_slice_buffer_move_into(protected_slices, &impl->protected_sb);
/* Unprotect each frame, if we get a full frame. */
while (impl->protected_sb.length >= TSI_FAKE_FRAME_HEADER_SIZE) {
@@ -456,10 +458,10 @@ static tsi_result fake_zero_copy_grpc_protector_unprotect(
}
static void fake_zero_copy_grpc_protector_destroy(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self) {
+ grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self) {
if (self == NULL) return;
- tsi_fake_zero_copy_grpc_protector *impl =
- (tsi_fake_zero_copy_grpc_protector *)self;
+ tsi_fake_zero_copy_grpc_protector* impl =
+ (tsi_fake_zero_copy_grpc_protector*)self;
grpc_slice_buffer_destroy_internal(exec_ctx, &impl->header_sb);
grpc_slice_buffer_destroy_internal(exec_ctx, &impl->protected_sb);
gpr_free(impl);
@@ -476,12 +478,12 @@ static const tsi_zero_copy_grpc_protector_vtable
typedef struct {
tsi_handshaker_result base;
- unsigned char *unused_bytes;
+ unsigned char* unused_bytes;
size_t unused_bytes_size;
} fake_handshaker_result;
static tsi_result fake_handshaker_result_extract_peer(
- const tsi_handshaker_result *self, tsi_peer *peer) {
+ const tsi_handshaker_result* self, tsi_peer* peer) {
/* Construct a tsi_peer with 1 property: certificate type. */
tsi_result result = tsi_construct_peer(1, peer);
if (result != TSI_OK) return result;
@@ -493,32 +495,32 @@ static tsi_result fake_handshaker_result_extract_peer(
}
static tsi_result fake_handshaker_result_create_zero_copy_grpc_protector(
- void *exec_ctx, const tsi_handshaker_result *self,
- size_t *max_output_protected_frame_size,
- tsi_zero_copy_grpc_protector **protector) {
+ void* exec_ctx, const tsi_handshaker_result* self,
+ size_t* max_output_protected_frame_size,
+ tsi_zero_copy_grpc_protector** protector) {
*protector =
tsi_create_fake_zero_copy_grpc_protector(max_output_protected_frame_size);
return TSI_OK;
}
static tsi_result fake_handshaker_result_create_frame_protector(
- const tsi_handshaker_result *self, size_t *max_output_protected_frame_size,
- tsi_frame_protector **protector) {
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
+ tsi_frame_protector** protector) {
*protector = tsi_create_fake_frame_protector(max_output_protected_frame_size);
return TSI_OK;
}
static tsi_result fake_handshaker_result_get_unused_bytes(
- const tsi_handshaker_result *self, const unsigned char **bytes,
- size_t *bytes_size) {
- fake_handshaker_result *result = (fake_handshaker_result *)self;
+ const tsi_handshaker_result* self, const unsigned char** bytes,
+ size_t* bytes_size) {
+ fake_handshaker_result* result = (fake_handshaker_result*)self;
*bytes_size = result->unused_bytes_size;
*bytes = result->unused_bytes;
return TSI_OK;
}
-static void fake_handshaker_result_destroy(tsi_handshaker_result *self) {
- fake_handshaker_result *result = (fake_handshaker_result *)self;
+static void fake_handshaker_result_destroy(tsi_handshaker_result* self) {
+ fake_handshaker_result* result = (fake_handshaker_result*)self;
gpr_free(result->unused_bytes);
gpr_free(self);
}
@@ -532,17 +534,17 @@ static const tsi_handshaker_result_vtable handshaker_result_vtable = {
};
static tsi_result fake_handshaker_result_create(
- const unsigned char *unused_bytes, size_t unused_bytes_size,
- tsi_handshaker_result **handshaker_result) {
+ const unsigned char* unused_bytes, size_t unused_bytes_size,
+ tsi_handshaker_result** handshaker_result) {
if ((unused_bytes_size > 0 && unused_bytes == NULL) ||
handshaker_result == NULL) {
return TSI_INVALID_ARGUMENT;
}
- fake_handshaker_result *result =
- (fake_handshaker_result *)gpr_zalloc(sizeof(*result));
+ fake_handshaker_result* result =
+ (fake_handshaker_result*)gpr_zalloc(sizeof(*result));
result->base.vtable = &handshaker_result_vtable;
if (unused_bytes_size > 0) {
- result->unused_bytes = (unsigned char *)gpr_malloc(unused_bytes_size);
+ result->unused_bytes = (unsigned char*)gpr_malloc(unused_bytes_size);
memcpy(result->unused_bytes, unused_bytes, unused_bytes_size);
}
result->unused_bytes_size = unused_bytes_size;
@@ -553,8 +555,8 @@ static tsi_result fake_handshaker_result_create(
/* --- tsi_handshaker methods implementation. ---*/
static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
- tsi_handshaker *self, unsigned char *bytes, size_t *bytes_size) {
- tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
+ tsi_handshaker* self, unsigned char* bytes, size_t* bytes_size) {
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)self;
tsi_result result = TSI_OK;
if (impl->needs_incoming_message || impl->result == TSI_OK) {
*bytes_size = 0;
@@ -563,9 +565,9 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
if (!impl->outgoing_frame.needs_draining) {
tsi_fake_handshake_message next_message_to_send =
(tsi_fake_handshake_message)(impl->next_message_to_send + 2);
- const char *msg_string =
+ const char* msg_string =
tsi_fake_handshake_message_to_string(impl->next_message_to_send);
- result = tsi_fake_frame_set_data((unsigned char *)msg_string,
+ result = tsi_fake_frame_set_data((unsigned char*)msg_string,
strlen(msg_string), &impl->outgoing_frame);
if (result != TSI_OK) return result;
if (next_message_to_send > TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
@@ -594,9 +596,9 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
}
static tsi_result fake_handshaker_process_bytes_from_peer(
- tsi_handshaker *self, const unsigned char *bytes, size_t *bytes_size) {
+ tsi_handshaker* self, const unsigned char* bytes, size_t* bytes_size) {
tsi_result result = TSI_OK;
- tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)self;
tsi_fake_handshake_message expected_msg =
(tsi_fake_handshake_message)(impl->next_message_to_send - 1);
tsi_fake_handshake_message received_msg;
@@ -610,7 +612,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
/* We now have a complete frame. */
result = tsi_fake_handshake_message_from_string(
- (const char *)impl->incoming_frame.data + TSI_FAKE_FRAME_HEADER_SIZE,
+ (const char*)impl->incoming_frame.data + TSI_FAKE_FRAME_HEADER_SIZE,
&received_msg);
if (result != TSI_OK) {
impl->result = result;
@@ -637,13 +639,13 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
return TSI_OK;
}
-static tsi_result fake_handshaker_get_result(tsi_handshaker *self) {
- tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
+static tsi_result fake_handshaker_get_result(tsi_handshaker* self) {
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)self;
return impl->result;
}
-static void fake_handshaker_destroy(tsi_handshaker *self) {
- tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
+static void fake_handshaker_destroy(tsi_handshaker* self) {
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)self;
tsi_fake_frame_destruct(&impl->incoming_frame);
tsi_fake_frame_destruct(&impl->outgoing_frame);
gpr_free(impl->outgoing_bytes_buffer);
@@ -651,17 +653,17 @@ static void fake_handshaker_destroy(tsi_handshaker *self) {
}
static tsi_result fake_handshaker_next(
- tsi_handshaker *self, const unsigned char *received_bytes,
- size_t received_bytes_size, const unsigned char **bytes_to_send,
- size_t *bytes_to_send_size, tsi_handshaker_result **handshaker_result,
- tsi_handshaker_on_next_done_cb cb, void *user_data) {
+ tsi_handshaker* self, const unsigned char* received_bytes,
+ size_t received_bytes_size, const unsigned char** bytes_to_send,
+ size_t* bytes_to_send_size, tsi_handshaker_result** handshaker_result,
+ tsi_handshaker_on_next_done_cb cb, void* user_data) {
/* Sanity check the arguments. */
if ((received_bytes_size > 0 && received_bytes == NULL) ||
bytes_to_send == NULL || bytes_to_send_size == NULL ||
handshaker_result == NULL) {
return TSI_INVALID_ARGUMENT;
}
- tsi_fake_handshaker *handshaker = (tsi_fake_handshaker *)self;
+ tsi_fake_handshaker* handshaker = (tsi_fake_handshaker*)self;
tsi_result result = TSI_OK;
/* Decode and process a handshake frame from the peer. */
@@ -683,8 +685,8 @@ static tsi_result fake_handshaker_next(
if (result == TSI_INCOMPLETE_DATA) {
handshaker->outgoing_bytes_buffer_size *= 2;
handshaker->outgoing_bytes_buffer =
- (unsigned char *)gpr_realloc(handshaker->outgoing_bytes_buffer,
- handshaker->outgoing_bytes_buffer_size);
+ (unsigned char*)gpr_realloc(handshaker->outgoing_bytes_buffer,
+ handshaker->outgoing_bytes_buffer_size);
}
} while (result == TSI_INCOMPLETE_DATA);
if (result != TSI_OK) return result;
@@ -696,7 +698,7 @@ static tsi_result fake_handshaker_next(
*handshaker_result = NULL;
} else {
/* Calculate the unused bytes. */
- const unsigned char *unused_bytes = NULL;
+ const unsigned char* unused_bytes = NULL;
size_t unused_bytes_size = received_bytes_size - consumed_bytes_size;
if (unused_bytes_size > 0) {
unused_bytes = received_bytes + consumed_bytes_size;
@@ -724,15 +726,15 @@ static const tsi_handshaker_vtable handshaker_vtable = {
fake_handshaker_next,
};
-tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
- tsi_fake_handshaker *impl = (tsi_fake_handshaker *)gpr_zalloc(sizeof(*impl));
+tsi_handshaker* tsi_create_fake_handshaker(int is_client) {
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)gpr_zalloc(sizeof(*impl));
impl->base.vtable = &handshaker_vtable;
impl->is_client = is_client;
impl->result = TSI_HANDSHAKE_IN_PROGRESS;
impl->outgoing_bytes_buffer_size =
TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE;
impl->outgoing_bytes_buffer =
- (unsigned char *)gpr_malloc(impl->outgoing_bytes_buffer_size);
+ (unsigned char*)gpr_malloc(impl->outgoing_bytes_buffer_size);
if (is_client) {
impl->needs_incoming_message = 0;
impl->next_message_to_send = TSI_FAKE_CLIENT_INIT;
@@ -743,10 +745,10 @@ tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
return &impl->base;
}
-tsi_frame_protector *tsi_create_fake_frame_protector(
- size_t *max_protected_frame_size) {
- tsi_fake_frame_protector *impl =
- (tsi_fake_frame_protector *)gpr_zalloc(sizeof(*impl));
+tsi_frame_protector* tsi_create_fake_frame_protector(
+ size_t* max_protected_frame_size) {
+ tsi_fake_frame_protector* impl =
+ (tsi_fake_frame_protector*)gpr_zalloc(sizeof(*impl));
impl->max_frame_size = (max_protected_frame_size == NULL)
? TSI_FAKE_DEFAULT_FRAME_SIZE
: *max_protected_frame_size;
@@ -754,10 +756,10 @@ tsi_frame_protector *tsi_create_fake_frame_protector(
return &impl->base;
}
-tsi_zero_copy_grpc_protector *tsi_create_fake_zero_copy_grpc_protector(
- size_t *max_protected_frame_size) {
- tsi_fake_zero_copy_grpc_protector *impl =
- (tsi_fake_zero_copy_grpc_protector *)gpr_zalloc(sizeof(*impl));
+tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector(
+ size_t* max_protected_frame_size) {
+ tsi_fake_zero_copy_grpc_protector* impl =
+ (tsi_fake_zero_copy_grpc_protector*)gpr_zalloc(sizeof(*impl));
grpc_slice_buffer_init(&impl->header_sb);
grpc_slice_buffer_init(&impl->protected_sb);
impl->max_frame_size = (max_protected_frame_size == NULL)