port_route_add()
Adds a new route to the local port.
Description
The port_route_add()
function adds a new route to the routing table of the local port. A route specifies how network traffic should be forwarded based on the destination IP address.
Syntax
;;; Adds a new route to the local port
(@interface func (export "port_route_add")
(param $cidr (@witx const_pointer $addr_cidr))
(param $via_router (@witx const_pointer $addr))
(param $preferred_until (@witx const_pointer $option_timestamp))
(param $expires_at (@witx const_pointer $option_timestamp))
(result $error (expected (error $errno)))
)
Parameters
ctx
: A mutable reference to the function environment.cidr
: AWasmPtr
pointing to the memory location where the CIDR (Classless Inter-Domain Routing) notation of the destination IP address range is stored.via_router
: AWasmPtr
pointing to the memory location where the IP address of the next hop router is stored.preferred_until
: AWasmPtr
pointing to the memory location where the preferred duration for the route is stored.expires_at
: AWasmPtr
pointing to the memory location where the expiration time of the route is stored.
Return Value
The function returns a Result
indicating the outcome of the operation. If the operation is successful, Ok(Errno::Success)
is returned. If an error occurs, an appropriate WasiError
is returned.
Notes
- The
port_route_add()
function adds a new route to the routing table of the local port, specifying how network traffic should be forwarded for the specified destination IP address range. - The CIDR notation of the destination IP address range is provided through the
cidr
parameter, which should point to a memory location that stores the CIDR in the__wasi_cidr_t
format. - The IP address of the next hop router is provided through the
via_router
parameter, which should point to a memory location that stores the IP address in the__wasi_addr_t
format. - The preferred duration for the route and the expiration time of the route can be optionally specified through the
preferred_until
andexpires_at
parameters, respectively. These parameters should point to memory locations that storeOptionTimestamp
values. - The behavior and limitations of the
port_route_add()
function may vary depending on the specific runtime environment and underlying networking implementation. It is important to consult the documentation or specifications of the specific environment to understand its behavior in that context.