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

Side by Side Diff: webrtc/p2p/base/dtlstransportchannel_unittest.cc

Issue 2679103006: Rename "PacketTransportInterface" to "PacketTransportInternal". (Closed)
Patch Set: Created 3 years, 10 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 | « webrtc/p2p/base/dtlstransportchannel.cc ('k') | webrtc/p2p/base/dtlstransportinternal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 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
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 13
14 #include "webrtc/p2p/base/dtlstransportchannel.h" 14 #include "webrtc/p2p/base/dtlstransportchannel.h"
15 #include "webrtc/p2p/base/fakeicetransport.h" 15 #include "webrtc/p2p/base/fakeicetransport.h"
16 #include "webrtc/p2p/base/packettransportinterface.h" 16 #include "webrtc/p2p/base/packettransportinternal.h"
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/dscp.h" 18 #include "webrtc/base/dscp.h"
19 #include "webrtc/base/gunit.h" 19 #include "webrtc/base/gunit.h"
20 #include "webrtc/base/helpers.h" 20 #include "webrtc/base/helpers.h"
21 #include "webrtc/base/ssladapter.h" 21 #include "webrtc/base/ssladapter.h"
22 #include "webrtc/base/sslidentity.h" 22 #include "webrtc/base/sslidentity.h"
23 #include "webrtc/base/sslstreamadapter.h" 23 #include "webrtc/base/sslstreamadapter.h"
24 #include "webrtc/base/stringutils.h" 24 #include "webrtc/base/stringutils.h"
25 25
26 #define MAYBE_SKIP_TEST(feature) \ 26 #define MAYBE_SKIP_TEST(feature) \
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 for (size_t i = kPacketNumOffset; i < size; ++i) { 371 for (size_t i = kPacketNumOffset; i < size; ++i) {
372 if (static_cast<uint8_t>(data[i]) == (packet_num & 0xff)) { 372 if (static_cast<uint8_t>(data[i]) == (packet_num & 0xff)) {
373 ++num_matches; 373 ++num_matches;
374 } 374 }
375 } 375 }
376 return (num_matches < ((static_cast<int>(size) - 5) / 10)); 376 return (num_matches < ((static_cast<int>(size) - 5) / 10));
377 } 377 }
378 378
379 // Transport channel callbacks 379 // Transport channel callbacks
380 void OnTransportChannelWritableState( 380 void OnTransportChannelWritableState(
381 rtc::PacketTransportInterface* transport) { 381 rtc::PacketTransportInternal* transport) {
382 LOG(LS_INFO) << name_ << ": Channel '" << transport->debug_name() 382 LOG(LS_INFO) << name_ << ": Channel '" << transport->debug_name()
383 << "' is writable"; 383 << "' is writable";
384 } 384 }
385 385
386 void OnTransportChannelReadPacket(rtc::PacketTransportInterface* transport, 386 void OnTransportChannelReadPacket(rtc::PacketTransportInternal* transport,
387 const char* data, 387 const char* data,
388 size_t size, 388 size_t size,
389 const rtc::PacketTime& packet_time, 389 const rtc::PacketTime& packet_time,
390 int flags) { 390 int flags) {
391 uint32_t packet_num = 0; 391 uint32_t packet_num = 0;
392 ASSERT_TRUE(VerifyPacket(data, size, &packet_num)); 392 ASSERT_TRUE(VerifyPacket(data, size, &packet_num));
393 received_.insert(packet_num); 393 received_.insert(packet_num);
394 // Only DTLS-SRTP packets should have the bypass flag set. 394 // Only DTLS-SRTP packets should have the bypass flag set.
395 int expected_flags = 395 int expected_flags =
396 (certificate_ && IsRtpLeadByte(data[0])) ? cricket::PF_SRTP_BYPASS : 0; 396 (certificate_ && IsRtpLeadByte(data[0])) ? cricket::PF_SRTP_BYPASS : 0;
397 ASSERT_EQ(expected_flags, flags); 397 ASSERT_EQ(expected_flags, flags);
398 } 398 }
399 399
400 void OnTransportChannelSentPacket(rtc::PacketTransportInterface* transport, 400 void OnTransportChannelSentPacket(rtc::PacketTransportInternal* transport,
401 const rtc::SentPacket& sent_packet) { 401 const rtc::SentPacket& sent_packet) {
402 sent_packet_ = sent_packet; 402 sent_packet_ = sent_packet;
403 } 403 }
404 404
405 rtc::SentPacket sent_packet() const { return sent_packet_; } 405 rtc::SentPacket sent_packet() const { return sent_packet_; }
406 406
407 // Hook into the raw packet stream to make sure DTLS packets are encrypted. 407 // Hook into the raw packet stream to make sure DTLS packets are encrypted.
408 void OnFakeTransportChannelReadPacket( 408 void OnFakeTransportChannelReadPacket(rtc::PacketTransportInternal* transport,
409 rtc::PacketTransportInterface* transport, 409 const char* data,
410 const char* data, 410 size_t size,
411 size_t size, 411 const rtc::PacketTime& time,
412 const rtc::PacketTime& time, 412 int flags) {
413 int flags) {
414 // Flags shouldn't be set on the underlying TransportChannel packets. 413 // Flags shouldn't be set on the underlying TransportChannel packets.
415 ASSERT_EQ(0, flags); 414 ASSERT_EQ(0, flags);
416 415
417 // Look at the handshake packets to see what role we played. 416 // Look at the handshake packets to see what role we played.
418 // Check that non-handshake packets are DTLS data or SRTP bypass. 417 // Check that non-handshake packets are DTLS data or SRTP bypass.
419 if (data[0] == 22 && size > 17) { 418 if (data[0] == 22 && size > 17) {
420 if (data[13] == 1) { 419 if (data[13] == 1) {
421 ++received_dtls_client_hellos_; 420 ++received_dtls_client_hellos_;
422 } else if (data[13] == 2) { 421 } else if (data[13] == 2) {
423 ++received_dtls_server_hellos_; 422 ++received_dtls_server_hellos_;
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 std::vector<DtlsTransportEvent>{ 1160 std::vector<DtlsTransportEvent>{
1162 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT, 1161 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT,
1163 CALLER_WRITABLE, HANDSHAKE_FINISHES}, 1162 CALLER_WRITABLE, HANDSHAKE_FINISHES},
1164 std::vector<DtlsTransportEvent>{ 1163 std::vector<DtlsTransportEvent>{
1165 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE, 1164 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE,
1166 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES}, 1165 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES},
1167 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO, 1166 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO,
1168 CALLER_WRITABLE, HANDSHAKE_FINISHES, 1167 CALLER_WRITABLE, HANDSHAKE_FINISHES,
1169 CALLER_RECEIVES_FINGERPRINT}), 1168 CALLER_RECEIVES_FINGERPRINT}),
1170 ::testing::Bool())); 1169 ::testing::Bool()));
OLDNEW
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel.cc ('k') | webrtc/p2p/base/dtlstransportinternal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698