blob: 8ac4dd1e0e201351c9b7fdc2da69d406b793c56a [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Craig Tiller06059952015-02-18 08:34:56 -08003 * Copyright 2015, Google Inc.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34#include "src/core/surface/client.h"
35
36#include "src/core/surface/call.h"
Craig Tillerda669372015-02-05 10:10:15 -080037#include "src/core/surface/channel.h"
Craig Tiller485d7762015-01-23 12:54:05 -080038#include "src/core/support/string.h"
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080039#include <grpc/support/alloc.h>
40#include <grpc/support/log.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080041
Craig Tiller87d5b192015-04-16 14:37:57 -070042typedef struct { void *unused; } call_data;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080043
Craig Tiller87d5b192015-04-16 14:37:57 -070044typedef struct { void *unused; } channel_data;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080045
Craig Tiller06aeea72015-04-23 10:54:45 -070046static void client_start_transport_op(grpc_call_element *elem,
47 grpc_transport_op *op) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080048 GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
Craig Tillerbe18b8d2015-04-22 14:00:47 -070049 grpc_call_next_op(elem, op);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080050}
51
ctillerf962f522014-12-10 15:28:27 -080052static void channel_op(grpc_channel_element *elem,
53 grpc_channel_element *from_elem, grpc_channel_op *op) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080054 switch (op->type) {
55 case GRPC_ACCEPT_CALL:
56 gpr_log(GPR_ERROR, "Client cannot accept new calls");
57 break;
58 case GRPC_TRANSPORT_CLOSED:
Craig Tillerda669372015-02-05 10:10:15 -080059 grpc_client_channel_closed(elem);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080060 break;
nnoble0c475f02014-12-05 15:37:39 -080061 case GRPC_TRANSPORT_GOAWAY:
62 gpr_slice_unref(op->data.goaway.message);
63 break;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080064 default:
65 GPR_ASSERT(op->dir == GRPC_CALL_DOWN);
66 grpc_channel_next_op(elem, op);
67 }
68}
69
70static void init_call_elem(grpc_call_element *elem,
Craig Tiller06aeea72015-04-23 10:54:45 -070071 const void *transport_server_data,
72 grpc_transport_op *initial_op) {}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080073
74static void destroy_call_elem(grpc_call_element *elem) {}
75
76static void init_channel_elem(grpc_channel_element *elem,
77 const grpc_channel_args *args, grpc_mdctx *mdctx,
78 int is_first, int is_last) {
79 GPR_ASSERT(is_first);
80 GPR_ASSERT(!is_last);
81}
82
Craig Tillerb5dcec52015-01-13 11:13:42 -080083static void destroy_channel_elem(grpc_channel_element *elem) {}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080084
85const grpc_channel_filter grpc_client_surface_filter = {
Craig Tiller06aeea72015-04-23 10:54:45 -070086 client_start_transport_op, channel_op, sizeof(call_data), init_call_elem,
87 destroy_call_elem, sizeof(channel_data), init_channel_elem,
88 destroy_channel_elem, "client",
Craig Tiller87d5b192015-04-16 14:37:57 -070089};