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