Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: runtime/bin/net/nss_memio.h

Issue 1319703002: Breaking Change: merge BoringSSL branch into master (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/net/nss.gyp ('k') | runtime/bin/net/nss_memio.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 // Written in NSPR style to also be suitable for adding to the NSS demo suite
5
6 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
7 // for details. All rights reserved. Use of this source code is governed by a
8 // BSD-style license that can be found in the LICENSE file.
9
10 // This file is a modified copy of Chromium's src/net/base/nss_memio.h.
11 // char* has been changed to uint8_t* everywhere, and C++ casts are used.
12 // Revision 291806 (this should agree with "nss_rev" in DEPS).
13
14 #ifndef BIN_NET_NSS_MEMIO_H_
15 #define BIN_NET_NSS_MEMIO_H_
16
17 #include <stddef.h>
18 #include "vm/globals.h"
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include "prio.h"
25
26 /* Opaque structure. Really just a more typesafe alias for PRFilePrivate. */
27 struct memio_Private;
28 typedef struct memio_Private memio_Private;
29
30 /*----------------------------------------------------------------------
31 NSPR I/O layer that terminates in a pair of circular buffers
32 rather than talking to the real network.
33 To use this with NSS:
34 1) call memio_CreateIOLayer to create a fake NSPR socket
35 2) call SSL_ImportFD to ssl-ify the socket
36 3) Do your own networking calls to set up a TCP connection
37 4) call memio_SetPeerName to tell NSS about the other end of the connection
38 5) While at the same time doing plaintext nonblocking NSPR I/O as
39 usual to the nspr file descriptor returned by SSL_ImportFD,
40 your app must shuttle encrypted data between
41 the real network and memio's network buffers.
42 memio_GetReadParams/memio_PutReadResult
43 are the hooks you need to pump data into memio's input buffer,
44 and memio_GetWriteParams/memio_PutWriteResult
45 are the hooks you need to pump data out of memio's output buffer.
46 ----------------------------------------------------------------------*/
47
48 /* Create the I/O layer and its two circular buffers. */
49 PRFileDesc *memio_CreateIOLayer(int readbufsize, int writebufsize);
50
51 /* Must call before trying to make an ssl connection */
52 void memio_SetPeerName(PRFileDesc *fd, const PRNetAddr *peername);
53
54 /* Return a private pointer needed by the following
55 * four functions. (We could have passed a PRFileDesc to
56 * them, but that would be slower. Better for the caller
57 * to grab the pointer once and cache it.
58 * This may be a premature optimization.)
59 */
60 memio_Private *memio_GetSecret(PRFileDesc *fd);
61
62 /* Ask memio how many bytes were requested by a higher layer if the
63 * last attempt to read data resulted in PR_WOULD_BLOCK_ERROR, due to the
64 * transport buffer being empty. If the last attempt to read data from the
65 * memio did not result in PR_WOULD_BLOCK_ERROR, returns 0.
66 */
67 int memio_GetReadRequest(memio_Private *secret);
68
69 /* Ask memio where to put bytes from the network, and how many it can handle.
70 * Returns bytes available to write, or 0 if none available.
71 * Puts current buffer position into *buf.
72 */
73 int memio_GetReadParams(memio_Private *secret, uint8_t **buf);
74
75 /* Ask memio how many bytes are contained in the internal buffer.
76 * Returns bytes available to read, or 0 if none available.
77 */
78 int memio_GetReadableBufferSize(memio_Private *secret);
79
80 /* Tell memio how many bytes were read from the network.
81 * If bytes_read is 0, causes EOF to be reported to
82 * NSS after it reads the last byte from the circular buffer.
83 * If bytes_read is < 0, it is treated as an NSPR error code.
84 * See nspr/pr/src/md/unix/unix_errors.c for how to
85 * map from Unix errors to NSPR error codes.
86 * On EWOULDBLOCK or the equivalent, don't call this function.
87 */
88 void memio_PutReadResult(memio_Private *secret, int bytes_read);
89
90 /* Ask memio what data it has to send to the network.
91 * If there was previous a write error, the NSPR error code is returned.
92 * Otherwise, it returns 0 and provides up to two buffers of data by
93 * writing the positions and lengths into |buf1|, |len1| and |buf2|, |len2|.
94 */
95 int memio_GetWriteParams(memio_Private *secret,
96 const uint8_t **buf1, unsigned int *len1,
97 const uint8_t **buf2, unsigned int *len2);
98
99 /* Tell memio how many bytes were sent to the network.
100 * If bytes_written is < 0, it is treated as an NSPR error code.
101 * See nspr/pr/src/md/unix/unix_errors.c for how to
102 * map from Unix errors to NSPR error codes.
103 * On EWOULDBLOCK or the equivalent, don't call this function.
104 */
105 void memio_PutWriteResult(memio_Private *secret, int bytes_written);
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif // BIN_NET_NSS_MEMIO_H_
OLDNEW
« no previous file with comments | « runtime/bin/net/nss.gyp ('k') | runtime/bin/net/nss_memio.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698