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: AWasmPtrpointing to the memory location where the CIDR (Classless Inter-Domain Routing) notation of the destination IP address range is stored.via_router: AWasmPtrpointing to the memory location where the IP address of the next hop router is stored.preferred_until: AWasmPtrpointing to the memory location where the preferred duration for the route is stored.expires_at: AWasmPtrpointing 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
cidrparameter, which should point to a memory location that stores the CIDR in the__wasi_cidr_tformat. - The IP address of the next hop router is provided through the
via_routerparameter, which should point to a memory location that stores the IP address in the__wasi_addr_tformat. - The preferred duration for the route and the expiration time of the route can be optionally specified through the
preferred_untilandexpires_atparameters, respectively. These parameters should point to memory locations that storeOptionTimestampvalues. - 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.