Fix clang style warnings in p2p/base/stun.h
Bug: webrtc:163 Change-Id: Ief9c59f80f36d3339fd40bed9f33e8c6eeef4f90 Reviewed-on: https://webrtc-review.googlesource.com/15781 Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20434}
This commit is contained in:
115
p2p/base/stun.cc
115
p2p/base/stun.cc
@ -52,6 +52,8 @@ StunMessage::StunMessage()
|
|||||||
RTC_DCHECK(IsValidTransactionId(transaction_id_));
|
RTC_DCHECK(IsValidTransactionId(transaction_id_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunMessage::~StunMessage() = default;
|
||||||
|
|
||||||
bool StunMessage::IsLegacy() const {
|
bool StunMessage::IsLegacy() const {
|
||||||
if (transaction_id_.size() == kStunLegacyTransactionIdLength)
|
if (transaction_id_.size() == kStunLegacyTransactionIdLength)
|
||||||
return true;
|
return true;
|
||||||
@ -287,7 +289,7 @@ bool StunMessage::AddFingerprint() {
|
|||||||
// it can't fail.
|
// it can't fail.
|
||||||
auto fingerprint_attr_ptr =
|
auto fingerprint_attr_ptr =
|
||||||
rtc::MakeUnique<StunUInt32Attribute>(STUN_ATTR_FINGERPRINT, 0);
|
rtc::MakeUnique<StunUInt32Attribute>(STUN_ATTR_FINGERPRINT, 0);
|
||||||
auto fingerprint_attr = fingerprint_attr_ptr.get();
|
auto* fingerprint_attr = fingerprint_attr_ptr.get();
|
||||||
AddAttribute(std::move(fingerprint_attr_ptr));
|
AddAttribute(std::move(fingerprint_attr_ptr));
|
||||||
|
|
||||||
// Calculate the CRC-32 for the message and insert it.
|
// Calculate the CRC-32 for the message and insert it.
|
||||||
@ -386,6 +388,10 @@ bool StunMessage::Write(ByteBufferWriter* buf) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunMessage* StunMessage::CreateNew() const {
|
||||||
|
return new StunMessage();
|
||||||
|
}
|
||||||
|
|
||||||
StunAttributeValueType StunMessage::GetAttributeValueType(int type) const {
|
StunAttributeValueType StunMessage::GetAttributeValueType(int type) const {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case STUN_ATTR_MAPPED_ADDRESS: return STUN_VALUE_ADDRESS;
|
case STUN_ATTR_MAPPED_ADDRESS: return STUN_VALUE_ADDRESS;
|
||||||
@ -524,6 +530,10 @@ StunAddressAttribute::StunAddressAttribute(uint16_t type, uint16_t length)
|
|||||||
: StunAttribute(type, length) {
|
: StunAttribute(type, length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType StunAddressAttribute::value_type() const {
|
||||||
|
return STUN_VALUE_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
bool StunAddressAttribute::Read(ByteBufferReader* buf) {
|
bool StunAddressAttribute::Read(ByteBufferReader* buf) {
|
||||||
uint8_t dummy;
|
uint8_t dummy;
|
||||||
if (!buf->ReadUInt8(&dummy))
|
if (!buf->ReadUInt8(&dummy))
|
||||||
@ -597,6 +607,14 @@ StunXorAddressAttribute::StunXorAddressAttribute(uint16_t type,
|
|||||||
: StunAddressAttribute(type, length), owner_(owner) {
|
: StunAddressAttribute(type, length), owner_(owner) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType StunXorAddressAttribute::value_type() const {
|
||||||
|
return STUN_VALUE_XOR_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StunXorAddressAttribute::SetOwner(StunMessage* owner) {
|
||||||
|
owner_ = owner;
|
||||||
|
}
|
||||||
|
|
||||||
rtc::IPAddress StunXorAddressAttribute::GetXoredIP() const {
|
rtc::IPAddress StunXorAddressAttribute::GetXoredIP() const {
|
||||||
if (owner_) {
|
if (owner_) {
|
||||||
rtc::IPAddress ip = ipaddr();
|
rtc::IPAddress ip = ipaddr();
|
||||||
@ -678,6 +696,10 @@ StunUInt32Attribute::StunUInt32Attribute(uint16_t type)
|
|||||||
: StunAttribute(type, SIZE), bits_(0) {
|
: StunAttribute(type, SIZE), bits_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType StunUInt32Attribute::value_type() const {
|
||||||
|
return STUN_VALUE_UINT32;
|
||||||
|
}
|
||||||
|
|
||||||
bool StunUInt32Attribute::GetBit(size_t index) const {
|
bool StunUInt32Attribute::GetBit(size_t index) const {
|
||||||
RTC_DCHECK(index < 32);
|
RTC_DCHECK(index < 32);
|
||||||
return static_cast<bool>((bits_ >> index) & 0x1);
|
return static_cast<bool>((bits_ >> index) & 0x1);
|
||||||
@ -708,6 +730,10 @@ StunUInt64Attribute::StunUInt64Attribute(uint16_t type)
|
|||||||
: StunAttribute(type, SIZE), bits_(0) {
|
: StunAttribute(type, SIZE), bits_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType StunUInt64Attribute::value_type() const {
|
||||||
|
return STUN_VALUE_UINT64;
|
||||||
|
}
|
||||||
|
|
||||||
bool StunUInt64Attribute::Read(ByteBufferReader* buf) {
|
bool StunUInt64Attribute::Read(ByteBufferReader* buf) {
|
||||||
if (length() != SIZE || !buf->ReadUInt64(&bits_))
|
if (length() != SIZE || !buf->ReadUInt64(&bits_))
|
||||||
return false;
|
return false;
|
||||||
@ -744,6 +770,10 @@ StunByteStringAttribute::~StunByteStringAttribute() {
|
|||||||
delete [] bytes_;
|
delete [] bytes_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType StunByteStringAttribute::value_type() const {
|
||||||
|
return STUN_VALUE_BYTE_STRING;
|
||||||
|
}
|
||||||
|
|
||||||
void StunByteStringAttribute::CopyBytes(const char* bytes) {
|
void StunByteStringAttribute::CopyBytes(const char* bytes) {
|
||||||
CopyBytes(bytes, strlen(bytes));
|
CopyBytes(bytes, strlen(bytes));
|
||||||
}
|
}
|
||||||
@ -805,6 +835,10 @@ StunErrorCodeAttribute::StunErrorCodeAttribute(uint16_t type, uint16_t length)
|
|||||||
StunErrorCodeAttribute::~StunErrorCodeAttribute() {
|
StunErrorCodeAttribute::~StunErrorCodeAttribute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType StunErrorCodeAttribute::value_type() const {
|
||||||
|
return STUN_VALUE_ERROR_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
int StunErrorCodeAttribute::code() const {
|
int StunErrorCodeAttribute::code() const {
|
||||||
return class_ * 100 + number_;
|
return class_ * 100 + number_;
|
||||||
}
|
}
|
||||||
@ -853,6 +887,10 @@ StunUInt16ListAttribute::~StunUInt16ListAttribute() {
|
|||||||
delete attr_types_;
|
delete attr_types_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType StunUInt16ListAttribute::value_type() const {
|
||||||
|
return STUN_VALUE_UINT16_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
size_t StunUInt16ListAttribute::Size() const {
|
size_t StunUInt16ListAttribute::Size() const {
|
||||||
return attr_types_->size();
|
return attr_types_->size();
|
||||||
}
|
}
|
||||||
@ -946,4 +984,79 @@ bool ComputeStunCredentialHash(const std::string& username,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType RelayMessage::GetAttributeValueType(int type) const {
|
||||||
|
switch (type) {
|
||||||
|
case STUN_ATTR_LIFETIME:
|
||||||
|
return STUN_VALUE_UINT32;
|
||||||
|
case STUN_ATTR_MAGIC_COOKIE:
|
||||||
|
return STUN_VALUE_BYTE_STRING;
|
||||||
|
case STUN_ATTR_BANDWIDTH:
|
||||||
|
return STUN_VALUE_UINT32;
|
||||||
|
case STUN_ATTR_DESTINATION_ADDRESS:
|
||||||
|
return STUN_VALUE_ADDRESS;
|
||||||
|
case STUN_ATTR_SOURCE_ADDRESS2:
|
||||||
|
return STUN_VALUE_ADDRESS;
|
||||||
|
case STUN_ATTR_DATA:
|
||||||
|
return STUN_VALUE_BYTE_STRING;
|
||||||
|
case STUN_ATTR_OPTIONS:
|
||||||
|
return STUN_VALUE_UINT32;
|
||||||
|
default:
|
||||||
|
return StunMessage::GetAttributeValueType(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StunMessage* RelayMessage::CreateNew() const {
|
||||||
|
return new RelayMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType TurnMessage::GetAttributeValueType(int type) const {
|
||||||
|
switch (type) {
|
||||||
|
case STUN_ATTR_CHANNEL_NUMBER:
|
||||||
|
return STUN_VALUE_UINT32;
|
||||||
|
case STUN_ATTR_TURN_LIFETIME:
|
||||||
|
return STUN_VALUE_UINT32;
|
||||||
|
case STUN_ATTR_XOR_PEER_ADDRESS:
|
||||||
|
return STUN_VALUE_XOR_ADDRESS;
|
||||||
|
case STUN_ATTR_DATA:
|
||||||
|
return STUN_VALUE_BYTE_STRING;
|
||||||
|
case STUN_ATTR_XOR_RELAYED_ADDRESS:
|
||||||
|
return STUN_VALUE_XOR_ADDRESS;
|
||||||
|
case STUN_ATTR_EVEN_PORT:
|
||||||
|
return STUN_VALUE_BYTE_STRING;
|
||||||
|
case STUN_ATTR_REQUESTED_TRANSPORT:
|
||||||
|
return STUN_VALUE_UINT32;
|
||||||
|
case STUN_ATTR_DONT_FRAGMENT:
|
||||||
|
return STUN_VALUE_BYTE_STRING;
|
||||||
|
case STUN_ATTR_RESERVATION_TOKEN:
|
||||||
|
return STUN_VALUE_BYTE_STRING;
|
||||||
|
default:
|
||||||
|
return StunMessage::GetAttributeValueType(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StunMessage* TurnMessage::CreateNew() const {
|
||||||
|
return new TurnMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
StunAttributeValueType IceMessage::GetAttributeValueType(int type) const {
|
||||||
|
switch (type) {
|
||||||
|
case STUN_ATTR_PRIORITY:
|
||||||
|
case STUN_ATTR_NETWORK_INFO:
|
||||||
|
case STUN_ATTR_NOMINATION:
|
||||||
|
return STUN_VALUE_UINT32;
|
||||||
|
case STUN_ATTR_USE_CANDIDATE:
|
||||||
|
return STUN_VALUE_BYTE_STRING;
|
||||||
|
case STUN_ATTR_ICE_CONTROLLED:
|
||||||
|
return STUN_VALUE_UINT64;
|
||||||
|
case STUN_ATTR_ICE_CONTROLLING:
|
||||||
|
return STUN_VALUE_UINT64;
|
||||||
|
default:
|
||||||
|
return StunMessage::GetAttributeValueType(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StunMessage* IceMessage::CreateNew() const {
|
||||||
|
return new IceMessage();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace cricket
|
} // namespace cricket
|
||||||
|
|||||||
117
p2p/base/stun.h
117
p2p/base/stun.h
@ -132,7 +132,7 @@ class StunUInt16ListAttribute;
|
|||||||
class StunMessage {
|
class StunMessage {
|
||||||
public:
|
public:
|
||||||
StunMessage();
|
StunMessage();
|
||||||
virtual ~StunMessage() = default;
|
virtual ~StunMessage();
|
||||||
|
|
||||||
int type() const { return type_; }
|
int type() const { return type_; }
|
||||||
size_t length() const { return length_; }
|
size_t length() const { return length_; }
|
||||||
@ -188,7 +188,7 @@ class StunMessage {
|
|||||||
bool Write(rtc::ByteBufferWriter* buf) const;
|
bool Write(rtc::ByteBufferWriter* buf) const;
|
||||||
|
|
||||||
// Creates an empty message. Overridable by derived classes.
|
// Creates an empty message. Overridable by derived classes.
|
||||||
virtual StunMessage* CreateNew() const { return new StunMessage(); }
|
virtual StunMessage* CreateNew() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Verifies that the given attribute is allowed for this message.
|
// Verifies that the given attribute is allowed for this message.
|
||||||
@ -265,9 +265,7 @@ class StunAddressAttribute : public StunAttribute {
|
|||||||
StunAddressAttribute(uint16_t type, const rtc::SocketAddress& addr);
|
StunAddressAttribute(uint16_t type, const rtc::SocketAddress& addr);
|
||||||
StunAddressAttribute(uint16_t type, uint16_t length);
|
StunAddressAttribute(uint16_t type, uint16_t length);
|
||||||
|
|
||||||
virtual StunAttributeValueType value_type() const {
|
StunAttributeValueType value_type() const override;
|
||||||
return STUN_VALUE_ADDRESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
StunAddressFamily family() const {
|
StunAddressFamily family() const {
|
||||||
switch (address_.ipaddr().family()) {
|
switch (address_.ipaddr().family()) {
|
||||||
@ -293,8 +291,8 @@ class StunAddressAttribute : public StunAttribute {
|
|||||||
}
|
}
|
||||||
void SetPort(uint16_t port) { address_.SetPort(port); }
|
void SetPort(uint16_t port) { address_.SetPort(port); }
|
||||||
|
|
||||||
virtual bool Read(rtc::ByteBufferReader* buf);
|
bool Read(rtc::ByteBufferReader* buf) override;
|
||||||
virtual bool Write(rtc::ByteBufferWriter* buf) const;
|
bool Write(rtc::ByteBufferWriter* buf) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void EnsureAddressLength() {
|
void EnsureAddressLength() {
|
||||||
@ -324,14 +322,10 @@ class StunXorAddressAttribute : public StunAddressAttribute {
|
|||||||
StunXorAddressAttribute(uint16_t type, const rtc::SocketAddress& addr);
|
StunXorAddressAttribute(uint16_t type, const rtc::SocketAddress& addr);
|
||||||
StunXorAddressAttribute(uint16_t type, uint16_t length, StunMessage* owner);
|
StunXorAddressAttribute(uint16_t type, uint16_t length, StunMessage* owner);
|
||||||
|
|
||||||
virtual StunAttributeValueType value_type() const {
|
StunAttributeValueType value_type() const override;
|
||||||
return STUN_VALUE_XOR_ADDRESS;
|
void SetOwner(StunMessage* owner) override;
|
||||||
}
|
bool Read(rtc::ByteBufferReader* buf) override;
|
||||||
virtual void SetOwner(StunMessage* owner) {
|
bool Write(rtc::ByteBufferWriter* buf) const override;
|
||||||
owner_ = owner;
|
|
||||||
}
|
|
||||||
virtual bool Read(rtc::ByteBufferReader* buf);
|
|
||||||
virtual bool Write(rtc::ByteBufferWriter* buf) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rtc::IPAddress GetXoredIP() const;
|
rtc::IPAddress GetXoredIP() const;
|
||||||
@ -345,9 +339,7 @@ class StunUInt32Attribute : public StunAttribute {
|
|||||||
StunUInt32Attribute(uint16_t type, uint32_t value);
|
StunUInt32Attribute(uint16_t type, uint32_t value);
|
||||||
explicit StunUInt32Attribute(uint16_t type);
|
explicit StunUInt32Attribute(uint16_t type);
|
||||||
|
|
||||||
virtual StunAttributeValueType value_type() const {
|
StunAttributeValueType value_type() const override;
|
||||||
return STUN_VALUE_UINT32;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t value() const { return bits_; }
|
uint32_t value() const { return bits_; }
|
||||||
void SetValue(uint32_t bits) { bits_ = bits; }
|
void SetValue(uint32_t bits) { bits_ = bits; }
|
||||||
@ -355,8 +347,8 @@ class StunUInt32Attribute : public StunAttribute {
|
|||||||
bool GetBit(size_t index) const;
|
bool GetBit(size_t index) const;
|
||||||
void SetBit(size_t index, bool value);
|
void SetBit(size_t index, bool value);
|
||||||
|
|
||||||
virtual bool Read(rtc::ByteBufferReader* buf);
|
bool Read(rtc::ByteBufferReader* buf) override;
|
||||||
virtual bool Write(rtc::ByteBufferWriter* buf) const;
|
bool Write(rtc::ByteBufferWriter* buf) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t bits_;
|
uint32_t bits_;
|
||||||
@ -368,15 +360,13 @@ class StunUInt64Attribute : public StunAttribute {
|
|||||||
StunUInt64Attribute(uint16_t type, uint64_t value);
|
StunUInt64Attribute(uint16_t type, uint64_t value);
|
||||||
explicit StunUInt64Attribute(uint16_t type);
|
explicit StunUInt64Attribute(uint16_t type);
|
||||||
|
|
||||||
virtual StunAttributeValueType value_type() const {
|
StunAttributeValueType value_type() const override;
|
||||||
return STUN_VALUE_UINT64;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t value() const { return bits_; }
|
uint64_t value() const { return bits_; }
|
||||||
void SetValue(uint64_t bits) { bits_ = bits; }
|
void SetValue(uint64_t bits) { bits_ = bits; }
|
||||||
|
|
||||||
virtual bool Read(rtc::ByteBufferReader* buf);
|
bool Read(rtc::ByteBufferReader* buf) override;
|
||||||
virtual bool Write(rtc::ByteBufferWriter* buf) const;
|
bool Write(rtc::ByteBufferWriter* buf) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t bits_;
|
uint64_t bits_;
|
||||||
@ -389,11 +379,9 @@ class StunByteStringAttribute : public StunAttribute {
|
|||||||
StunByteStringAttribute(uint16_t type, const std::string& str);
|
StunByteStringAttribute(uint16_t type, const std::string& str);
|
||||||
StunByteStringAttribute(uint16_t type, const void* bytes, size_t length);
|
StunByteStringAttribute(uint16_t type, const void* bytes, size_t length);
|
||||||
StunByteStringAttribute(uint16_t type, uint16_t length);
|
StunByteStringAttribute(uint16_t type, uint16_t length);
|
||||||
~StunByteStringAttribute();
|
~StunByteStringAttribute() override;
|
||||||
|
|
||||||
virtual StunAttributeValueType value_type() const {
|
StunAttributeValueType value_type() const override;
|
||||||
return STUN_VALUE_BYTE_STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* bytes() const { return bytes_; }
|
const char* bytes() const { return bytes_; }
|
||||||
std::string GetString() const { return std::string(bytes_, length()); }
|
std::string GetString() const { return std::string(bytes_, length()); }
|
||||||
@ -404,8 +392,8 @@ class StunByteStringAttribute : public StunAttribute {
|
|||||||
uint8_t GetByte(size_t index) const;
|
uint8_t GetByte(size_t index) const;
|
||||||
void SetByte(size_t index, uint8_t value);
|
void SetByte(size_t index, uint8_t value);
|
||||||
|
|
||||||
virtual bool Read(rtc::ByteBufferReader* buf);
|
bool Read(rtc::ByteBufferReader* buf) override;
|
||||||
virtual bool Write(rtc::ByteBufferWriter* buf) const;
|
bool Write(rtc::ByteBufferWriter* buf) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetBytes(char* bytes, size_t length);
|
void SetBytes(char* bytes, size_t length);
|
||||||
@ -419,11 +407,9 @@ class StunErrorCodeAttribute : public StunAttribute {
|
|||||||
static const uint16_t MIN_SIZE;
|
static const uint16_t MIN_SIZE;
|
||||||
StunErrorCodeAttribute(uint16_t type, int code, const std::string& reason);
|
StunErrorCodeAttribute(uint16_t type, int code, const std::string& reason);
|
||||||
StunErrorCodeAttribute(uint16_t type, uint16_t length);
|
StunErrorCodeAttribute(uint16_t type, uint16_t length);
|
||||||
~StunErrorCodeAttribute();
|
~StunErrorCodeAttribute() override;
|
||||||
|
|
||||||
virtual StunAttributeValueType value_type() const {
|
StunAttributeValueType value_type() const override;
|
||||||
return STUN_VALUE_ERROR_CODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The combined error and class, e.g. 0x400.
|
// The combined error and class, e.g. 0x400.
|
||||||
int code() const;
|
int code() const;
|
||||||
@ -437,8 +423,8 @@ class StunErrorCodeAttribute : public StunAttribute {
|
|||||||
void SetNumber(uint8_t number) { number_ = number; }
|
void SetNumber(uint8_t number) { number_ = number; }
|
||||||
void SetReason(const std::string& reason);
|
void SetReason(const std::string& reason);
|
||||||
|
|
||||||
bool Read(rtc::ByteBufferReader* buf);
|
bool Read(rtc::ByteBufferReader* buf) override;
|
||||||
bool Write(rtc::ByteBufferWriter* buf) const;
|
bool Write(rtc::ByteBufferWriter* buf) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t class_;
|
uint8_t class_;
|
||||||
@ -450,19 +436,17 @@ class StunErrorCodeAttribute : public StunAttribute {
|
|||||||
class StunUInt16ListAttribute : public StunAttribute {
|
class StunUInt16ListAttribute : public StunAttribute {
|
||||||
public:
|
public:
|
||||||
StunUInt16ListAttribute(uint16_t type, uint16_t length);
|
StunUInt16ListAttribute(uint16_t type, uint16_t length);
|
||||||
~StunUInt16ListAttribute();
|
~StunUInt16ListAttribute() override;
|
||||||
|
|
||||||
virtual StunAttributeValueType value_type() const {
|
StunAttributeValueType value_type() const override;
|
||||||
return STUN_VALUE_UINT16_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t Size() const;
|
size_t Size() const;
|
||||||
uint16_t GetType(int index) const;
|
uint16_t GetType(int index) const;
|
||||||
void SetType(int index, uint16_t value);
|
void SetType(int index, uint16_t value);
|
||||||
void AddType(uint16_t value);
|
void AddType(uint16_t value);
|
||||||
|
|
||||||
bool Read(rtc::ByteBufferReader* buf);
|
bool Read(rtc::ByteBufferReader* buf) override;
|
||||||
bool Write(rtc::ByteBufferWriter* buf) const;
|
bool Write(rtc::ByteBufferWriter* buf) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<uint16_t>* attr_types_;
|
std::vector<uint16_t>* attr_types_;
|
||||||
@ -524,19 +508,8 @@ enum RelayAttributeType {
|
|||||||
// A "GTURN" STUN message.
|
// A "GTURN" STUN message.
|
||||||
class RelayMessage : public StunMessage {
|
class RelayMessage : public StunMessage {
|
||||||
protected:
|
protected:
|
||||||
virtual StunAttributeValueType GetAttributeValueType(int type) const {
|
StunAttributeValueType GetAttributeValueType(int type) const override;
|
||||||
switch (type) {
|
StunMessage* CreateNew() const override;
|
||||||
case STUN_ATTR_LIFETIME: return STUN_VALUE_UINT32;
|
|
||||||
case STUN_ATTR_MAGIC_COOKIE: return STUN_VALUE_BYTE_STRING;
|
|
||||||
case STUN_ATTR_BANDWIDTH: return STUN_VALUE_UINT32;
|
|
||||||
case STUN_ATTR_DESTINATION_ADDRESS: return STUN_VALUE_ADDRESS;
|
|
||||||
case STUN_ATTR_SOURCE_ADDRESS2: return STUN_VALUE_ADDRESS;
|
|
||||||
case STUN_ATTR_DATA: return STUN_VALUE_BYTE_STRING;
|
|
||||||
case STUN_ATTR_OPTIONS: return STUN_VALUE_UINT32;
|
|
||||||
default: return StunMessage::GetAttributeValueType(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual StunMessage* CreateNew() const { return new RelayMessage(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Defined in TURN RFC 5766.
|
// Defined in TURN RFC 5766.
|
||||||
@ -586,21 +559,8 @@ extern const char STUN_ERROR_REASON_WRONG_CREDENTIALS[];
|
|||||||
extern const char STUN_ERROR_REASON_UNSUPPORTED_PROTOCOL[];
|
extern const char STUN_ERROR_REASON_UNSUPPORTED_PROTOCOL[];
|
||||||
class TurnMessage : public StunMessage {
|
class TurnMessage : public StunMessage {
|
||||||
protected:
|
protected:
|
||||||
virtual StunAttributeValueType GetAttributeValueType(int type) const {
|
StunAttributeValueType GetAttributeValueType(int type) const override;
|
||||||
switch (type) {
|
StunMessage* CreateNew() const override;
|
||||||
case STUN_ATTR_CHANNEL_NUMBER: return STUN_VALUE_UINT32;
|
|
||||||
case STUN_ATTR_TURN_LIFETIME: return STUN_VALUE_UINT32;
|
|
||||||
case STUN_ATTR_XOR_PEER_ADDRESS: return STUN_VALUE_XOR_ADDRESS;
|
|
||||||
case STUN_ATTR_DATA: return STUN_VALUE_BYTE_STRING;
|
|
||||||
case STUN_ATTR_XOR_RELAYED_ADDRESS: return STUN_VALUE_XOR_ADDRESS;
|
|
||||||
case STUN_ATTR_EVEN_PORT: return STUN_VALUE_BYTE_STRING;
|
|
||||||
case STUN_ATTR_REQUESTED_TRANSPORT: return STUN_VALUE_UINT32;
|
|
||||||
case STUN_ATTR_DONT_FRAGMENT: return STUN_VALUE_BYTE_STRING;
|
|
||||||
case STUN_ATTR_RESERVATION_TOKEN: return STUN_VALUE_BYTE_STRING;
|
|
||||||
default: return StunMessage::GetAttributeValueType(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual StunMessage* CreateNew() const { return new TurnMessage(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// RFC 5245 ICE STUN attributes.
|
// RFC 5245 ICE STUN attributes.
|
||||||
@ -624,19 +584,8 @@ extern const char STUN_ERROR_REASON_ROLE_CONFLICT[];
|
|||||||
// A RFC 5245 ICE STUN message.
|
// A RFC 5245 ICE STUN message.
|
||||||
class IceMessage : public StunMessage {
|
class IceMessage : public StunMessage {
|
||||||
protected:
|
protected:
|
||||||
virtual StunAttributeValueType GetAttributeValueType(int type) const {
|
StunAttributeValueType GetAttributeValueType(int type) const override;
|
||||||
switch (type) {
|
StunMessage* CreateNew() const override;
|
||||||
case STUN_ATTR_PRIORITY:
|
|
||||||
case STUN_ATTR_NETWORK_INFO:
|
|
||||||
case STUN_ATTR_NOMINATION:
|
|
||||||
return STUN_VALUE_UINT32;
|
|
||||||
case STUN_ATTR_USE_CANDIDATE: return STUN_VALUE_BYTE_STRING;
|
|
||||||
case STUN_ATTR_ICE_CONTROLLED: return STUN_VALUE_UINT64;
|
|
||||||
case STUN_ATTR_ICE_CONTROLLING: return STUN_VALUE_UINT64;
|
|
||||||
default: return StunMessage::GetAttributeValueType(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual StunMessage* CreateNew() const { return new IceMessage(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cricket
|
} // namespace cricket
|
||||||
|
|||||||
Reference in New Issue
Block a user