| 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 int64_t timestamp; |
| 123 int result = socket->Recv(out, outl, ×tamp); |
| 123 if (result > 0) { | 124 if (result > 0) { |
| 124 return result; | 125 return result; |
| 125 } else if (result == 0) { | 126 } else if (result == 0) { |
| 126 b->num = 1; | 127 b->num = 1; |
| 127 } else if (socket->IsBlocking()) { | 128 } else if (socket->IsBlocking()) { |
| 128 BIO_set_retry_read(b); | 129 BIO_set_retry_read(b); |
| 129 } | 130 } |
| 130 return -1; | 131 return -1; |
| 131 } | 132 } |
| 132 | 133 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 if (socket_->GetState() == Socket::CS_CONNECTED && | 518 if (socket_->GetState() == Socket::CS_CONNECTED && |
| 518 addr == socket_->GetRemoteAddress()) { | 519 addr == socket_->GetRemoteAddress()) { |
| 519 return Send(pv, cb); | 520 return Send(pv, cb); |
| 520 } | 521 } |
| 521 | 522 |
| 522 SetError(ENOTCONN); | 523 SetError(ENOTCONN); |
| 523 | 524 |
| 524 return SOCKET_ERROR; | 525 return SOCKET_ERROR; |
| 525 } | 526 } |
| 526 | 527 |
| 527 int | 528 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 << ")"; | 529 //LOG(LS_INFO) << "OpenSSLAdapter::Recv(" << cb << ")"; |
| 530 switch (state_) { | 530 switch (state_) { |
| 531 | 531 |
| 532 case SSL_NONE: | 532 case SSL_NONE: |
| 533 return AsyncSocketAdapter::Recv(pv, cb); | 533 return AsyncSocketAdapter::Recv(pv, cb, timestamp); |
| 534 | 534 |
| 535 case SSL_WAIT: | 535 case SSL_WAIT: |
| 536 case SSL_CONNECTING: | 536 case SSL_CONNECTING: |
| 537 SetError(EWOULDBLOCK); | 537 SetError(EWOULDBLOCK); |
| 538 return SOCKET_ERROR; | 538 return SOCKET_ERROR; |
| 539 | 539 |
| 540 case SSL_CONNECTED: | 540 case SSL_CONNECTED: |
| 541 break; | 541 break; |
| 542 | 542 |
| 543 case SSL_ERROR: | 543 case SSL_ERROR: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 572 break; | 572 break; |
| 573 default: | 573 default: |
| 574 //LOG(LS_INFO) << " -- error " << code; | 574 //LOG(LS_INFO) << " -- error " << code; |
| 575 Error("SSL_read", (code ? code : -1), false); | 575 Error("SSL_read", (code ? code : -1), false); |
| 576 break; | 576 break; |
| 577 } | 577 } |
| 578 | 578 |
| 579 return SOCKET_ERROR; | 579 return SOCKET_ERROR; |
| 580 } | 580 } |
| 581 | 581 |
| 582 int | 582 int OpenSSLAdapter::RecvFrom(void* pv, |
| 583 OpenSSLAdapter::RecvFrom(void* pv, size_t cb, SocketAddress* paddr) { | 583 size_t cb, |
| 584 SocketAddress* paddr, |
| 585 int64_t* timestamp) { |
| 584 if (socket_->GetState() == Socket::CS_CONNECTED) { | 586 if (socket_->GetState() == Socket::CS_CONNECTED) { |
| 585 int ret = Recv(pv, cb); | 587 int ret = Recv(pv, cb, timestamp); |
| 586 | 588 |
| 587 *paddr = GetRemoteAddress(); | 589 *paddr = GetRemoteAddress(); |
| 588 | 590 |
| 589 return ret; | 591 return ret; |
| 590 } | 592 } |
| 591 | 593 |
| 592 SetError(ENOTCONN); | 594 SetError(ENOTCONN); |
| 593 | 595 |
| 594 return SOCKET_ERROR; | 596 return SOCKET_ERROR; |
| 595 } | 597 } |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 if (ssl_mode_ == SSL_MODE_DTLS) { | 959 if (ssl_mode_ == SSL_MODE_DTLS) { |
| 958 SSL_CTX_set_read_ahead(ctx, 1); | 960 SSL_CTX_set_read_ahead(ctx, 1); |
| 959 } | 961 } |
| 960 | 962 |
| 961 return ctx; | 963 return ctx; |
| 962 } | 964 } |
| 963 | 965 |
| 964 } // namespace rtc | 966 } // namespace rtc |
| 965 | 967 |
| 966 #endif // HAVE_OPENSSL_SSL_H | 968 #endif // HAVE_OPENSSL_SSL_H |
| OLD | NEW |