| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.posix.socket; |
| |
| using fuchsia.io; |
| using fuchsia.net; |
| using fuchsia.net.interfaces; |
| using fuchsia.posix; |
| using zx; |
| |
| /// Socket shutdown mode. |
| type ShutdownMode = strict bits : uint16 { |
| /// Shutdown socket read endpoint. |
| READ = 1; |
| /// Shutdown socket write endpoint. |
| WRITE = 2; |
| }; |
| |
| /// A socket. |
| protocol BaseSocket { |
| compose fuchsia.io.Node; |
| |
| /// Set `SOL_SOCKET` -> `SO_REUSEADDR`. |
| SetReuseAddress(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_REUSEADDR`. |
| GetReuseAddress() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| // NOTE: get `SOL_SOCKET` -> `SO_TYPE` is implemented in the client |
| // (libfdio). |
| |
| /// Get `SOL_SOCKET` -> `SO_ERROR`. |
| /// Returns the last error if there is an error set on the socket. |
| GetError() -> (struct {}) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_BROADCAST`. |
| SetBroadcast(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_BROADCAST`. |
| GetBroadcast() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_SNDBUF`. |
| SetSendBuffer(struct { |
| value_bytes uint64; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_SNDBUF`. |
| GetSendBuffer() -> (struct { |
| value_bytes uint64; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_RCVBUF`. |
| SetReceiveBuffer(struct { |
| value_bytes uint64; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_RCVBUF`. |
| GetReceiveBuffer() -> (struct { |
| value_bytes uint64; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_KEEPALIVE`. |
| SetKeepAlive(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_KEEPALIVE`. |
| GetKeepAlive() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_OOBINLINE`. |
| SetOutOfBandInline(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_OOBINLINE`. |
| GetOutOfBandInline() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_NO_CHECK`. |
| SetNoCheck(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_NO_CHECK`. |
| GetNoCheck() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_LINGER`. |
| SetLinger(struct { |
| linger bool; |
| length_secs uint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_LINGER`. |
| GetLinger() -> (struct { |
| linger bool; |
| length_secs uint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_REUSEPORT`. |
| SetReusePort(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_REUSEPORT`. |
| GetReusePort() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| // NOTE: get `SOL_SOCKET` -> `SO_PEERCRED` not supported in netstack. |
| |
| // NOTE: get/set `SOL_SOCKET` -> `SO_SNDTIMEO` is implemented in the client |
| // (libfdio). |
| // NOTE: get/set `SOL_SOCKET` -> `SO_RCVTIMEO` is implemented in the client |
| // (libfdio). |
| |
| /// Get `SOL_SOCKET` -> `SO_ACCEPTCONN`. |
| GetAcceptConn() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_BINDTODEVICE`. |
| SetBindToDevice(struct { |
| value fuchsia.net.interfaces.name; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_BINDTODEVICE`. |
| GetBindToDevice() -> (struct { |
| value fuchsia.net.interfaces.name; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_SOCKET` -> `SO_TIMESTAMP`. |
| SetTimestamp(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_SOCKET` -> `SO_TIMESTAMP`. |
| GetTimestamp() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| }; |
| |
| /// A network socket. |
| protocol BaseNetworkSocket { |
| compose BaseSocket; |
| |
| /// Sets the local address used for the socket. |
| Bind(struct { |
| addr fuchsia.net.SocketAddress; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Initiates a connection to a remote address. |
| Connect(struct { |
| addr fuchsia.net.SocketAddress; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Clears connection information from this socket. |
| Disconnect() -> (struct {}) error fuchsia.posix.Errno; |
| /// Retrieves the local socket address. |
| GetSockName() -> (struct { |
| addr fuchsia.net.SocketAddress; |
| }) error fuchsia.posix.Errno; |
| /// Retrieves the remote socket address. |
| GetPeerName() -> (struct { |
| addr fuchsia.net.SocketAddress; |
| }) error fuchsia.posix.Errno; |
| /// Shuts down part of the socket. |
| Shutdown(struct { |
| mode ShutdownMode; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IP` -> `IP_TOS`. |
| SetIpTypeOfService(struct { |
| value uint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IP` -> `IP_TOS`. |
| GetIpTypeOfService() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IP` -> `IP_TTL`. |
| // [1, 255] but -1 means ipv4.sysctl_ip_default_ttl. |
| // https://github.com/torvalds/linux/blob/v5.11/net/ipv4/ip_sockglue.c#L1596-L1603 |
| SetIpTtl(struct { |
| value OptionalUint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IP` -> `IP_TTL`. |
| GetIpTtl() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IP` -> `IP_PKTINFO`. |
| SetIpPacketInfo(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IP` -> `IP_PKTINFO`. |
| GetIpPacketInfo() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IP` -> `IP_RECVTOS`. |
| SetIpReceiveTypeOfService(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IP` -> `IP_RECVTOS`. |
| GetIpReceiveTypeOfService() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IP` -> `IP_MULTICAST_IF`. |
| SetIpMulticastInterface(struct { |
| iface fuchsia.net.interface_id; |
| address fuchsia.net.Ipv4Address; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IP` -> `IP_MULTICAST_IF`. |
| GetIpMulticastInterface() -> (struct { |
| value fuchsia.net.Ipv4Address; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IP` -> `IP_MULTICAST_TTL`. |
| // [1, 255] but -1 means 1. |
| // https://github.com/torvalds/linux/blob/v5.11/net/ipv4/ip_sockglue.c#L1086-L1096 |
| SetIpMulticastTtl(struct { |
| value OptionalUint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IP` -> `IP_MULTICAST_TTL`. |
| GetIpMulticastTtl() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IP` -> `IP_MULTICAST_LOOP`. |
| SetIpMulticastLoopback(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IP` -> `IP_MULTICAST_LOOP`. |
| GetIpMulticastLoopback() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IP` -> `IP_ADD_MEMBERSHIP` |
| AddIpMembership(struct { |
| membership IpMulticastMembership; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Set `SOL_IP` -> `IP_DROP_MEMBERSHIP` |
| DropIpMembership(struct { |
| membership IpMulticastMembership; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IPV6` -> `IPV6_ADD_MEMBERSHIP`. |
| AddIpv6Membership(struct { |
| membership Ipv6MulticastMembership; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Set `SOL_IPV6` -> `IPV6_DROP_MEMBERSHIP`. |
| DropIpv6Membership(struct { |
| membership Ipv6MulticastMembership; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IPV6` -> `IPV6_MULTICAST_IF`. |
| SetIpv6MulticastInterface(struct { |
| value fuchsia.net.interface_id; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IPV6` -> `IPV6_MULTICAST_IF`. |
| GetIpv6MulticastInterface() -> (struct { |
| value fuchsia.net.interface_id; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IPV6` -> `IPV6_MULTICAST_HOPS`. |
| // [-1, 255] where -1 means IPV6_DEFAULT_MCASTHOPS, which is 1. |
| // https://github.com/torvalds/linux/blob/v5.11/net/ipv6/ipv6_sockglue.c#L742-L751 |
| SetIpv6MulticastHops(struct { |
| value OptionalUint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IPV6` -> `IPV6_MULTICAST_HOPS`. |
| GetIpv6MulticastHops() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IPV6` -> `IPV6_MULTICAST_LOOP`. |
| SetIpv6MulticastLoopback(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IPV6` -> `IPV6_MULTICAST_LOOP`. |
| GetIpv6MulticastLoopback() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IPV6` -> `IPV6_V6ONLY`. |
| SetIpv6Only(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IPV6` -> `IPV6_V6ONLY`. |
| GetIpv6Only() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| // NOTE: get `SOL_IPV6` -> `IPV6_PATHMTU` not supported in netstack. |
| |
| /// Set `SOL_IPV6` -> `IPV6_RECVTCLASS`. |
| SetIpv6ReceiveTrafficClass(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IPV6` -> `IPV6_RECVTCLASS`. |
| GetIpv6ReceiveTrafficClass() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_IPV6` -> `IPV6_TCLASS` |
| // NOTE: see https://tools.ietf.org/html/rfc3542.html for definitions. |
| // |
| // [-1, 255] where -1 means "kernel default", which is 0. |
| // https://github.com/torvalds/linux/blob/v5.11/net/ipv6/ipv6_sockglue.c#L592-L602 |
| SetIpv6TrafficClass(struct { |
| value OptionalUint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_IPV6` -> `IPV6_TCLASS`. |
| GetIpv6TrafficClass() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| |
| // TODO(https://fxbug.dev/82723): Remove once out-of-tree users no longer |
| // depend on the below methods. |
| @deprecated("Use Bind instead") |
| @selector("fuchsia.posix.socket/BaseSocket.Bind") |
| BaseSocketBind(struct { |
| addr fuchsia.net.SocketAddress; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use Connect instead") |
| @selector("fuchsia.posix.socket/BaseSocket.Connect") |
| BaseSocketConnect(struct { |
| addr fuchsia.net.SocketAddress; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use Disconnect instead") |
| @selector("fuchsia.posix.socket/BaseSocket.Disconnect") |
| BaseSocketDisconnect() -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetSockName instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetSockName") |
| BaseSocketGetSockName() -> (struct { |
| addr fuchsia.net.SocketAddress; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetPeerName instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetPeerName") |
| BaseSocketGetPeerName() -> (struct { |
| addr fuchsia.net.SocketAddress; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use Shutdown instead") |
| @selector("fuchsia.posix.socket/BaseSocket.Shutdown") |
| BaseSocketShutdown(struct { |
| mode ShutdownMode; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpTypeOfService instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpTypeOfService") |
| BaseSocketSetIpTypeOfService(struct { |
| value uint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpTypeOfService instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpTypeOfService") |
| BaseSocketGetIpTypeOfService() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpTtl instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpTtl") |
| BaseSocketSetIpTtl(struct { |
| value OptionalUint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpTtl instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpTtl") |
| BaseSocketGetIpTtl() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpPacketInfo instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpPacketInfo") |
| BaseSocketSetIpPacketInfo(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpPacketInfo instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpPacketInfo") |
| BaseSocketGetIpPacketInfo() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpReceiveTypeOfService instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpReceiveTypeOfService") |
| BaseSocketSetIpReceiveTypeOfService(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpReceiveTypeOfService instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpReceiveTypeOfService") |
| BaseSocketGetIpReceiveTypeOfService() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpMulticastInterface instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpMulticastInterface") |
| BaseSocketSetIpMulticastInterface(struct { |
| iface fuchsia.net.interface_id; |
| address fuchsia.net.Ipv4Address; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpMulticastInterface instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpMulticastInterface") |
| BaseSocketGetIpMulticastInterface() -> (struct { |
| value fuchsia.net.Ipv4Address; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpMulticastTtl instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpMulticastTtl") |
| BaseSocketSetIpMulticastTtl(struct { |
| value OptionalUint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpMulticastTtl instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpMulticastTtl") |
| BaseSocketGetIpMulticastTtl() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpMulticastLoopback instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpMulticastLoopback") |
| BaseSocketSetIpMulticastLoopback(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpMulticastLoopback instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpMulticastLoopback") |
| BaseSocketGetIpMulticastLoopback() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use AddIpMembership instead") |
| @selector("fuchsia.posix.socket/BaseSocket.AddIpMembership") |
| BaseSocketAddIpMembership(struct { |
| membership IpMulticastMembership; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use DropIpMembership instead") |
| @selector("fuchsia.posix.socket/BaseSocket.DropIpMembership") |
| BaseSocketDropIpMembership(struct { |
| membership IpMulticastMembership; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use AddIpv6Membership instead") |
| @selector("fuchsia.posix.socket/BaseSocket.AddIpv6Membership") |
| BaseSocketAddIpv6Membership(struct { |
| membership Ipv6MulticastMembership; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use DropIpv6Membership instead") |
| @selector("fuchsia.posix.socket/BaseSocket.DropIpv6Membership") |
| BaseSocketDropIpv6Membership(struct { |
| membership Ipv6MulticastMembership; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpv6MulticastInterface instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpv6MulticastInterface") |
| BaseSocketSetIpv6MulticastInterface(struct { |
| value fuchsia.net.interface_id; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpv6MulticastInterface instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpv6MulticastInterface") |
| BaseSocketGetIpv6MulticastInterface() -> (struct { |
| value fuchsia.net.interface_id; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpv6MulticastHops instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpv6MulticastHops") |
| BaseSocketSetIpv6MulticastHops(struct { |
| value OptionalUint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpv6MulticastHops instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpv6MulticastHops") |
| BaseSocketGetIpv6MulticastHops() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpv6MulticastLoopback instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpv6MulticastLoopback") |
| BaseSocketSetIpv6MulticastLoopback(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpv6MulticastLoopback instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpv6MulticastLoopback") |
| BaseSocketGetIpv6MulticastLoopback() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpv6Only instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpv6Only") |
| BaseSocketSetIpv6Only(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpv6Only instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpv6Only") |
| BaseSocketGetIpv6Only() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpv6ReceiveTrafficClass instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpv6ReceiveTrafficClass") |
| BaseSocketSetIpv6ReceiveTrafficClass(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpv6ReceiveTrafficClass instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpv6ReceiveTrafficClass") |
| BaseSocketGetIpv6ReceiveTrafficClass() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| @deprecated("Use SetIpv6TrafficClass instead") |
| @selector("fuchsia.posix.socket/BaseSocket.SetIpv6TrafficClass") |
| BaseSocketSetIpv6TrafficClass(struct { |
| value OptionalUint8; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| |
| @deprecated("Use GetIpv6TrafficClass instead") |
| @selector("fuchsia.posix.socket/BaseSocket.GetIpv6TrafficClass") |
| BaseSocketGetIpv6TrafficClass() -> (struct { |
| value uint8; |
| }) error fuchsia.posix.Errno; |
| }; |
| |
| /// IPv4 multicast membership options. |
| type IpMulticastMembership = struct { |
| /// Interface index for membership. |
| iface fuchsia.net.interface_id; |
| /// Local interface address requesting or relinquishing ownership. |
| local_addr fuchsia.net.Ipv4Address; |
| /// Address of the multicast group the membership refers to. |
| mcast_addr fuchsia.net.Ipv4Address; |
| }; |
| |
| /// IPv6 multicast membership options. |
| type Ipv6MulticastMembership = struct { |
| /// Interface index for membership. |
| iface fuchsia.net.interface_id; |
| /// Address of the multicast group the membership refers to. |
| mcast_addr fuchsia.net.Ipv6Address; |
| }; |
| |
| /// An optional byte value. |
| // This exists because FIDL does not allow optional integers. |
| type OptionalUint8 = strict union { |
| 1: value uint8; |
| 2: unset Empty; |
| }; |
| |
| /// An optional uint32 value. |
| // This exists because FIDL does not allow optional integers. |
| type OptionalUint32 = strict union { |
| 1: value uint32; |
| 2: unset Empty; |
| }; |
| |
| type Empty = struct {}; |
| |
| /// Socket level ancillary data that can be received. |
| /// |
| /// These match the POSIX `SOL_SOCKET` options. |
| type SocketRecvControlData = table { |
| /// The time in nanoseconds since epoch (January 1 1970 GMT) at which a |
| /// packet was received. |
| /// |
| /// Present if the `SOL_SOCKET` -> `SO_TIMESTAMP` option is enabled. |
| 1: timestamp_ns int64; |
| }; |
| |
| /// Network socket (L3) ancillary data that can be sent. |
| type NetworkSocketSendControlData = table {}; |
| |
| /// Network socket (L3) ancillary data that can be received. |
| type NetworkSocketRecvControlData = table { |
| /// Socket level ancillary data. |
| 1: socket SocketRecvControlData; |
| }; |
| |
| /// Flags controlling RecvMsg behavior. |
| type RecvMsgFlags = strict bits : uint16 { |
| /// Returns data from the receive queue without removing from it. |
| /// |
| /// Equivalent to `MSG_PEEK`. |
| PEEK = 2; |
| }; |
| |
| // Flags controlling SendMsg behavior. |
| type SendMsgFlags = strict bits : uint16 { |
| // NOTE We don't currently support any flags, but we need at least one |
| // definition. |
| RESERVED = 0x8000; |
| }; |
| |
| /// A datagram socket. |
| /// |
| /// This type's [`fuchsia.io.Node/Describe`] method returns an eventpair which |
| /// is used to signal additional information about the state of the socket such |
| /// as readiness or shutdown-ness. |
| /// |
| /// All methods on this type are nonblocking; their exact behaviors match their |
| /// Linux counterparts. |
| /// |
| /// *Warning:* This protocol is not yet ready for direct use by clients. |
| /// Instead, clients should use the BSD sockets API to interact with sockets. |
| /// We plan to change this protocol substantially and clients that couple |
| /// directly to this protocol will make those changes more difficult. |
| protocol DatagramSocket { |
| compose BaseNetworkSocket; |
| |
| /// Receives a message from the socket. |
| /// |
| /// + request `want_addr` request message's source address information to |
| /// be returned. |
| /// + request `data_len` the maximum allowed length of the response data |
| /// buffer. |
| /// + request `want_control` request ancillary data to be returned. |
| /// + request `flags` flags for the receive request. |
| /// - response `addr` the message's source address information, if |
| /// requested. |
| /// - response `data` the message. |
| /// - response `control` control messages, if requested. |
| /// - response `truncated` indicates whether or not the returned message |
| /// was truncated. |
| RecvMsg(struct { |
| want_addr bool; |
| data_len uint32; |
| want_control bool; |
| flags RecvMsgFlags; |
| }) -> (struct { |
| addr fuchsia.net.SocketAddress:optional; |
| data bytes; |
| control @generated_name("DatagramSocketRecvControlData") table { |
| /// Network socket ancillary data. |
| 1: network NetworkSocketRecvControlData; |
| }; |
| truncated uint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Sends a message on the socket. |
| /// |
| /// + request `addr` the address to send the message to. If unset, will |
| /// send to the connected peer. |
| /// + request `data` the message. |
| /// + request `control` ancillary data. |
| /// + request `flags` flags for the send request. |
| /// - response `len` the number of bytes sent. |
| // TODO(https://fxbug.dev/82346): Drop `len`. |
| SendMsg(struct { |
| addr fuchsia.net.SocketAddress:optional; |
| data bytes:MAX; |
| control @generated_name("DatagramSocketSendControlData") table { |
| /// Network socket ancillary data. |
| 1: network NetworkSocketSendControlData; |
| }; |
| flags SendMsgFlags; |
| }) -> (struct { |
| len int64; |
| }) error fuchsia.posix.Errno; |
| |
| /// Retrieves creation information from the socket. |
| /// |
| /// - response `domain` the socket's associated domain. |
| /// - response `proto` the socket's associated protocol. |
| GetInfo() -> (struct { |
| domain Domain; |
| proto DatagramSocketProtocol; |
| }) error fuchsia.posix.Errno; |
| }; |
| |
| /// A stream socket. |
| /// |
| /// This type's [`fuchsia.io.Node/Describe`] method returns a socket which is |
| /// used to transfer data to and from the caller. Signals are used to |
| /// communicate additional information about the state of the socket such as |
| /// connectedness and the presence of incoming connections in the case of a |
| /// listening socket. |
| /// |
| /// All methods on this type are nonblocking; their exact behaviors match their |
| /// Linux counterparts. |
| /// |
| /// *Warning:* This protocol is not yet ready for direct use by clients. |
| /// Instead, clients should use the BSD sockets API to interact with sockets. |
| /// We plan to change this protocol substantially and clients that couple |
| /// directly to this protocol will make those changes more difficult. |
| protocol StreamSocket { |
| compose BaseNetworkSocket; |
| |
| /// Begins listening for new incoming connections. At most `backlog` |
| /// connections will be buffered. |
| Listen(struct { |
| backlog int16; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Accepts a buffered incoming connection. |
| Accept(struct { |
| want_addr bool; |
| }) -> (resource struct { |
| addr fuchsia.net.SocketAddress:optional; |
| s client_end:StreamSocket; |
| }) error fuchsia.posix.Errno; |
| |
| /// Retrieves creation information from the socket. |
| GetInfo() -> (struct { |
| domain Domain; |
| proto StreamSocketProtocol; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_NODELAY`. |
| SetTcpNoDelay(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_NODELAY`. |
| GetTcpNoDelay() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_MAXSEG`. |
| SetTcpMaxSegment(struct { |
| value_bytes uint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_MAXSEG`. |
| GetTcpMaxSegment() -> (struct { |
| value_bytes uint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_CORK`. |
| SetTcpCork(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_CORK`. |
| GetTcpCork() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_KEEPIDLE`. |
| SetTcpKeepAliveIdle(struct { |
| value_secs uint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_KEEPIDLE`. |
| GetTcpKeepAliveIdle() -> (struct { |
| value_secs uint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_KEEPINTVL`. |
| SetTcpKeepAliveInterval(struct { |
| value_secs uint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_KEEPINTVL`. |
| GetTcpKeepAliveInterval() -> (struct { |
| value_secs uint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_KEEPCNT`. |
| SetTcpKeepAliveCount(struct { |
| value uint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_KEEPCNT`. |
| GetTcpKeepAliveCount() -> (struct { |
| value uint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_SYNCNT`. |
| SetTcpSynCount(struct { |
| value uint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_SYNCNT`. |
| GetTcpSynCount() -> (struct { |
| value uint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_LINGER2`. |
| SetTcpLinger(struct { |
| value_secs OptionalUint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_LINGER2`. |
| GetTcpLinger() -> (struct { |
| value_secs OptionalUint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_DEFER_ACCEPT`. |
| SetTcpDeferAccept(struct { |
| value_secs uint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_DEFER_ACCEPT`. |
| GetTcpDeferAccept() -> (struct { |
| value_secs uint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_WINDOW_CLAMP`. |
| SetTcpWindowClamp(struct { |
| value uint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_WINDOW_CLAMP`. |
| GetTcpWindowClamp() -> (struct { |
| value uint32; |
| }) error fuchsia.posix.Errno; |
| |
| /// Get `SOL_TCP` -> `TCP_INFO`. |
| GetTcpInfo() -> (struct { |
| info TcpInfo; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_QUICKACK`. |
| SetTcpQuickAck(struct { |
| value bool; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_QUICKACK`. |
| GetTcpQuickAck() -> (struct { |
| value bool; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_CONGESTION`. |
| SetTcpCongestion(struct { |
| value TcpCongestionControl; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_CONGESTION`. |
| GetTcpCongestion() -> (struct { |
| value TcpCongestionControl; |
| }) error fuchsia.posix.Errno; |
| |
| /// Set `SOL_TCP` -> `TCP_USER_TIMEOUT`. |
| SetTcpUserTimeout(struct { |
| value_millis uint32; |
| }) -> (struct {}) error fuchsia.posix.Errno; |
| /// Get `SOL_TCP` -> `TCP_USER_TIMEOUT`. |
| GetTcpUserTimeout() -> (struct { |
| value_millis uint32; |
| }) error fuchsia.posix.Errno; |
| |
| // NOTE: set `SOL_TCP` -> `TCP_REPAIR_OPTIONS` not supported in netstack. |
| // NOTE: get `SOL_CTP` -> `TCP_NOTSENT_LOWAT` not supported in netstack. |
| // NOTE: get `SOL_TCP` -> `TCP_CC_INFO` not supported in netstack. |
| }; |
| |
| /// TCP congestion control modes. |
| type TcpCongestionControl = strict enum { |
| RENO = 1; |
| CUBIC = 2; |
| }; |
| |
| /// TCP state machine state. |
| type TcpState = strict enum { |
| ESTABLISHED = 1; |
| SYN_SENT = 2; |
| SYN_RECV = 3; |
| FIN_WAIT1 = 4; |
| FIN_WAIT2 = 5; |
| TIME_WAIT = 6; |
| CLOSE = 7; |
| CLOSE_WAIT = 8; |
| LAST_ACK = 9; |
| LISTEN = 10; |
| CLOSING = 11; |
| }; |
| |
| /// TCP congestion control state machine state. |
| type TcpCongestionControlState = strict enum { |
| OPEN = 0; |
| DISORDER = 1; |
| CONGESTION_WINDOW_REDUCED = 2; |
| RECOVERY = 3; |
| LOSS = 4; |
| }; |
| |
| /// TCP protocol state. |
| type TcpInfo = table { |
| 1: state TcpState; |
| 2: ca_state TcpCongestionControlState; |
| 3: reserved; // uint8_t tcpi_retransmits; |
| 4: reserved; // uint8_t tcpi_probes; |
| 5: reserved; // uint8_t tcpi_backoff; |
| 6: reserved; // uint8_t tcpi_options; |
| 7: reserved; // uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; |
| 8: reserved; |
| 9: reserved; // uint8_t tcpi_delivery_rate_app_limited : 1, tcpi_fastopen_client_fail : 2; |
| 10: reserved; |
| 11: rto_usec uint32; |
| 12: reserved; // uint32_t tcpi_ato; |
| 13: reserved; // uint32_t tcpi_snd_mss; |
| 14: reserved; // uint32_t tcpi_rcv_mss; |
| 15: reserved; // uint32_t tcpi_unacked; |
| 16: reserved; // uint32_t tcpi_sacked; |
| 17: reserved; // uint32_t tcpi_lost; |
| 18: reserved; // uint32_t tcpi_retrans; |
| 19: reserved; // uint32_t tcpi_fackets; |
| 20: reserved; // uint32_t tcpi_last_data_sent; |
| 21: reserved; // uint32_t tcpi_last_ack_sent; |
| 22: reserved; // uint32_t tcpi_last_data_recv; |
| 23: reserved; // uint32_t tcpi_last_ack_recv; |
| 24: reserved; // uint32_t tcpi_pmtu; |
| 25: reserved; // uint32_t tcpi_rcv_ssthresh; |
| 26: rtt_usec uint32; |
| 27: rtt_var_usec uint32; |
| 28: snd_ssthresh uint32; |
| 29: snd_cwnd uint32; |
| 30: reserved; // uint32_t tcpi_advmss; |
| 31: reserved; // uint32_t tcpi_reordering; |
| 32: reserved; // uint32_t tcpi_rcv_rtt; |
| 33: reserved; // uint32_t tcpi_rcv_space; |
| 34: reserved; // uint32_t tcpi_total_retrans; |
| 35: reserved; // uint64_t tcpi_pacing_rate; |
| 36: reserved; // uint64_t tcpi_max_pacing_rate; |
| 37: reserved; // uint64_t tcpi_bytes_acked; |
| 38: reserved; // uint64_t tcpi_bytes_received; |
| 39: reserved; // uint32_t tcpi_segs_out; |
| 40: reserved; // uint32_t tcpi_segs_in; |
| 41: reserved; // uint32_t tcpi_notsent_bytes; |
| 42: reserved; // uint32_t tcpi_min_rtt; |
| 43: reserved; // uint32_t tcpi_data_segs_in; |
| 44: reserved; // uint32_t tcpi_data_segs_out; |
| 45: reserved; // uint64_t tcpi_delivery_rate; |
| 46: reserved; // uint64_t tcpi_busy_time; |
| 47: reserved; // uint64_t tcpi_rwnd_limited; |
| 48: reserved; // uint64_t tcpi_sndbuf_limited; |
| 49: reserved; // uint32_t tcpi_delivered; |
| 50: reserved; // uint32_t tcpi_delivered_ce; |
| 51: reserved; // uint64_t tcpi_bytes_sent; |
| 52: reserved; // uint64_t tcpi_bytes_retrans; |
| 53: reserved; // uint32_t tcpi_dsack_dups; |
| 54: reorder_seen bool; |
| 55: reserved; // uint32_t tcpi_rcv_ooopack; |
| 56: reserved; // uint32_t tcpi_snd_wnd; |
| }; |
| |
| /// Holds information about an interface and its addresses. |
| type InterfaceAddresses = table { |
| /// ID of the interface. |
| 1: id uint64; |
| /// Name of the interface. |
| 2: name fuchsia.net.interfaces.name; |
| /// Contains the interface flags, as returned by the SIOCGIFFLAGS ioctl |
| /// operation. |
| /// |
| /// TODO(fxbug.dev/64758): remove this once all clients are transitioned to |
| /// use more strongly-typed `interface_flags`. |
| 3: flags uint32; |
| /// All addresses currently assigned to the interface. |
| 4: addresses vector<fuchsia.net.Subnet>:MAX; |
| /// Contains the interface flags, as returned by the SIOCGIFFLAGS ioctl |
| /// operation. |
| 5: interface_flags InterfaceFlags; |
| }; |
| |
| /// A socket's domain. |
| /// |
| /// Determines the addressing domain for a socket. |
| type Domain = strict enum : int16 { |
| /// An IPv4 socket. Equivalent to `AF_INET`. |
| IPV4 = 0; |
| /// An IPv6 socket. Equivalent to `AF_INET6`. |
| IPV6 = 1; |
| }; |
| |
| /// Protocols supported by [`fuchsia.posix.socket/DatagramSocket`]. |
| /// |
| /// `DatagramSocketProtocol` enumerates the protocols supported by the network |
| /// stack over datagram sockets. |
| // NOTE: This list can be expanded to accommodate other protocols should the |
| // need arise. Most notably, there exists the question on whether to support |
| // raw IP sockets and what the access model for those should be. |
| type DatagramSocketProtocol = strict enum { |
| /// UDP (User Datagram Protocol). |
| /// |
| /// A UDP socket is equivalent to the POSIX API of `SOCK_DGRAM` with a |
| /// protocol of 0 or `IPPROTO_UDP`. |
| UDP = 1; |
| /// ICMP (Internet Control Message Protocol) echo. |
| /// |
| /// An ICMP echo socket is equivalent to the POSIX API of `SOCK_DGRAM` with |
| /// a protocol of `IPPROTO_ICMP` `IPPROTO_ICMPV6` (depending on provided |
| /// domain). |
| /// |
| /// Datagrams sent over an ICMP echo socket *must* have a valid ICMP or |
| /// ICMPv6 echo header. |
| ICMP_ECHO = 2; |
| }; |
| |
| /// Protocols supported by [`fuchsia.posix.socket/StreamSocket`]. |
| /// |
| /// `StreamSocketProtocol` enumerates the protocols supported by the network |
| /// stack over stream sockets. |
| type StreamSocketProtocol = strict enum { |
| /// TCP (Transmission Control Protocol). |
| /// |
| /// A TCP socket is equivalent to the POSIX API of `SOCK_STREAM` with a |
| /// protocol of 0 or `IPPROTO_TCP`. |
| TCP = 0; |
| }; |
| |
| /// Bits representing the interface flags as returned by the SIOCGIFFLAGS ioctl |
| /// operation. These bitmasks are intended to track the C API definition. For |
| /// example, `InterfaceFlags.UP` corresponds to `IFF_UP`, etc. |
| type InterfaceFlags = strict bits : uint16 { |
| UP = 0x1; |
| BROADCAST = 0x2; |
| DEBUG = 0x4; |
| LOOPBACK = 0x8; |
| POINTTOPOINT = 0x10; |
| NOTRAILERS = 0x20; |
| RUNNING = 0x40; |
| NOARP = 0x80; |
| PROMISC = 0x100; |
| ALLMULTI = 0x200; |
| LEADER = 0x400; |
| FOLLOWER = 0x800; |
| MULTICAST = 0x1000; |
| PORTSEL = 0x2000; |
| AUTOMEDIA = 0x4000; |
| DYNAMIC = 0x8000; |
| }; |
| |
| /// Provider implements the POSIX sockets API. |
| /// |
| /// *Warning:* This protocol is not yet ready for direct use by clients. |
| /// Instead, clients should use the BSD sockets API to interact with sockets. |
| /// We plan to change this protocol substantially and clients that couple |
| /// directly to this protocol will make those changes more difficult. |
| @discoverable |
| protocol Provider { |
| /// Requests a stream socket with the specified parameters. |
| StreamSocket(struct { |
| domain Domain; |
| proto StreamSocketProtocol; |
| }) -> (resource struct { |
| s client_end:StreamSocket; |
| }) error fuchsia.posix.Errno; |
| /// Requests a datagram socket with the specified parameters. |
| DatagramSocket(struct { |
| domain Domain; |
| proto DatagramSocketProtocol; |
| }) -> (resource struct { |
| s client_end:DatagramSocket; |
| }) error fuchsia.posix.Errno; |
| |
| /// Looks up an interface by its index and returns its name. Returns |
| /// `ZX_ERR_NOT_FOUND` if the specified index doesn't exist. |
| InterfaceIndexToName(struct { |
| index uint64; |
| }) -> (struct { |
| name fuchsia.net.interfaces.name; |
| }) error zx.status; |
| /// Looks up an interface by its name and returns its index. Returns |
| /// `ZX_ERR_NOT_FOUND` if the specified name doesn't exist. |
| InterfaceNameToIndex(struct { |
| name fuchsia.net.interfaces.name; |
| }) -> (struct { |
| index uint64; |
| }) error zx.status; |
| /// Looks up an interface by its name and returns its flags. Returns |
| /// `ZX_ERR_NOT_FOUND` if the specified name doesn't exist. |
| InterfaceNameToFlags(struct { |
| name fuchsia.net.interfaces.name; |
| }) -> (struct { |
| flags InterfaceFlags; |
| }) error zx.status; |
| |
| /// Requests a list of [`fuchsia.posix.socket.InterfaceAddresses`] |
| /// describing the network interfaces on the system. |
| GetInterfaceAddresses() -> (struct { |
| interfaces vector<InterfaceAddresses>:MAX; |
| }); |
| }; |