OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2013 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 15 matching lines...) Expand all Loading... |
26 static const size_t kBufSize = kMaxPacketSize + kStunHeaderSize; | 26 static const size_t kBufSize = kMaxPacketSize + kStunHeaderSize; |
27 static const size_t kTurnChannelDataHdrSize = 4; | 27 static const size_t kTurnChannelDataHdrSize = 4; |
28 | 28 |
29 inline bool IsStunMessage(uint16_t msg_type) { | 29 inline bool IsStunMessage(uint16_t msg_type) { |
30 // The first two bits of a channel data message are 0b01. | 30 // The first two bits of a channel data message are 0b01. |
31 return (msg_type & 0xC000) ? false : true; | 31 return (msg_type & 0xC000) ? false : true; |
32 } | 32 } |
33 | 33 |
34 // AsyncStunTCPSocket | 34 // AsyncStunTCPSocket |
35 // Binds and connects |socket| and creates AsyncTCPSocket for | 35 // Binds and connects |socket| and creates AsyncTCPSocket for |
36 // it. Takes ownership of |socket|. Returns NULL if bind() or | 36 // it. Takes ownership of |socket|. Returns null if bind() or |
37 // connect() fail (|socket| is destroyed in that case). | 37 // connect() fail (|socket| is destroyed in that case). |
38 AsyncStunTCPSocket* AsyncStunTCPSocket::Create( | 38 AsyncStunTCPSocket* AsyncStunTCPSocket::Create( |
39 rtc::AsyncSocket* socket, | 39 rtc::AsyncSocket* socket, |
40 const rtc::SocketAddress& bind_address, | 40 const rtc::SocketAddress& bind_address, |
41 const rtc::SocketAddress& remote_address) { | 41 const rtc::SocketAddress& remote_address) { |
42 return new AsyncStunTCPSocket(AsyncTCPSocketBase::ConnectSocket( | 42 return new AsyncStunTCPSocket(AsyncTCPSocketBase::ConnectSocket( |
43 socket, bind_address, remote_address), false); | 43 socket, bind_address, remote_address), false); |
44 } | 44 } |
45 | 45 |
46 AsyncStunTCPSocket::AsyncStunTCPSocket( | 46 AsyncStunTCPSocket::AsyncStunTCPSocket( |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // message (including padding) is (4 + Length) rounded up to the nearest | 144 // message (including padding) is (4 + Length) rounded up to the nearest |
145 // multiple of 4. Over UDP, the padding is not required but MAY be | 145 // multiple of 4. Over UDP, the padding is not required but MAY be |
146 // included. | 146 // included. |
147 if (expected_pkt_len % 4) | 147 if (expected_pkt_len % 4) |
148 *pad_bytes = 4 - (expected_pkt_len % 4); | 148 *pad_bytes = 4 - (expected_pkt_len % 4); |
149 } | 149 } |
150 return expected_pkt_len; | 150 return expected_pkt_len; |
151 } | 151 } |
152 | 152 |
153 } // namespace cricket | 153 } // namespace cricket |
OLD | NEW |