nx_bencode.nx
buildroot/runtime/nx_bencode.nx
about
nx_bencode.nx -- bencoding parser (bits-up), the BitTorrent keystone.
module: nishi-core.torrent.bencode
depends: nx_syscalls.nx
capability: CORE_COMPUTE
wired_status: FULLY_WIRED
genealogy_id: bittorrent_bep0003_bencoding
The format ALL of BitTorrent is built on (.torrent metainfo, tracker
responses, the peer wire protocol's extended messages): integers (i<d>e),
byte strings (<len>:<bytes>), lists (l..e), dicts (d<key><val>..e). Parsing
is length-driven (strings carry their length), so a real parser is required
(you cannot byte-count 'e's -- strings contain arbitrary bytes). First piece
of the sovereign torrent client; the tracker-announce step reuses
nx_http_get_ua + nx_net_governor (the primitives extracted this session).
Iterative skip (no recursion); offsets returned, no copying. Deterministic.
dependencies 1 imports · 13 importers
diagram shows first 10 each side; +0 more imports, +3 more importers in the complete lists below.
imports: nx_syscalls.nx
imported by: nx_bencode_test.nxnx_dht.nxnx_http_tracker.nxnx_metainfo.nxnx_peer_ext_handshake.nxnx_peer_meta_live.nxnx_peer_metadata.nxnx_pex.nxnx_torrent_daemon.nxnx_torrent_extract.nxnx_torrent_peer_dl.nxnx_torrent_seedeval.nxnx_tracker.nx
structs
| none |
consts
| 21 | const NX_BC_ERR: i64 = 0 |
| 22 | const NX_BC_INT: i64 = 1 |
| 23 | const NX_BC_STR: i64 = 2 |
| 24 | const NX_BC_LIST: i64 = 3 |
| 25 | const NX_BC_DICT: i64 = 4 |
functions
| 27 | func _bc_is_digit(c: i64) -> i64 { if c >= 0x30 { if c <= 0x39 { return 1 } } return 0 } |
| 29 | func _bc_bytes_eq(buf: *u8, off: i64, key: *u8, keylen: i64) -> i64 called by 1: nx_bc_dict_get |
| 36 | func nx_bc_type(buf: *u8, off: i64, n: i64) -> i64 |
| 47 | func nx_bc_int(buf: *u8, off: i64, n: i64, out_val: *i64) -> i64 |
| 64 | func nx_bc_str(buf: *u8, off: i64, n: i64, out_so: *i64, out_sl: *i64) -> i64 called by 15: nx_bc_dict_getmaindht_parse_tokendht_parse_valuesdht_parse_nodesht_parse_peers+9 calls 1: _bc_is_digit |
| 79 | func nx_bc_skip(buf: *u8, off: i64, n: i64) -> i64 called by 13: nx_bc_dict_getdht_parse_valuesnx_metainfo_parsepm_childmainpp_child+7 calls 1: _bc_is_digit |
| 110 | func nx_bc_dict_get(buf: *u8, dict_off: i64, n: i64, key: *u8, keylen: i64) -> i64 called by 24: maindht_parse_tokendht_is_responsedht_parse_valuesdht_parse_nodesmain+18 calls 4: sys_mmapnx_bc_str_bc_bytes_eqnx_bc_skip |