| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/crypto/crypto_handshake_message.h" | 5 #include "net/quic/crypto/crypto_handshake_message.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "net/quic/crypto/crypto_framer.h" | 9 #include "net/quic/crypto/crypto_framer.h" |
| 10 #include "net/quic/crypto/crypto_protocol.h" | 10 #include "net/quic/crypto/crypto_protocol.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 if (i == index) { | 158 if (i == index) { |
| 159 *out = StringPiece(value.data(), size); | 159 *out = StringPiece(value.data(), size); |
| 160 return QUIC_NO_ERROR; | 160 return QUIC_NO_ERROR; |
| 161 } | 161 } |
| 162 | 162 |
| 163 value.remove_prefix(size); | 163 value.remove_prefix(size); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 QuicErrorCode CryptoHandshakeMessage::GetUint32(QuicTag tag, | 167 QuicErrorCode CryptoHandshakeMessage::GetUint32(QuicTag tag, |
| 168 uint32* out) const { | 168 uint32_t* out) const { |
| 169 return GetPOD(tag, out, sizeof(uint32)); | 169 return GetPOD(tag, out, sizeof(uint32_t)); |
| 170 } | 170 } |
| 171 | 171 |
| 172 QuicErrorCode CryptoHandshakeMessage::GetUint64(QuicTag tag, | 172 QuicErrorCode CryptoHandshakeMessage::GetUint64(QuicTag tag, |
| 173 uint64* out) const { | 173 uint64_t* out) const { |
| 174 return GetPOD(tag, out, sizeof(uint64)); | 174 return GetPOD(tag, out, sizeof(uint64_t)); |
| 175 } | 175 } |
| 176 | 176 |
| 177 size_t CryptoHandshakeMessage::size() const { | 177 size_t CryptoHandshakeMessage::size() const { |
| 178 size_t ret = sizeof(QuicTag) + sizeof(uint16) /* number of entries */ + | 178 size_t ret = sizeof(QuicTag) + sizeof(uint16_t) /* number of entries */ + |
| 179 sizeof(uint16) /* padding */; | 179 sizeof(uint16_t) /* padding */; |
| 180 ret += (sizeof(QuicTag) + sizeof(uint32) /* end offset */) * | 180 ret += (sizeof(QuicTag) + sizeof(uint32_t) /* end offset */) * |
| 181 tag_value_map_.size(); | 181 tag_value_map_.size(); |
| 182 for (QuicTagValueMap::const_iterator i = tag_value_map_.begin(); | 182 for (QuicTagValueMap::const_iterator i = tag_value_map_.begin(); |
| 183 i != tag_value_map_.end(); ++i) { | 183 i != tag_value_map_.end(); ++i) { |
| 184 ret += i->second.size(); | 184 ret += i->second.size(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 return ret; | 187 return ret; |
| 188 } | 188 } |
| 189 | 189 |
| 190 void CryptoHandshakeMessage::set_minimum_size(size_t min_bytes) { | 190 void CryptoHandshakeMessage::set_minimum_size(size_t min_bytes) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 bool done = false; | 234 bool done = false; |
| 235 switch (it->first) { | 235 switch (it->first) { |
| 236 case kICSL: | 236 case kICSL: |
| 237 case kCFCW: | 237 case kCFCW: |
| 238 case kSFCW: | 238 case kSFCW: |
| 239 case kIRTT: | 239 case kIRTT: |
| 240 case kMSPC: | 240 case kMSPC: |
| 241 case kSRBF: | 241 case kSRBF: |
| 242 case kSWND: | 242 case kSWND: |
| 243 // uint32 value | 243 // uint32_t value |
| 244 if (it->second.size() == 4) { | 244 if (it->second.size() == 4) { |
| 245 uint32 value; | 245 uint32_t value; |
| 246 memcpy(&value, it->second.data(), sizeof(value)); | 246 memcpy(&value, it->second.data(), sizeof(value)); |
| 247 ret += base::UintToString(value); | 247 ret += base::UintToString(value); |
| 248 done = true; | 248 done = true; |
| 249 } | 249 } |
| 250 break; | 250 break; |
| 251 case kTBKP: | 251 case kTBKP: |
| 252 case kKEXS: | 252 case kKEXS: |
| 253 case kAEAD: | 253 case kAEAD: |
| 254 case kCOPT: | 254 case kCOPT: |
| 255 case kPDMD: | 255 case kPDMD: |
| 256 case kVER: | 256 case kVER: |
| 257 // tag lists | 257 // tag lists |
| 258 if (it->second.size() % sizeof(QuicTag) == 0) { | 258 if (it->second.size() % sizeof(QuicTag) == 0) { |
| 259 for (size_t j = 0; j < it->second.size(); j += sizeof(QuicTag)) { | 259 for (size_t j = 0; j < it->second.size(); j += sizeof(QuicTag)) { |
| 260 QuicTag tag; | 260 QuicTag tag; |
| 261 memcpy(&tag, it->second.data() + j, sizeof(tag)); | 261 memcpy(&tag, it->second.data() + j, sizeof(tag)); |
| 262 if (j > 0) { | 262 if (j > 0) { |
| 263 ret += ","; | 263 ret += ","; |
| 264 } | 264 } |
| 265 ret += "'" + QuicUtils::TagToString(tag) + "'"; | 265 ret += "'" + QuicUtils::TagToString(tag) + "'"; |
| 266 } | 266 } |
| 267 done = true; | 267 done = true; |
| 268 } | 268 } |
| 269 break; | 269 break; |
| 270 case kRREJ: | 270 case kRREJ: |
| 271 // uint32 lists | 271 // uint32_t lists |
| 272 if (it->second.size() % sizeof(uint32) == 0) { | 272 if (it->second.size() % sizeof(uint32_t) == 0) { |
| 273 for (size_t j = 0; j < it->second.size(); j += sizeof(uint32)) { | 273 for (size_t j = 0; j < it->second.size(); j += sizeof(uint32_t)) { |
| 274 uint32 value; | 274 uint32_t value; |
| 275 memcpy(&value, it->second.data() + j, sizeof(value)); | 275 memcpy(&value, it->second.data() + j, sizeof(value)); |
| 276 if (j > 0) { | 276 if (j > 0) { |
| 277 ret += ","; | 277 ret += ","; |
| 278 } | 278 } |
| 279 ret += CryptoUtils::HandshakeFailureReasonToString( | 279 ret += CryptoUtils::HandshakeFailureReasonToString( |
| 280 static_cast<HandshakeFailureReason>(value)); | 280 static_cast<HandshakeFailureReason>(value)); |
| 281 } | 281 } |
| 282 done = true; | 282 done = true; |
| 283 } | 283 } |
| 284 break; | 284 break; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 ret += "0x" + base::HexEncode(it->second.data(), it->second.size()); | 323 ret += "0x" + base::HexEncode(it->second.data(), it->second.size()); |
| 324 } | 324 } |
| 325 ret += "\n"; | 325 ret += "\n"; |
| 326 } | 326 } |
| 327 --indent; | 327 --indent; |
| 328 ret += string(2 * indent, ' ') + ">"; | 328 ret += string(2 * indent, ' ') + ">"; |
| 329 return ret; | 329 return ret; |
| 330 } | 330 } |
| 331 | 331 |
| 332 } // namespace net | 332 } // namespace net |
| OLD | NEW |