mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 17:15:43 +00:00
Create easytier-core as the portable owner of configuration, connectivity, tunnels, peer and routing state, gateways, management, the data plane, and instance lifecycle. Keep operating-system integration, native protocol engines, process startup, and presentation in easytier behind explicit Host capability adapters. Create easytier-proto to own schemas, generated RPC types, descriptors, and feature-scoped protocol slices. Remove runtime protobuf reflection from core while preserving unknown route-peer fields across forwarding. Normalize instance construction through CoreInstance, CoreHostAdapters, CoreProcessRuntime, and InstanceManager. Make the runtime config store the only authoritative mutable configuration after startup. Move the portable TCP/UDP data plane into core and extract a generic OperationBroker for completion, cancellation, disposal, and capacity accounting. Expose the session-based FFI v2 completion API and keep the WASI guest ABI, wire schemas, and adapters with core. Migrate CLI, GUI, web, FFI, Android JNI, OHOS, uptime, and mobile consumers to the shared manager and core state. Add explicit user/web config ownership and revision-aware web reconciliation. Preserve configuration, wire, and management behavior while fixing regressions discovered by the full platform and integration matrix: - inherit advertised relay capabilities in foreign networks; - refresh OSPF peer state immediately after runtime config changes; - restore CLI GlobalCtx event output without forcing GUI logging; - retain legacy encryption names and standalone RPC tunnel metadata; - restore ICMP host composition and fragmented UDP handling; - use portable 64-bit atomics on 32-bit MIPS targets; and - retain discarded operations until late cancellation completes. Validate the refactor across 45 GitHub checks, including Linux, macOS, Windows, FreeBSD, web, GUI, Android, OHOS, feature profiles, and three-node and subnet-proxy integration tests. BREAKING CHANGE: internal Rust module paths are not preserved. Legacy native data-plane APIs are replaced by the session-based FFI v2 API. The dedicated Android data-plane wrapper is removed.
101 lines
3.0 KiB
Markdown
101 lines
3.0 KiB
Markdown
# Native data-plane ABI v2
|
|
|
|
The native data-plane ABI is a thin adapter over the instance-owned
|
|
`DataPlaneSession`. It does not own sockets, operation state, completion
|
|
queues, routing policy, or timeouts.
|
|
|
|
## Conventions
|
|
|
|
- Every immediate call returns `0` on success or a negative
|
|
`DataPlaneErrorKind` value on failure.
|
|
- `data_plane_completion_wait` returns `1` when a completion is ready, `0` on
|
|
timeout or session close, and a negative error value on failure.
|
|
- `data_plane_completion_drain` returns a non-negative descriptor count or a
|
|
negative error value.
|
|
- Handle zero is invalid.
|
|
- `timeout_ms == UINT64_MAX` means no deadline. Every other timeout starts when
|
|
submission is accepted, including time spent waiting for an I/O direction
|
|
lock.
|
|
- Request and write bytes are copied before a submit call returns.
|
|
- Socket-address fields use native-endian integers. Address bytes are in
|
|
network order. ABI v2 accepts IPv4 only.
|
|
|
|
`DataPlaneSocketAddr` is:
|
|
|
|
```c
|
|
typedef struct {
|
|
uint16_t family; /* 4 */
|
|
uint16_t port;
|
|
uint8_t address[16]; /* IPv4 uses the first four bytes */
|
|
} DataPlaneSocketAddr;
|
|
```
|
|
|
|
`DataPlaneCompletion` is:
|
|
|
|
```c
|
|
typedef struct {
|
|
uint64_t operation_id;
|
|
uint16_t operation_kind;
|
|
uint16_t status; /* 0 or DataPlaneErrorKind */
|
|
} DataPlaneCompletion;
|
|
```
|
|
|
|
## Lifecycle
|
|
|
|
One native session may be open for an EasyTier instance at a time:
|
|
|
|
```text
|
|
data_plane_session_open
|
|
-> submit operations
|
|
-> completion_wait
|
|
-> completion_drain
|
|
-> typed result_take
|
|
-> resource_close / operation_free
|
|
data_plane_session_close
|
|
```
|
|
|
|
Closing a native session cancels and discards its outstanding operations and
|
|
resources and wakes a thread blocked in `data_plane_completion_wait`.
|
|
|
|
The resource and operation IDs returned by the ABI belong to that session.
|
|
They must always be passed together with the same session handle.
|
|
|
|
## Completion and result ownership
|
|
|
|
Submission returns an operation ID immediately. Completion descriptors carry
|
|
only the operation ID, operation kind, and terminal status. Draining a
|
|
descriptor makes its typed result available but does not consume it.
|
|
|
|
`data_plane_result_size` reports the TCP-read or UDP-receive payload size.
|
|
Typed result-take functions consume the result exactly once. If a supplied
|
|
buffer is too small, they return `-BufferTooSmall` and leave the result
|
|
available for a later call.
|
|
|
|
Call `data_plane_operation_free` when a drained result is intentionally
|
|
abandoned. Call `data_plane_resource_close` for TCP streams, listeners, and
|
|
UDP sockets.
|
|
|
|
## Operation kinds
|
|
|
|
| Value | Operation |
|
|
| ---: | --- |
|
|
| 1 | TCP connect |
|
|
| 2 | TCP bind |
|
|
| 3 | TCP accept |
|
|
| 4 | TCP read |
|
|
| 5 | TCP write |
|
|
| 6 | UDP bind |
|
|
| 7 | UDP receive |
|
|
| 8 | UDP send |
|
|
|
|
The exported function families are:
|
|
|
|
- `data_plane_tcp_*_submit`
|
|
- `data_plane_udp_*_submit`
|
|
- `data_plane_completion_wait`
|
|
- `data_plane_completion_drain`
|
|
- `data_plane_*_result_take`
|
|
- `data_plane_operation_cancel`
|
|
- `data_plane_operation_free`
|
|
- `data_plane_resource_close`
|