2020-11-02 00:52:13 +01:00
|
|
|
from cc import quicly_cc_t
|
|
|
|
from cid import quicly_cid_t, quicly_cid_encryptor_t, quicly_cid_plaintext_t
|
|
|
|
from loss import quicly_loss_conf_t
|
2020-11-07 11:05:57 +01:00
|
|
|
from posix import IOVec
|
|
|
|
|
|
|
|
from nativesockets import
|
|
|
|
SockAddr,
|
|
|
|
Sockaddr_storage,
|
|
|
|
Sockaddr_in,
|
|
|
|
Sockaddr_in6,
|
|
|
|
SockLen
|
2020-11-02 00:52:13 +01:00
|
|
|
|
|
|
|
from constants import
|
|
|
|
quicly_conn_t,
|
|
|
|
quicly_stream_id_t,
|
|
|
|
quicly_stream_t
|
|
|
|
|
|
|
|
from ../picotls/picotls import
|
|
|
|
ptls_aead_algorithm_t,
|
|
|
|
ptls_aead_context_t,
|
|
|
|
ptls_buffer_t,
|
|
|
|
ptls_cipher_context_t,
|
|
|
|
ptls_context_t,
|
|
|
|
ptls_handshake_properties_t,
|
|
|
|
ptls_hash_algorithm_t,
|
|
|
|
ptls_iovec_t
|
|
|
|
|
2020-11-02 09:59:28 +01:00
|
|
|
export
|
2020-11-07 11:05:57 +01:00
|
|
|
quicly_conn_t,
|
2020-11-02 09:59:28 +01:00
|
|
|
quicly_stream_t,
|
|
|
|
quicly_stream_id_t
|
|
|
|
|
2020-11-02 00:52:13 +01:00
|
|
|
type
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_address_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-07 11:05:57 +01:00
|
|
|
sa*: SockAddr
|
|
|
|
sin*: Sockaddr_in
|
|
|
|
sin6*: Sockaddr_in6
|
2020-11-02 00:52:13 +01:00
|
|
|
|
|
|
|
Retry* {.bycopy.} = object
|
|
|
|
original_dcid*: quicly_cid_t
|
|
|
|
client_cid*: quicly_cid_t
|
|
|
|
server_cid*: quicly_cid_t
|
|
|
|
|
|
|
|
Resumption* {.bycopy.} = object
|
|
|
|
bytes*: array[256, uint8]
|
|
|
|
len*: csize_t
|
|
|
|
|
|
|
|
RetryOrResumption* {.union, bycopy.} = object
|
|
|
|
retry*: Retry
|
|
|
|
resumption*: Resumption
|
|
|
|
|
|
|
|
AppData* {.bycopy.} = object
|
|
|
|
bytes*: array[256, uint8]
|
|
|
|
len*: csize_t
|
|
|
|
|
|
|
|
AddressTokenType* {.bycopy.} = enum
|
|
|
|
QUICLY_ADDRESS_TOKEN_TYPE_RETRY
|
|
|
|
QUICLY_ADDRESS_TOKEN_TYPE_RESUMPTION
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_address_token_plaintext_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
`type`: AddressTokenType
|
|
|
|
issued_at*: uint64
|
|
|
|
local*: quicly_address_t
|
|
|
|
remote*: quicly_address_t
|
|
|
|
type_specific*: RetryOrResumption
|
|
|
|
appdata*: AppData
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_stream_open_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 09:59:28 +01:00
|
|
|
cb*: proc(self: ptr quicly_stream_open_t, stream: ptr quicly_stream_t): cint
|
|
|
|
{.cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_receive_datagram_frame_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 09:59:28 +01:00
|
|
|
cb*: proc(self: ptr quicly_receive_datagram_frame_t, conn: ptr quicly_conn_t,
|
|
|
|
payload: ptls_iovec_t) {.cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_closed_by_remote_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 09:59:28 +01:00
|
|
|
cb*: proc(self: ptr quicly_closed_by_remote_t, conn: ptr quicly_conn_t,
|
|
|
|
err: cint, frame_type: uint64, reason: cstring,
|
|
|
|
reason_len: csize_t) {.cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_now_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 09:59:28 +01:00
|
|
|
cb*: proc(self: ptr quicly_now_t): int64 {.cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_save_resumption_token_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 09:59:28 +01:00
|
|
|
cb*: proc(self: ptr quicly_save_resumption_token_t, conn: ptr quicly_conn_t,
|
|
|
|
token: ptls_iovec_t): cint {.cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_generate_resumption_token_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 09:59:28 +01:00
|
|
|
cb*: proc(self: ptr quicly_generate_resumption_token_t,
|
|
|
|
conn: ptr quicly_conn_t, buf: ptr ptls_buffer_t,
|
|
|
|
token: ptr quicly_address_token_plaintext_t): cint {.cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_init_cc_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 09:59:28 +01:00
|
|
|
cb*: proc(self: ptr quicly_init_cc_t, cc: ptr quicly_cc_t, initcwnd: uint32,
|
|
|
|
now: int64) {.cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_max_stream_data_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
bidi_local*: uint64
|
|
|
|
bidi_remote*: uint64
|
|
|
|
uni*: uint64
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_transport_parameters_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
max_stream_data*: quicly_max_stream_data_t
|
|
|
|
max_data*: uint64
|
|
|
|
max_idle_timeout*: uint64
|
|
|
|
max_streams_bidi*: uint64
|
|
|
|
max_streams_uni*: uint64
|
|
|
|
max_udp_payload_size*: uint64
|
|
|
|
ack_delay_exponent*: uint8
|
|
|
|
max_ack_delay*: uint8
|
|
|
|
min_ack_delay_usec*: uint64
|
|
|
|
disable_active_migration* {.bitsize: 1.}: uint8
|
|
|
|
active_connection_id_limit*: uint64
|
|
|
|
max_datagram_frame_size*: uint16
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_stream_scheduler_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
can_send*: proc(sched: ptr quicly_stream_scheduler_t,
|
|
|
|
conn: ptr quicly_conn_t, conn_is_saturated: cint): cint
|
|
|
|
{.cdecl.}
|
|
|
|
do_send*: proc(sched: ptr quicly_stream_scheduler_t,
|
|
|
|
stream: ptr quicly_stream_t): cint {.cdecl.}
|
|
|
|
update_state*: proc(sched: ptr quicly_stream_scheduler_t,
|
|
|
|
stream: ptr quicly_stream_t): cint {.cdecl.}
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_crypto_engine_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
setup_cipher*: proc(engine: ptr quicly_crypto_engine_t,
|
|
|
|
conn: ptr quicly_conn_t, epoch: csize_t, is_enc: cint,
|
|
|
|
header_protect_ctx: ptr ptr ptls_cipher_context_t,
|
|
|
|
packet_protect_ctx: ptr ptr ptls_aead_context_t,
|
|
|
|
aead: ptr ptls_aead_algorithm_t,
|
|
|
|
hash: ptr ptls_hash_algorithm_t, secret: pointer): cint
|
|
|
|
{.cdecl.}
|
|
|
|
encrypt_packet: proc(engine: ptr quicly_crypto_engine_t,
|
|
|
|
conn: ptr quicly_conn_t,
|
|
|
|
header_protect_ctx: ptr ptls_cipher_context_t,
|
|
|
|
packet_protect_ctx: ptr ptls_aead_context_t,
|
|
|
|
datagram: ptls_iovec_t, first_byte_at: csize_t)
|
|
|
|
{.cdecl.}
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_context_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
tls*: ptr ptls_context_t
|
|
|
|
initial_egress_max_udp_payload_size*: uint16
|
|
|
|
loss*: quicly_loss_conf_t
|
|
|
|
transport_params*: quicly_transport_parameters_t
|
|
|
|
max_packets_per_key*: uint64
|
|
|
|
max_crypto_bytes*: uint64
|
|
|
|
initial_version*: uint32
|
|
|
|
pre_validation_amplification_limit*: uint16
|
|
|
|
is_clustered* {.bitsize: 1.}: cuint
|
|
|
|
expand_client_hello* {.bitsize: 1.}: cuint
|
|
|
|
cid_encryptor*: ptr quicly_cid_encryptor_t
|
|
|
|
stream_open*: ptr quicly_stream_open_t
|
|
|
|
stream_scheduler*: ptr quicly_stream_scheduler_t
|
|
|
|
receive_datagram_frame*: ptr quicly_receive_datagram_frame_t
|
|
|
|
closed_by_remote*: ptr quicly_closed_by_remote_t
|
|
|
|
now*: ptr quicly_now_t
|
|
|
|
save_resumption_token*: ptr quicly_save_resumption_token_t
|
|
|
|
generate_resumption_token*: ptr quicly_generate_resumption_token_t
|
|
|
|
crypto_engine*: ptr quicly_crypto_engine_t
|
|
|
|
init_cc*: ptr quicly_init_cc_t
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
CidDest* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
encrypted*: ptls_iovec_t
|
|
|
|
plaintext*: quicly_cid_plaintext_t
|
|
|
|
might_be_client_generated* {.bitsize: 1.}: cuint
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
Cid* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
dest: CidDest
|
|
|
|
src: ptls_iovec_t
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
Decrypted* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
pn: uint64
|
|
|
|
key_phase: uint64
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
IsStatelessReset* {.importc, header: "quicly.h", bycopy.} = enum
|
2020-11-02 00:52:13 +01:00
|
|
|
QUICLY_DECODED_PACKET_CACHED_MAYBE_STATELESS_RESET = 0,
|
|
|
|
QUICLY_DECODED_PACKET_CACHED_IS_STATELESS_RESET,
|
|
|
|
QUICLY_DECODED_PACKET_CACHED_NOT_STATELESS_RESET
|
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
quicly_decoded_packet_t* {.importc, header: "quicly.h", bycopy.} = object
|
2020-11-02 00:52:13 +01:00
|
|
|
octets*: ptls_iovec_t
|
|
|
|
cid*: Cid
|
|
|
|
version*: uint32
|
|
|
|
token*: ptls_iovec_t
|
|
|
|
encrypted_off*: csize_t
|
|
|
|
datagram_size*: csize_t
|
|
|
|
decrypted*: Decrypted
|
|
|
|
is_stateless_reset_cached: IsStatelessReset
|
|
|
|
|
|
|
|
proc quicly_get_stream*(conn: ptr quicly_conn_t, stream_id: quicly_stream_id_t):
|
2020-11-07 11:42:11 +01:00
|
|
|
ptr quicly_stream_t {.importc, header: "quicly.h", cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
|
|
|
proc quicly_close*(conn: ptr quicly_conn_t, err: cint, reason_phrase: cstring):
|
2020-11-07 11:42:11 +01:00
|
|
|
cint {.importc, header: "quicly.h", cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:42:11 +01:00
|
|
|
proc quicly_free*(conn: ptr quicly_conn_t) {.importc, header: "quicly.h", cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
|
|
|
proc quicly_decode_packet*(ctx: ptr quicly_context_t,
|
|
|
|
packet: ptr quicly_decoded_packet_t,
|
|
|
|
datagram: ptr uint8, datagram_size: csize_t,
|
2020-11-07 11:05:57 +01:00
|
|
|
off: ptr csize_t): csize_t
|
2020-11-07 11:42:11 +01:00
|
|
|
{.importc, header: "quicly.h", cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:05:57 +01:00
|
|
|
proc quicly_is_destination*(conn: ptr quicly_conn_t,
|
|
|
|
dest_addr: ptr SockAddr | ptr Sockaddr_storage,
|
|
|
|
src_addr: ptr SockAddr | ptr Sockaddr_storage,
|
2020-11-02 00:52:13 +01:00
|
|
|
decoded: ptr quicly_decoded_packet_t): cint
|
2020-11-07 11:42:11 +01:00
|
|
|
{.importc, header: "quicly.h", cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:05:57 +01:00
|
|
|
proc quicly_receive*(conn: ptr quicly_conn_t,
|
|
|
|
dest_addr: ptr SockAddr | ptr Sockaddr_storage,
|
|
|
|
src_addr: ptr SockAddr | ptr Sockaddr_storage,
|
2020-11-02 00:52:13 +01:00
|
|
|
packet: ptr quicly_decoded_packet_t): cint
|
2020-11-07 11:42:11 +01:00
|
|
|
{.importc, header: "quicly.h", cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:05:57 +01:00
|
|
|
proc quicly_send*(conn: ptr quicly_conn_t, dest: ptr quicly_address_t,
|
|
|
|
src: ptr quicly_address_t, datagrams: ptr IOVec,
|
|
|
|
num_diagrams: ptr csize_t, buf: pointer, bufsize: csize_t):
|
2020-11-07 11:42:11 +01:00
|
|
|
cint {.importc, header: "quicly.h", cdecl.}
|
2020-11-07 11:05:57 +01:00
|
|
|
|
2020-11-02 00:52:13 +01:00
|
|
|
proc quicly_accept*(conn: ptr ptr quicly_conn_t, ctx: ptr quicly_context_t,
|
2020-11-07 11:05:57 +01:00
|
|
|
dest_addr: ptr SockAddr | ptr Sockaddr_storage,
|
|
|
|
src_addr: ptr SockAddr | ptr Sockaddr_storage,
|
2020-11-02 00:52:13 +01:00
|
|
|
packet: ptr quicly_decoded_packet_t,
|
|
|
|
address_token: ptr quicly_address_token_plaintext_t,
|
|
|
|
new_cid: ptr quicly_cid_plaintext_t,
|
|
|
|
handshake_properties: ptr ptls_handshake_properties_t): cint
|
2020-11-07 11:42:11 +01:00
|
|
|
{.importc, header: "quicly.h", cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:05:57 +01:00
|
|
|
proc quicly_connect*(conn: ptr ptr quicly_conn_t, ctx: ptr quicly_context_t,
|
|
|
|
server_name: cstring,
|
|
|
|
dest_addr: ptr SockAddr | ptr Sockaddr_storage,
|
|
|
|
src_addr: ptr SockAddr | ptr Sockaddr_storage,
|
2020-11-02 00:52:13 +01:00
|
|
|
new_cid: ptr quicly_cid_plaintext_t,
|
2020-11-07 11:05:57 +01:00
|
|
|
address_token: ptls_iovec_t,
|
2020-11-02 00:52:13 +01:00
|
|
|
handshake_properties: ptr ptls_handshake_properties_t,
|
|
|
|
resumed_transport_params: ptr quicly_transport_parameters_t):
|
2020-11-07 11:42:11 +01:00
|
|
|
cint {.importc, header: "quicly.h", cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:05:57 +01:00
|
|
|
proc quicly_open_stream*(conn: ptr quicly_conn_t,
|
|
|
|
stream: ptr ptr quicly_stream_t, unidirectional: cint):
|
2020-11-07 11:42:11 +01:00
|
|
|
cint {.importc, header: "quicly.h", cdecl.}
|
2020-11-07 11:05:57 +01:00
|
|
|
|
2020-11-02 09:59:28 +01:00
|
|
|
proc quicly_amend_ptls_context*(ptls: ptr ptls_context_t)
|
2020-11-07 11:42:11 +01:00
|
|
|
{.importc, header: "quicly.h", cdecl.}
|
2020-11-02 09:59:28 +01:00
|
|
|
|
2020-11-07 11:05:57 +01:00
|
|
|
proc quicly_get_socklen*(sa: ptr SockAddr | ptr Sockaddr_storage): SockLen
|
2020-11-07 11:42:11 +01:00
|
|
|
{.importc, header: "quicly.h", cdecl.}
|
2020-11-02 00:52:13 +01:00
|
|
|
|
2020-11-07 11:05:57 +01:00
|
|
|
proc quicly_get_first_timeout*(conn: ptr quicly_conn_t): int64
|
2020-11-07 11:42:11 +01:00
|
|
|
{.importc, header: "quicly.h", cdecl.}
|