12c593315Sopenharmony_ci/* 22c593315Sopenharmony_ci * nghttp2 - HTTP/2 C Library 32c593315Sopenharmony_ci * 42c593315Sopenharmony_ci * Copyright (c) 2019 nghttp2 contributors 52c593315Sopenharmony_ci * 62c593315Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining 72c593315Sopenharmony_ci * a copy of this software and associated documentation files (the 82c593315Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 92c593315Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 102c593315Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to 112c593315Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 122c593315Sopenharmony_ci * the following conditions: 132c593315Sopenharmony_ci * 142c593315Sopenharmony_ci * The above copyright notice and this permission notice shall be 152c593315Sopenharmony_ci * included in all copies or substantial portions of the Software. 162c593315Sopenharmony_ci * 172c593315Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 182c593315Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 192c593315Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 202c593315Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 212c593315Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 222c593315Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 232c593315Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 242c593315Sopenharmony_ci */ 252c593315Sopenharmony_ci#ifndef H2LOAD_HTTP3_SESSION_H 262c593315Sopenharmony_ci#define H2LOAD_HTTP3_SESSION_H 272c593315Sopenharmony_ci 282c593315Sopenharmony_ci#include "h2load_session.h" 292c593315Sopenharmony_ci 302c593315Sopenharmony_ci#include <nghttp3/nghttp3.h> 312c593315Sopenharmony_ci 322c593315Sopenharmony_cinamespace h2load { 332c593315Sopenharmony_ci 342c593315Sopenharmony_cistruct Client; 352c593315Sopenharmony_ci 362c593315Sopenharmony_ciclass Http3Session : public Session { 372c593315Sopenharmony_cipublic: 382c593315Sopenharmony_ci Http3Session(Client *client); 392c593315Sopenharmony_ci virtual ~Http3Session(); 402c593315Sopenharmony_ci virtual void on_connect(); 412c593315Sopenharmony_ci virtual int submit_request(); 422c593315Sopenharmony_ci virtual int on_read(const uint8_t *data, size_t len); 432c593315Sopenharmony_ci virtual int on_write(); 442c593315Sopenharmony_ci virtual void terminate(); 452c593315Sopenharmony_ci virtual size_t max_concurrent_streams(); 462c593315Sopenharmony_ci 472c593315Sopenharmony_ci int init_conn(); 482c593315Sopenharmony_ci int stream_close(int64_t stream_id, uint64_t app_error_code); 492c593315Sopenharmony_ci void recv_data(int64_t stream_id, const uint8_t *data, size_t datalen); 502c593315Sopenharmony_ci void consume(int64_t stream_id, size_t nconsumed); 512c593315Sopenharmony_ci void begin_headers(int64_t stream_id); 522c593315Sopenharmony_ci void recv_header(int64_t stream_id, const nghttp3_vec *name, 532c593315Sopenharmony_ci const nghttp3_vec *value); 542c593315Sopenharmony_ci int stop_sending(int64_t stream_id, uint64_t app_error_code); 552c593315Sopenharmony_ci int reset_stream(int64_t stream_id, uint64_t app_error_code); 562c593315Sopenharmony_ci 572c593315Sopenharmony_ci int close_stream(int64_t stream_id, uint64_t app_error_code); 582c593315Sopenharmony_ci int shutdown_stream_read(int64_t stream_id); 592c593315Sopenharmony_ci int extend_max_local_streams(); 602c593315Sopenharmony_ci int64_t submit_request_internal(); 612c593315Sopenharmony_ci 622c593315Sopenharmony_ci ssize_t read_stream(uint32_t flags, int64_t stream_id, const uint8_t *data, 632c593315Sopenharmony_ci size_t datalen); 642c593315Sopenharmony_ci ssize_t write_stream(int64_t &stream_id, int &fin, nghttp3_vec *vec, 652c593315Sopenharmony_ci size_t veccnt); 662c593315Sopenharmony_ci void block_stream(int64_t stream_id); 672c593315Sopenharmony_ci int unblock_stream(int64_t stream_id); 682c593315Sopenharmony_ci void shutdown_stream_write(int64_t stream_id); 692c593315Sopenharmony_ci int add_write_offset(int64_t stream_id, size_t ndatalen); 702c593315Sopenharmony_ci int add_ack_offset(int64_t stream_id, size_t datalen); 712c593315Sopenharmony_ci 722c593315Sopenharmony_ci void read_data(nghttp3_vec *vec, size_t veccnt, uint32_t *pflags); 732c593315Sopenharmony_ci 742c593315Sopenharmony_ciprivate: 752c593315Sopenharmony_ci Client *client_; 762c593315Sopenharmony_ci nghttp3_conn *conn_; 772c593315Sopenharmony_ci size_t npending_request_; 782c593315Sopenharmony_ci size_t reqidx_; 792c593315Sopenharmony_ci}; 802c593315Sopenharmony_ci 812c593315Sopenharmony_ci} // namespace h2load 822c593315Sopenharmony_ci 832c593315Sopenharmony_ci#endif // H2LOAD_HTTP3_SESSION_H 84