| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 class StunErrorCodeAttribute; | 125 class StunErrorCodeAttribute; |
| 126 class StunUInt16ListAttribute; | 126 class StunUInt16ListAttribute; |
| 127 | 127 |
| 128 // Records a complete STUN/TURN message. Each message consists of a type and | 128 // Records a complete STUN/TURN message. Each message consists of a type and |
| 129 // any number of attributes. Each attribute is parsed into an instance of an | 129 // any number of attributes. Each attribute is parsed into an instance of an |
| 130 // appropriate class (see above). The Get* methods will return instances of | 130 // appropriate class (see above). The Get* methods will return instances of |
| 131 // that attribute class. | 131 // that attribute class. |
| 132 class StunMessage { | 132 class StunMessage { |
| 133 public: | 133 public: |
| 134 StunMessage(); | 134 StunMessage(); |
| 135 virtual ~StunMessage(); | 135 virtual ~StunMessage() = default; |
| 136 | 136 |
| 137 int type() const { return type_; } | 137 int type() const { return type_; } |
| 138 size_t length() const { return length_; } | 138 size_t length() const { return length_; } |
| 139 const std::string& transaction_id() const { return transaction_id_; } | 139 const std::string& transaction_id() const { return transaction_id_; } |
| 140 | 140 |
| 141 // Returns true if the message confirms to RFC3489 rather than | 141 // Returns true if the message confirms to RFC3489 rather than |
| 142 // RFC5389. The main difference between two version of the STUN | 142 // RFC5389. The main difference between two version of the STUN |
| 143 // protocol is the presence of the magic cookie and different length | 143 // protocol is the presence of the magic cookie and different length |
| 144 // of transaction ID. For outgoing packets version of the protocol | 144 // of transaction ID. For outgoing packets version of the protocol |
| 145 // is determined by the lengths of the transaction ID. | 145 // is determined by the lengths of the transaction ID. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 virtual StunAttributeValueType GetAttributeValueType(int type) const; | 192 virtual StunAttributeValueType GetAttributeValueType(int type) const; |
| 193 | 193 |
| 194 private: | 194 private: |
| 195 StunAttribute* CreateAttribute(int type, size_t length) /* const*/; | 195 StunAttribute* CreateAttribute(int type, size_t length) /* const*/; |
| 196 const StunAttribute* GetAttribute(int type) const; | 196 const StunAttribute* GetAttribute(int type) const; |
| 197 static bool IsValidTransactionId(const std::string& transaction_id); | 197 static bool IsValidTransactionId(const std::string& transaction_id); |
| 198 | 198 |
| 199 uint16_t type_; | 199 uint16_t type_; |
| 200 uint16_t length_; | 200 uint16_t length_; |
| 201 std::string transaction_id_; | 201 std::string transaction_id_; |
| 202 std::vector<StunAttribute*>* attrs_; | 202 std::vector<std::unique_ptr<StunAttribute>> attrs_; |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 // Base class for all STUN/TURN attributes. | 205 // Base class for all STUN/TURN attributes. |
| 206 class StunAttribute { | 206 class StunAttribute { |
| 207 public: | 207 public: |
| 208 virtual ~StunAttribute() { | 208 virtual ~StunAttribute() { |
| 209 } | 209 } |
| 210 | 210 |
| 211 int type() const { return type_; } | 211 int type() const { return type_; } |
| 212 size_t length() const { return length_; } | 212 size_t length() const { return length_; } |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 case STUN_ATTR_ICE_CONTROLLING: return STUN_VALUE_UINT64; | 630 case STUN_ATTR_ICE_CONTROLLING: return STUN_VALUE_UINT64; |
| 631 default: return StunMessage::GetAttributeValueType(type); | 631 default: return StunMessage::GetAttributeValueType(type); |
| 632 } | 632 } |
| 633 } | 633 } |
| 634 virtual StunMessage* CreateNew() const { return new IceMessage(); } | 634 virtual StunMessage* CreateNew() const { return new IceMessage(); } |
| 635 }; | 635 }; |
| 636 | 636 |
| 637 } // namespace cricket | 637 } // namespace cricket |
| 638 | 638 |
| 639 #endif // WEBRTC_P2P_BASE_STUN_H_ | 639 #endif // WEBRTC_P2P_BASE_STUN_H_ |
| OLD | NEW |