#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 | setStunTid (stun_tid &tid) |
stun_tid | getStunTid () |
bool | isChallenge (std::string &realm, std::string &nonce) |
Protected Member Functions | |
virtual void | constructBuffer () |
virtual bool | check () |
Definition at line 615 of file TurnMsgLib.h.
StunMsgResponse::StunMsgResponse | ( | u16bits | method, |
stun_tid & | tid | ||
) | [inline] |
Definition at line 617 of file TurnMsgLib.h.
: _method(method), _err(0), _reason(""), _tid(tid) {};
StunMsgResponse::StunMsgResponse | ( | u16bits | method, |
int | error_code, | ||
std::string | reason, | ||
stun_tid & | tid | ||
) | [inline] |
Definition at line 618 of file TurnMsgLib.h.
: _method(method), _err(error_code), _reason(reason), _tid(tid) { };
StunMsgResponse::StunMsgResponse | ( | u08bits * | buffer, |
size_t | total_sz, | ||
size_t | sz, | ||
bool | constructed | ||
) | throw (WrongStunBufferFormatException) [inline] |
Definition at line 622 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 StunMsgResponse::check | ( | ) | [inline, protected, virtual] |
Implements StunMsg.
Definition at line 698 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; }
virtual void StunMsgResponse::constructBuffer | ( | ) | [inline, protected, virtual] |
Implements StunMsg.
Definition at line 689 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; }
int StunMsgResponse::getError | ( | ) | const [inline] |
Definition at line 647 of file TurnMsgLib.h.
{
return _err;
}
u16bits StunMsgResponse::getMethod | ( | ) | const [inline] |
Definition at line 639 of file TurnMsgLib.h.
{
return _method;
}
std::string StunMsgResponse::getReason | ( | ) | const [inline] |
Definition at line 655 of file TurnMsgLib.h.
{
return _reason;
}
stun_tid StunMsgResponse::getStunTid | ( | ) | [inline] |
Definition at line 667 of file TurnMsgLib.h.
{
return _tid;
}
bool StunMsgResponse::isChallenge | ( | std::string & | realm, |
std::string & | nonce | ||
) | [inline] |
Definition at line 671 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; }
void StunMsgResponse::setError | ( | int | err | ) | [inline] |
Definition at line 651 of file TurnMsgLib.h.
{ _err = err; }
void StunMsgResponse::setMethod | ( | u16bits | method | ) | [inline] |
Definition at line 643 of file TurnMsgLib.h.
{ _method = method; }
void StunMsgResponse::setReason | ( | std::string | reason | ) | [inline] |
Definition at line 659 of file TurnMsgLib.h.
{ _reason = reason; }
void StunMsgResponse::setStunTid | ( | stun_tid & | tid | ) | [inline] |
Definition at line 663 of file TurnMsgLib.h.
{ _tid = tid; }