OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_protocol.h" | 5 #include "net/quic/quic_protocol.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/quic/quic_utils.h" | 8 #include "net/quic/quic_utils.h" |
9 | 9 |
10 using base::StringPiece; | 10 using base::StringPiece; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 | 151 |
152 QuicTag QuicVersionToQuicTag(const QuicVersion version) { | 152 QuicTag QuicVersionToQuicTag(const QuicVersion version) { |
153 switch (version) { | 153 switch (version) { |
154 case QUIC_VERSION_12: | 154 case QUIC_VERSION_12: |
155 return MakeQuicTag('Q', '0', '1', '2'); | 155 return MakeQuicTag('Q', '0', '1', '2'); |
156 case QUIC_VERSION_13: | 156 case QUIC_VERSION_13: |
157 return MakeQuicTag('Q', '0', '1', '3'); | 157 return MakeQuicTag('Q', '0', '1', '3'); |
158 case QUIC_VERSION_14: | 158 case QUIC_VERSION_14: |
159 return MakeQuicTag('Q', '0', '1', '4'); | 159 return MakeQuicTag('Q', '0', '1', '4'); |
| 160 case QUIC_VERSION_15: |
| 161 return MakeQuicTag('Q', '0', '1', '5'); |
160 default: | 162 default: |
161 // This shold be an ERROR because we should never attempt to convert an | 163 // This shold be an ERROR because we should never attempt to convert an |
162 // invalid QuicVersion to be written to the wire. | 164 // invalid QuicVersion to be written to the wire. |
163 LOG(ERROR) << "Unsupported QuicVersion: " << version; | 165 LOG(ERROR) << "Unsupported QuicVersion: " << version; |
164 return 0; | 166 return 0; |
165 } | 167 } |
166 } | 168 } |
167 | 169 |
168 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) { | 170 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) { |
169 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { | 171 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { |
170 if (version_tag == QuicVersionToQuicTag(kSupportedQuicVersions[i])) { | 172 if (version_tag == QuicVersionToQuicTag(kSupportedQuicVersions[i])) { |
171 return kSupportedQuicVersions[i]; | 173 return kSupportedQuicVersions[i]; |
172 } | 174 } |
173 } | 175 } |
174 // Reading from the client so this should not be considered an ERROR. | 176 // Reading from the client so this should not be considered an ERROR. |
175 DVLOG(1) << "Unsupported QuicTag version: " | 177 DVLOG(1) << "Unsupported QuicTag version: " |
176 << QuicUtils::TagToString(version_tag); | 178 << QuicUtils::TagToString(version_tag); |
177 return QUIC_VERSION_UNSUPPORTED; | 179 return QUIC_VERSION_UNSUPPORTED; |
178 } | 180 } |
179 | 181 |
180 #define RETURN_STRING_LITERAL(x) \ | 182 #define RETURN_STRING_LITERAL(x) \ |
181 case x: \ | 183 case x: \ |
182 return #x | 184 return #x |
183 | 185 |
184 string QuicVersionToString(const QuicVersion version) { | 186 string QuicVersionToString(const QuicVersion version) { |
185 switch (version) { | 187 switch (version) { |
186 RETURN_STRING_LITERAL(QUIC_VERSION_12); | 188 RETURN_STRING_LITERAL(QUIC_VERSION_12); |
187 RETURN_STRING_LITERAL(QUIC_VERSION_13); | 189 RETURN_STRING_LITERAL(QUIC_VERSION_13); |
188 RETURN_STRING_LITERAL(QUIC_VERSION_14); | 190 RETURN_STRING_LITERAL(QUIC_VERSION_14); |
| 191 RETURN_STRING_LITERAL(QUIC_VERSION_15); |
189 default: | 192 default: |
190 return "QUIC_VERSION_UNSUPPORTED"; | 193 return "QUIC_VERSION_UNSUPPORTED"; |
191 } | 194 } |
192 } | 195 } |
193 | 196 |
194 string QuicVersionVectorToString(const QuicVersionVector& versions) { | 197 string QuicVersionVectorToString(const QuicVersionVector& versions) { |
195 string result = ""; | 198 string result = ""; |
196 for (size_t i = 0; i < versions.size(); ++i) { | 199 for (size_t i = 0; i < versions.size(); ++i) { |
197 if (i != 0) { | 200 if (i != 0) { |
198 result.append(","); | 201 result.append(","); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 356 |
354 ostream& operator<<(ostream& os, const ReceivedPacketInfo& received_info) { | 357 ostream& operator<<(ostream& os, const ReceivedPacketInfo& received_info) { |
355 os << "entropy_hash: " << static_cast<int>(received_info.entropy_hash) | 358 os << "entropy_hash: " << static_cast<int>(received_info.entropy_hash) |
356 << " largest_observed: " << received_info.largest_observed | 359 << " largest_observed: " << received_info.largest_observed |
357 << " missing_packets: [ "; | 360 << " missing_packets: [ "; |
358 for (SequenceNumberSet::const_iterator it = | 361 for (SequenceNumberSet::const_iterator it = |
359 received_info.missing_packets.begin(); | 362 received_info.missing_packets.begin(); |
360 it != received_info.missing_packets.end(); ++it) { | 363 it != received_info.missing_packets.end(); ++it) { |
361 os << *it << " "; | 364 os << *it << " "; |
362 } | 365 } |
| 366 os << " ] revived_packets: [ "; |
| 367 for (SequenceNumberSet::const_iterator it = |
| 368 received_info.revived_packets.begin(); |
| 369 it != received_info.revived_packets.end(); ++it) { |
| 370 os << *it << " "; |
| 371 } |
363 os << " ] "; | 372 os << " ] "; |
364 return os; | 373 return os; |
365 } | 374 } |
366 | 375 |
367 ostream& operator<<(ostream& os, const QuicFrame& frame) { | 376 ostream& operator<<(ostream& os, const QuicFrame& frame) { |
368 switch (frame.type) { | 377 switch (frame.type) { |
369 case PADDING_FRAME: { | 378 case PADDING_FRAME: { |
370 os << "type { PADDING_FRAME } "; | 379 os << "type { PADDING_FRAME } "; |
371 break; | 380 break; |
372 } | 381 } |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 return os; | 713 return os; |
705 } | 714 } |
706 | 715 |
707 WriteResult::WriteResult(WriteStatus status, | 716 WriteResult::WriteResult(WriteStatus status, |
708 int bytes_written_or_error_code) | 717 int bytes_written_or_error_code) |
709 : status(status), | 718 : status(status), |
710 bytes_written(bytes_written_or_error_code) { | 719 bytes_written(bytes_written_or_error_code) { |
711 } | 720 } |
712 | 721 |
713 } // namespace net | 722 } // namespace net |
OLD | NEW |