1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <grpc/support/port_platform.h>
16 
17 #include "src/core/lib/surface/builtins.h"
18 
19 #include <limits.h>
20 
21 #include "src/core/lib/channel/call_tracer.h"
22 #include "src/core/lib/channel/channel_stack_builder.h"
23 #include "src/core/lib/channel/connected_channel.h"
24 #include "src/core/lib/config/core_configuration.h"
25 #include "src/core/lib/surface/channel_init.h"
26 #include "src/core/lib/surface/channel_stack_type.h"
27 #include "src/core/lib/surface/lame_client.h"
28 #include "src/core/lib/surface/server.h"
29 
30 namespace grpc_core {
31 
RegisterBuiltins(CoreConfiguration::Builder * builder)32 void RegisterBuiltins(CoreConfiguration::Builder* builder) {
33   RegisterServerCallTracerFilter(builder);
34   builder->channel_init()->RegisterStage(GRPC_CLIENT_SUBCHANNEL,
35                                          GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
36                                          grpc_add_connected_filter);
37   builder->channel_init()->RegisterStage(GRPC_CLIENT_DIRECT_CHANNEL,
38                                          GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
39                                          grpc_add_connected_filter);
40   builder->channel_init()->RegisterStage(GRPC_SERVER_CHANNEL,
41                                          GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
42                                          grpc_add_connected_filter);
43   builder->channel_init()->RegisterStage(
44       GRPC_CLIENT_LAME_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
45       [](ChannelStackBuilder* builder) {
46         builder->AppendFilter(&LameClientFilter::kFilter);
47         return true;
48       });
49   builder->channel_init()->RegisterStage(
50       GRPC_SERVER_CHANNEL, INT_MAX, [](ChannelStackBuilder* builder) {
51         builder->PrependFilter(&Server::kServerTopFilter);
52         return true;
53       });
54 }
55 
56 }  // namespace grpc_core
57