OLD | NEW |
1 /* | 1 /* |
2 * Gather (Read) entire SSL2 records from socket into buffer. | 2 * Gather (Read) entire SSL2 records from socket into buffer. |
3 * | 3 * |
4 * This Source Code Form is subject to the terms of the Mozilla Public | 4 * This Source Code Form is subject to the terms of the Mozilla Public |
5 * License, v. 2.0. If a copy of the MPL was not distributed with this | 5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 #include "cert.h" | 7 #include "cert.h" |
8 #include "ssl.h" | 8 #include "ssl.h" |
9 #include "sslimpl.h" | 9 #include "sslimpl.h" |
10 #include "sslproto.h" | 10 #include "sslproto.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 * Called by ssl_GatherRecord1stHandshake in sslcon.c, | 357 * Called by ssl_GatherRecord1stHandshake in sslcon.c, |
358 * and by DoRecv in sslsecur.c | 358 * and by DoRecv in sslsecur.c |
359 * Caller must hold RecvBufLock. | 359 * Caller must hold RecvBufLock. |
360 */ | 360 */ |
361 int | 361 int |
362 ssl2_GatherRecord(sslSocket *ss, int flags) | 362 ssl2_GatherRecord(sslSocket *ss, int flags) |
363 { | 363 { |
364 return ssl2_GatherData(ss, &ss->gs, flags); | 364 return ssl2_GatherData(ss, &ss->gs, flags); |
365 } | 365 } |
366 | 366 |
367 /* | |
368 * Returns +1 when it has gathered a complete SSLV2 record. | |
369 * Returns 0 if it hits EOF. | |
370 * Returns -1 (SECFailure) on any error | |
371 * Returns -2 (SECWouldBlock) | |
372 * | |
373 * Called from SocksStartGather in sslsocks.c | |
374 * Caller must hold RecvBufLock. | |
375 */ | |
376 int | |
377 ssl2_StartGatherBytes(sslSocket *ss, sslGather *gs, unsigned int count) | |
378 { | |
379 int rv; | |
380 | |
381 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); | |
382 gs->state = GS_DATA; | |
383 gs->remainder = count; | |
384 gs->count = count; | |
385 gs->offset = 0; | |
386 if (count > gs->buf.space) { | |
387 rv = sslBuffer_Grow(&gs->buf, count); | |
388 if (rv) { | |
389 return rv; | |
390 } | |
391 } | |
392 return ssl2_GatherData(ss, gs, 0); | |
393 } | |
394 | |
395 /* Caller should hold RecvBufLock. */ | 367 /* Caller should hold RecvBufLock. */ |
396 SECStatus | 368 SECStatus |
397 ssl_InitGather(sslGather *gs) | 369 ssl_InitGather(sslGather *gs) |
398 { | 370 { |
399 SECStatus status; | 371 SECStatus status; |
400 | 372 |
401 gs->state = GS_INIT; | 373 gs->state = GS_INIT; |
402 gs->writeOffset = 0; | 374 gs->writeOffset = 0; |
403 gs->readOffset = 0; | 375 gs->readOffset = 0; |
404 gs->dtlsPacketOffset = 0; | 376 gs->dtlsPacketOffset = 0; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 rv = ssl3_NegotiateVersion(ss, SSL_LIBRARY_VERSION_MAX_SUPPORTED, | 416 rv = ssl3_NegotiateVersion(ss, SSL_LIBRARY_VERSION_MAX_SUPPORTED, |
445 PR_TRUE); | 417 PR_TRUE); |
446 if (rv != SECSuccess) { | 418 if (rv != SECSuccess) { |
447 return rv; | 419 return rv; |
448 } | 420 } |
449 | 421 |
450 ss->sec.send = ssl3_SendApplicationData; | 422 ss->sec.send = ssl3_SendApplicationData; |
451 | 423 |
452 return SECSuccess; | 424 return SECSuccess; |
453 } | 425 } |
OLD | NEW |