Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace usage of tabs in wasi:sockets with spaces #7296

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/wasi-http/wit/deps/sockets/instance-network.wit
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

/// This interface provides a value-export of the default network handle..
interface instance-network {
use network.{network};
use network.{network};

/// Get a handle to the default network.
instance-network: func() -> network;
/// Get a handle to the default network.
instance-network: func() -> network;

}
108 changes: 54 additions & 54 deletions crates/wasi-http/wit/deps/sockets/ip-name-lookup.wit
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@

interface ip-name-lookup {
use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
use network.{network, error-code, ip-address, ip-address-family};
use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
use network.{network, error-code, ip-address, ip-address-family};


/// Resolve an internet host name to a list of IP addresses.
///
/// See the wasi-socket proposal README.md for a comparison with getaddrinfo.
///
/// # Parameters
/// - `name`: The name to look up. IP addresses are not allowed. Unicode domain names are automatically converted
/// to ASCII using IDNA encoding.
/// - `address-family`: If provided, limit the results to addresses of this specific address family.
/// - `include-unavailable`: When set to true, this function will also return addresses of which the runtime
/// thinks (or knows) can't be connected to at the moment. For example, this will return IPv6 addresses on
/// systems without an active IPv6 interface. Notes:
/// - Even when no public IPv6 interfaces are present or active, names like "localhost" can still resolve to an IPv6 address.
/// - Whatever is "available" or "unavailable" is volatile and can change everytime a network cable is unplugged.
///
/// This function never blocks. It either immediately fails or immediately returns successfully with a `resolve-address-stream`
/// that can be used to (asynchronously) fetch the results.
///
/// At the moment, the stream never completes successfully with 0 items. Ie. the first call
/// to `resolve-next-address` never returns `ok(none)`. This may change in the future.
///
/// # Typical errors
/// - `invalid-argument`: `name` is a syntactically invalid domain name.
/// - `invalid-argument`: `name` is an IP address.
/// - `not-supported`: The specified `address-family` is not supported. (EAI_FAMILY)
///
/// # References:
/// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
/// - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
/// - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
/// - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
resolve-addresses: func(network: borrow<network>, name: string, address-family: option<ip-address-family>, include-unavailable: bool) -> result<resolve-address-stream, error-code>;
/// Resolve an internet host name to a list of IP addresses.
///
/// See the wasi-socket proposal README.md for a comparison with getaddrinfo.
///
/// # Parameters
/// - `name`: The name to look up. IP addresses are not allowed. Unicode domain names are automatically converted
/// to ASCII using IDNA encoding.
/// - `address-family`: If provided, limit the results to addresses of this specific address family.
/// - `include-unavailable`: When set to true, this function will also return addresses of which the runtime
/// thinks (or knows) can't be connected to at the moment. For example, this will return IPv6 addresses on
/// systems without an active IPv6 interface. Notes:
/// - Even when no public IPv6 interfaces are present or active, names like "localhost" can still resolve to an IPv6 address.
/// - Whatever is "available" or "unavailable" is volatile and can change everytime a network cable is unplugged.
///
/// This function never blocks. It either immediately fails or immediately returns successfully with a `resolve-address-stream`
/// that can be used to (asynchronously) fetch the results.
///
/// At the moment, the stream never completes successfully with 0 items. Ie. the first call
/// to `resolve-next-address` never returns `ok(none)`. This may change in the future.
///
/// # Typical errors
/// - `invalid-argument`: `name` is a syntactically invalid domain name.
/// - `invalid-argument`: `name` is an IP address.
/// - `not-supported`: The specified `address-family` is not supported. (EAI_FAMILY)
///
/// # References:
/// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
/// - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
/// - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
/// - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
resolve-addresses: func(network: borrow<network>, name: string, address-family: option<ip-address-family>, include-unavailable: bool) -> result<resolve-address-stream, error-code>;

resource resolve-address-stream {
/// Returns the next address from the resolver.
///
/// This function should be called multiple times. On each call, it will
/// return the next address in connection order preference. If all
/// addresses have been exhausted, this function returns `none`.
///
/// This function never returns IPv4-mapped IPv6 addresses.
///
/// # Typical errors
/// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY)
/// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
/// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL)
/// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN)
resolve-next-address: func() -> result<option<ip-address>, error-code>;
resource resolve-address-stream {
/// Returns the next address from the resolver.
///
/// This function should be called multiple times. On each call, it will
/// return the next address in connection order preference. If all
/// addresses have been exhausted, this function returns `none`.
///
/// This function never returns IPv4-mapped IPv6 addresses.
///
/// # Typical errors
/// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY)
/// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
/// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL)
/// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN)
resolve-next-address: func() -> result<option<ip-address>, error-code>;

/// Create a `pollable` which will resolve once the stream is ready for I/O.
///
/// Note: this function is here for WASI Preview2 only.
/// It's planned to be removed when `future` is natively supported in Preview3.
subscribe: func() -> pollable;
}
/// Create a `pollable` which will resolve once the stream is ready for I/O.
///
/// Note: this function is here for WASI Preview2 only.
/// It's planned to be removed when `future` is natively supported in Preview3.
subscribe: func() -> pollable;
}
}
212 changes: 106 additions & 106 deletions crates/wasi-http/wit/deps/sockets/network.wit
Original file line number Diff line number Diff line change
@@ -1,147 +1,147 @@

interface network {
/// An opaque resource that represents access to (a subset of) the network.
/// This enables context-based security for networking.
/// There is no need for this to map 1:1 to a physical network interface.
resource network;
/// An opaque resource that represents access to (a subset of) the network.
/// This enables context-based security for networking.
/// There is no need for this to map 1:1 to a physical network interface.
resource network;

/// Error codes.
///
/// In theory, every API can return any error code.
/// In practice, API's typically only return the errors documented per API
/// combined with a couple of errors that are always possible:
/// - `unknown`
/// - `access-denied`
/// - `not-supported`
/// - `out-of-memory`
/// - `concurrency-conflict`
///
/// See each individual API for what the POSIX equivalents are. They sometimes differ per API.
enum error-code {
// ### GENERAL ERRORS ###
/// Error codes.
///
/// In theory, every API can return any error code.
/// In practice, API's typically only return the errors documented per API
/// combined with a couple of errors that are always possible:
/// - `unknown`
/// - `access-denied`
/// - `not-supported`
/// - `out-of-memory`
/// - `concurrency-conflict`
///
/// See each individual API for what the POSIX equivalents are. They sometimes differ per API.
enum error-code {
// ### GENERAL ERRORS ###

/// Unknown error
unknown,
/// Unknown error
unknown,

/// Access denied.
///
/// POSIX equivalent: EACCES, EPERM
access-denied,
/// Access denied.
///
/// POSIX equivalent: EACCES, EPERM
access-denied,

/// The operation is not supported.
///
/// POSIX equivalent: EOPNOTSUPP
not-supported,
/// The operation is not supported.
///
/// POSIX equivalent: EOPNOTSUPP
not-supported,

/// One of the arguments is invalid.
///
/// POSIX equivalent: EINVAL
invalid-argument,
/// One of the arguments is invalid.
///
/// POSIX equivalent: EINVAL
invalid-argument,

/// Not enough memory to complete the operation.
///
/// POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
out-of-memory,
/// Not enough memory to complete the operation.
///
/// POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
out-of-memory,

/// The operation timed out before it could finish completely.
timeout,
/// The operation timed out before it could finish completely.
timeout,

/// This operation is incompatible with another asynchronous operation that is already in progress.
///
/// POSIX equivalent: EALREADY
concurrency-conflict,
/// This operation is incompatible with another asynchronous operation that is already in progress.
///
/// POSIX equivalent: EALREADY
concurrency-conflict,

/// Trying to finish an asynchronous operation that:
/// - has not been started yet, or:
/// - was already finished by a previous `finish-*` call.
///
/// Note: this is scheduled to be removed when `future`s are natively supported.
not-in-progress,
/// Trying to finish an asynchronous operation that:
/// - has not been started yet, or:
/// - was already finished by a previous `finish-*` call.
///
/// Note: this is scheduled to be removed when `future`s are natively supported.
not-in-progress,

/// The operation has been aborted because it could not be completed immediately.
///
/// Note: this is scheduled to be removed when `future`s are natively supported.
would-block,
/// The operation has been aborted because it could not be completed immediately.
///
/// Note: this is scheduled to be removed when `future`s are natively supported.
would-block,



// ### TCP & UDP SOCKET ERRORS ###
// ### TCP & UDP SOCKET ERRORS ###

/// The operation is not valid in the socket's current state.
invalid-state,
/// The operation is not valid in the socket's current state.
invalid-state,

/// A new socket resource could not be created because of a system limit.
new-socket-limit,
/// A new socket resource could not be created because of a system limit.
new-socket-limit,

/// A bind operation failed because the provided address is not an address that the `network` can bind to.
address-not-bindable,
/// A bind operation failed because the provided address is not an address that the `network` can bind to.
address-not-bindable,

/// A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.
address-in-use,
/// A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.
address-in-use,

/// The remote address is not reachable
remote-unreachable,
/// The remote address is not reachable
remote-unreachable,


// ### TCP SOCKET ERRORS ###
// ### TCP SOCKET ERRORS ###

/// The connection was forcefully rejected
connection-refused,
/// The connection was forcefully rejected
connection-refused,

/// The connection was reset.
connection-reset,
/// The connection was reset.
connection-reset,

/// A connection was aborted.
connection-aborted,
/// A connection was aborted.
connection-aborted,


// ### UDP SOCKET ERRORS ###
datagram-too-large,
// ### UDP SOCKET ERRORS ###
datagram-too-large,


// ### NAME LOOKUP ERRORS ###
// ### NAME LOOKUP ERRORS ###

/// Name does not exist or has no suitable associated IP addresses.
name-unresolvable,
/// Name does not exist or has no suitable associated IP addresses.
name-unresolvable,

/// A temporary failure in name resolution occurred.
temporary-resolver-failure,
/// A temporary failure in name resolution occurred.
temporary-resolver-failure,

/// A permanent failure in name resolution occurred.
permanent-resolver-failure,
}
/// A permanent failure in name resolution occurred.
permanent-resolver-failure,
}

enum ip-address-family {
/// Similar to `AF_INET` in POSIX.
ipv4,
enum ip-address-family {
/// Similar to `AF_INET` in POSIX.
ipv4,

/// Similar to `AF_INET6` in POSIX.
ipv6,
}
/// Similar to `AF_INET6` in POSIX.
ipv6,
}

type ipv4-address = tuple<u8, u8, u8, u8>;
type ipv6-address = tuple<u16, u16, u16, u16, u16, u16, u16, u16>;
type ipv4-address = tuple<u8, u8, u8, u8>;
type ipv6-address = tuple<u16, u16, u16, u16, u16, u16, u16, u16>;

variant ip-address {
ipv4(ipv4-address),
ipv6(ipv6-address),
}
variant ip-address {
ipv4(ipv4-address),
ipv6(ipv6-address),
}

record ipv4-socket-address {
port: u16, // sin_port
address: ipv4-address, // sin_addr
}
record ipv4-socket-address {
port: u16, // sin_port
address: ipv4-address, // sin_addr
}

record ipv6-socket-address {
port: u16, // sin6_port
flow-info: u32, // sin6_flowinfo
address: ipv6-address, // sin6_addr
scope-id: u32, // sin6_scope_id
}
record ipv6-socket-address {
port: u16, // sin6_port
flow-info: u32, // sin6_flowinfo
address: ipv6-address, // sin6_addr
scope-id: u32, // sin6_scope_id
}

variant ip-socket-address {
ipv4(ipv4-socket-address),
ipv6(ipv6-socket-address),
}
variant ip-socket-address {
ipv4(ipv4-socket-address),
ipv6(ipv6-socket-address),
}

}
Loading