11cb0ef41Sopenharmony_ci/* 21cb0ef41Sopenharmony_ci * nghttp2 - HTTP/2 C Library 31cb0ef41Sopenharmony_ci * 41cb0ef41Sopenharmony_ci * Copyright (c) 2014 Tatsuhiro Tsujikawa 51cb0ef41Sopenharmony_ci * 61cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining 71cb0ef41Sopenharmony_ci * a copy of this software and associated documentation files (the 81cb0ef41Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 91cb0ef41Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 101cb0ef41Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to 111cb0ef41Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 121cb0ef41Sopenharmony_ci * the following conditions: 131cb0ef41Sopenharmony_ci * 141cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice shall be 151cb0ef41Sopenharmony_ci * included in all copies or substantial portions of the Software. 161cb0ef41Sopenharmony_ci * 171cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 181cb0ef41Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 191cb0ef41Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 201cb0ef41Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 211cb0ef41Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 221cb0ef41Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 231cb0ef41Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 241cb0ef41Sopenharmony_ci */ 251cb0ef41Sopenharmony_ci#include "nghttp2_callbacks.h" 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci#include <stdlib.h> 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciint nghttp2_session_callbacks_new(nghttp2_session_callbacks **callbacks_ptr) { 301cb0ef41Sopenharmony_ci *callbacks_ptr = calloc(1, sizeof(nghttp2_session_callbacks)); 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci if (*callbacks_ptr == NULL) { 331cb0ef41Sopenharmony_ci return NGHTTP2_ERR_NOMEM; 341cb0ef41Sopenharmony_ci } 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci return 0; 371cb0ef41Sopenharmony_ci} 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_del(nghttp2_session_callbacks *callbacks) { 401cb0ef41Sopenharmony_ci free(callbacks); 411cb0ef41Sopenharmony_ci} 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_send_callback( 441cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, nghttp2_send_callback send_callback) { 451cb0ef41Sopenharmony_ci cbs->send_callback = send_callback; 461cb0ef41Sopenharmony_ci} 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_recv_callback( 491cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, nghttp2_recv_callback recv_callback) { 501cb0ef41Sopenharmony_ci cbs->recv_callback = recv_callback; 511cb0ef41Sopenharmony_ci} 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_frame_recv_callback( 541cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 551cb0ef41Sopenharmony_ci nghttp2_on_frame_recv_callback on_frame_recv_callback) { 561cb0ef41Sopenharmony_ci cbs->on_frame_recv_callback = on_frame_recv_callback; 571cb0ef41Sopenharmony_ci} 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_invalid_frame_recv_callback( 601cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 611cb0ef41Sopenharmony_ci nghttp2_on_invalid_frame_recv_callback on_invalid_frame_recv_callback) { 621cb0ef41Sopenharmony_ci cbs->on_invalid_frame_recv_callback = on_invalid_frame_recv_callback; 631cb0ef41Sopenharmony_ci} 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_data_chunk_recv_callback( 661cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 671cb0ef41Sopenharmony_ci nghttp2_on_data_chunk_recv_callback on_data_chunk_recv_callback) { 681cb0ef41Sopenharmony_ci cbs->on_data_chunk_recv_callback = on_data_chunk_recv_callback; 691cb0ef41Sopenharmony_ci} 701cb0ef41Sopenharmony_ci 711cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_before_frame_send_callback( 721cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 731cb0ef41Sopenharmony_ci nghttp2_before_frame_send_callback before_frame_send_callback) { 741cb0ef41Sopenharmony_ci cbs->before_frame_send_callback = before_frame_send_callback; 751cb0ef41Sopenharmony_ci} 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_frame_send_callback( 781cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 791cb0ef41Sopenharmony_ci nghttp2_on_frame_send_callback on_frame_send_callback) { 801cb0ef41Sopenharmony_ci cbs->on_frame_send_callback = on_frame_send_callback; 811cb0ef41Sopenharmony_ci} 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_frame_not_send_callback( 841cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 851cb0ef41Sopenharmony_ci nghttp2_on_frame_not_send_callback on_frame_not_send_callback) { 861cb0ef41Sopenharmony_ci cbs->on_frame_not_send_callback = on_frame_not_send_callback; 871cb0ef41Sopenharmony_ci} 881cb0ef41Sopenharmony_ci 891cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_stream_close_callback( 901cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 911cb0ef41Sopenharmony_ci nghttp2_on_stream_close_callback on_stream_close_callback) { 921cb0ef41Sopenharmony_ci cbs->on_stream_close_callback = on_stream_close_callback; 931cb0ef41Sopenharmony_ci} 941cb0ef41Sopenharmony_ci 951cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_begin_headers_callback( 961cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 971cb0ef41Sopenharmony_ci nghttp2_on_begin_headers_callback on_begin_headers_callback) { 981cb0ef41Sopenharmony_ci cbs->on_begin_headers_callback = on_begin_headers_callback; 991cb0ef41Sopenharmony_ci} 1001cb0ef41Sopenharmony_ci 1011cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_header_callback( 1021cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1031cb0ef41Sopenharmony_ci nghttp2_on_header_callback on_header_callback) { 1041cb0ef41Sopenharmony_ci cbs->on_header_callback = on_header_callback; 1051cb0ef41Sopenharmony_ci} 1061cb0ef41Sopenharmony_ci 1071cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_header_callback2( 1081cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1091cb0ef41Sopenharmony_ci nghttp2_on_header_callback2 on_header_callback2) { 1101cb0ef41Sopenharmony_ci cbs->on_header_callback2 = on_header_callback2; 1111cb0ef41Sopenharmony_ci} 1121cb0ef41Sopenharmony_ci 1131cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_invalid_header_callback( 1141cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1151cb0ef41Sopenharmony_ci nghttp2_on_invalid_header_callback on_invalid_header_callback) { 1161cb0ef41Sopenharmony_ci cbs->on_invalid_header_callback = on_invalid_header_callback; 1171cb0ef41Sopenharmony_ci} 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_invalid_header_callback2( 1201cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1211cb0ef41Sopenharmony_ci nghttp2_on_invalid_header_callback2 on_invalid_header_callback2) { 1221cb0ef41Sopenharmony_ci cbs->on_invalid_header_callback2 = on_invalid_header_callback2; 1231cb0ef41Sopenharmony_ci} 1241cb0ef41Sopenharmony_ci 1251cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_select_padding_callback( 1261cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1271cb0ef41Sopenharmony_ci nghttp2_select_padding_callback select_padding_callback) { 1281cb0ef41Sopenharmony_ci cbs->select_padding_callback = select_padding_callback; 1291cb0ef41Sopenharmony_ci} 1301cb0ef41Sopenharmony_ci 1311cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_data_source_read_length_callback( 1321cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1331cb0ef41Sopenharmony_ci nghttp2_data_source_read_length_callback data_source_read_length_callback) { 1341cb0ef41Sopenharmony_ci cbs->read_length_callback = data_source_read_length_callback; 1351cb0ef41Sopenharmony_ci} 1361cb0ef41Sopenharmony_ci 1371cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_begin_frame_callback( 1381cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1391cb0ef41Sopenharmony_ci nghttp2_on_begin_frame_callback on_begin_frame_callback) { 1401cb0ef41Sopenharmony_ci cbs->on_begin_frame_callback = on_begin_frame_callback; 1411cb0ef41Sopenharmony_ci} 1421cb0ef41Sopenharmony_ci 1431cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_send_data_callback( 1441cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1451cb0ef41Sopenharmony_ci nghttp2_send_data_callback send_data_callback) { 1461cb0ef41Sopenharmony_ci cbs->send_data_callback = send_data_callback; 1471cb0ef41Sopenharmony_ci} 1481cb0ef41Sopenharmony_ci 1491cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_pack_extension_callback( 1501cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1511cb0ef41Sopenharmony_ci nghttp2_pack_extension_callback pack_extension_callback) { 1521cb0ef41Sopenharmony_ci cbs->pack_extension_callback = pack_extension_callback; 1531cb0ef41Sopenharmony_ci} 1541cb0ef41Sopenharmony_ci 1551cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_unpack_extension_callback( 1561cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1571cb0ef41Sopenharmony_ci nghttp2_unpack_extension_callback unpack_extension_callback) { 1581cb0ef41Sopenharmony_ci cbs->unpack_extension_callback = unpack_extension_callback; 1591cb0ef41Sopenharmony_ci} 1601cb0ef41Sopenharmony_ci 1611cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_on_extension_chunk_recv_callback( 1621cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, 1631cb0ef41Sopenharmony_ci nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback) { 1641cb0ef41Sopenharmony_ci cbs->on_extension_chunk_recv_callback = on_extension_chunk_recv_callback; 1651cb0ef41Sopenharmony_ci} 1661cb0ef41Sopenharmony_ci 1671cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_error_callback( 1681cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, nghttp2_error_callback error_callback) { 1691cb0ef41Sopenharmony_ci cbs->error_callback = error_callback; 1701cb0ef41Sopenharmony_ci} 1711cb0ef41Sopenharmony_ci 1721cb0ef41Sopenharmony_civoid nghttp2_session_callbacks_set_error_callback2( 1731cb0ef41Sopenharmony_ci nghttp2_session_callbacks *cbs, nghttp2_error_callback2 error_callback2) { 1741cb0ef41Sopenharmony_ci cbs->error_callback2 = error_callback2; 1751cb0ef41Sopenharmony_ci} 176