Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsITransport.idl"
8 interface nsIInterfaceRequestor;
9 interface nsINetAddr;
11 %{ C++
12 namespace mozilla {
13 namespace net {
14 union NetAddr;
15 }
16 }
17 %}
18 native NetAddr(mozilla::net::NetAddr);
20 /**
21 * nsISocketTransport
22 *
23 * NOTE: Connection setup is triggered by opening an input or output stream,
24 * it does not start on its own. Completion of the connection setup is
25 * indicated by a STATUS_CONNECTED_TO notification to the event sink (if set).
26 *
27 * NOTE: This is a free-threaded interface, meaning that the methods on
28 * this interface may be called from any thread.
29 */
30 [scriptable, uuid(3F41704C-CD5D-4537-8C4C-7B2EBFC5D972)]
31 interface nsISocketTransport : nsITransport
32 {
33 /**
34 * Get the peer's host for the underlying socket connection.
35 * For Unix domain sockets, this is a pathname, or the empty string for
36 * unnamed and abstract socket addresses.
37 */
38 readonly attribute AUTF8String host;
40 /**
41 * Get the port for the underlying socket connection.
42 * For Unix domain sockets, this is zero.
43 */
44 readonly attribute long port;
46 /**
47 * Returns the IP address of the socket connection peer. This
48 * attribute is defined only once a connection has been established.
49 */
50 [noscript] NetAddr getPeerAddr();
52 /**
53 * Returns the IP address of the initiating end. This attribute
54 * is defined only once a connection has been established.
55 */
56 [noscript] NetAddr getSelfAddr();
58 /**
59 * Returns a scriptable version of getPeerAddr. This attribute is defined
60 * only once a connection has been established.
61 */
62 nsINetAddr getScriptablePeerAddr();
64 /**
65 * Returns a scriptable version of getSelfAddr. This attribute is defined
66 * only once a connection has been established.
67 */
68 nsINetAddr getScriptableSelfAddr();
70 /**
71 * Security info object returned from the secure socket provider. This
72 * object supports nsISSLSocketControl, nsITransportSecurityInfo, and
73 * possibly other interfaces.
74 *
75 * This attribute is only available once the socket is connected.
76 */
77 readonly attribute nsISupports securityInfo;
79 /**
80 * Security notification callbacks passed to the secure socket provider
81 * via nsISSLSocketControl at socket creation time.
82 *
83 * NOTE: this attribute cannot be changed once a stream has been opened.
84 */
85 attribute nsIInterfaceRequestor securityCallbacks;
87 /**
88 * Test if this socket transport is (still) connected.
89 */
90 boolean isAlive();
92 /**
93 * Socket timeouts in seconds. To specify no timeout, pass UINT32_MAX
94 * as aValue to setTimeout. The implementation may truncate timeout values
95 * to a smaller range of values (e.g., 0 to 0xFFFF).
96 */
97 unsigned long getTimeout(in unsigned long aType);
98 void setTimeout(in unsigned long aType, in unsigned long aValue);
100 /**
101 * Values for the aType parameter passed to get/setTimeout.
102 */
103 const unsigned long TIMEOUT_CONNECT = 0;
104 const unsigned long TIMEOUT_READ_WRITE = 1;
106 /**
107 * nsITransportEventSink status codes.
108 *
109 * Although these look like XPCOM error codes and are passed in an nsresult
110 * variable, they are *not* error codes. Note that while they *do* overlap
111 * with existing error codes in Necko, these status codes are confined
112 * within a very limited context where no error codes may appear, so there
113 * is no ambiguity.
114 *
115 * The values of these status codes must never change.
116 *
117 * The status codes appear in near-chronological order (not in numeric
118 * order). STATUS_RESOLVING may be skipped if the host does not need to be
119 * resolved. STATUS_WAITING_FOR is an optional status code, which the impl
120 * of this interface may choose not to generate.
121 *
122 * In C++, these constants have a type of uint32_t, so C++ callers must use
123 * the NS_NET_STATUS_* constants defined below, which have a type of
124 * nsresult.
125 */
126 const unsigned long STATUS_RESOLVING = 0x804b0003;
127 const unsigned long STATUS_RESOLVED = 0x804b000b;
128 const unsigned long STATUS_CONNECTING_TO = 0x804b0007;
129 const unsigned long STATUS_CONNECTED_TO = 0x804b0004;
130 const unsigned long STATUS_SENDING_TO = 0x804b0005;
131 const unsigned long STATUS_WAITING_FOR = 0x804b000a;
132 const unsigned long STATUS_RECEIVING_FROM = 0x804b0006;
134 /**
135 * connectionFlags is a bitmask that can be used to modify underlying
136 * behavior of the socket connection. See the flags below.
137 */
138 attribute unsigned long connectionFlags;
140 /**
141 * Values for the connectionFlags
142 *
143 * When making a new connection BYPASS_CACHE will force the Necko DNS
144 * cache entry to be refreshed with a new call to NSPR if it is set before
145 * opening the new stream.
146 */
147 const unsigned long BYPASS_CACHE = (1 << 0);
149 /**
150 * When setting this flag, the socket will not apply any
151 * credentials when establishing a connection. For example,
152 * an SSL connection would not send any client-certificates
153 * if this flag is set.
154 */
155 const unsigned long ANONYMOUS_CONNECT = (1 << 1);
157 /**
158 * If set, we will skip all IPv6 addresses the host may have and only
159 * connect to IPv4 ones.
160 */
161 const unsigned long DISABLE_IPV6 = (1 << 2);
163 /**
164 * If set, indicates that the connection was initiated from a source
165 * defined as being private in the sense of Private Browsing. Generally,
166 * there should be no state shared between connections that are private
167 * and those that are not; it is OK for multiple private connections
168 * to share state with each other, and it is OK for multiple non-private
169 * connections to share state with each other.
170 */
171 const unsigned long NO_PERMANENT_STORAGE = (1 << 3);
173 /**
174 * If set, we will skip all IPv4 addresses the host may have and only
175 * connect to IPv6 ones.
176 */
177 const unsigned long DISABLE_IPV4 = (1 << 4);
179 /**
180 * If set, indicates that the socket should not connect if the hostname
181 * resolves to an RFC1918 address or IPv6 equivalent.
182 */
183 const unsigned long DISABLE_RFC1918 = (1 << 5);
185 /**
186 * Socket QoS/ToS markings. Valid values are IPTOS_DSCP_AFxx or
187 * IPTOS_CLASS_CSx (or IPTOS_DSCP_EF, but currently no supported
188 * services require expedited-forwarding).
189 * Not setting this value will leave the socket with the default
190 * ToS value, which on most systems if IPTOS_CLASS_CS0 (formerly
191 * IPTOS_PREC_ROUTINE).
192 */
193 attribute octet QoSBits;
195 /**
196 * TCP send and receive buffer sizes. A value of 0 means OS level
197 * auto-tuning is in effect.
198 */
199 attribute unsigned long recvBufferSize;
200 attribute unsigned long sendBufferSize;
202 /**
203 * TCP keepalive configuration (support varies by platform).
204 */
205 attribute boolean keepaliveEnabled;
206 void setKeepaliveVals(in long keepaliveIdleTime,
207 in long keepaliveRetryInterval);
208 };