]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/BIO_s_bio.3
This commit was generated by cvs2svn to compensate for changes in r102528,
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / BIO_s_bio.3
1 .\" Automatically generated by Pod::Man version 1.15
2 .\" Tue Jul 30 09:21:09 2002
3 .\"
4 .\" Standard preamble:
5 .\" ======================================================================
6 .de Sh \" Subsection heading
7 .br
8 .if t .Sp
9 .ne 5
10 .PP
11 \fB\\$1\fR
12 .PP
13 ..
14 .de Sp \" Vertical space (when we can't use .PP)
15 .if t .sp .5v
16 .if n .sp
17 ..
18 .de Ip \" List item
19 .br
20 .ie \\n(.$>=3 .ne \\$3
21 .el .ne 3
22 .IP "\\$1" \\$2
23 ..
24 .de Vb \" Begin verbatim text
25 .ft CW
26 .nf
27 .ne \\$1
28 ..
29 .de Ve \" End verbatim text
30 .ft R
31
32 .fi
33 ..
34 .\" Set up some character translations and predefined strings.  \*(-- will
35 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
36 .\" double quote, and \*(R" will give a right double quote.  | will give a
37 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used
38 .\" to do unbreakable dashes and therefore won't be available.  \*(C` and
39 .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
40 .tr \(*W-|\(bv\*(Tr
41 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
42 .ie n \{\
43 .    ds -- \(*W-
44 .    ds PI pi
45 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
46 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
47 .    ds L" ""
48 .    ds R" ""
49 .    ds C` ""
50 .    ds C' ""
51 'br\}
52 .el\{\
53 .    ds -- \|\(em\|
54 .    ds PI \(*p
55 .    ds L" ``
56 .    ds R" ''
57 'br\}
58 .\"
59 .\" If the F register is turned on, we'll generate index entries on stderr
60 .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
61 .\" index entries marked with X<> in POD.  Of course, you'll have to process
62 .\" the output yourself in some meaningful fashion.
63 .if \nF \{\
64 .    de IX
65 .    tm Index:\\$1\t\\n%\t"\\$2"
66 ..
67 .    nr % 0
68 .    rr F
69 .\}
70 .\"
71 .\" For nroff, turn off justification.  Always turn off hyphenation; it
72 .\" makes way too many mistakes in technical documents.
73 .hy 0
74 .if n .na
75 .\"
76 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
77 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
78 .bd B 3
79 .    \" fudge factors for nroff and troff
80 .if n \{\
81 .    ds #H 0
82 .    ds #V .8m
83 .    ds #F .3m
84 .    ds #[ \f1
85 .    ds #] \fP
86 .\}
87 .if t \{\
88 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 .    ds #V .6m
90 .    ds #F 0
91 .    ds #[ \&
92 .    ds #] \&
93 .\}
94 .    \" simple accents for nroff and troff
95 .if n \{\
96 .    ds ' \&
97 .    ds ` \&
98 .    ds ^ \&
99 .    ds , \&
100 .    ds ~ ~
101 .    ds /
102 .\}
103 .if t \{\
104 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
105 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
106 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
107 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
108 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
109 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
110 .\}
111 .    \" troff and (daisy-wheel) nroff accents
112 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
113 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
114 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
115 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
116 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
117 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
118 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
119 .ds ae a\h'-(\w'a'u*4/10)'e
120 .ds Ae A\h'-(\w'A'u*4/10)'E
121 .    \" corrections for vroff
122 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
123 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
124 .    \" for low resolution devices (crt and lpr)
125 .if \n(.H>23 .if \n(.V>19 \
126 \{\
127 .    ds : e
128 .    ds 8 ss
129 .    ds o a
130 .    ds d- d\h'-1'\(ga
131 .    ds D- D\h'-1'\(hy
132 .    ds th \o'bp'
133 .    ds Th \o'LP'
134 .    ds ae ae
135 .    ds Ae AE
136 .\}
137 .rm #[ #] #H #V #F C
138 .\" ======================================================================
139 .\"
140 .IX Title "BIO_s_bio 3"
141 .TH BIO_s_bio 3 "0.9.6e" "2000-11-12" "OpenSSL"
142 .UC
143 .SH "NAME"
144 BIO_s_bio, BIO_make_bio_pair, BIO_destroy_bio_pair, BIO_shutdown_wr, 
145 BIO_set_write_buf_size, BIO_get_write_buf_size, BIO_new_bio_pair,
146 BIO_get_write_guarantee, BIO_ctrl_get_write_guarantee, BIO_get_read_request,
147 BIO_ctrl_get_read_request, BIO_ctrl_reset_read_request \- \s-1BIO\s0 pair \s-1BIO\s0
148 .SH "SYNOPSIS"
149 .IX Header "SYNOPSIS"
150 .Vb 1
151 \& #include <openssl/bio.h>
152 .Ve
153 .Vb 1
154 \& BIO_METHOD *BIO_s_bio(void);
155 .Ve
156 .Vb 2
157 \& #define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
158 \& #define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
159 .Ve
160 .Vb 1
161 \& #define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
162 .Ve
163 .Vb 2
164 \& #define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
165 \& #define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
166 .Ve
167 .Vb 1
168 \& int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2);
169 .Ve
170 .Vb 2
171 \& #define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
172 \& size_t BIO_ctrl_get_write_guarantee(BIO *b);
173 .Ve
174 .Vb 2
175 \& #define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
176 \& size_t BIO_ctrl_get_read_request(BIO *b);
177 .Ve
178 .Vb 1
179 \& int BIO_ctrl_reset_read_request(BIO *b);
180 .Ve
181 .SH "DESCRIPTION"
182 .IX Header "DESCRIPTION"
183 \&\fIBIO_s_bio()\fR returns the method for a \s-1BIO\s0 pair. A \s-1BIO\s0 pair is a pair of source/sink
184 BIOs where data written to either half of the pair is buffered and can be read from
185 the other half. Both halves must usually by handled by the same application thread
186 since no locking is done on the internal data structures.
187 .PP
188 Since \s-1BIO\s0 chains typically end in a source/sink \s-1BIO\s0 it is possible to make this
189 one half of a \s-1BIO\s0 pair and have all the data processed by the chain under application
190 control.
191 .PP
192 One typical use of \s-1BIO\s0 pairs is to place \s-1TLS/SSL\s0 I/O under application control, this
193 can be used when the application wishes to use a non standard transport for
194 \&\s-1TLS/SSL\s0 or the normal socket routines are inappropriate.
195 .PP
196 Calls to \fIBIO_read()\fR will read data from the buffer or request a retry if no
197 data is available.
198 .PP
199 Calls to \fIBIO_write()\fR will place data in the buffer or request a retry if the
200 buffer is full.
201 .PP
202 The standard calls \fIBIO_ctrl_pending()\fR and \fIBIO_ctrl_wpending()\fR can be used to
203 determine the amount of pending data in the read or write buffer.
204 .PP
205 \&\fIBIO_reset()\fR clears any data in the write buffer.
206 .PP
207 \&\fIBIO_make_bio_pair()\fR joins two separate BIOs into a connected pair.
208 .PP
209 \&\fIBIO_destroy_pair()\fR destroys the association between two connected BIOs. Freeing
210 up any half of the pair will automatically destroy the association.
211 .PP
212 \&\fIBIO_shutdown_wr()\fR is used to close down a \s-1BIO\s0 \fBb\fR. After this call no further
213 writes on \s-1BIO\s0 \fBb\fR are allowed (they will return an error). Reads on the other
214 half of the pair will return any pending data or \s-1EOF\s0 when all pending data has
215 been read. 
216 .PP
217 \&\fIBIO_set_write_buf_size()\fR sets the write buffer size of \s-1BIO\s0 \fBb\fR to \fBsize\fR.
218 If the size is not initialized a default value is used. This is currently
219 17K, sufficient for a maximum size \s-1TLS\s0 record.
220 .PP
221 \&\fIBIO_get_write_buf_size()\fR returns the size of the write buffer.
222 .PP
223 \&\fIBIO_new_bio_pair()\fR combines the calls to \fIBIO_new()\fR, \fIBIO_make_bio_pair()\fR and
224 \&\fIBIO_set_write_buf_size()\fR to create a connected pair of BIOs \fBbio1\fR, \fBbio2\fR
225 with write buffer sizes \fBwritebuf1\fR and \fBwritebuf2\fR. If either size is
226 zero then the default size is used.
227 .PP
228 \&\fIBIO_get_write_guarantee()\fR and \fIBIO_ctrl_get_write_guarantee()\fR return the maximum
229 length of data that can be currently written to the \s-1BIO\s0. Writes larger than this
230 value will return a value from \fIBIO_write()\fR less than the amount requested or if the
231 buffer is full request a retry. \fIBIO_ctrl_get_write_guarantee()\fR is a function
232 whereas \fIBIO_get_write_guarantee()\fR is a macro.
233 .PP
234 \&\fIBIO_get_read_request()\fR and \fIBIO_ctrl_get_read_request()\fR return the
235 amount of data requested, or the buffer size if it is less, if the
236 last read attempt at the other half of the \s-1BIO\s0 pair failed due to an
237 empty buffer.  This can be used to determine how much data should be
238 written to the \s-1BIO\s0 so the next read will succeed: this is most useful
239 in \s-1TLS/SSL\s0 applications where the amount of data read is usually
240 meaningful rather than just a buffer size. After a successful read
241 this call will return zero.  It also will return zero once new data
242 has been written satisfying the read request or part of it.
243 Note that \fIBIO_get_read_request()\fR never returns an amount larger
244 than that returned by \fIBIO_get_write_guarantee()\fR.
245 .PP
246 \&\fIBIO_ctrl_reset_read_request()\fR can also be used to reset the value returned by
247 \&\fIBIO_get_read_request()\fR to zero.
248 .SH "NOTES"
249 .IX Header "NOTES"
250 Both halves of a \s-1BIO\s0 pair should be freed. That is even if one half is implicit
251 freed due to a \fIBIO_free_all()\fR or \fISSL_free()\fR call the other half needs to be freed.
252 .PP
253 When used in bidirectional applications (such as \s-1TLS/SSL\s0) care should be taken to
254 flush any data in the write buffer. This can be done by calling \fIBIO_pending()\fR
255 on the other half of the pair and, if any data is pending, reading it and sending
256 it to the underlying transport. This must be done before any normal processing
257 (such as calling \fIselect()\fR ) due to a request and \fIBIO_should_read()\fR being true.
258 .PP
259 To see why this is important consider a case where a request is sent using
260 \&\fIBIO_write()\fR and a response read with \fIBIO_read()\fR, this can occur during an
261 \&\s-1TLS/SSL\s0 handshake for example. \fIBIO_write()\fR will succeed and place data in the write
262 buffer. \fIBIO_read()\fR will initially fail and \fIBIO_should_read()\fR will be true. If
263 the application then waits for data to be available on the underlying transport
264 before flushing the write buffer it will never succeed because the request was
265 never sent!
266 .SH "EXAMPLE"
267 .IX Header "EXAMPLE"
268 \&\s-1TBA\s0
269 .SH "SEE ALSO"
270 .IX Header "SEE ALSO"
271 SSL_set_bio(3), ssl(3), bio(3),
272 BIO_should_retry(3), BIO_read(3)