Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: webrtc/p2p/base/stun.h

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/relayserver_unittest.cc ('k') | webrtc/p2p/base/stun.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Strings for the error codes above. 90 // Strings for the error codes above.
91 extern const char STUN_ERROR_REASON_TRY_ALTERNATE_SERVER[]; 91 extern const char STUN_ERROR_REASON_TRY_ALTERNATE_SERVER[];
92 extern const char STUN_ERROR_REASON_BAD_REQUEST[]; 92 extern const char STUN_ERROR_REASON_BAD_REQUEST[];
93 extern const char STUN_ERROR_REASON_UNAUTHORIZED[]; 93 extern const char STUN_ERROR_REASON_UNAUTHORIZED[];
94 extern const char STUN_ERROR_REASON_UNKNOWN_ATTRIBUTE[]; 94 extern const char STUN_ERROR_REASON_UNKNOWN_ATTRIBUTE[];
95 extern const char STUN_ERROR_REASON_STALE_CREDENTIALS[]; 95 extern const char STUN_ERROR_REASON_STALE_CREDENTIALS[];
96 extern const char STUN_ERROR_REASON_STALE_NONCE[]; 96 extern const char STUN_ERROR_REASON_STALE_NONCE[];
97 extern const char STUN_ERROR_REASON_SERVER_ERROR[]; 97 extern const char STUN_ERROR_REASON_SERVER_ERROR[];
98 98
99 // The mask used to determine whether a STUN message is a request/response etc. 99 // The mask used to determine whether a STUN message is a request/response etc.
100 const uint32 kStunTypeMask = 0x0110; 100 const uint32_t kStunTypeMask = 0x0110;
101 101
102 // STUN Attribute header length. 102 // STUN Attribute header length.
103 const size_t kStunAttributeHeaderSize = 4; 103 const size_t kStunAttributeHeaderSize = 4;
104 104
105 // Following values correspond to RFC5389. 105 // Following values correspond to RFC5389.
106 const size_t kStunHeaderSize = 20; 106 const size_t kStunHeaderSize = 20;
107 const size_t kStunTransactionIdOffset = 8; 107 const size_t kStunTransactionIdOffset = 8;
108 const size_t kStunTransactionIdLength = 12; 108 const size_t kStunTransactionIdLength = 12;
109 const uint32 kStunMagicCookie = 0x2112A442; 109 const uint32_t kStunMagicCookie = 0x2112A442;
110 const size_t kStunMagicCookieLength = sizeof(kStunMagicCookie); 110 const size_t kStunMagicCookieLength = sizeof(kStunMagicCookie);
111 111
112 // Following value corresponds to an earlier version of STUN from 112 // Following value corresponds to an earlier version of STUN from
113 // RFC3489. 113 // RFC3489.
114 const size_t kStunLegacyTransactionIdLength = 16; 114 const size_t kStunLegacyTransactionIdLength = 16;
115 115
116 // STUN Message Integrity HMAC length. 116 // STUN Message Integrity HMAC length.
117 const size_t kStunMessageIntegritySize = 20; 117 const size_t kStunMessageIntegritySize = 20;
118 118
119 class StunAttribute; 119 class StunAttribute;
(...skipping 18 matching lines...) Expand all
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.
146 bool IsLegacy() const; 146 bool IsLegacy() const;
147 147
148 void SetType(int type) { type_ = static_cast<uint16>(type); } 148 void SetType(int type) { type_ = static_cast<uint16_t>(type); }
149 bool SetTransactionID(const std::string& str); 149 bool SetTransactionID(const std::string& str);
150 150
151 // Gets the desired attribute value, or NULL if no such attribute type exists. 151 // Gets the desired attribute value, or NULL if no such attribute type exists.
152 const StunAddressAttribute* GetAddress(int type) const; 152 const StunAddressAttribute* GetAddress(int type) const;
153 const StunUInt32Attribute* GetUInt32(int type) const; 153 const StunUInt32Attribute* GetUInt32(int type) const;
154 const StunUInt64Attribute* GetUInt64(int type) const; 154 const StunUInt64Attribute* GetUInt64(int type) const;
155 const StunByteStringAttribute* GetByteString(int type) const; 155 const StunByteStringAttribute* GetByteString(int type) const;
156 156
157 // Gets these specific attribute values. 157 // Gets these specific attribute values.
158 const StunErrorCodeAttribute* GetErrorCode() const; 158 const StunErrorCodeAttribute* GetErrorCode() const;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 protected: 192 protected:
193 // Verifies that the given attribute is allowed for this message. 193 // Verifies that the given attribute is allowed for this message.
194 virtual StunAttributeValueType GetAttributeValueType(int type) const; 194 virtual StunAttributeValueType GetAttributeValueType(int type) const;
195 195
196 private: 196 private:
197 StunAttribute* CreateAttribute(int type, size_t length) /* const*/; 197 StunAttribute* CreateAttribute(int type, size_t length) /* const*/;
198 const StunAttribute* GetAttribute(int type) const; 198 const StunAttribute* GetAttribute(int type) const;
199 static bool IsValidTransactionId(const std::string& transaction_id); 199 static bool IsValidTransactionId(const std::string& transaction_id);
200 200
201 uint16 type_; 201 uint16_t type_;
202 uint16 length_; 202 uint16_t length_;
203 std::string transaction_id_; 203 std::string transaction_id_;
204 std::vector<StunAttribute*>* attrs_; 204 std::vector<StunAttribute*>* attrs_;
205 }; 205 };
206 206
207 // Base class for all STUN/TURN attributes. 207 // Base class for all STUN/TURN attributes.
208 class StunAttribute { 208 class StunAttribute {
209 public: 209 public:
210 virtual ~StunAttribute() { 210 virtual ~StunAttribute() {
211 } 211 }
212 212
213 int type() const { return type_; } 213 int type() const { return type_; }
214 size_t length() const { return length_; } 214 size_t length() const { return length_; }
215 215
216 // Return the type of this attribute. 216 // Return the type of this attribute.
217 virtual StunAttributeValueType value_type() const = 0; 217 virtual StunAttributeValueType value_type() const = 0;
218 218
219 // Only XorAddressAttribute needs this so far. 219 // Only XorAddressAttribute needs this so far.
220 virtual void SetOwner(StunMessage* owner) {} 220 virtual void SetOwner(StunMessage* owner) {}
221 221
222 // Reads the body (not the type or length) for this type of attribute from 222 // Reads the body (not the type or length) for this type of attribute from
223 // the given buffer. Return value is true if successful. 223 // the given buffer. Return value is true if successful.
224 virtual bool Read(rtc::ByteBuffer* buf) = 0; 224 virtual bool Read(rtc::ByteBuffer* buf) = 0;
225 225
226 // Writes the body (not the type or length) to the given buffer. Return 226 // Writes the body (not the type or length) to the given buffer. Return
227 // value is true if successful. 227 // value is true if successful.
228 virtual bool Write(rtc::ByteBuffer* buf) const = 0; 228 virtual bool Write(rtc::ByteBuffer* buf) const = 0;
229 229
230 // Creates an attribute object with the given type and smallest length. 230 // Creates an attribute object with the given type and smallest length.
231 static StunAttribute* Create(StunAttributeValueType value_type, uint16 type, 231 static StunAttribute* Create(StunAttributeValueType value_type,
232 uint16 length, StunMessage* owner); 232 uint16_t type,
233 uint16_t length,
234 StunMessage* owner);
233 // TODO: Allow these create functions to take parameters, to reduce 235 // TODO: Allow these create functions to take parameters, to reduce
234 // the amount of work callers need to do to initialize attributes. 236 // the amount of work callers need to do to initialize attributes.
235 static StunAddressAttribute* CreateAddress(uint16 type); 237 static StunAddressAttribute* CreateAddress(uint16_t type);
236 static StunXorAddressAttribute* CreateXorAddress(uint16 type); 238 static StunXorAddressAttribute* CreateXorAddress(uint16_t type);
237 static StunUInt32Attribute* CreateUInt32(uint16 type); 239 static StunUInt32Attribute* CreateUInt32(uint16_t type);
238 static StunUInt64Attribute* CreateUInt64(uint16 type); 240 static StunUInt64Attribute* CreateUInt64(uint16_t type);
239 static StunByteStringAttribute* CreateByteString(uint16 type); 241 static StunByteStringAttribute* CreateByteString(uint16_t type);
240 static StunErrorCodeAttribute* CreateErrorCode(); 242 static StunErrorCodeAttribute* CreateErrorCode();
241 static StunUInt16ListAttribute* CreateUnknownAttributes(); 243 static StunUInt16ListAttribute* CreateUnknownAttributes();
242 244
243 protected: 245 protected:
244 StunAttribute(uint16 type, uint16 length); 246 StunAttribute(uint16_t type, uint16_t length);
245 void SetLength(uint16 length) { length_ = length; } 247 void SetLength(uint16_t length) { length_ = length; }
246 void WritePadding(rtc::ByteBuffer* buf) const; 248 void WritePadding(rtc::ByteBuffer* buf) const;
247 void ConsumePadding(rtc::ByteBuffer* buf) const; 249 void ConsumePadding(rtc::ByteBuffer* buf) const;
248 250
249 private: 251 private:
250 uint16 type_; 252 uint16_t type_;
251 uint16 length_; 253 uint16_t length_;
252 }; 254 };
253 255
254 // Implements STUN attributes that record an Internet address. 256 // Implements STUN attributes that record an Internet address.
255 class StunAddressAttribute : public StunAttribute { 257 class StunAddressAttribute : public StunAttribute {
256 public: 258 public:
257 static const uint16 SIZE_UNDEF = 0; 259 static const uint16_t SIZE_UNDEF = 0;
258 static const uint16 SIZE_IP4 = 8; 260 static const uint16_t SIZE_IP4 = 8;
259 static const uint16 SIZE_IP6 = 20; 261 static const uint16_t SIZE_IP6 = 20;
260 StunAddressAttribute(uint16 type, const rtc::SocketAddress& addr); 262 StunAddressAttribute(uint16_t type, const rtc::SocketAddress& addr);
261 StunAddressAttribute(uint16 type, uint16 length); 263 StunAddressAttribute(uint16_t type, uint16_t length);
262 264
263 virtual StunAttributeValueType value_type() const { 265 virtual StunAttributeValueType value_type() const {
264 return STUN_VALUE_ADDRESS; 266 return STUN_VALUE_ADDRESS;
265 } 267 }
266 268
267 StunAddressFamily family() const { 269 StunAddressFamily family() const {
268 switch (address_.ipaddr().family()) { 270 switch (address_.ipaddr().family()) {
269 case AF_INET: 271 case AF_INET:
270 return STUN_ADDRESS_IPV4; 272 return STUN_ADDRESS_IPV4;
271 case AF_INET6: 273 case AF_INET6:
272 return STUN_ADDRESS_IPV6; 274 return STUN_ADDRESS_IPV6;
273 } 275 }
274 return STUN_ADDRESS_UNDEF; 276 return STUN_ADDRESS_UNDEF;
275 } 277 }
276 278
277 const rtc::SocketAddress& GetAddress() const { return address_; } 279 const rtc::SocketAddress& GetAddress() const { return address_; }
278 const rtc::IPAddress& ipaddr() const { return address_.ipaddr(); } 280 const rtc::IPAddress& ipaddr() const { return address_.ipaddr(); }
279 uint16 port() const { return address_.port(); } 281 uint16_t port() const { return address_.port(); }
280 282
281 void SetAddress(const rtc::SocketAddress& addr) { 283 void SetAddress(const rtc::SocketAddress& addr) {
282 address_ = addr; 284 address_ = addr;
283 EnsureAddressLength(); 285 EnsureAddressLength();
284 } 286 }
285 void SetIP(const rtc::IPAddress& ip) { 287 void SetIP(const rtc::IPAddress& ip) {
286 address_.SetIP(ip); 288 address_.SetIP(ip);
287 EnsureAddressLength(); 289 EnsureAddressLength();
288 } 290 }
289 void SetPort(uint16 port) { address_.SetPort(port); } 291 void SetPort(uint16_t port) { address_.SetPort(port); }
290 292
291 virtual bool Read(rtc::ByteBuffer* buf); 293 virtual bool Read(rtc::ByteBuffer* buf);
292 virtual bool Write(rtc::ByteBuffer* buf) const; 294 virtual bool Write(rtc::ByteBuffer* buf) const;
293 295
294 private: 296 private:
295 void EnsureAddressLength() { 297 void EnsureAddressLength() {
296 switch (family()) { 298 switch (family()) {
297 case STUN_ADDRESS_IPV4: { 299 case STUN_ADDRESS_IPV4: {
298 SetLength(SIZE_IP4); 300 SetLength(SIZE_IP4);
299 break; 301 break;
300 } 302 }
301 case STUN_ADDRESS_IPV6: { 303 case STUN_ADDRESS_IPV6: {
302 SetLength(SIZE_IP6); 304 SetLength(SIZE_IP6);
303 break; 305 break;
304 } 306 }
305 default: { 307 default: {
306 SetLength(SIZE_UNDEF); 308 SetLength(SIZE_UNDEF);
307 break; 309 break;
308 } 310 }
309 } 311 }
310 } 312 }
311 rtc::SocketAddress address_; 313 rtc::SocketAddress address_;
312 }; 314 };
313 315
314 // Implements STUN attributes that record an Internet address. When encoded 316 // Implements STUN attributes that record an Internet address. When encoded
315 // in a STUN message, the address contained in this attribute is XORed with the 317 // in a STUN message, the address contained in this attribute is XORed with the
316 // transaction ID of the message. 318 // transaction ID of the message.
317 class StunXorAddressAttribute : public StunAddressAttribute { 319 class StunXorAddressAttribute : public StunAddressAttribute {
318 public: 320 public:
319 StunXorAddressAttribute(uint16 type, const rtc::SocketAddress& addr); 321 StunXorAddressAttribute(uint16_t type, const rtc::SocketAddress& addr);
320 StunXorAddressAttribute(uint16 type, uint16 length, 322 StunXorAddressAttribute(uint16_t type, uint16_t length, StunMessage* owner);
321 StunMessage* owner);
322 323
323 virtual StunAttributeValueType value_type() const { 324 virtual StunAttributeValueType value_type() const {
324 return STUN_VALUE_XOR_ADDRESS; 325 return STUN_VALUE_XOR_ADDRESS;
325 } 326 }
326 virtual void SetOwner(StunMessage* owner) { 327 virtual void SetOwner(StunMessage* owner) {
327 owner_ = owner; 328 owner_ = owner;
328 } 329 }
329 virtual bool Read(rtc::ByteBuffer* buf); 330 virtual bool Read(rtc::ByteBuffer* buf);
330 virtual bool Write(rtc::ByteBuffer* buf) const; 331 virtual bool Write(rtc::ByteBuffer* buf) const;
331 332
332 private: 333 private:
333 rtc::IPAddress GetXoredIP() const; 334 rtc::IPAddress GetXoredIP() const;
334 StunMessage* owner_; 335 StunMessage* owner_;
335 }; 336 };
336 337
337 // Implements STUN attributes that record a 32-bit integer. 338 // Implements STUN attributes that record a 32-bit integer.
338 class StunUInt32Attribute : public StunAttribute { 339 class StunUInt32Attribute : public StunAttribute {
339 public: 340 public:
340 static const uint16 SIZE = 4; 341 static const uint16_t SIZE = 4;
341 StunUInt32Attribute(uint16 type, uint32 value); 342 StunUInt32Attribute(uint16_t type, uint32_t value);
342 explicit StunUInt32Attribute(uint16 type); 343 explicit StunUInt32Attribute(uint16_t type);
343 344
344 virtual StunAttributeValueType value_type() const { 345 virtual StunAttributeValueType value_type() const {
345 return STUN_VALUE_UINT32; 346 return STUN_VALUE_UINT32;
346 } 347 }
347 348
348 uint32 value() const { return bits_; } 349 uint32_t value() const { return bits_; }
349 void SetValue(uint32 bits) { bits_ = bits; } 350 void SetValue(uint32_t bits) { bits_ = bits; }
350 351
351 bool GetBit(size_t index) const; 352 bool GetBit(size_t index) const;
352 void SetBit(size_t index, bool value); 353 void SetBit(size_t index, bool value);
353 354
354 virtual bool Read(rtc::ByteBuffer* buf); 355 virtual bool Read(rtc::ByteBuffer* buf);
355 virtual bool Write(rtc::ByteBuffer* buf) const; 356 virtual bool Write(rtc::ByteBuffer* buf) const;
356 357
357 private: 358 private:
358 uint32 bits_; 359 uint32_t bits_;
359 }; 360 };
360 361
361 class StunUInt64Attribute : public StunAttribute { 362 class StunUInt64Attribute : public StunAttribute {
362 public: 363 public:
363 static const uint16 SIZE = 8; 364 static const uint16_t SIZE = 8;
364 StunUInt64Attribute(uint16 type, uint64 value); 365 StunUInt64Attribute(uint16_t type, uint64_t value);
365 explicit StunUInt64Attribute(uint16 type); 366 explicit StunUInt64Attribute(uint16_t type);
366 367
367 virtual StunAttributeValueType value_type() const { 368 virtual StunAttributeValueType value_type() const {
368 return STUN_VALUE_UINT64; 369 return STUN_VALUE_UINT64;
369 } 370 }
370 371
371 uint64 value() const { return bits_; } 372 uint64_t value() const { return bits_; }
372 void SetValue(uint64 bits) { bits_ = bits; } 373 void SetValue(uint64_t bits) { bits_ = bits; }
373 374
374 virtual bool Read(rtc::ByteBuffer* buf); 375 virtual bool Read(rtc::ByteBuffer* buf);
375 virtual bool Write(rtc::ByteBuffer* buf) const; 376 virtual bool Write(rtc::ByteBuffer* buf) const;
376 377
377 private: 378 private:
378 uint64 bits_; 379 uint64_t bits_;
379 }; 380 };
380 381
381 // Implements STUN attributes that record an arbitrary byte string. 382 // Implements STUN attributes that record an arbitrary byte string.
382 class StunByteStringAttribute : public StunAttribute { 383 class StunByteStringAttribute : public StunAttribute {
383 public: 384 public:
384 explicit StunByteStringAttribute(uint16 type); 385 explicit StunByteStringAttribute(uint16_t type);
385 StunByteStringAttribute(uint16 type, const std::string& str); 386 StunByteStringAttribute(uint16_t type, const std::string& str);
386 StunByteStringAttribute(uint16 type, const void* bytes, size_t length); 387 StunByteStringAttribute(uint16_t type, const void* bytes, size_t length);
387 StunByteStringAttribute(uint16 type, uint16 length); 388 StunByteStringAttribute(uint16_t type, uint16_t length);
388 ~StunByteStringAttribute(); 389 ~StunByteStringAttribute();
389 390
390 virtual StunAttributeValueType value_type() const { 391 virtual StunAttributeValueType value_type() const {
391 return STUN_VALUE_BYTE_STRING; 392 return STUN_VALUE_BYTE_STRING;
392 } 393 }
393 394
394 const char* bytes() const { return bytes_; } 395 const char* bytes() const { return bytes_; }
395 std::string GetString() const { return std::string(bytes_, length()); } 396 std::string GetString() const { return std::string(bytes_, length()); }
396 397
397 void CopyBytes(const char* bytes); // uses strlen 398 void CopyBytes(const char* bytes); // uses strlen
398 void CopyBytes(const void* bytes, size_t length); 399 void CopyBytes(const void* bytes, size_t length);
399 400
400 uint8 GetByte(size_t index) const; 401 uint8_t GetByte(size_t index) const;
401 void SetByte(size_t index, uint8 value); 402 void SetByte(size_t index, uint8_t value);
402 403
403 virtual bool Read(rtc::ByteBuffer* buf); 404 virtual bool Read(rtc::ByteBuffer* buf);
404 virtual bool Write(rtc::ByteBuffer* buf) const; 405 virtual bool Write(rtc::ByteBuffer* buf) const;
405 406
406 private: 407 private:
407 void SetBytes(char* bytes, size_t length); 408 void SetBytes(char* bytes, size_t length);
408 409
409 char* bytes_; 410 char* bytes_;
410 }; 411 };
411 412
412 // Implements STUN attributes that record an error code. 413 // Implements STUN attributes that record an error code.
413 class StunErrorCodeAttribute : public StunAttribute { 414 class StunErrorCodeAttribute : public StunAttribute {
414 public: 415 public:
415 static const uint16 MIN_SIZE = 4; 416 static const uint16_t MIN_SIZE = 4;
416 StunErrorCodeAttribute(uint16 type, int code, const std::string& reason); 417 StunErrorCodeAttribute(uint16_t type, int code, const std::string& reason);
417 StunErrorCodeAttribute(uint16 type, uint16 length); 418 StunErrorCodeAttribute(uint16_t type, uint16_t length);
418 ~StunErrorCodeAttribute(); 419 ~StunErrorCodeAttribute();
419 420
420 virtual StunAttributeValueType value_type() const { 421 virtual StunAttributeValueType value_type() const {
421 return STUN_VALUE_ERROR_CODE; 422 return STUN_VALUE_ERROR_CODE;
422 } 423 }
423 424
424 // The combined error and class, e.g. 0x400. 425 // The combined error and class, e.g. 0x400.
425 int code() const; 426 int code() const;
426 void SetCode(int code); 427 void SetCode(int code);
427 428
428 // The individual error components. 429 // The individual error components.
429 int eclass() const { return class_; } 430 int eclass() const { return class_; }
430 int number() const { return number_; } 431 int number() const { return number_; }
431 const std::string& reason() const { return reason_; } 432 const std::string& reason() const { return reason_; }
432 void SetClass(uint8 eclass) { class_ = eclass; } 433 void SetClass(uint8_t eclass) { class_ = eclass; }
433 void SetNumber(uint8 number) { number_ = number; } 434 void SetNumber(uint8_t number) { number_ = number; }
434 void SetReason(const std::string& reason); 435 void SetReason(const std::string& reason);
435 436
436 bool Read(rtc::ByteBuffer* buf); 437 bool Read(rtc::ByteBuffer* buf);
437 bool Write(rtc::ByteBuffer* buf) const; 438 bool Write(rtc::ByteBuffer* buf) const;
438 439
439 private: 440 private:
440 uint8 class_; 441 uint8_t class_;
441 uint8 number_; 442 uint8_t number_;
442 std::string reason_; 443 std::string reason_;
443 }; 444 };
444 445
445 // Implements STUN attributes that record a list of attribute names. 446 // Implements STUN attributes that record a list of attribute names.
446 class StunUInt16ListAttribute : public StunAttribute { 447 class StunUInt16ListAttribute : public StunAttribute {
447 public: 448 public:
448 StunUInt16ListAttribute(uint16 type, uint16 length); 449 StunUInt16ListAttribute(uint16_t type, uint16_t length);
449 ~StunUInt16ListAttribute(); 450 ~StunUInt16ListAttribute();
450 451
451 virtual StunAttributeValueType value_type() const { 452 virtual StunAttributeValueType value_type() const {
452 return STUN_VALUE_UINT16_LIST; 453 return STUN_VALUE_UINT16_LIST;
453 } 454 }
454 455
455 size_t Size() const; 456 size_t Size() const;
456 uint16 GetType(int index) const; 457 uint16_t GetType(int index) const;
457 void SetType(int index, uint16 value); 458 void SetType(int index, uint16_t value);
458 void AddType(uint16 value); 459 void AddType(uint16_t value);
459 460
460 bool Read(rtc::ByteBuffer* buf); 461 bool Read(rtc::ByteBuffer* buf);
461 bool Write(rtc::ByteBuffer* buf) const; 462 bool Write(rtc::ByteBuffer* buf) const;
462 463
463 private: 464 private:
464 std::vector<uint16>* attr_types_; 465 std::vector<uint16_t>* attr_types_;
465 }; 466 };
466 467
467 // Returns the (successful) response type for the given request type. 468 // Returns the (successful) response type for the given request type.
468 // Returns -1 if |request_type| is not a valid request type. 469 // Returns -1 if |request_type| is not a valid request type.
469 int GetStunSuccessResponseType(int request_type); 470 int GetStunSuccessResponseType(int request_type);
470 471
471 // Returns the error response type for the given request type. 472 // Returns the error response type for the given request type.
472 // Returns -1 if |request_type| is not a valid request type. 473 // Returns -1 if |request_type| is not a valid request type.
473 int GetStunErrorResponseType(int request_type); 474 int GetStunErrorResponseType(int request_type);
474 475
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 case STUN_ATTR_ICE_CONTROLLING: return STUN_VALUE_UINT64; 625 case STUN_ATTR_ICE_CONTROLLING: return STUN_VALUE_UINT64;
625 default: return StunMessage::GetAttributeValueType(type); 626 default: return StunMessage::GetAttributeValueType(type);
626 } 627 }
627 } 628 }
628 virtual StunMessage* CreateNew() const { return new IceMessage(); } 629 virtual StunMessage* CreateNew() const { return new IceMessage(); }
629 }; 630 };
630 631
631 } // namespace cricket 632 } // namespace cricket
632 633
633 #endif // WEBRTC_P2P_BASE_STUN_H_ 634 #endif // WEBRTC_P2P_BASE_STUN_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/relayserver_unittest.cc ('k') | webrtc/p2p/base/stun.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698