1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/base/public/nsISocketTransport.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,208 @@ 1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsITransport.idl" 1.10 + 1.11 +interface nsIInterfaceRequestor; 1.12 +interface nsINetAddr; 1.13 + 1.14 +%{ C++ 1.15 +namespace mozilla { 1.16 +namespace net { 1.17 +union NetAddr; 1.18 +} 1.19 +} 1.20 +%} 1.21 +native NetAddr(mozilla::net::NetAddr); 1.22 + 1.23 +/** 1.24 + * nsISocketTransport 1.25 + * 1.26 + * NOTE: Connection setup is triggered by opening an input or output stream, 1.27 + * it does not start on its own. Completion of the connection setup is 1.28 + * indicated by a STATUS_CONNECTED_TO notification to the event sink (if set). 1.29 + * 1.30 + * NOTE: This is a free-threaded interface, meaning that the methods on 1.31 + * this interface may be called from any thread. 1.32 + */ 1.33 +[scriptable, uuid(3F41704C-CD5D-4537-8C4C-7B2EBFC5D972)] 1.34 +interface nsISocketTransport : nsITransport 1.35 +{ 1.36 + /** 1.37 + * Get the peer's host for the underlying socket connection. 1.38 + * For Unix domain sockets, this is a pathname, or the empty string for 1.39 + * unnamed and abstract socket addresses. 1.40 + */ 1.41 + readonly attribute AUTF8String host; 1.42 + 1.43 + /** 1.44 + * Get the port for the underlying socket connection. 1.45 + * For Unix domain sockets, this is zero. 1.46 + */ 1.47 + readonly attribute long port; 1.48 + 1.49 + /** 1.50 + * Returns the IP address of the socket connection peer. This 1.51 + * attribute is defined only once a connection has been established. 1.52 + */ 1.53 + [noscript] NetAddr getPeerAddr(); 1.54 + 1.55 + /** 1.56 + * Returns the IP address of the initiating end. This attribute 1.57 + * is defined only once a connection has been established. 1.58 + */ 1.59 + [noscript] NetAddr getSelfAddr(); 1.60 + 1.61 + /** 1.62 + * Returns a scriptable version of getPeerAddr. This attribute is defined 1.63 + * only once a connection has been established. 1.64 + */ 1.65 + nsINetAddr getScriptablePeerAddr(); 1.66 + 1.67 + /** 1.68 + * Returns a scriptable version of getSelfAddr. This attribute is defined 1.69 + * only once a connection has been established. 1.70 + */ 1.71 + nsINetAddr getScriptableSelfAddr(); 1.72 + 1.73 + /** 1.74 + * Security info object returned from the secure socket provider. This 1.75 + * object supports nsISSLSocketControl, nsITransportSecurityInfo, and 1.76 + * possibly other interfaces. 1.77 + * 1.78 + * This attribute is only available once the socket is connected. 1.79 + */ 1.80 + readonly attribute nsISupports securityInfo; 1.81 + 1.82 + /** 1.83 + * Security notification callbacks passed to the secure socket provider 1.84 + * via nsISSLSocketControl at socket creation time. 1.85 + * 1.86 + * NOTE: this attribute cannot be changed once a stream has been opened. 1.87 + */ 1.88 + attribute nsIInterfaceRequestor securityCallbacks; 1.89 + 1.90 + /** 1.91 + * Test if this socket transport is (still) connected. 1.92 + */ 1.93 + boolean isAlive(); 1.94 + 1.95 + /** 1.96 + * Socket timeouts in seconds. To specify no timeout, pass UINT32_MAX 1.97 + * as aValue to setTimeout. The implementation may truncate timeout values 1.98 + * to a smaller range of values (e.g., 0 to 0xFFFF). 1.99 + */ 1.100 + unsigned long getTimeout(in unsigned long aType); 1.101 + void setTimeout(in unsigned long aType, in unsigned long aValue); 1.102 + 1.103 + /** 1.104 + * Values for the aType parameter passed to get/setTimeout. 1.105 + */ 1.106 + const unsigned long TIMEOUT_CONNECT = 0; 1.107 + const unsigned long TIMEOUT_READ_WRITE = 1; 1.108 + 1.109 + /** 1.110 + * nsITransportEventSink status codes. 1.111 + * 1.112 + * Although these look like XPCOM error codes and are passed in an nsresult 1.113 + * variable, they are *not* error codes. Note that while they *do* overlap 1.114 + * with existing error codes in Necko, these status codes are confined 1.115 + * within a very limited context where no error codes may appear, so there 1.116 + * is no ambiguity. 1.117 + * 1.118 + * The values of these status codes must never change. 1.119 + * 1.120 + * The status codes appear in near-chronological order (not in numeric 1.121 + * order). STATUS_RESOLVING may be skipped if the host does not need to be 1.122 + * resolved. STATUS_WAITING_FOR is an optional status code, which the impl 1.123 + * of this interface may choose not to generate. 1.124 + * 1.125 + * In C++, these constants have a type of uint32_t, so C++ callers must use 1.126 + * the NS_NET_STATUS_* constants defined below, which have a type of 1.127 + * nsresult. 1.128 + */ 1.129 + const unsigned long STATUS_RESOLVING = 0x804b0003; 1.130 + const unsigned long STATUS_RESOLVED = 0x804b000b; 1.131 + const unsigned long STATUS_CONNECTING_TO = 0x804b0007; 1.132 + const unsigned long STATUS_CONNECTED_TO = 0x804b0004; 1.133 + const unsigned long STATUS_SENDING_TO = 0x804b0005; 1.134 + const unsigned long STATUS_WAITING_FOR = 0x804b000a; 1.135 + const unsigned long STATUS_RECEIVING_FROM = 0x804b0006; 1.136 + 1.137 + /** 1.138 + * connectionFlags is a bitmask that can be used to modify underlying 1.139 + * behavior of the socket connection. See the flags below. 1.140 + */ 1.141 + attribute unsigned long connectionFlags; 1.142 + 1.143 + /** 1.144 + * Values for the connectionFlags 1.145 + * 1.146 + * When making a new connection BYPASS_CACHE will force the Necko DNS 1.147 + * cache entry to be refreshed with a new call to NSPR if it is set before 1.148 + * opening the new stream. 1.149 + */ 1.150 + const unsigned long BYPASS_CACHE = (1 << 0); 1.151 + 1.152 + /** 1.153 + * When setting this flag, the socket will not apply any 1.154 + * credentials when establishing a connection. For example, 1.155 + * an SSL connection would not send any client-certificates 1.156 + * if this flag is set. 1.157 + */ 1.158 + const unsigned long ANONYMOUS_CONNECT = (1 << 1); 1.159 + 1.160 + /** 1.161 + * If set, we will skip all IPv6 addresses the host may have and only 1.162 + * connect to IPv4 ones. 1.163 + */ 1.164 + const unsigned long DISABLE_IPV6 = (1 << 2); 1.165 + 1.166 + /** 1.167 + * If set, indicates that the connection was initiated from a source 1.168 + * defined as being private in the sense of Private Browsing. Generally, 1.169 + * there should be no state shared between connections that are private 1.170 + * and those that are not; it is OK for multiple private connections 1.171 + * to share state with each other, and it is OK for multiple non-private 1.172 + * connections to share state with each other. 1.173 + */ 1.174 + const unsigned long NO_PERMANENT_STORAGE = (1 << 3); 1.175 + 1.176 + /** 1.177 + * If set, we will skip all IPv4 addresses the host may have and only 1.178 + * connect to IPv6 ones. 1.179 + */ 1.180 + const unsigned long DISABLE_IPV4 = (1 << 4); 1.181 + 1.182 + /** 1.183 + * If set, indicates that the socket should not connect if the hostname 1.184 + * resolves to an RFC1918 address or IPv6 equivalent. 1.185 + */ 1.186 + const unsigned long DISABLE_RFC1918 = (1 << 5); 1.187 + 1.188 + /** 1.189 + * Socket QoS/ToS markings. Valid values are IPTOS_DSCP_AFxx or 1.190 + * IPTOS_CLASS_CSx (or IPTOS_DSCP_EF, but currently no supported 1.191 + * services require expedited-forwarding). 1.192 + * Not setting this value will leave the socket with the default 1.193 + * ToS value, which on most systems if IPTOS_CLASS_CS0 (formerly 1.194 + * IPTOS_PREC_ROUTINE). 1.195 + */ 1.196 + attribute octet QoSBits; 1.197 + 1.198 + /** 1.199 + * TCP send and receive buffer sizes. A value of 0 means OS level 1.200 + * auto-tuning is in effect. 1.201 + */ 1.202 + attribute unsigned long recvBufferSize; 1.203 + attribute unsigned long sendBufferSize; 1.204 + 1.205 + /** 1.206 + * TCP keepalive configuration (support varies by platform). 1.207 + */ 1.208 + attribute boolean keepaliveEnabled; 1.209 + void setKeepaliveVals(in long keepaliveIdleTime, 1.210 + in long keepaliveRetryInterval); 1.211 +};