code wiki / (root) / nx_tls13_read_record_from_fd.nx

nx_tls13_read_record_from_fd.nx

buildroot/runtime/nx_tls13_read_record_from_fd.nx

4941 B128 linesdepth 7pulls 14 transitivereach 531 importersview sourcekind tooltopic tls13
docsdependenciesstructsconstsfunctions

about

nx_tls13_read_record_from_fd.nx -- read ONE TLS record from a file descriptor into a caller-supplied buffer. Step 3c.6a of the nx_https_client wiring arc. This is the network-IO helper that step 3c.6b (the top-level handshake-run orchestrator) uses every time it needs the server's next record. TLS record framing (RFC 8446 §5.1): [0] ContentType (1 byte) [1..2] legacy_record_version (2 bytes, big-endian) [3..4] length (2 bytes, big-endian) [5..] fragment / ciphertext (length bytes) Total record size = 5 + length. This primitive: 1. Reads 5 bytes from fd (looping sys_read to handle partial reads from TCP -- a typical kernel ships TCP data in MTU-sized chunks) 2. Parses the 2-byte length field 3. Validates length <= out_cap - 5 and length <= TLS spec max (2^14 + 256 = 16640 per RFC 8446 §5.2) 4. Reads `length` more bytes from fd into out_buf[5..5+length] 5. Returns 5 + length on success On failure: returns NEGATIVE -NX_TLS13_READ_REC_* code. Public API: nx_tls13_read_record_from_fd(fd, out_buf, out_cap) -> POSITIVE total bytes written | NEGATIVE -verdict nx_tls13_read_rec_verdict_is_valid(v) -> 0|1 Sealed verdict: NX_TLS13_READ_REC_OK positive rc = bytes written NX_TLS13_READ_REC_EOF fd closed before 5-byte header NX_TLS13_READ_REC_PAYLOAD_EOF fd closed mid-payload NX_TLS13_READ_REC_BUF_OVERFLOW length exceeds out_cap NX_TLS13_READ_REC_TOO_LONG length exceeds RFC §5.2 max

dependencies 2 imports · 37 importers

nx_syscalls.nx nx_tls13_record.nx nx_tls13_read_record_from_fd.n _h2_serve_loopback_gate.nx nx_cms_tls_front.nx nx_cms_tls_gate.nx nx_dev_api_build_probe.nx nx_h2_client_over_tls.nx nx_h2_serve.nx nx_h2_serve_multi.nx nx_https_get_complete.nx nx_https_get_spoof.nx nx_https_get_stream.nx

diagram shows first 10 each side; +0 more imports, +27 more importers in the complete lists below.

imports: nx_syscalls.nxnx_tls13_record.nx

imported by: _h2_serve_loopback_gate.nxnx_cms_tls_front.nxnx_cms_tls_gate.nxnx_dev_api_build_probe.nxnx_h2_client_over_tls.nxnx_h2_serve.nxnx_h2_serve_multi.nxnx_https_get_complete.nxnx_https_get_spoof.nxnx_https_get_stream.nxnx_https_ka_probe.nxnx_https_post_complete.nxnx_lib_fetch_cookie.nxnx_login_e2e_probe.nxnx_mcp_call.nxnx_mgmt_client.nxnx_porkbun_ping_probe.nxnx_research_ka.nxnx_sites_daemon_v2.nxnx_sites_reconciled.nxnx_sites_sni_cert_gate.nxnx_sovgit_push.nxnx_tls12_client_session.nxnx_tls12_frag_read_gate.nxnx_tls12_probe_test.nxnx_tls13_ch_compat_test.nxnx_tls13_client_h2run.nxnx_tls13_client_session_run.nxnx_tls13_read_record_from_fd_loopback_test.nxnx_tls13_read_record_from_fd_test.nxnx_tls13_recv_hs_diff_test.nxnx_tls13_recv_hs_probe_test.nxnx_tls13_server_session_run.nxnx_tls13_server_session_run_h2.nxnx_tls13_server_session_run_mtls.nxnx_tls13_sh_probe_test.nxnx_video_get.nx

structs

none

consts

62const NX_TLS13_READ_REC_OK: i64 = 1
63const NX_TLS13_READ_REC_EOF: i64 = 2
64const NX_TLS13_READ_REC_PAYLOAD_EOF: i64 = 3
65const NX_TLS13_READ_REC_BUF_OVERFLOW: i64 = 4
66const NX_TLS13_READ_REC_TOO_LONG: i64 = 5
67const NX_TLS13_READ_REC_READ_ERR: i64 = 6
68const NX_TLS13_READ_REC_VERDICT_N: i64 = 7

functions

70func nx_tls13_read_rec_verdict_is_valid(v: i64) -> i64
called by 1: main
79func _read_n(fd: i64, buf: *u8, off: i64, n: i64) -> i64
94func nx_tls13_read_record_from_fd(
126func main() -> i64