| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (b == NULL) | 112 if (b == NULL) |
| 113 return 0; | 113 return 0; |
| 114 return 1; | 114 return 1; |
| 115 } | 115 } |
| 116 | 116 |
| 117 static int socket_read(BIO* b, char* out, int outl) { | 117 static int socket_read(BIO* b, char* out, int outl) { |
| 118 if (!out) | 118 if (!out) |
| 119 return -1; | 119 return -1; |
| 120 rtc::AsyncSocket* socket = static_cast<rtc::AsyncSocket*>(b->ptr); | 120 rtc::AsyncSocket* socket = static_cast<rtc::AsyncSocket*>(b->ptr); |
| 121 BIO_clear_retry_flags(b); | 121 BIO_clear_retry_flags(b); |
| 122 int result = socket->Recv(out, outl); | 122 int result = socket->Recv(out, outl, nullptr); |
| 123 if (result > 0) { | 123 if (result > 0) { |
| 124 return result; | 124 return result; |
| 125 } else if (result == 0) { | 125 } else if (result == 0) { |
| 126 b->num = 1; | 126 b->num = 1; |
| 127 } else if (socket->IsBlocking()) { | 127 } else if (socket->IsBlocking()) { |
| 128 BIO_set_retry_read(b); | 128 BIO_set_retry_read(b); |
| 129 } | 129 } |
| 130 return -1; | 130 return -1; |
| 131 } | 131 } |
| 132 | 132 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 if (socket_->GetState() == Socket::CS_CONNECTED && | 517 if (socket_->GetState() == Socket::CS_CONNECTED && |
| 518 addr == socket_->GetRemoteAddress()) { | 518 addr == socket_->GetRemoteAddress()) { |
| 519 return Send(pv, cb); | 519 return Send(pv, cb); |
| 520 } | 520 } |
| 521 | 521 |
| 522 SetError(ENOTCONN); | 522 SetError(ENOTCONN); |
| 523 | 523 |
| 524 return SOCKET_ERROR; | 524 return SOCKET_ERROR; |
| 525 } | 525 } |
| 526 | 526 |
| 527 int | 527 int OpenSSLAdapter::Recv(void* pv, size_t cb, int64_t* timestamp) { |
| 528 OpenSSLAdapter::Recv(void* pv, size_t cb) { | |
| 529 //LOG(LS_INFO) << "OpenSSLAdapter::Recv(" << cb << ")"; | 528 //LOG(LS_INFO) << "OpenSSLAdapter::Recv(" << cb << ")"; |
| 530 switch (state_) { | 529 switch (state_) { |
| 531 | 530 |
| 532 case SSL_NONE: | 531 case SSL_NONE: |
| 533 return AsyncSocketAdapter::Recv(pv, cb); | 532 return AsyncSocketAdapter::Recv(pv, cb, timestamp); |
| 534 | 533 |
| 535 case SSL_WAIT: | 534 case SSL_WAIT: |
| 536 case SSL_CONNECTING: | 535 case SSL_CONNECTING: |
| 537 SetError(EWOULDBLOCK); | 536 SetError(EWOULDBLOCK); |
| 538 return SOCKET_ERROR; | 537 return SOCKET_ERROR; |
| 539 | 538 |
| 540 case SSL_CONNECTED: | 539 case SSL_CONNECTED: |
| 541 break; | 540 break; |
| 542 | 541 |
| 543 case SSL_ERROR: | 542 case SSL_ERROR: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 572 break; | 571 break; |
| 573 default: | 572 default: |
| 574 //LOG(LS_INFO) << " -- error " << code; | 573 //LOG(LS_INFO) << " -- error " << code; |
| 575 Error("SSL_read", (code ? code : -1), false); | 574 Error("SSL_read", (code ? code : -1), false); |
| 576 break; | 575 break; |
| 577 } | 576 } |
| 578 | 577 |
| 579 return SOCKET_ERROR; | 578 return SOCKET_ERROR; |
| 580 } | 579 } |
| 581 | 580 |
| 582 int | 581 int OpenSSLAdapter::RecvFrom(void* pv, |
| 583 OpenSSLAdapter::RecvFrom(void* pv, size_t cb, SocketAddress* paddr) { | 582 size_t cb, |
| 583 SocketAddress* paddr, |
| 584 int64_t* timestamp) { |
| 584 if (socket_->GetState() == Socket::CS_CONNECTED) { | 585 if (socket_->GetState() == Socket::CS_CONNECTED) { |
| 585 int ret = Recv(pv, cb); | 586 int ret = Recv(pv, cb, timestamp); |
| 586 | 587 |
| 587 *paddr = GetRemoteAddress(); | 588 *paddr = GetRemoteAddress(); |
| 588 | 589 |
| 589 return ret; | 590 return ret; |
| 590 } | 591 } |
| 591 | 592 |
| 592 SetError(ENOTCONN); | 593 SetError(ENOTCONN); |
| 593 | 594 |
| 594 return SOCKET_ERROR; | 595 return SOCKET_ERROR; |
| 595 } | 596 } |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 if (ssl_mode_ == SSL_MODE_DTLS) { | 958 if (ssl_mode_ == SSL_MODE_DTLS) { |
| 958 SSL_CTX_set_read_ahead(ctx, 1); | 959 SSL_CTX_set_read_ahead(ctx, 1); |
| 959 } | 960 } |
| 960 | 961 |
| 961 return ctx; | 962 return ctx; |
| 962 } | 963 } |
| 963 | 964 |
| 964 } // namespace rtc | 965 } // namespace rtc |
| 965 | 966 |
| 966 #endif // HAVE_OPENSSL_SSL_H | 967 #endif // HAVE_OPENSSL_SSL_H |
| OLD | NEW |