#include <TurnMsgLib.h>
Public Member Functions | |
| StunMsgResponse (u16bits method, stun_tid &tid) | |
| StunMsgResponse (u16bits method, int error_code, std::string reason, stun_tid &tid) | |
| StunMsgResponse (u08bits *buffer, size_t total_sz, size_t sz, bool constructed) throw (WrongStunBufferFormatException) | |
| u16bits | getMethod () const |
| void | setMethod (u16bits method) |
| int | getError () const |
| void | setError (int err) |
| std::string | getReason () const |
| void | setReason (std::string reason) |
| void | setTid (stun_tid &tid) throw (WrongStunBufferFormatException) |
| stun_tid | getTid () throw (WrongStunBufferFormatException) |
| bool | isChallenge (std::string &realm, std::string &nonce) const |
| bool | isChallenge () const |
| bool | isSuccess () const |
| void | constructBindingResponse (stun_tid &tid, const ioa_addr &reflexive_addr, int error_code, const u08bits *reason) |
| bool | isBindingResponse () const |
| void | constructAllocateResponse (stun_tid &tid, const ioa_addr &relayed_addr, const ioa_addr &reflexive_addr, u32bits lifetime, int error_code, const u08bits *reason, u64bits reservation_token) |
| void | constructChannelBindResponse (stun_tid &tid, int error_code, const u08bits *reason) |
Protected Member Functions | |
| virtual void | constructBuffer () |
| virtual bool | check () |
Class for STUN/TURN responses
Definition at line 854 of file TurnMsgLib.h.
| turn::StunMsgResponse::StunMsgResponse | ( | u16bits | method, |
| stun_tid & | tid | ||
| ) | [inline] |
Definition at line 856 of file TurnMsgLib.h.
: _method(method), _err(0), _reason(""), _tid(tid) {};
| turn::StunMsgResponse::StunMsgResponse | ( | u16bits | method, |
| int | error_code, | ||
| std::string | reason, | ||
| stun_tid & | tid | ||
| ) | [inline] |
Definition at line 857 of file TurnMsgLib.h.
:
_method(method), _err(error_code), _reason(reason), _tid(tid) {
};
| turn::StunMsgResponse::StunMsgResponse | ( | u08bits * | buffer, |
| size_t | total_sz, | ||
| size_t | sz, | ||
| bool | constructed | ||
| ) | throw (WrongStunBufferFormatException) [inline] |
Definition at line 861 of file TurnMsgLib.h.
:
StunMsg(buffer,total_sz,sz,constructed),_method(0),_err(0),_reason("") {
if(constructed) {
if(!stun_is_success_response_str(buffer,sz)) {
u08bits errtxt[0xFFFF];
if(!stun_is_error_response_str(buffer,sz,&_err,errtxt,sizeof(errtxt))) {
throw WrongStunBufferFormatException();
}
_reason = (char*)errtxt;
}
_method = stun_get_method_str(buffer,sz);
stun_tid_from_message_str(_buffer,_sz,&_tid);
}
}
| virtual bool turn::StunMsgResponse::check | ( | ) | [inline, protected, virtual] |
Implements turn::StunMsg.
Definition at line 1009 of file TurnMsgLib.h.
{
if(!_constructed)
return false;
if(!stun_is_success_response_str(_buffer,_sz)) {
u08bits errtxt[0xFFFF];
int cerr=0;
if(!stun_is_error_response_str(_buffer,_sz,&cerr,errtxt,sizeof(errtxt))) {
throw WrongStunBufferFormatException();
}
if(cerr != _err) {
throw WrongStunBufferFormatException();
}
}
if(_method != stun_get_method_str(_buffer,_sz)) {
return false;
}
return true;
}
| void turn::StunMsgResponse::constructAllocateResponse | ( | stun_tid & | tid, |
| const ioa_addr & | relayed_addr, | ||
| const ioa_addr & | reflexive_addr, | ||
| u32bits | lifetime, | ||
| int | error_code, | ||
| const u08bits * | reason, | ||
| u64bits | reservation_token | ||
| ) | [inline] |
Construct allocate response
Definition at line 979 of file TurnMsgLib.h.
{
stun_set_allocate_response_str(_buffer, &_sz, &tid,
&relayed_addr,
&reflexive_addr,
lifetime, error_code, reason,
reservation_token);
}
| void turn::StunMsgResponse::constructBindingResponse | ( | stun_tid & | tid, |
| const ioa_addr & | reflexive_addr, | ||
| int | error_code, | ||
| const u08bits * | reason | ||
| ) | [inline] |
Construct binding response
Definition at line 963 of file TurnMsgLib.h.
{
stun_set_binding_response_str(_buffer, &_sz, &tid,
&reflexive_addr, error_code,
reason);
}
| virtual void turn::StunMsgResponse::constructBuffer | ( | ) | [inline, protected, virtual] |
Implements turn::StunMsg.
Definition at line 1000 of file TurnMsgLib.h.
{
if(_err) {
stun_init_error_response_str(_method, _buffer, &_sz, _err, (u08bits*)_reason.c_str(), &_tid);
} else {
stun_init_success_response_str(_method, _buffer, &_sz, &_tid);
}
_constructed = true;
}
| void turn::StunMsgResponse::constructChannelBindResponse | ( | stun_tid & | tid, |
| int | error_code, | ||
| const u08bits * | reason | ||
| ) | [inline] |
Construct channel bind response
Definition at line 995 of file TurnMsgLib.h.
{
stun_set_channel_bind_response_str(_buffer, &_sz, &tid, error_code, reason);
}
| int turn::StunMsgResponse::getError | ( | ) | const [inline] |
| u16bits turn::StunMsgResponse::getMethod | ( | ) | const [inline] |
Definition at line 878 of file TurnMsgLib.h.
{
return _method;
}
| std::string turn::StunMsgResponse::getReason | ( | ) | const [inline] |
| stun_tid turn::StunMsgResponse::getTid | ( | ) | throw (WrongStunBufferFormatException) [inline] |
| bool turn::StunMsgResponse::isBindingResponse | ( | ) | const [inline] |
Definition at line 972 of file TurnMsgLib.h.
{
return stun_is_binding_response_str(_buffer,_sz);
}
| bool turn::StunMsgResponse::isChallenge | ( | std::string & | realm, |
| std::string & | nonce | ||
| ) | const [inline] |
Check if this is a challenge response, and return realm and nonce
Definition at line 931 of file TurnMsgLib.h.
{
bool ret = false;
if(_constructed) {
int err_code;
u08bits err_msg[1025];
size_t err_msg_size=sizeof(err_msg);
u08bits srealm[0xFFFF];
u08bits snonce[0xFFFF];
ret = stun_is_challenge_response_str(_buffer, _sz, &err_code, err_msg, err_msg_size, srealm, snonce);
if(ret) {
realm = (char*)srealm;
nonce = (char*)snonce;
}
}
return ret;
}
| bool turn::StunMsgResponse::isChallenge | ( | ) | const [inline] |
Definition at line 948 of file TurnMsgLib.h.
{
std::string realm, nonce;
return isChallenge(realm, nonce);
}
| bool turn::StunMsgResponse::isSuccess | ( | ) | const [inline] |
Check if this is a success response
Definition at line 956 of file TurnMsgLib.h.
{
return (_err == 0);
}
| void turn::StunMsgResponse::setError | ( | int | err | ) | [inline] |
| void turn::StunMsgResponse::setMethod | ( | u16bits | method | ) | [inline] |
Definition at line 882 of file TurnMsgLib.h.
{
_method = method;
}
| void turn::StunMsgResponse::setReason | ( | std::string | reason | ) | [inline] |
| void turn::StunMsgResponse::setTid | ( | stun_tid & | tid | ) | throw (WrongStunBufferFormatException) [inline, virtual] |
Set transaction ID
Reimplemented from turn::StunMsg.
Definition at line 917 of file TurnMsgLib.h.
{
_tid = tid;
}
1.8.0