xref: /trafficserver/proxy/http3/Http3Session.h (revision 64e44402)
1 /** @file
2 
3   A brief file description
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 "ProxySession.h"
27 #include "Http3Transaction.h"
28 #include "QPACK.h"
29 
30 class HQSession : public ProxySession
31 {
32 public:
33   using super = ProxySession; ///< Parent type
34 
HQSession(NetVConnection * vc)35   HQSession(NetVConnection *vc) : _client_vc(vc){};
36   virtual ~HQSession();
37 
38   // Implement VConnection interface
39   VIO *do_io_read(Continuation *c, int64_t nbytes = INT64_MAX, MIOBuffer *buf = nullptr) override;
40   VIO *do_io_write(Continuation *c = nullptr, int64_t nbytes = INT64_MAX, IOBufferReader *buf = 0, bool owner = false) override;
41   void do_io_close(int lerrno = -1) override;
42   void do_io_shutdown(ShutdownHowTo_t howto) override;
43   void reenable(VIO *vio) override;
44 
45   // Implement ProxySession interface
46   void new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) override;
47   void start() override;
48   void destroy() override;
49   void release(ProxyTransaction *trans) override;
50   NetVConnection *get_netvc() const override;
51   int get_transact_count() const override;
52   bool support_sni() const override;
53 
54   // HQSession
55   void add_transaction(HQTransaction *);
56   HQTransaction *get_transaction(QUICStreamId);
57 
58 protected:
59   NetVConnection *_client_vc = nullptr;
60 
61 private:
62   // this should be unordered map?
63   Queue<HQTransaction> _transaction_list;
64 };
65 
66 class Http3Session : public HQSession
67 {
68 public:
69   using super = HQSession; ///< Parent type
70 
71   Http3Session(NetVConnection *vc);
72   ~Http3Session();
73 
74   // ProxySession interface
75   const char *get_protocol_string() const override;
76   int populate_protocol(std::string_view *result, int size) const override;
77   void increment_current_active_client_connections_stat() override;
78   void decrement_current_active_client_connections_stat() override;
79 
80   QPACK *local_qpack();
81   QPACK *remote_qpack();
82 
83 private:
84   QPACK *_remote_qpack = nullptr; // QPACK for decoding
85   QPACK *_local_qpack  = nullptr; // QPACK for encoding
86 };
87 
88 /**
89    Only for interop. Will be removed.
90  */
91 class Http09Session : public HQSession
92 {
93 public:
94   using super = HQSession; ///< Parent type
95 
Http09Session(NetVConnection * vc)96   Http09Session(NetVConnection *vc) : HQSession(vc) {}
97   ~Http09Session();
98 
99   // ProxySession interface
100   const char *get_protocol_string() const override;
101   int populate_protocol(std::string_view *result, int size) const override;
102   void increment_current_active_client_connections_stat() override;
103   void decrement_current_active_client_connections_stat() override;
104 
105 private:
106 };
107