Source code

Revision control

Other Tools

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/. */
5
6
#include "nsITransport.idl"
7
8
interface nsIInterfaceRequestor;
9
interface nsINetAddr;
10
11
%{ C++
12
#include "mozilla/BasePrincipal.h"
13
namespace mozilla {
14
namespace net {
15
union NetAddr;
16
class TCPFastOpen;
17
}
18
}
19
%}
20
native NetAddr(mozilla::net::NetAddr);
21
[ptr] native NetAddrPtr(mozilla::net::NetAddr);
22
native OriginAttributes(mozilla::OriginAttributes);
23
[ref] native const_OriginAttributesRef(const mozilla::OriginAttributes);
24
[ptr] native TCPFastOpenPtr(mozilla::net::TCPFastOpen);
25
26
/**
27
* nsISocketTransport
28
*
29
* NOTE: Connection setup is triggered by opening an input or output stream,
30
* it does not start on its own. Completion of the connection setup is
31
* indicated by a STATUS_CONNECTED_TO notification to the event sink (if set).
32
*
33
* NOTE: This is a free-threaded interface, meaning that the methods on
34
* this interface may be called from any thread.
35
*/
36
[scriptable, uuid(79221831-85e2-43a8-8152-05d77d6fde31)]
37
interface nsISocketTransport : nsITransport
38
{
39
/**
40
* Get the peer's host for the underlying socket connection.
41
* For Unix domain sockets, this is a pathname, or the empty string for
42
* unnamed and abstract socket addresses.
43
*/
44
readonly attribute AUTF8String host;
45
46
/**
47
* Get the port for the underlying socket connection.
48
* For Unix domain sockets, this is zero.
49
*/
50
readonly attribute long port;
51
52
/**
53
* The origin attributes are used to create sockets. The first party domain
54
* will eventually be used to isolate OCSP cache and is only non-empty when
55
* "privacy.firstparty.isolate" is enabled. Setting this is the only way to
56
* carry origin attributes down to NSPR layers which are final consumers.
57
* It must be set before the socket transport is built.
58
*/
59
[implicit_jscontext, binaryname(ScriptableOriginAttributes)]
60
attribute jsval originAttributes;
61
62
[noscript, nostdcall, binaryname(GetOriginAttributes)]
63
OriginAttributes binaryGetOriginAttributes();
64
65
[noscript, nostdcall, binaryname(SetOriginAttributes)]
66
void binarySetOriginAttributes(in const_OriginAttributesRef aOriginAttrs);
67
68
/**
69
* Returns the IP address of the socket connection peer. This
70
* attribute is defined only once a connection has been established.
71
*/
72
[noscript] NetAddr getPeerAddr();
73
74
/**
75
* Returns the IP address of the initiating end. This attribute
76
* is defined only once a connection has been established.
77
*/
78
[noscript] NetAddr getSelfAddr();
79
80
/**
81
* Bind to a specific local address.
82
*/
83
[noscript] void bind(in NetAddrPtr aLocalAddr);
84
85
/**
86
* Returns a scriptable version of getPeerAddr. This attribute is defined
87
* only once a connection has been established.
88
*/
89
nsINetAddr getScriptablePeerAddr();
90
91
/**
92
* Returns a scriptable version of getSelfAddr. This attribute is defined
93
* only once a connection has been established.
94
*/
95
nsINetAddr getScriptableSelfAddr();
96
97
/**
98
* Security info object returned from the secure socket provider. This
99
* object supports nsISSLSocketControl, nsITransportSecurityInfo, and
100
* possibly other interfaces.
101
*
102
* This attribute is only available once the socket is connected.
103
*/
104
readonly attribute nsISupports securityInfo;
105
106
/**
107
* Security notification callbacks passed to the secure socket provider
108
* via nsISSLSocketControl at socket creation time.
109
*
110
* NOTE: this attribute cannot be changed once a stream has been opened.
111
*/
112
attribute nsIInterfaceRequestor securityCallbacks;
113
114
/**
115
* Test if this socket transport is (still) connected.
116
*/
117
boolean isAlive();
118
119
/**
120
* Socket timeouts in seconds. To specify no timeout, pass UINT32_MAX
121
* as aValue to setTimeout. The implementation may truncate timeout values
122
* to a smaller range of values (e.g., 0 to 0xFFFF).
123
*/
124
unsigned long getTimeout(in unsigned long aType);
125
void setTimeout(in unsigned long aType, in unsigned long aValue);
126
127
/**
128
* Sets the SO_LINGER option with the specified values for the l_onoff and
129
* l_linger parameters. This applies PR_SockOpt_Linger before PR_Close and
130
* can be used with a timeout of zero to send an RST packet when closing.
131
*/
132
void setLinger(in boolean aPolarity, in short aTimeout);
133
134
/**
135
* True to set addr and port reuse socket options.
136
*/
137
void setReuseAddrPort(in bool reuseAddrPort);
138
139
/**
140
* Values for the aType parameter passed to get/setTimeout.
141
*/
142
const unsigned long TIMEOUT_CONNECT = 0;
143
const unsigned long TIMEOUT_READ_WRITE = 1;
144
145
/**
146
* nsITransportEventSink status codes.
147
*
148
* Although these look like XPCOM error codes and are passed in an nsresult
149
* variable, they are *not* error codes. Note that while they *do* overlap
150
* with existing error codes in Necko, these status codes are confined
151
* within a very limited context where no error codes may appear, so there
152
* is no ambiguity.
153
*
154
* The values of these status codes must never change.
155
*
156
* The status codes appear in near-chronological order (not in numeric
157
* order). STATUS_RESOLVING may be skipped if the host does not need to be
158
* resolved. STATUS_WAITING_FOR is an optional status code, which the impl
159
* of this interface may choose not to generate.
160
*
161
* In C++, these constants have a type of uint32_t, so C++ callers must use
162
* the NS_NET_STATUS_* constants defined below, which have a type of
163
* nsresult.
164
*/
165
const unsigned long STATUS_RESOLVING = 0x804b0003;
166
const unsigned long STATUS_RESOLVED = 0x804b000b;
167
const unsigned long STATUS_CONNECTING_TO = 0x804b0007;
168
const unsigned long STATUS_CONNECTED_TO = 0x804b0004;
169
const unsigned long STATUS_SENDING_TO = 0x804b0005;
170
const unsigned long STATUS_WAITING_FOR = 0x804b000a;
171
const unsigned long STATUS_RECEIVING_FROM = 0x804b0006;
172
const unsigned long STATUS_TLS_HANDSHAKE_STARTING = 0x804b000c;
173
const unsigned long STATUS_TLS_HANDSHAKE_ENDED = 0x804b000d;
174
175
/**
176
* connectionFlags is a bitmask that can be used to modify underlying
177
* behavior of the socket connection. See the flags below.
178
*/
179
attribute unsigned long connectionFlags;
180
181
/**
182
* Values for the connectionFlags
183
*
184
* When making a new connection BYPASS_CACHE will force the Necko DNS
185
* cache entry to be refreshed with a new call to NSPR if it is set before
186
* opening the new stream.
187
*/
188
const unsigned long BYPASS_CACHE = (1 << 0);
189
190
/**
191
* When setting this flag, the socket will not apply any
192
* credentials when establishing a connection. For example,
193
* an SSL connection would not send any client-certificates
194
* if this flag is set.
195
*/
196
const unsigned long ANONYMOUS_CONNECT = (1 << 1);
197
198
/**
199
* If set, we will skip all IPv6 addresses the host may have and only
200
* connect to IPv4 ones.
201
*/
202
const unsigned long DISABLE_IPV6 = (1 << 2);
203
204
/**
205
* If set, indicates that the connection was initiated from a source
206
* defined as being private in the sense of Private Browsing. Generally,
207
* there should be no state shared between connections that are private
208
* and those that are not; it is OK for multiple private connections
209
* to share state with each other, and it is OK for multiple non-private
210
* connections to share state with each other.
211
*/
212
const unsigned long NO_PERMANENT_STORAGE = (1 << 3);
213
214
/**
215
* If set, we will skip all IPv4 addresses the host may have and only
216
* connect to IPv6 ones.
217
*/
218
const unsigned long DISABLE_IPV4 = (1 << 4);
219
220
/**
221
* If set, indicates that the socket should not connect if the hostname
222
* resolves to an RFC1918 address or IPv6 equivalent.
223
*/
224
const unsigned long DISABLE_RFC1918 = (1 << 5);
225
226
/**
227
* This flag is an explicit opt-in that allows a normally secure socket
228
* provider to use, at its discretion, an insecure algorithm. e.g.
229
* a TLS socket without authentication.
230
*/
231
const unsigned long MITM_OK = (1 << 6);
232
233
/**
234
* If set, do not use newer protocol features that might have interop problems
235
* on the Internet. Intended only for use with critical infra like the updater.
236
* default is false.
237
*/
238
const unsigned long BE_CONSERVATIVE = (1 << 7);
239
240
/**
241
* If set, do not use TRR for resolving the host name. Intended only for
242
* retries or other scenarios when TRR is deemed likely to have returned a
243
* wrong adddress.
244
*/
245
const unsigned long DISABLE_TRR = (1 << 8);
246
247
/**
248
* Values for the connectionFlags
249
*
250
* When using BYPASS_CACHE, setting this bit will invalidate the existing
251
* cached entry immediately while the new resolve is being done to avoid
252
* other users from using stale content in the mean time.
253
*/
254
const unsigned long REFRESH_CACHE = (1 << 9);
255
256
/**
257
* If this flag is set then it means that if connecting the preferred ip
258
* family has failed, retry with the oppsite one once more.
259
*/
260
const unsigned long RETRY_WITH_DIFFERENT_IP_FAMILY = (1 << 10);
261
262
/**
263
* If we know that a server speaks only tls <1.3 there is no need to try
264
* to use esni and query dns for esni keys.
265
*/
266
const unsigned long DONT_TRY_ESNI = (1 << 11);
267
268
/**
269
* An opaque flags for non-standard behavior of the TLS system.
270
* It is unlikely this will need to be set outside of telemetry studies
271
* relating to the TLS implementation.
272
*/
273
attribute unsigned long tlsFlags;
274
275
/**
276
* Socket QoS/ToS markings. Valid values are IPTOS_DSCP_AFxx or
277
* IPTOS_CLASS_CSx (or IPTOS_DSCP_EF, but currently no supported
278
* services require expedited-forwarding).
279
* Not setting this value will leave the socket with the default
280
* ToS value, which on most systems if IPTOS_CLASS_CS0 (formerly
281
* IPTOS_PREC_ROUTINE).
282
*/
283
attribute octet QoSBits;
284
285
/**
286
* TCP send and receive buffer sizes. A value of 0 means OS level
287
* auto-tuning is in effect.
288
*/
289
attribute unsigned long recvBufferSize;
290
attribute unsigned long sendBufferSize;
291
292
/**
293
* TCP keepalive configuration (support varies by platform).
294
* Note that the attribute as well as the setter can only accessed
295
* in the socket thread.
296
*/
297
attribute boolean keepaliveEnabled;
298
void setKeepaliveVals(in long keepaliveIdleTime,
299
in long keepaliveRetryInterval);
300
301
[noscript] void setFastOpenCallback(in TCPFastOpenPtr aFastOpen);
302
303
readonly attribute nsresult firstRetryError;
304
305
/**
306
* If true, this socket transport has found out the prefered family
307
* according it's connection flags could not be used to establish
308
* connections any more. Hence, the preference should be reset.
309
*/
310
readonly attribute boolean resetIPFamilyPreference;
311
312
/**
313
* This attribute holds information whether esni has been used.
314
* The value is set after PR_Connect is called.
315
*/
316
readonly attribute boolean esniUsed;
317
318
/**
319
* IP address resolved using TRR.
320
*/
321
bool resolvedByTRR();
322
};