mirror of
				https://github.com/coturn/coturn.git
				synced 2025-11-04 08:51:00 +01:00 
			
		
		
		
	
							parent
							
								
									30c1a2076b
								
							
						
					
					
						commit
						50ebef7a3f
					
				@ -1124,7 +1124,7 @@ static void mongo_reread_realms(secrets_list_t * realms_list) {
 | 
				
			|||||||
								ur_string_map_value_type value =
 | 
													ur_string_map_value_type value =
 | 
				
			||||||
										(ur_string_map_value_type) (rval);
 | 
															(ur_string_map_value_type) (rval);
 | 
				
			||||||
								ur_string_map_put(o_to_realm_new,
 | 
													ur_string_map_put(o_to_realm_new,
 | 
				
			||||||
										(const ur_string_map_key_type) _origin,
 | 
															(ur_string_map_key_type) _origin,
 | 
				
			||||||
										value);
 | 
															value);
 | 
				
			||||||
								free(_origin);
 | 
													free(_origin);
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
 | 
				
			|||||||
@ -1048,7 +1048,7 @@ static void mysql_reread_realms(secrets_list_t * realms_list) {
 | 
				
			|||||||
									char *rval=strdup(row[1]);
 | 
														char *rval=strdup(row[1]);
 | 
				
			||||||
									get_realm(rval);
 | 
														get_realm(rval);
 | 
				
			||||||
									ur_string_map_value_type value = (ur_string_map_value_type)rval;
 | 
														ur_string_map_value_type value = (ur_string_map_value_type)rval;
 | 
				
			||||||
									ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
 | 
														ur_string_map_put(o_to_realm_new, (ur_string_map_key_type) oval, value);
 | 
				
			||||||
								}
 | 
													}
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
 | 
				
			|||||||
@ -758,7 +758,7 @@ static void pgsql_reread_realms(secrets_list_t * realms_list) {
 | 
				
			|||||||
						if(rval) {
 | 
											if(rval) {
 | 
				
			||||||
							get_realm(rval);
 | 
												get_realm(rval);
 | 
				
			||||||
							ur_string_map_value_type value = strdup(rval);
 | 
												ur_string_map_value_type value = strdup(rval);
 | 
				
			||||||
							ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
 | 
												ur_string_map_put(o_to_realm_new, (ur_string_map_key_type) oval, value);
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
				
			|||||||
@ -1161,7 +1161,7 @@ static void redis_reread_realms(secrets_list_t * realms_list) {
 | 
				
			|||||||
					} else {
 | 
										} else {
 | 
				
			||||||
						get_realm(rget->str);
 | 
											get_realm(rget->str);
 | 
				
			||||||
						ur_string_map_value_type value = strdup(rget->str);
 | 
											ur_string_map_value_type value = strdup(rget->str);
 | 
				
			||||||
						ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) origin, value);
 | 
											ur_string_map_put(o_to_realm_new, (ur_string_map_key_type) origin, value);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					turnFreeRedisReply(rget);
 | 
										turnFreeRedisReply(rget);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
				
			|||||||
@ -1038,7 +1038,7 @@ static void sqlite_reread_realms(secrets_list_t * realms_list)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
						get_realm(rval);
 | 
											get_realm(rval);
 | 
				
			||||||
						ur_string_map_value_type value = rval;
 | 
											ur_string_map_value_type value = rval;
 | 
				
			||||||
						ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
 | 
											ur_string_map_put(o_to_realm_new, (ur_string_map_key_type) oval, value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						free(oval);
 | 
											free(oval);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1173,7 +1173,7 @@ static void set_option(int c, char *value)
 | 
				
			|||||||
	  STRCPY(turn_params.oauth_server_name,value);
 | 
						  STRCPY(turn_params.oauth_server_name,value);
 | 
				
			||||||
	  break;
 | 
						  break;
 | 
				
			||||||
  case OAUTH_OPT:
 | 
					  case OAUTH_OPT:
 | 
				
			||||||
	  if(!ENC_ALG_NUM) {
 | 
						  if( ENC_ALG_NUM == 0) {
 | 
				
			||||||
		  TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING, "WARNING: option --oauth is not supported; ignored.\n");
 | 
							  TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING, "WARNING: option --oauth is not supported; ignored.\n");
 | 
				
			||||||
	  } else {
 | 
						  } else {
 | 
				
			||||||
		  turn_params.oauth = get_bool_value(value);
 | 
							  turn_params.oauth = get_bool_value(value);
 | 
				
			||||||
@ -2062,7 +2062,7 @@ static void print_features(unsigned long mfn)
 | 
				
			|||||||
	TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "TURN/STUN ALPN is not supported\n");
 | 
						TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "TURN/STUN ALPN is not supported\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(!ENC_ALG_NUM) {
 | 
						if(ENC_ALG_NUM == 0) {
 | 
				
			||||||
		TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Third-party authorization (oAuth) is not supported\n");
 | 
							TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Third-party authorization (oAuth) is not supported\n");
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Third-party authorization (oAuth) supported\n");
 | 
							TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Third-party authorization (oAuth) supported\n");
 | 
				
			||||||
@ -2588,7 +2588,7 @@ static int THREAD_setup(void) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	mutex_buf_initialized = 1;
 | 
						mutex_buf_initialized = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
 | 
					#if OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER <= OPENSSL_VERSION_1_1_1
 | 
				
			||||||
	CRYPTO_THREADID_set_callback(coturn_id_function);
 | 
						CRYPTO_THREADID_set_callback(coturn_id_function);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	CRYPTO_set_id_callback(coturn_id_function);
 | 
						CRYPTO_set_id_callback(coturn_id_function);
 | 
				
			||||||
@ -2610,7 +2610,7 @@ int THREAD_cleanup(void) {
 | 
				
			|||||||
  if (!mutex_buf_initialized)
 | 
					  if (!mutex_buf_initialized)
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
 | 
					#if OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER <= OPENSSL_VERSION_1_1_1
 | 
				
			||||||
	CRYPTO_THREADID_set_callback(NULL);
 | 
						CRYPTO_THREADID_set_callback(NULL);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	CRYPTO_set_id_callback(NULL);
 | 
						CRYPTO_set_id_callback(NULL);
 | 
				
			||||||
 | 
				
			|||||||
@ -75,7 +75,7 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Iterator constructor: creates iterator on raw messagebuffer.
 | 
						 * Iterator constructor: creates iterator on raw messagebuffer.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	StunAttrIterator(uint8_t *buf, size_t sz) throw (WrongStunBufferFormatException) :
 | 
						StunAttrIterator(uint8_t *buf, size_t sz) :
 | 
				
			||||||
		_buf(buf), _sz(sz)  {
 | 
							_buf(buf), _sz(sz)  {
 | 
				
			||||||
		if(!stun_is_command_message_str(_buf, _sz)) {
 | 
							if(!stun_is_command_message_str(_buf, _sz)) {
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
@ -87,7 +87,7 @@ public:
 | 
				
			|||||||
	 * Iterator constructor: create iterator over message.
 | 
						 * Iterator constructor: create iterator over message.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	template<class T>
 | 
						template<class T>
 | 
				
			||||||
	StunAttrIterator(T &msg) throw (WrongStunBufferFormatException) :
 | 
						StunAttrIterator(T &msg) :
 | 
				
			||||||
		_buf(msg.getRawBuffer()), _sz(msg.getSize())  {
 | 
							_buf(msg.getRawBuffer()), _sz(msg.getSize())  {
 | 
				
			||||||
		if(!stun_is_command_message_str(_buf, _sz)) {
 | 
							if(!stun_is_command_message_str(_buf, _sz)) {
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
@ -99,7 +99,7 @@ public:
 | 
				
			|||||||
	 * Iterator constructor: creates iterator over raw buffer, starting from first
 | 
						 * Iterator constructor: creates iterator over raw buffer, starting from first
 | 
				
			||||||
	 * location of an attribute of particular type.
 | 
						 * location of an attribute of particular type.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	StunAttrIterator(uint8_t *buf, size_t sz, uint16_t attr_type) throw (WrongStunBufferFormatException) :
 | 
						StunAttrIterator(uint8_t *buf, size_t sz, uint16_t attr_type) :
 | 
				
			||||||
			_buf(buf), _sz(sz)  {
 | 
								_buf(buf), _sz(sz)  {
 | 
				
			||||||
		if(!stun_is_command_message_str(_buf, _sz)) {
 | 
							if(!stun_is_command_message_str(_buf, _sz)) {
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
@ -112,7 +112,7 @@ public:
 | 
				
			|||||||
	 * location of an attribute of particular type.
 | 
						 * location of an attribute of particular type.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	template<class T>
 | 
						template<class T>
 | 
				
			||||||
	StunAttrIterator(T &msg, uint16_t attr_type) throw (WrongStunBufferFormatException) :
 | 
						StunAttrIterator(T &msg, uint16_t attr_type) :
 | 
				
			||||||
			_buf(msg.getRawBuffer()), _sz(msg.getSize())  {
 | 
								_buf(msg.getRawBuffer()), _sz(msg.getSize())  {
 | 
				
			||||||
		if(!stun_is_command_message_str(_buf, _sz)) {
 | 
							if(!stun_is_command_message_str(_buf, _sz)) {
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
@ -123,7 +123,7 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Moves iterator to next attribute location
 | 
						 * Moves iterator to next attribute location
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	void next() throw(EndOfStunMsgException) {
 | 
						void next() {
 | 
				
			||||||
		if(!_sar) {
 | 
							if(!_sar) {
 | 
				
			||||||
			throw EndOfStunMsgException();
 | 
								throw EndOfStunMsgException();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -167,7 +167,7 @@ public:
 | 
				
			|||||||
	 * Return raw memroy field of the attribute value.
 | 
						 * Return raw memroy field of the attribute value.
 | 
				
			||||||
	 * If the attribute value length is zero (0), then return NULL.
 | 
						 * If the attribute value length is zero (0), then return NULL.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	const uint8_t *getRawBuffer(size_t &sz) const throw(WrongStunAttrFormatException) {
 | 
						const uint8_t *getRawBuffer(size_t &sz) const {
 | 
				
			||||||
		int len = stun_attr_get_len(_sar);
 | 
							int len = stun_attr_get_len(_sar);
 | 
				
			||||||
		if(len<0)
 | 
							if(len<0)
 | 
				
			||||||
			throw WrongStunAttrFormatException();
 | 
								throw WrongStunAttrFormatException();
 | 
				
			||||||
@ -196,7 +196,7 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Constructs attribute from iterator
 | 
						 * Constructs attribute from iterator
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	StunAttr(const StunAttrIterator &iter) throw(WrongStunAttrFormatException, EndOfStunMsgException) {
 | 
						StunAttr(const StunAttrIterator &iter) {
 | 
				
			||||||
		if(iter.eof()) {
 | 
							if(iter.eof()) {
 | 
				
			||||||
			throw EndOfStunMsgException();
 | 
								throw EndOfStunMsgException();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -219,7 +219,7 @@ public:
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
	virtual ~StunAttr() {
 | 
						virtual ~StunAttr() {
 | 
				
			||||||
		if(_value)
 | 
							if(_value)
 | 
				
			||||||
			free(_value,_sz);
 | 
								free(_value);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
@ -233,11 +233,11 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Set raw data value
 | 
						 * Set raw data value
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	void setRawValue(uint8_t *value, size_t sz) throw(WrongStunAttrFormatException) {
 | 
						void setRawValue(uint8_t *value, size_t sz) {
 | 
				
			||||||
		if(sz>0xFFFF)
 | 
							if(sz>0xFFFF)
 | 
				
			||||||
			throw WrongStunAttrFormatException();
 | 
								throw WrongStunAttrFormatException();
 | 
				
			||||||
		if(_value)
 | 
							if(_value)
 | 
				
			||||||
			free(_value,_sz);
 | 
								free(_value);
 | 
				
			||||||
		_sz = sz;
 | 
							_sz = sz;
 | 
				
			||||||
		_value=(uint8_t*)malloc(_sz);
 | 
							_value=(uint8_t*)malloc(_sz);
 | 
				
			||||||
		if(value)
 | 
							if(value)
 | 
				
			||||||
@ -262,7 +262,7 @@ public:
 | 
				
			|||||||
	 * Add attribute to a message
 | 
						 * Add attribute to a message
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	template<class T>
 | 
						template<class T>
 | 
				
			||||||
	int addToMsg(T &msg) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						int addToMsg(T &msg) {
 | 
				
			||||||
		if(!_attr_type)
 | 
							if(!_attr_type)
 | 
				
			||||||
			throw WrongStunAttrFormatException();
 | 
								throw WrongStunAttrFormatException();
 | 
				
			||||||
		uint8_t *buffer = msg.getRawBuffer();
 | 
							uint8_t *buffer = msg.getRawBuffer();
 | 
				
			||||||
@ -281,7 +281,7 @@ protected:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Virtual function member to add attribute to a raw buffer
 | 
						 * Virtual function member to add attribute to a raw buffer
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						virtual int addToBuffer(uint8_t *buffer, size_t &sz) {
 | 
				
			||||||
		if(buffer) {
 | 
							if(buffer) {
 | 
				
			||||||
			if(!_value)
 | 
								if(!_value)
 | 
				
			||||||
				throw WrongStunAttrFormatException();
 | 
									throw WrongStunAttrFormatException();
 | 
				
			||||||
@ -313,8 +313,7 @@ public:
 | 
				
			|||||||
	StunAttrChannelNumber() : _cn(0) {
 | 
						StunAttrChannelNumber() : _cn(0) {
 | 
				
			||||||
		setType(STUN_ATTRIBUTE_CHANNEL_NUMBER);
 | 
							setType(STUN_ATTRIBUTE_CHANNEL_NUMBER);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	StunAttrChannelNumber(const StunAttrIterator &iter)
 | 
						StunAttrChannelNumber(const StunAttrIterator &iter) :
 | 
				
			||||||
		throw(WrongStunAttrFormatException, EndOfStunMsgException) :
 | 
					 | 
				
			||||||
		StunAttr(iter) {
 | 
							StunAttr(iter) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(iter.eof())
 | 
							if(iter.eof())
 | 
				
			||||||
@ -331,7 +330,7 @@ public:
 | 
				
			|||||||
		_cn = cn;
 | 
							_cn = cn;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						virtual int addToBuffer(uint8_t *buffer, size_t &sz) {
 | 
				
			||||||
		return stun_attr_add_channel_number_str(buffer,&sz,_cn);
 | 
							return stun_attr_add_channel_number_str(buffer,&sz,_cn);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
@ -346,8 +345,7 @@ public:
 | 
				
			|||||||
	StunAttrEvenPort() : _ep(0) {
 | 
						StunAttrEvenPort() : _ep(0) {
 | 
				
			||||||
		setType(STUN_ATTRIBUTE_EVEN_PORT);
 | 
							setType(STUN_ATTRIBUTE_EVEN_PORT);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	StunAttrEvenPort(const StunAttrIterator &iter)
 | 
						StunAttrEvenPort(const StunAttrIterator &iter) :
 | 
				
			||||||
		throw(WrongStunAttrFormatException, EndOfStunMsgException) :
 | 
					 | 
				
			||||||
		StunAttr(iter) {
 | 
							StunAttr(iter) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(iter.eof())
 | 
							if(iter.eof())
 | 
				
			||||||
@ -362,7 +360,7 @@ public:
 | 
				
			|||||||
		_ep = ep;
 | 
							_ep = ep;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						virtual int addToBuffer(uint8_t *buffer, size_t &sz) {
 | 
				
			||||||
		return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_EVEN_PORT, &_ep, 1);
 | 
							return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_EVEN_PORT, &_ep, 1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
@ -377,8 +375,7 @@ public:
 | 
				
			|||||||
	StunAttrReservationToken() : _rt(0) {
 | 
						StunAttrReservationToken() : _rt(0) {
 | 
				
			||||||
		setType(STUN_ATTRIBUTE_RESERVATION_TOKEN);
 | 
							setType(STUN_ATTRIBUTE_RESERVATION_TOKEN);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	StunAttrReservationToken(const StunAttrIterator &iter)
 | 
						StunAttrReservationToken(const StunAttrIterator &iter) :
 | 
				
			||||||
		throw(WrongStunAttrFormatException, EndOfStunMsgException) :
 | 
					 | 
				
			||||||
		StunAttr(iter) {
 | 
							StunAttr(iter) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(iter.eof())
 | 
							if(iter.eof())
 | 
				
			||||||
@ -393,7 +390,7 @@ public:
 | 
				
			|||||||
		_rt = rt;
 | 
							_rt = rt;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						virtual int addToBuffer(uint8_t *buffer, size_t &sz) {
 | 
				
			||||||
		uint64_t reservation_token = ioa_ntoh64(_rt);
 | 
							uint64_t reservation_token = ioa_ntoh64(_rt);
 | 
				
			||||||
		return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_RESERVATION_TOKEN, (uint8_t*) (&reservation_token), 8);
 | 
							return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_RESERVATION_TOKEN, (uint8_t*) (&reservation_token), 8);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -410,8 +407,7 @@ public:
 | 
				
			|||||||
		addr_set_any(&_addr);
 | 
							addr_set_any(&_addr);
 | 
				
			||||||
		setType(attr_type);
 | 
							setType(attr_type);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	StunAttrAddr(const StunAttrIterator &iter)
 | 
						StunAttrAddr(const StunAttrIterator &iter) :
 | 
				
			||||||
		throw(WrongStunAttrFormatException, EndOfStunMsgException) :
 | 
					 | 
				
			||||||
		StunAttr(iter) {
 | 
							StunAttr(iter) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(iter.eof())
 | 
							if(iter.eof())
 | 
				
			||||||
@ -430,7 +426,7 @@ public:
 | 
				
			|||||||
		addr_cpy(&_addr,&addr);
 | 
							addr_cpy(&_addr,&addr);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						virtual int addToBuffer(uint8_t *buffer, size_t &sz) {
 | 
				
			||||||
		return stun_attr_add_addr_str(buffer, &sz, getType(), &_addr);
 | 
							return stun_attr_add_addr_str(buffer, &sz, getType(), &_addr);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
@ -445,8 +441,7 @@ public:
 | 
				
			|||||||
	StunAttrChangeRequest() : _changeIp(0), _changePort(0) {
 | 
						StunAttrChangeRequest() : _changeIp(0), _changePort(0) {
 | 
				
			||||||
		setType(STUN_ATTRIBUTE_CHANGE_REQUEST);
 | 
							setType(STUN_ATTRIBUTE_CHANGE_REQUEST);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	StunAttrChangeRequest(const StunAttrIterator &iter)
 | 
						StunAttrChangeRequest(const StunAttrIterator &iter) :
 | 
				
			||||||
		throw(WrongStunAttrFormatException, EndOfStunMsgException) :
 | 
					 | 
				
			||||||
		StunAttr(iter) {
 | 
							StunAttr(iter) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(iter.eof())
 | 
							if(iter.eof())
 | 
				
			||||||
@ -476,7 +471,7 @@ public:
 | 
				
			|||||||
			_changePort = 0;
 | 
								_changePort = 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						virtual int addToBuffer(uint8_t *buffer, size_t &sz) {
 | 
				
			||||||
		return stun_attr_add_change_request_str(buffer, &sz, _changeIp, _changePort);
 | 
							return stun_attr_add_change_request_str(buffer, &sz, _changeIp, _changePort);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
@ -492,8 +487,7 @@ public:
 | 
				
			|||||||
	StunAttrResponsePort() : _rp(0) {
 | 
						StunAttrResponsePort() : _rp(0) {
 | 
				
			||||||
		setType(STUN_ATTRIBUTE_RESPONSE_PORT);
 | 
							setType(STUN_ATTRIBUTE_RESPONSE_PORT);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	StunAttrResponsePort(const StunAttrIterator &iter)
 | 
						StunAttrResponsePort(const StunAttrIterator &iter) :
 | 
				
			||||||
		throw(WrongStunAttrFormatException, EndOfStunMsgException) :
 | 
					 | 
				
			||||||
		StunAttr(iter) {
 | 
							StunAttr(iter) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(iter.eof())
 | 
							if(iter.eof())
 | 
				
			||||||
@ -513,7 +507,7 @@ public:
 | 
				
			|||||||
		_rp = p;
 | 
							_rp = p;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						virtual int addToBuffer(uint8_t *buffer, size_t &sz) {
 | 
				
			||||||
		return stun_attr_add_response_port_str(buffer, &sz, _rp);
 | 
							return stun_attr_add_response_port_str(buffer, &sz, _rp);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
@ -528,8 +522,7 @@ public:
 | 
				
			|||||||
	StunAttrPadding() : _p(0) {
 | 
						StunAttrPadding() : _p(0) {
 | 
				
			||||||
		setType(STUN_ATTRIBUTE_PADDING);
 | 
							setType(STUN_ATTRIBUTE_PADDING);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	StunAttrPadding(const StunAttrIterator &iter)
 | 
						StunAttrPadding(const StunAttrIterator &iter) :
 | 
				
			||||||
		throw(WrongStunAttrFormatException, EndOfStunMsgException) :
 | 
					 | 
				
			||||||
		StunAttr(iter) {
 | 
							StunAttr(iter) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(iter.eof())
 | 
							if(iter.eof())
 | 
				
			||||||
@ -552,7 +545,7 @@ public:
 | 
				
			|||||||
		_p = p;
 | 
							_p = p;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						virtual int addToBuffer(uint8_t *buffer, size_t &sz) {
 | 
				
			||||||
		return stun_attr_add_padding_str(buffer, &sz, _p);
 | 
							return stun_attr_add_padding_str(buffer, &sz, _p);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
@ -588,7 +581,7 @@ public:
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
	virtual ~StunMsg() {
 | 
						virtual ~StunMsg() {
 | 
				
			||||||
		if(_deallocate && _buffer) {
 | 
							if(_deallocate && _buffer) {
 | 
				
			||||||
			free(_buffer, _allocated_sz);
 | 
								free(_buffer);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -623,7 +616,7 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Set message size
 | 
						 * Set message size
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	void setSize(size_t sz) throw(WrongStunBufferFormatException) {
 | 
						void setSize(size_t sz) {
 | 
				
			||||||
		if(sz>_allocated_sz)
 | 
							if(sz>_allocated_sz)
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
		_sz = sz;
 | 
							_sz = sz;
 | 
				
			||||||
@ -700,14 +693,14 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Add attribute to the message
 | 
						 * Add attribute to the message
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	int addAttr(StunAttr &attr) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
 | 
						int addAttr(StunAttr &attr) {
 | 
				
			||||||
		return attr.addToMsg(*this);
 | 
							return attr.addToMsg(*this);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Get transaction ID
 | 
						 * Get transaction ID
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	virtual stun_tid getTid() const throw(WrongStunBufferFormatException) {
 | 
						virtual stun_tid getTid() const {
 | 
				
			||||||
		if(!_constructed || !isCommand())
 | 
							if(!_constructed || !isCommand())
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
		stun_tid tid;
 | 
							stun_tid tid;
 | 
				
			||||||
@ -718,7 +711,7 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Set transaction ID
 | 
						 * Set transaction ID
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	virtual void setTid(stun_tid &tid) throw(WrongStunBufferFormatException) {
 | 
						virtual void setTid(stun_tid &tid) {
 | 
				
			||||||
		if(!_constructed || !isCommand())
 | 
							if(!_constructed || !isCommand())
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
		stun_tid_message_cpy(_buffer, &tid);
 | 
							stun_tid_message_cpy(_buffer, &tid);
 | 
				
			||||||
@ -727,7 +720,7 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Add fingerprint to the message
 | 
						 * Add fingerprint to the message
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	void addFingerprint() throw(WrongStunBufferFormatException) {
 | 
						void addFingerprint() {
 | 
				
			||||||
		if(!_constructed || !isCommand())
 | 
							if(!_constructed || !isCommand())
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
		stun_attr_add_fingerprint_str(_buffer,&_sz);
 | 
							stun_attr_add_fingerprint_str(_buffer,&_sz);
 | 
				
			||||||
@ -736,8 +729,7 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Check message integrity, in secure communications.
 | 
						 * Check message integrity, in secure communications.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	bool checkMessageIntegrity(turn_credential_type ct, std::string &uname, std::string &realm, std::string &upwd) const
 | 
						bool checkMessageIntegrity(turn_credential_type ct, std::string &uname, std::string &realm, std::string &upwd) const {
 | 
				
			||||||
		throw(WrongStunBufferFormatException) {
 | 
					 | 
				
			||||||
		if(!_constructed || !isCommand())
 | 
							if(!_constructed || !isCommand())
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
		uint8_t *suname=(uint8_t*)strdup(uname.c_str());
 | 
							uint8_t *suname=(uint8_t*)strdup(uname.c_str());
 | 
				
			||||||
@ -754,8 +746,7 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Adds long-term message integrity data to the message.
 | 
						 * Adds long-term message integrity data to the message.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	void addLTMessageIntegrity(std::string &uname, std::string &realm, std::string &upwd, std::string &nonce)
 | 
						void addLTMessageIntegrity(std::string &uname, std::string &realm, std::string &upwd, std::string &nonce) {
 | 
				
			||||||
		throw(WrongStunBufferFormatException) {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(!_constructed || !isCommand())
 | 
							if(!_constructed || !isCommand())
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
@ -776,8 +767,7 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Adds short-term message integrity data to the message.
 | 
						 * Adds short-term message integrity data to the message.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	void addSTMessageIntegrity(std::string &uname, std::string &upwd)
 | 
						void addSTMessageIntegrity(std::string &uname, std::string &upwd) {
 | 
				
			||||||
		throw(WrongStunBufferFormatException) {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(!_constructed || !isCommand())
 | 
							if(!_constructed || !isCommand())
 | 
				
			||||||
			throw WrongStunBufferFormatException();
 | 
								throw WrongStunBufferFormatException();
 | 
				
			||||||
@ -808,8 +798,7 @@ protected:
 | 
				
			|||||||
class StunMsgRequest : public StunMsg {
 | 
					class StunMsgRequest : public StunMsg {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	StunMsgRequest(uint16_t method) : _method(method) {};
 | 
						StunMsgRequest(uint16_t method) : _method(method) {};
 | 
				
			||||||
	StunMsgRequest(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
 | 
						StunMsgRequest(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed) :
 | 
				
			||||||
		throw(WrongStunBufferFormatException) :
 | 
					 | 
				
			||||||
			StunMsg(buffer,total_sz,sz,constructed),_method(0) {
 | 
								StunMsg(buffer,total_sz,sz,constructed),_method(0) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(constructed) {
 | 
							if(constructed) {
 | 
				
			||||||
@ -893,8 +882,7 @@ public:
 | 
				
			|||||||
		_method(method), _err(error_code), _reason(reason), _tid(tid) {
 | 
							_method(method), _err(error_code), _reason(reason), _tid(tid) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	StunMsgResponse(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
 | 
						StunMsgResponse(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed) :
 | 
				
			||||||
		throw(WrongStunBufferFormatException) :
 | 
					 | 
				
			||||||
			StunMsg(buffer,total_sz,sz,constructed),_method(0),_err(0),_reason("") {
 | 
								StunMsg(buffer,total_sz,sz,constructed),_method(0),_err(0),_reason("") {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(constructed) {
 | 
							if(constructed) {
 | 
				
			||||||
@ -949,14 +937,14 @@ public:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Set transaction ID
 | 
						 * Set transaction ID
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	void setTid(stun_tid &tid) throw(WrongStunBufferFormatException) {
 | 
						void setTid(stun_tid &tid) {
 | 
				
			||||||
		_tid = tid;
 | 
							_tid = tid;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Get transaction ID
 | 
						 * Get transaction ID
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	virtual stun_tid getTid() const throw(WrongStunBufferFormatException) {
 | 
						virtual stun_tid getTid() const {
 | 
				
			||||||
		return _tid;
 | 
							return _tid;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1074,8 +1062,7 @@ private:
 | 
				
			|||||||
class StunMsgIndication : public StunMsg {
 | 
					class StunMsgIndication : public StunMsg {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	StunMsgIndication(uint16_t method) : _method(method) {};
 | 
						StunMsgIndication(uint16_t method) : _method(method) {};
 | 
				
			||||||
	StunMsgIndication(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
 | 
						StunMsgIndication(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed) :
 | 
				
			||||||
		throw(WrongStunBufferFormatException) :
 | 
					 | 
				
			||||||
			StunMsg(buffer,total_sz,sz,constructed),_method(0) {
 | 
								StunMsg(buffer,total_sz,sz,constructed),_method(0) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(constructed) {
 | 
							if(constructed) {
 | 
				
			||||||
@ -1123,8 +1110,7 @@ private:
 | 
				
			|||||||
class StunMsgChannel : public StunMsg {
 | 
					class StunMsgChannel : public StunMsg {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	StunMsgChannel(uint16_t cn, int length) : _cn(cn), _len(length) {};
 | 
						StunMsgChannel(uint16_t cn, int length) : _cn(cn), _len(length) {};
 | 
				
			||||||
	StunMsgChannel(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
 | 
						StunMsgChannel(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed) :
 | 
				
			||||||
		throw(WrongStunBufferFormatException) :
 | 
					 | 
				
			||||||
			StunMsg(buffer,total_sz,sz,constructed),_cn(0) {
 | 
								StunMsg(buffer,total_sz,sz,constructed),_cn(0) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(constructed) {
 | 
							if(constructed) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user