blob: 366c452942787df6287e133ea8a3733be257c0b3 [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2016 gRPC authors.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080016 *
17 */
18
Craig Tiller9533d042016-03-25 17:11:06 -070019#include "src/core/lib/surface/channel_stack_type.h"
Craig Tiller178edfa2016-02-17 20:54:46 -080020#include <grpc/support/log.h>
Craig Tillerf40df232016-03-25 13:38:14 -070021#include <grpc/support/port_platform.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080022
Craig Tiller178edfa2016-02-17 20:54:46 -080023bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type) {
24 switch (type) {
25 case GRPC_CLIENT_CHANNEL:
26 return true;
Craig Tiller178edfa2016-02-17 20:54:46 -080027 case GRPC_CLIENT_SUBCHANNEL:
28 return true;
29 case GRPC_CLIENT_LAME_CHANNEL:
30 return true;
Craig Tillerde676262016-02-19 12:28:34 -080031 case GRPC_CLIENT_DIRECT_CHANNEL:
32 return true;
Craig Tiller178edfa2016-02-17 20:54:46 -080033 case GRPC_SERVER_CHANNEL:
34 return false;
35 case GRPC_NUM_CHANNEL_STACK_TYPES:
36 break;
37 }
38 GPR_UNREACHABLE_CODE(return true;);
Craig Tiller190d3602015-02-18 09:23:38 -080039}
Craig Tiller4f89b0b2017-04-03 10:00:17 -070040
Craig Tillerbaa14a92017-11-03 09:09:36 -070041const char* grpc_channel_stack_type_string(grpc_channel_stack_type type) {
Craig Tiller4f89b0b2017-04-03 10:00:17 -070042 switch (type) {
43 case GRPC_CLIENT_CHANNEL:
44 return "CLIENT_CHANNEL";
45 case GRPC_CLIENT_SUBCHANNEL:
46 return "CLIENT_SUBCHANNEL";
47 case GRPC_SERVER_CHANNEL:
48 return "SERVER_CHANNEL";
49 case GRPC_CLIENT_LAME_CHANNEL:
50 return "CLIENT_LAME_CHANNEL";
51 case GRPC_CLIENT_DIRECT_CHANNEL:
52 return "CLIENT_DIRECT_CHANNEL";
53 case GRPC_NUM_CHANNEL_STACK_TYPES:
54 break;
55 }
56 GPR_UNREACHABLE_CODE(return "UNKNOWN");
57}