Files
WoW-Hybrid-gateway/native/session.h
T
praxisandClaude Fable 5.2 8e02dccb86 In-client stack: transport, session lifecycle and engine bridge
175 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

221 lines
15 KiB
C

#pragma once
#include <stdint.h>
#include "serializer.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Local development ABI. No exceptions or owning C++ types cross this boundary. */
#define GW_NATIVE_ABI 1
struct gw_native_session;
struct gw_native_login;
struct gw_native_config {
uint32_t abi;
uint16_t auth_port, world_port;
uint32_t world_build;
const char *username, *password_path, *version_hash_path, *addon_path;
};
struct gw_native_character { uint64_t guid; uint32_t level, race, class_id; char name[64]; };
#define GW_NATIVE_ROSTER_DIAGNOSTICS_ABI 2
enum gw_native_roster_reason {
GW_NATIVE_ROSTER_OK=0,GW_NATIVE_ROSTER_COUNT_BOUND=1,GW_NATIVE_ROSTER_UNSUPPORTED_PAIR=2,
GW_NATIVE_ROSTER_GENDER_BOUND=3,GW_NATIVE_ROSTER_NAME_SHAPE=4,
GW_NATIVE_ROSTER_SOURCE_IDENTITY=5,GW_NATIVE_ROSTER_VISUAL_TYPE=6
};
struct gw_native_roster_diagnostic_row {
uint32_t race,class_id,gender,level,reason,preview_race;
};
struct gw_native_roster_diagnostics {
uint32_t abi,size,count,overall_reason;
struct gw_native_roster_diagnostic_row rows[10];
};
struct gw_native_world { uint32_t map, packets, objects; float x,y,z,orientation; };
struct gw_native_packet { uint32_t opcode,payload_bytes; };
struct gw_native_lifecycle {
uint32_t abi,size;
/* Backend facts only. These never imply Forever account/realm adoption. */
uint32_t server_proof_verified,world_authenticated,character_login_sent;
int32_t stream_error;
uint32_t ping_pending,pings_sent,pongs_received,packet_pending;
};
struct gw_native_auth_config {
uint32_t abi;
uint16_t auth_port;
const char *username,*password_path,*version_hash_path;
};
struct gw_native_auth_memory_config {
uint32_t abi;
uint16_t auth_port;
const char *username;
const uint8_t *password;
uint32_t password_bytes;
const char *version_hash_path;
};
/* Separate explicit opt-in endpoint profile. Version1 APIs remain restricted
* to loopback. Numeric IPv4 only; no DNS or implicit public configuration. */
#define GW_NATIVE_IPV4_ABI 2
struct gw_native_auth_memory_ipv4_config {
uint32_t abi,size;
uint16_t auth_port,reserved;
const char *auth_ipv4,*username;
const uint8_t *password;
uint32_t password_bytes;
const char *version_hash_path;
};
#define GW_NATIVE_IPV4_HASH_ABI 3
struct gw_native_auth_memory_ipv4_hash_config {
uint32_t abi,size;
uint16_t auth_port,reserved;
const char *auth_ipv4,*username;
const uint8_t *password;
uint32_t password_bytes;
const uint8_t *version_hash;
uint32_t version_hash_bytes;
};
struct gw_native_realm {
uint32_t type,flags,characters,category,wire_id;
float population;
char name[128],address[256];
};
/* Authenticates AND validates M2. No modern engine login state is fabricated.
* Discovery preserves the actual server metadata. Selection rejects offline or
* non-loopback endpoints, and derives the port from the advertised address. */
int gw_native_authenticate(const struct gw_native_auth_config*,struct gw_native_login**);
/* Same real SRP/M2 as the file API. Borrows password only for this call;
* caller must wipe its buffer afterwards. Never exports session keys. */
int gw_native_authenticate_memory(const struct gw_native_auth_memory_config*,struct gw_native_login**);
int gw_native_authenticate_memory_ipv4(const struct gw_native_auth_memory_ipv4_config*,struct gw_native_login**);
int gw_native_authenticate_memory_ipv4_hash(const struct gw_native_auth_memory_ipv4_hash_config*,struct gw_native_login**);
/* Private diagnostic variant: detail encodes Source challenge/proof rejection only. */
int gw_native_authenticate_memory_ipv4_hash_detail(const struct gw_native_auth_memory_ipv4_hash_config*,struct gw_native_login**,uint32_t* detail);
int gw_native_discover(struct gw_native_login*);
uint32_t gw_native_realm_count(const struct gw_native_login*);
int gw_native_realm_at(const struct gw_native_login*,uint32_t,struct gw_native_realm*);
int gw_native_select(struct gw_native_login*,uint32_t,const char* addon_path,uint32_t world_build,struct gw_native_session**);
void gw_native_login_close(struct gw_native_login*);
int gw_native_open(const struct gw_native_config*,struct gw_native_session**);
uint32_t gw_native_character_count(const struct gw_native_session*);
int gw_native_character_at(const struct gw_native_session*,uint32_t,struct gw_native_character*);
/* Encode the authenticated cached roster using the verified Forever codec.
* Namespace values are explicit compatibility routing IDs, not invented server
* metadata. -3 reports required bytes without a partial destination copy. */
int gw_native_encode_roster(const struct gw_native_session*,uint32_t realm_id,uint32_t virtual_address,uint32_t super_district,uint8_t*,uint32_t capacity,uint32_t* required);
/* Missing glue initialization dependency: explicit client presentation policy,
* only available on an authentically established backend session. It does not
* authenticate/adopt the Forever engine or execute any engine callback. */
int gw_native_encode_glue_features(const struct gw_native_session*,uint32_t max_characters,uint8_t*,uint32_t capacity,uint32_t* required);
/* Socket-free world protocol for an engine-owned transport. Created only from
* a verified SRP login and an advertised local online realm; no socket/key
* crosses this ABI. These helpers do not adopt the Forever engine. One owner.
* Feed consumes one bounded segment and leaves excess input with the caller.
* packet: 1=no packet, -3=capacity retry; send retries do not advance ciphers. */
struct gw_native_transport;
int gw_native_transport_open(struct gw_native_login*,uint32_t realm_index,const char* addon_path,uint32_t build,struct gw_native_transport**);
/* Socket-free preparation only; requires a verified explicit-profile login
* and genuine online numeric advertised realm. Old transport_open is local. */
int gw_native_transport_open_ipv4(struct gw_native_login*,uint32_t realm_index,const char* addon_path,uint32_t build,struct gw_native_transport**);
/* Borrowed bytes copied during this synchronous call. Matches file(addons,10000):
* 0..9999 bytes accepted, 10000+ refused. Old path APIs remain available. */
int gw_native_transport_open_ipv4_bytes(struct gw_native_login*,uint32_t realm_index,const uint8_t* addon_bytes,uint32_t addon_bytes_len,uint32_t build,struct gw_native_transport**);
uint16_t gw_native_transport_port(const struct gw_native_transport*);
int gw_native_transport_challenge(struct gw_native_transport*,uint32_t opcode,const uint8_t*,uint32_t size);
int gw_native_transport_auth_request(struct gw_native_transport*,uint8_t*,uint32_t capacity,uint32_t* required);
int gw_native_transport_feed(struct gw_native_transport*,const uint8_t*,uint32_t size,uint32_t* consumed);
int gw_native_transport_packet(struct gw_native_transport*,struct gw_native_packet*,uint8_t*,uint32_t capacity);
int gw_native_transport_send(struct gw_native_transport*,uint32_t opcode,const uint8_t*,uint32_t size,uint8_t*,uint32_t capacity,uint32_t* required);
/* Validates bounded ordinary SAY and preserves Turtle type/language semantics.
* Requires genuine authenticated world/self-create; never logs message text. */
int gw_native_transport_say(struct gw_native_transport*,const uint8_t*,uint32_t,uint8_t*,uint32_t,uint32_t*);
/* Visible GUID-bound selection, combat and NPC interaction requests. The server
* remains authoritative for range, permissions, inventory and action validity. */
/* Also accepts read-only4400B6 before world entry, scoped to the fresh
* authenticated emitted roster guild/member/realm; no world is created. */
int gw_native_transport_gameplay(struct gw_native_transport*,uint32_t,const uint8_t*,uint32_t,uint8_t*,uint32_t,uint32_t*);
/* Owned PE send completion for the prepared Worldport ACK; no payload/cipher advance. */
int gw_native_transport_gameplay_completed(struct gw_native_transport*,uint32_t);
/* Validates Forever's active-mover GUID against the selected authenticated
* character, then emits Turtle CMSG_SET_ACTIVE_MOVER (0x26A). */
int gw_native_transport_active_mover(struct gw_native_transport*,const uint8_t*,uint32_t,uint8_t*,uint32_t,uint32_t*);
/* After self-create, validates the selected GUID and sends Turtle mover
* confirmation before its first movement. Capacity retries advance neither
* cipher nor mover state; unsupported movement layouts fail closed. */
/* Movement validation rejection returns -1 before cipher/control advancement.
* Capacity retries remain -3; existing transport/cipher failures remain fatal. */
int gw_native_transport_movement(struct gw_native_transport*,uint32_t,const uint8_t*,uint32_t,uint8_t*,uint32_t,uint32_t*);
/* Validates the actual modern selection against the authenticated roster.
* Capacity retries do not commit selection or advance the Turtle cipher. */
int gw_native_transport_begin_world(struct gw_native_transport*,uint32_t realm_id,const uint8_t*,uint32_t size,uint8_t*,uint32_t capacity,uint32_t* required);
/* Drains only source-generated requests derived from actual server object
* packets. Empty=1; capacity retry=-3 leaves queue and cipher untouched. */
int gw_native_transport_world_request(struct gw_native_transport*,uint32_t*,uint8_t*,uint32_t,uint32_t*);
/* Public bounded entity counters/identities; no engine pointers or auth data. */
int gw_native_transport_motion_state(const struct gw_native_transport*,uint8_t*,uint32_t,uint32_t*);
int gw_native_transport_inventory_state(const struct gw_native_transport*,uint8_t*,uint32_t,uint32_t*);
int gw_native_transport_aura_state(const struct gw_native_transport*,uint8_t*,uint32_t,uint32_t*);
int gw_native_transport_entity_state(const struct gw_native_transport*,uint8_t*,uint32_t,uint32_t*);
/* Authenticated PLAYER_LOGIN selection plus already parsed initial Source
* spells. No self-create requirement. Output LE: SourceGUID64,count32,IDs32;
* <=4096 sorted unique IDs, including an empty ready list. No input or consume.
* Not ready/unbound=-1; capacity=-3 sets required and copies no partial body. */
int gw_native_transport_initial_spell_ids(const struct gw_native_transport*,uint8_t*,uint32_t,uint32_t*);
/* Translates only the last genuinely received/delivered world packet. Caller
* supplies the already ABI-verified source codec, never an engine callback.
* Output: count32, repeated opcode32,size32,body. Capacity retry is stable. */
/* Before world entry, only a retained source55 guild reply is projected
* through the existing guild writer/batch; actor/entity translation is unused. */
int gw_native_transport_world_packet(struct gw_native_transport*,uint32_t realm_id,uint32_t virtual_address,uint64_t bridge_epoch,
int (*codec)(uint32_t,const uint8_t*,uint32_t,uint32_t,uint8_t*,uint32_t,uint32_t*),uint8_t*,uint32_t capacity,uint32_t* required);
/* Public boolean state at the existing World-packet call boundary; no packet,
* credential, endpoint, GUID or pointer values are returned. Bit 31 marks a
* valid backend snapshot. Bits 0..6: authenticated, world exists, logout
* complete, realm matches, source packet pending, encoded output pending,
* local presentation pending. Call only while the owning registry is locked. */
uint32_t gw_native_transport_world_call_state(const struct gw_native_transport*,uint32_t realm_id);
/* Registry-locked selected-player state; this does not imply native processing. */
int gw_native_transport_world_self_created(const struct gw_native_transport*,uint32_t realm_id);
int gw_native_transport_authenticated(const struct gw_native_transport*);
/* Character data comes only from authenticated received Turtle enumeration.
* A decoded cache enables the engine adapter without a database or second socket.
* Encoding before enumeration is rejected, including before an empty roster. */
uint32_t gw_native_transport_character_count(const struct gw_native_transport*);
/* Authenticated cached-roster public metadata only. Never includes account,
* character name/GUID, realm address, credentials or raw packet contents. */
int gw_native_transport_roster_diagnostics(const struct gw_native_transport*,struct gw_native_roster_diagnostics*);
int gw_native_transport_character_at(const struct gw_native_transport*,uint32_t index,struct gw_native_character*);
int gw_native_transport_encode_roster(const struct gw_native_transport*,uint32_t realm_id,uint32_t virtual_address,uint32_t super_district,uint8_t*,uint32_t capacity,uint32_t* required);
/* Initialization inputs are available only after genuine world authentication.
* Auth metadata contains routing namespace, caller-supplied bridge clock and
* real discovered realm name. Only the verified unmetered Classic profile is
* supported; no modern race/class entitlements or account data are invented. */
int gw_native_transport_auth_metadata(const struct gw_native_transport*,uint32_t virtual_address,uint64_t bridge_epoch,uint8_t*,uint32_t capacity,uint32_t* required);
int gw_native_transport_encode_glue_features(const struct gw_native_transport*,uint32_t max_characters,uint8_t*,uint32_t capacity,uint32_t* required);
int gw_native_transport_encode_restrictions(const struct gw_native_transport*,uint32_t realm_id,uint32_t virtual_address,uint32_t super_district,uint8_t*,uint32_t capacity,uint32_t* required);
void gw_native_transport_close(struct gw_native_transport*);
/* Begin without consuming initialization packets. Unlike the diagnostic enter
* helper below, this preserves the complete ordered stream for engine adoption.
* One owner/thread per handle. No sockets or session keys cross this ABI. */
int gw_native_begin_world(struct gw_native_session*,uint64_t);
/* -3: capacity too small, metadata reports required size; retry returns the SAME
* packet. -4: unsupported integrity challenge, session fails closed. -2: stream
* error, close/re-authenticate. No partial packet copy on any failure. */
int gw_native_receive(struct gw_native_session*,struct gw_native_packet*,uint8_t* payload,uint32_t capacity);
/* Bounded gameplay packets only, after begin_world. Authentication, integrity
* replies and character-login requests cannot override dedicated handlers. */
int gw_native_send(struct gw_native_session*,uint32_t opcode,const uint8_t* payload,uint32_t size);
/* Authenticated socket maintenance is valid at character selection too.
* One outstanding ping. The caller schedules >=30s between real server pings.
* service: 0=no complete packet, 1=matching pong, 2=deferred non-control packet.
* A deferred packet remains owned by the session for receive; nothing is lost.
* Partial frames survive bounded waits (0..1000ms). Integrity fails closed. */
int gw_native_ping(struct gw_native_session*,uint32_t sequence,uint32_t latency);
int gw_native_service(struct gw_native_session*,uint32_t timeout_ms);
int gw_native_lifecycle_at(const struct gw_native_session*,struct gw_native_lifecycle*);
/* This verifies backend login only. It does NOT enter Forever's engine world. */
int gw_native_enter(struct gw_native_session*,uint64_t,struct gw_native_world*);
void gw_native_close(struct gw_native_session*);
int gw_native_transport_private_capture(struct gw_native_transport*,uint32_t,uint32_t,uint32_t,uint8_t*,uint32_t,uint32_t*);
int gw_native_transport_private_capture_body(struct gw_native_transport*,uint32_t,uint32_t,uint32_t,const uint8_t*,uint32_t,uint8_t*,uint32_t,uint32_t*);
#ifdef __cplusplus
}
#endif