Skip to content

Commit

Permalink
test(prop): stateful client connection
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Feb 16, 2024
1 parent 507829e commit 241c477
Show file tree
Hide file tree
Showing 6 changed files with 752 additions and 428 deletions.
2 changes: 1 addition & 1 deletion c_src/quicer_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ csend4(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
if (!enif_get_uint(env, eopen_flag, &open_flag))
{
// if set must be valid.
// if set, must be valid.
return ERROR_TUPLE_2(ATOM_BADARG);
}
}
Expand Down
6 changes: 4 additions & 2 deletions include/quicer_types.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,15 @@

%% is sync send or not
-type send_flags() ::
csend_flags() | ?QUICER_SEND_FLAG_SYNC.

-type csend_flags() ::
?QUIC_SEND_FLAG_NONE
| ?QUIC_SEND_FLAG_ALLOW_0_RTT
| ?QUIC_SEND_FLAG_START
| ?QUIC_SEND_FLAG_FIN
| ?QUIC_SEND_FLAG_DGRAM_PRIORITY
| ?QUIC_SEND_FLAG_DELAY_SEND
| ?QUICER_SEND_FLAG_SYNC.
| ?QUIC_SEND_FLAG_DELAY_SEND.

-type stream_start_flag() ::
?QUIC_STREAM_START_FLAG_NONE
Expand Down
155 changes: 155 additions & 0 deletions test/prop_quic_types.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
%%--------------------------------------------------------------------
%% Copyright (c) 2024 EMQ Technologies Co., Ltd. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%--------------------------------------------------------------------

-record(prop_handle, {
type :: reg | listen | conn | stream,
name :: string(),
handle :: reference(),
destructor :: fun()
}).

-define(dummy_listener, dummy_listener).
-define(DUMMY_PORT, 14567).

-define(valid_flags(FlagType),
(?SUCHTHAT(
Flag,
?LET(
Flags,
[FlagType],
begin
lists:foldl(
fun(F, Acc) ->
Acc bor F
end,
0,
Flags
)
end
),
Flag =/= 0
))
).

-type quicer_listen_opts() :: [listen_opt()].

-type listen_opt() ::
{alpn, [alpn()]}
| {cert, file:filename()}
| {certfile, file:filename()}
%-| {key, file:filename()}. %% @FIXME reflect in types
| {keyfile, file:filename()}
| {verify, none | peer | verify_peer | verify_none}
| {cacertfile, file:filename()}
| {password, string()}
| {sslkeylogfile, file:filename()}
| {allow_insecure, boolean()}
%-| {quic_registration, reg_handle()}
| {conn_acceptors, non_neg_integer()}
| {settings, [quicer_setting()]}.

-type quicer_setting() ::
{max_bytes_per_key, uint64()}
| {handshake_idle_timeout_ms, uint64()}
| {idle_timeout_ms, uint64()}
| {tls_client_max_send_buffer, uint32()}
| {tls_server_max_send_buffer, uint32()}
| {stream_recv_window_default, uint32()}
| {stream_recv_buffer_default, uint32()}
| {conn_flow_control_window, uint32()}
| {max_stateless_operations, uint32()}
| {initial_window_packets, uint32()}
| {send_idle_timeout_ms, uint32()}
| {initial_rtt_ms, uint32()}
| {max_ack_delay_ms, uint32()}
| {disconnect_timeout_ms, uint32()}
| {keep_alive_interval_ms, uint32()}
| {peer_bidi_stream_count, uint16()}
| {peer_unidi_stream_count, uint16()}
| {retry_memory_limit, uint16()}
| {load_balancing_mode, uint16()}
| {max_operations_per_drain, uint8()}
| {send_buffering_enabled, uint8()}
| {pacing_enabled, uint8()}
| {migration_enabled, uint8()}
| {datagram_receive_enabled, uint8()}
| {server_resumption_level, 0 | 1 | 2}
| {minimum_mtu, uint16()}
| {maximum_mtu, uint16()}
| {mtu_discovery_search_complete_timeout_us, uint64()}
| {mtu_discovery_missing_probe_count, uint8()}
| {max_binding_stateless_operations, uint16()}
| {stateless_operation_expiration_ms, uint16()}.

-type quicer_conn_opts() :: [conn_opt()].
-type conn_opt() ::
{alpn, [string()]}
| {certfile, file:filename()}
| {keyfile, file:filename()}
| {password, string()}
| {verify, none | peer}
| {nst, binary()}
| {cacertfile, file:filename()}
| {sslkeylogfile, file:filename()}
| {local_bidi_stream_count, uint16()}
| {local_unidi_stream_count, uint16()}
| {handshake_idle_timeout_ms, non_neg_integer()}
| {quic_event_mask, uint32()}
| {disable_1rtt_encryption, boolean()}
| {quic_version, uint32()}
| {local_address, string()}
| {remote_address, string()}
| {ideal_processor, uint16()}
| {settings, [quicer_setting()]}
% @TODO
| {statistics, any()}
% @TODO
| {statistics_plat, any()}
| {share_udp_binding, boolean()}
| {max_stream_ids, uint64()}
| {close_reason_phrase, string()}
| {stream_scheduling_scheme, uint16()}
| {datagram_receive_enabled, boolean()}
| {datagram_send_enabled, boolean()}
| {resumption_ticket, [uint8()]}
| {peer_certificate_valid, boolean()}
| {local_interface, uint32()}
% @TODO
| {tls_secrets, binary()}
% @TODO
| {version_settings, any()}
| {cibir_id, [uint8()]}
% @TODO
| {statistics_v2, any()}
% @TODO
| {statistics_v2_plat, any()}.

-type quicer_acceptor_opts() :: [acceptor_opt()].
-type acceptor_opt() ::
{active, active_n()}
| quicer_setting().

-type quicer_stream_opts() :: [stream_opt()].
-type stream_opt() ::
{active, active_n()}
| {stream_id, uint62()}
| {priority, uint16()}
| {ideal_send_buffer_size, uint64()}
| {'0rtt_length', uint64()}
| {open_flag, stream_open_flags()}
| {start_flag, stream_start_flags()}
| {event_mask, uint32()}
| {disable_fpbuffer, boolean()}.
Loading

0 comments on commit 241c477

Please sign in to comment.