59 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
88 lines
4.7 KiB
Markdown
88 lines
4.7 KiB
Markdown
# Ordered native session packet stream
|
||
|
||
This is a reusable library boundary for future Forever engine integration.
|
||
It is **not actual Forever native authentication or world entry**. The existing
|
||
gateway remains intact. No client hook, UI registration, binary patch or server
|
||
modification was needed for this increment.
|
||
|
||
## Interface and ownership
|
||
|
||
`native/session.h` now exposes three operations:
|
||
|
||
- `gw_native_begin_world`: validate the selected GUID against the authenticated
|
||
roster and send the real character-login request once. It consumes no server
|
||
initialization packets.
|
||
- `gw_native_receive`: return one decrypted packet in wire order. Insufficient
|
||
capacity returns -3 with opcode and required size. The same packet remains
|
||
pending for a retry; no partial payload is copied. Empty payloads work with a
|
||
null buffer and zero capacity.
|
||
- `gw_native_send`: send bounded gameplay packets using the authenticated
|
||
session's existing framing and header encryption. Dedicated authentication,
|
||
character-login and integrity-response opcodes cannot be supplied here.
|
||
|
||
One owner thread must serialize access to each handle. Session keys and sockets
|
||
remain opaque. Receive currently blocks with the existing transport deadline;
|
||
it must not be called directly from a render/UI callback. A future engine adapter
|
||
needs a network worker and a verified main-thread dispatch/ownership boundary.
|
||
|
||
Transport/malformed-frame failures permanently return -2; unsupported integrity
|
||
challenges permanently return -4. The caller must close the handle and establish
|
||
a new authenticated session. There is no fabricated integrity response or
|
||
relaxed SRP proof check. The older `gw_native_enter` is a consuming diagnostic
|
||
helper; an engine adapter must choose the begin/receive path instead.
|
||
|
||
## Source basis
|
||
|
||
`src/legacy_client.cpp` implements `LegacyLogin::authenticate`,
|
||
`LegacySession::login`, `send` and `receive`; these remain the shared protocol
|
||
implementation. `src/protocol.cpp::frame` enforces the existing client payload
|
||
limit of10236 bytes and opcode bound10240. The server frame has a16-bit size
|
||
including its two-byte opcode, allowing65533 payload bytes. No modern Forever
|
||
packet format is substituted for this transport.
|
||
|
||
Authoritative Tortoise references, read without modification:
|
||
|
||
- `~/Servers/tortoise-wow/src/game/Protocol/Opcodes_1_12_1.h`: actual
|
||
CMSG_PING0x1DC and SMSG_PONG0x1DD, plus the character/world opcode definitions.
|
||
- `~/Servers/tortoise-wow/src/game/Protocol/WorldSocket.cpp::HandlePing`:
|
||
reads two uint32 values (sequence and latency), requires an authenticated
|
||
world session, and replies with the four-byte sequence.
|
||
|
||
## Verification
|
||
|
||
`tests/loopback_fixture.py --stream` exercises the existing13 authenticated
|
||
discovery cases plus post-login integrity, EOF and malformed-header failures.
|
||
`tests/native_realm_driver.cpp` checks ordering, repeatable capacity negotiation,
|
||
untouched destination buffers on failure, empty packets, duplicate/invalid GUID
|
||
rejection, protected opcodes, size bounds and terminal session errors. Fixtures
|
||
use synthetic credentials exclusively, including invalid-proof cases.
|
||
|
||
`ops/native_stream_local.py` also exercised the installed native library against
|
||
the actual local Tortoise authentication and world services with the gateway
|
||
port absent. Real SRP/M2 verification, advertised loopback realm selection,
|
||
character4509 level60, world initialization and a compressed object update were
|
||
received. All30 packets up to that update were retained in order; four capacity
|
||
retries preserved their packet. A real ping received its matching pong.
|
||
|
||
The measured library sequence took0.1951s. Its loopback ping was0.000076s; this
|
||
is not a Forever engine latency measurement or a gateway performance comparison.
|
||
The tool sent no movement, talents, spells or GM commands. A subsequent read-only
|
||
database query confirmed the same level60, health2609, money10000 and Hall of
|
||
Arms map/position. Normal server login/logout persistence is possible.
|
||
|
||
Typed evidence is in `evidence/gameplay/native-local-ordered-stream.json`.
|
||
Only opcode/length metadata and public character/world values are exported;
|
||
packet bodies, credentials and cryptographic material are omitted.
|
||
|
||
Full regression results: ordinary CTest18/18 in16.77s; ASan/UBSan18/18
|
||
in17.62s. Python compilation and `git diff --check` also passed.
|
||
|
||
## Remaining engine boundary
|
||
|
||
Forever's real authenticated account/realm caches, connection object and
|
||
main-thread dispatch ownership have not been adopted. The clean actual Forever
|
||
client remains a separate login-screen stability control. This library test
|
||
does not satisfy native-client milestones B–E. The disabled credential-capture
|
||
experiment must not be re-enabled to bridge this gap: its loader failure is
|
||
documented in `LOGIN_STABILITY_20261015.md`.
|