Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2016 gRPC authors. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | * 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 Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | * 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 Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 19 | #include "src/core/lib/surface/channel_stack_type.h" |
Craig Tiller | 178edfa | 2016-02-17 20:54:46 -0800 | [diff] [blame] | 20 | #include <grpc/support/log.h> |
Craig Tiller | f40df23 | 2016-03-25 13:38:14 -0700 | [diff] [blame] | 21 | #include <grpc/support/port_platform.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 22 | |
Craig Tiller | 178edfa | 2016-02-17 20:54:46 -0800 | [diff] [blame] | 23 | bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type) { |
| 24 | switch (type) { |
| 25 | case GRPC_CLIENT_CHANNEL: |
| 26 | return true; |
Craig Tiller | 178edfa | 2016-02-17 20:54:46 -0800 | [diff] [blame] | 27 | case GRPC_CLIENT_SUBCHANNEL: |
| 28 | return true; |
| 29 | case GRPC_CLIENT_LAME_CHANNEL: |
| 30 | return true; |
Craig Tiller | de67626 | 2016-02-19 12:28:34 -0800 | [diff] [blame] | 31 | case GRPC_CLIENT_DIRECT_CHANNEL: |
| 32 | return true; |
Craig Tiller | 178edfa | 2016-02-17 20:54:46 -0800 | [diff] [blame] | 33 | case GRPC_SERVER_CHANNEL: |
| 34 | return false; |
| 35 | case GRPC_NUM_CHANNEL_STACK_TYPES: |
| 36 | break; |
| 37 | } |
| 38 | GPR_UNREACHABLE_CODE(return true;); |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 39 | } |
Craig Tiller | 4f89b0b | 2017-04-03 10:00:17 -0700 | [diff] [blame] | 40 | |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 41 | const char* grpc_channel_stack_type_string(grpc_channel_stack_type type) { |
Craig Tiller | 4f89b0b | 2017-04-03 10:00:17 -0700 | [diff] [blame] | 42 | 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 | } |