1 /* 2 * Copyright (c) 2018 Fastly, Kazuho 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to 6 * deal in the Software without restriction, including without limitation the 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 * sell copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 * IN THE SOFTWARE. 21 */ 22 #ifndef h2o__http3_server_h 23 #define h2o__http3_server_h 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #include <sys/socket.h> 30 #include "quicly.h" 31 #include "h2o/http3_common.h" 32 #include "h2o.h" 33 34 typedef struct st_h2o_http3_server_ctx_t { 35 h2o_quic_ctx_t super; 36 h2o_accept_ctx_t *accept_ctx; 37 unsigned send_retry : 1; 38 h2o_http3_qpack_context_t qpack; 39 } h2o_http3_server_ctx_t; 40 41 extern const h2o_protocol_callbacks_t H2O_HTTP3_SERVER_CALLBACKS; 42 extern const h2o_http3_conn_callbacks_t H2O_HTTP3_CONN_CALLBACKS; 43 44 /** 45 * initializes the context 46 */ 47 void h2o_http3_server_init_context(h2o_context_t *h2o, h2o_quic_ctx_t *ctx, h2o_loop_t *loop, h2o_socket_t *sock, 48 quicly_context_t *quic, h2o_quic_accept_cb acceptor, 49 h2o_quic_notify_connection_update_cb notify_conn_update, uint8_t use_gso); 50 51 /** 52 * the acceptor callback to be used together with h2o_http3_server_ctx_t 53 * @return a pointer to a new connection object upon success, NULL or H2O_QUIC_ACCEPT_CONN_DECRYPTION_FAILED upon failure. 54 */ 55 h2o_http3_conn_t *h2o_http3_server_accept(h2o_http3_server_ctx_t *ctx, quicly_address_t *destaddr, quicly_address_t *srcaddr, 56 quicly_decoded_packet_t *packet, quicly_address_token_plaintext_t *address_token, 57 int skip_tracing, const h2o_http3_conn_callbacks_t *h3_callbacks); 58 /** 59 * amends the quicly context so that it could be used for the server 60 */ 61 void h2o_http3_server_amend_quicly_context(h2o_globalconf_t *conf, quicly_context_t *quic); 62 63 #ifdef __cplusplus 64 } 65 #endif 66 67 #endif 68