/src/trafficserver/include/proxy/ProtocolProbeSessionAccept.h
Line | Count | Source |
1 | | /** @file |
2 | | |
3 | | ProtocolProbeSessionAccept |
4 | | |
5 | | @section license License |
6 | | |
7 | | Licensed to the Apache Software Foundation (ASF) under one |
8 | | or more contributor license agreements. See the NOTICE file |
9 | | distributed with this work for additional information |
10 | | regarding copyright ownership. The ASF licenses this file |
11 | | to you under the Apache License, Version 2.0 (the |
12 | | "License"); you may not use this file except in compliance |
13 | | with the License. You may obtain a copy of the License at |
14 | | |
15 | | http://www.apache.org/licenses/LICENSE-2.0 |
16 | | |
17 | | Unless required by applicable law or agreed to in writing, software |
18 | | distributed under the License is distributed on an "AS IS" BASIS, |
19 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
20 | | See the License for the specific language governing permissions and |
21 | | limitations under the License. |
22 | | */ |
23 | | |
24 | | #pragma once |
25 | | |
26 | | #include "swoc/swoc_ip.h" |
27 | | |
28 | | #include "iocore/net/SessionAccept.h" |
29 | | |
30 | | struct ProtocolProbeSessionAcceptEnums { |
31 | | /// Enumeration for related groups of protocols. |
32 | | /// There is a child acceptor for each group which |
33 | | /// handles finer grained stuff. |
34 | | enum class ProtoGroupKey { |
35 | | HTTP, ///< HTTP group (0.9-1.1) |
36 | | HTTP2, ///< HTTP 2 group |
37 | | N_GROUPS ///< Size value. |
38 | | }; |
39 | | }; |
40 | | |
41 | | class ProtocolProbeSessionAccept : public SessionAccept, public ProtocolProbeSessionAcceptEnums |
42 | | { |
43 | | public: |
44 | 0 | ProtocolProbeSessionAccept() : SessionAccept(nullptr) |
45 | 0 | { |
46 | 0 | memset(endpoint, 0, sizeof(endpoint)); |
47 | 0 | SET_HANDLER(&ProtocolProbeSessionAccept::mainEvent); |
48 | 0 | } |
49 | 0 | ~ProtocolProbeSessionAccept() override {} |
50 | | void registerEndpoint(ProtoGroupKey key, SessionAccept *ap); |
51 | | |
52 | | bool accept(NetVConnection *, MIOBuffer *, IOBufferReader *) override; |
53 | | |
54 | | // noncopyable |
55 | | ProtocolProbeSessionAccept(const ProtocolProbeSessionAccept &) = delete; // disabled |
56 | | ProtocolProbeSessionAccept &operator=(const ProtocolProbeSessionAccept &) = delete; // disabled |
57 | | |
58 | | swoc::IPRangeSet *proxy_protocol_ipmap = nullptr; |
59 | | |
60 | | private: |
61 | | int mainEvent(int event, void *netvc) override; |
62 | | |
63 | | /** Child acceptors, index by @c ProtoGroupKey |
64 | | |
65 | | We pass on the actual accept to one of these after doing protocol sniffing. |
66 | | We make it one larger and leave the last entry NULL so we don't have to |
67 | | do range checks on the enum value. |
68 | | */ |
69 | | SessionAccept *endpoint[static_cast<int>(ProtoGroupKey::N_GROUPS) + 1]; |
70 | | |
71 | | friend struct ProtocolProbeTrampoline; |
72 | | }; |