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#include "quic.h" 262c593315Sopenharmony_ci 272c593315Sopenharmony_ci#include <cassert> 282c593315Sopenharmony_ci 292c593315Sopenharmony_ci#include <ngtcp2/ngtcp2.h> 302c593315Sopenharmony_ci#include <nghttp3/nghttp3.h> 312c593315Sopenharmony_ci 322c593315Sopenharmony_ci#include "template.h" 332c593315Sopenharmony_ci 342c593315Sopenharmony_ciusing namespace nghttp2; 352c593315Sopenharmony_ci 362c593315Sopenharmony_cinamespace quic { 372c593315Sopenharmony_ci 382c593315Sopenharmony_ciError err_transport(int liberr) { 392c593315Sopenharmony_ci if (liberr == NGTCP2_ERR_RECV_VERSION_NEGOTIATION) { 402c593315Sopenharmony_ci return {ErrorType::TransportVersionNegotiation, 0}; 412c593315Sopenharmony_ci } 422c593315Sopenharmony_ci return {ErrorType::Transport, 432c593315Sopenharmony_ci ngtcp2_err_infer_quic_transport_error_code(liberr)}; 442c593315Sopenharmony_ci} 452c593315Sopenharmony_ci 462c593315Sopenharmony_ciError err_transport_idle_timeout() { 472c593315Sopenharmony_ci return {ErrorType::TransportIdleTimeout, 0}; 482c593315Sopenharmony_ci} 492c593315Sopenharmony_ci 502c593315Sopenharmony_ciError err_transport_tls(int alert) { 512c593315Sopenharmony_ci return {ErrorType::Transport, ngtcp2_err_infer_quic_transport_error_code( 522c593315Sopenharmony_ci NGTCP2_CRYPTO_ERROR | alert)}; 532c593315Sopenharmony_ci} 542c593315Sopenharmony_ci 552c593315Sopenharmony_ciError err_application(int liberr) { 562c593315Sopenharmony_ci return {ErrorType::Application, 572c593315Sopenharmony_ci nghttp3_err_infer_quic_app_error_code(liberr)}; 582c593315Sopenharmony_ci} 592c593315Sopenharmony_ci 602c593315Sopenharmony_ci} // namespace quic 61