michael@0: /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsITransport.idl" michael@0: michael@0: interface nsIInterfaceRequestor; michael@0: interface nsINetAddr; michael@0: michael@0: %{ C++ michael@0: namespace mozilla { michael@0: namespace net { michael@0: union NetAddr; michael@0: } michael@0: } michael@0: %} michael@0: native NetAddr(mozilla::net::NetAddr); michael@0: michael@0: /** michael@0: * nsISocketTransport michael@0: * michael@0: * NOTE: Connection setup is triggered by opening an input or output stream, michael@0: * it does not start on its own. Completion of the connection setup is michael@0: * indicated by a STATUS_CONNECTED_TO notification to the event sink (if set). michael@0: * michael@0: * NOTE: This is a free-threaded interface, meaning that the methods on michael@0: * this interface may be called from any thread. michael@0: */ michael@0: [scriptable, uuid(3F41704C-CD5D-4537-8C4C-7B2EBFC5D972)] michael@0: interface nsISocketTransport : nsITransport michael@0: { michael@0: /** michael@0: * Get the peer's host for the underlying socket connection. michael@0: * For Unix domain sockets, this is a pathname, or the empty string for michael@0: * unnamed and abstract socket addresses. michael@0: */ michael@0: readonly attribute AUTF8String host; michael@0: michael@0: /** michael@0: * Get the port for the underlying socket connection. michael@0: * For Unix domain sockets, this is zero. michael@0: */ michael@0: readonly attribute long port; michael@0: michael@0: /** michael@0: * Returns the IP address of the socket connection peer. This michael@0: * attribute is defined only once a connection has been established. michael@0: */ michael@0: [noscript] NetAddr getPeerAddr(); michael@0: michael@0: /** michael@0: * Returns the IP address of the initiating end. This attribute michael@0: * is defined only once a connection has been established. michael@0: */ michael@0: [noscript] NetAddr getSelfAddr(); michael@0: michael@0: /** michael@0: * Returns a scriptable version of getPeerAddr. This attribute is defined michael@0: * only once a connection has been established. michael@0: */ michael@0: nsINetAddr getScriptablePeerAddr(); michael@0: michael@0: /** michael@0: * Returns a scriptable version of getSelfAddr. This attribute is defined michael@0: * only once a connection has been established. michael@0: */ michael@0: nsINetAddr getScriptableSelfAddr(); michael@0: michael@0: /** michael@0: * Security info object returned from the secure socket provider. This michael@0: * object supports nsISSLSocketControl, nsITransportSecurityInfo, and michael@0: * possibly other interfaces. michael@0: * michael@0: * This attribute is only available once the socket is connected. michael@0: */ michael@0: readonly attribute nsISupports securityInfo; michael@0: michael@0: /** michael@0: * Security notification callbacks passed to the secure socket provider michael@0: * via nsISSLSocketControl at socket creation time. michael@0: * michael@0: * NOTE: this attribute cannot be changed once a stream has been opened. michael@0: */ michael@0: attribute nsIInterfaceRequestor securityCallbacks; michael@0: michael@0: /** michael@0: * Test if this socket transport is (still) connected. michael@0: */ michael@0: boolean isAlive(); michael@0: michael@0: /** michael@0: * Socket timeouts in seconds. To specify no timeout, pass UINT32_MAX michael@0: * as aValue to setTimeout. The implementation may truncate timeout values michael@0: * to a smaller range of values (e.g., 0 to 0xFFFF). michael@0: */ michael@0: unsigned long getTimeout(in unsigned long aType); michael@0: void setTimeout(in unsigned long aType, in unsigned long aValue); michael@0: michael@0: /** michael@0: * Values for the aType parameter passed to get/setTimeout. michael@0: */ michael@0: const unsigned long TIMEOUT_CONNECT = 0; michael@0: const unsigned long TIMEOUT_READ_WRITE = 1; michael@0: michael@0: /** michael@0: * nsITransportEventSink status codes. michael@0: * michael@0: * Although these look like XPCOM error codes and are passed in an nsresult michael@0: * variable, they are *not* error codes. Note that while they *do* overlap michael@0: * with existing error codes in Necko, these status codes are confined michael@0: * within a very limited context where no error codes may appear, so there michael@0: * is no ambiguity. michael@0: * michael@0: * The values of these status codes must never change. michael@0: * michael@0: * The status codes appear in near-chronological order (not in numeric michael@0: * order). STATUS_RESOLVING may be skipped if the host does not need to be michael@0: * resolved. STATUS_WAITING_FOR is an optional status code, which the impl michael@0: * of this interface may choose not to generate. michael@0: * michael@0: * In C++, these constants have a type of uint32_t, so C++ callers must use michael@0: * the NS_NET_STATUS_* constants defined below, which have a type of michael@0: * nsresult. michael@0: */ michael@0: const unsigned long STATUS_RESOLVING = 0x804b0003; michael@0: const unsigned long STATUS_RESOLVED = 0x804b000b; michael@0: const unsigned long STATUS_CONNECTING_TO = 0x804b0007; michael@0: const unsigned long STATUS_CONNECTED_TO = 0x804b0004; michael@0: const unsigned long STATUS_SENDING_TO = 0x804b0005; michael@0: const unsigned long STATUS_WAITING_FOR = 0x804b000a; michael@0: const unsigned long STATUS_RECEIVING_FROM = 0x804b0006; michael@0: michael@0: /** michael@0: * connectionFlags is a bitmask that can be used to modify underlying michael@0: * behavior of the socket connection. See the flags below. michael@0: */ michael@0: attribute unsigned long connectionFlags; michael@0: michael@0: /** michael@0: * Values for the connectionFlags michael@0: * michael@0: * When making a new connection BYPASS_CACHE will force the Necko DNS michael@0: * cache entry to be refreshed with a new call to NSPR if it is set before michael@0: * opening the new stream. michael@0: */ michael@0: const unsigned long BYPASS_CACHE = (1 << 0); michael@0: michael@0: /** michael@0: * When setting this flag, the socket will not apply any michael@0: * credentials when establishing a connection. For example, michael@0: * an SSL connection would not send any client-certificates michael@0: * if this flag is set. michael@0: */ michael@0: const unsigned long ANONYMOUS_CONNECT = (1 << 1); michael@0: michael@0: /** michael@0: * If set, we will skip all IPv6 addresses the host may have and only michael@0: * connect to IPv4 ones. michael@0: */ michael@0: const unsigned long DISABLE_IPV6 = (1 << 2); michael@0: michael@0: /** michael@0: * If set, indicates that the connection was initiated from a source michael@0: * defined as being private in the sense of Private Browsing. Generally, michael@0: * there should be no state shared between connections that are private michael@0: * and those that are not; it is OK for multiple private connections michael@0: * to share state with each other, and it is OK for multiple non-private michael@0: * connections to share state with each other. michael@0: */ michael@0: const unsigned long NO_PERMANENT_STORAGE = (1 << 3); michael@0: michael@0: /** michael@0: * If set, we will skip all IPv4 addresses the host may have and only michael@0: * connect to IPv6 ones. michael@0: */ michael@0: const unsigned long DISABLE_IPV4 = (1 << 4); michael@0: michael@0: /** michael@0: * If set, indicates that the socket should not connect if the hostname michael@0: * resolves to an RFC1918 address or IPv6 equivalent. michael@0: */ michael@0: const unsigned long DISABLE_RFC1918 = (1 << 5); michael@0: michael@0: /** michael@0: * Socket QoS/ToS markings. Valid values are IPTOS_DSCP_AFxx or michael@0: * IPTOS_CLASS_CSx (or IPTOS_DSCP_EF, but currently no supported michael@0: * services require expedited-forwarding). michael@0: * Not setting this value will leave the socket with the default michael@0: * ToS value, which on most systems if IPTOS_CLASS_CS0 (formerly michael@0: * IPTOS_PREC_ROUTINE). michael@0: */ michael@0: attribute octet QoSBits; michael@0: michael@0: /** michael@0: * TCP send and receive buffer sizes. A value of 0 means OS level michael@0: * auto-tuning is in effect. michael@0: */ michael@0: attribute unsigned long recvBufferSize; michael@0: attribute unsigned long sendBufferSize; michael@0: michael@0: /** michael@0: * TCP keepalive configuration (support varies by platform). michael@0: */ michael@0: attribute boolean keepaliveEnabled; michael@0: void setKeepaliveVals(in long keepaliveIdleTime, michael@0: in long keepaliveRetryInterval); michael@0: };