Added support (default enabled) to run generic SIP messages in their own thread.
Fixed the raw text body encoding. git-svn-id: http://voip.null.ro/svn/yate@5453 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
a861cc9359
commit
cb72cd54eb
|
@ -223,6 +223,9 @@
|
|||
; Can be one of: base64, hex, hexs, raw
|
||||
;body_encoding=base64
|
||||
|
||||
; async_generic: bool: Process generic SIP messages asynchronously in their own thread
|
||||
;async_generic=enable
|
||||
|
||||
; flags: int: Miscellaneous SIP engine flags for broken implementations
|
||||
; See SIPMessage::Flags and SIPMessage::complete() in the source for gory details
|
||||
;flags=0
|
||||
|
|
|
@ -709,7 +709,8 @@ public:
|
|||
void regReq(SIPEvent* e, SIPTransaction* t);
|
||||
void regRun(const SIPMessage* message, SIPTransaction* t);
|
||||
void options(SIPEvent* e, SIPTransaction* t);
|
||||
bool generic(SIPEvent* e, SIPTransaction* t);
|
||||
bool generic(SIPEvent* e, SIPTransaction* t, int defErr = 405, bool async = false);
|
||||
bool generic(const SIPMessage* message, SIPTransaction* t, const String& meth, bool autoAuth);
|
||||
bool buildParty(SIPMessage* message, const char* host = 0, int port = 0, const YateSIPLine* line = 0);
|
||||
inline void addTcpTransport(YateSIPTCPTransport* trans) {
|
||||
if (!trans)
|
||||
|
@ -832,6 +833,26 @@ private:
|
|||
RefPointer<SIPTransaction> m_tr;
|
||||
};
|
||||
|
||||
class YateSIPGeneric : public Thread
|
||||
{
|
||||
public:
|
||||
inline YateSIPGeneric(YateSIPEndPoint* ep, SIPMessage* message, SIPTransaction* t,
|
||||
const char* method, int defErr, bool autoAuth)
|
||||
: Thread("YSIP Generic"),
|
||||
m_ep(ep), m_msg(message), m_tr(t),
|
||||
m_method(method), m_error(defErr), m_auth(autoAuth)
|
||||
{ }
|
||||
virtual void run()
|
||||
{ if (!m_ep->generic(m_msg,m_tr,m_method,m_auth)) m_tr->setResponse(m_error); }
|
||||
private:
|
||||
YateSIPEndPoint* m_ep;
|
||||
RefPointer<SIPMessage> m_msg;
|
||||
RefPointer<SIPTransaction> m_tr;
|
||||
String m_method;
|
||||
int m_error;
|
||||
bool m_auth;
|
||||
};
|
||||
|
||||
class YateSIPConnection : public Channel, public SDPSession, public YateSIPPartyHolder
|
||||
{
|
||||
friend class SipHandler;
|
||||
|
@ -1114,6 +1135,7 @@ static bool s_1xx_formats = true;
|
|||
static bool s_rtp_preserve = false;
|
||||
static bool s_auth_register = true;
|
||||
static bool s_reg_async = true;
|
||||
static bool s_gen_async = true;
|
||||
static bool s_multi_ringing = false;
|
||||
static bool s_refresh_nosdp = true;
|
||||
static bool s_update_target = false;
|
||||
|
@ -4591,14 +4613,14 @@ bool YateSIPEndPoint::incoming(SIPEvent* e, SIPTransaction* t)
|
|||
done = conn->doInfo(t);
|
||||
conn->deref();
|
||||
if (!done)
|
||||
done = generic(e,t);
|
||||
done = generic(e,t,415);
|
||||
}
|
||||
else if (t->getDialogTag()) {
|
||||
done = true;
|
||||
t->setResponse(481);
|
||||
}
|
||||
else
|
||||
done = generic(e,t);
|
||||
done = generic(e,t,415);
|
||||
if (!done)
|
||||
t->setResponse(415);
|
||||
}
|
||||
|
@ -4820,11 +4842,10 @@ void YateSIPEndPoint::options(SIPEvent* e, SIPTransaction* t)
|
|||
t->setResponse(200);
|
||||
}
|
||||
|
||||
bool YateSIPEndPoint::generic(SIPEvent* e, SIPTransaction* t)
|
||||
bool YateSIPEndPoint::generic(SIPEvent* e, SIPTransaction* t, int defErr, bool async)
|
||||
{
|
||||
String meth(t->getMethod());
|
||||
meth.toLower();
|
||||
String user;
|
||||
Lock mylock(s_globalMutex);
|
||||
const String* auth = s_cfg.getKey("methods",meth);
|
||||
if (!auth)
|
||||
|
@ -4832,12 +4853,24 @@ bool YateSIPEndPoint::generic(SIPEvent* e, SIPTransaction* t)
|
|||
bool autoAuth = auth->toBoolean(true);
|
||||
mylock.drop();
|
||||
|
||||
if (async || s_gen_async) {
|
||||
YateSIPGeneric* gen = new YateSIPGeneric(this,e->getMessage(),t,meth,defErr,autoAuth);
|
||||
if (gen->startup())
|
||||
return true;
|
||||
Debug(&plugin,DebugWarn,"Failed to start generic thread");
|
||||
delete gen;
|
||||
}
|
||||
return generic(e->getMessage(),t,meth,autoAuth);
|
||||
}
|
||||
|
||||
bool YateSIPEndPoint::generic(const SIPMessage* message, SIPTransaction* t, const String& meth, bool autoAuth)
|
||||
{
|
||||
Message m("sip." + meth);
|
||||
const SIPMessage* message = e->getMessage();
|
||||
String host;
|
||||
int portNum = 0;
|
||||
message->getParty()->getAddr(host,portNum,false);
|
||||
URI uri(message->uri);
|
||||
String user;
|
||||
YateSIPLine* line = plugin.findLine(host,portNum,uri.getUser());
|
||||
if (line) {
|
||||
// message comes from line we have registered to
|
||||
|
@ -7803,6 +7836,7 @@ bool SipHandler::received(Message &msg)
|
|||
case BodyRaw:
|
||||
binBody.append(body);
|
||||
ok = true;
|
||||
break;
|
||||
case BodyHex:
|
||||
ok = binBody.unHexify(body,body.length());
|
||||
break;
|
||||
|
@ -8096,6 +8130,7 @@ void SIPDriver::initialize()
|
|||
s_tcpMaxpkt = getMaxpkt(s_cfg.getIntValue("general","tcp_maxpkt",4096),4096);
|
||||
s_lineKeepTcpOffline = s_cfg.getBoolValue("general","line_keeptcpoffline",!Engine::clientMode());
|
||||
s_defEncoding = s_cfg.getIntValue("general","body_encoding",SipHandler::s_bodyEnc,SipHandler::BodyBase64);
|
||||
s_gen_async = s_cfg.getBoolValue("general","async_generic",true);
|
||||
s_sipt_isup = s_cfg.getBoolValue("sip-t","isup",false);
|
||||
s_expires_min = s_cfg.getIntValue("registrar","expires_min",EXPIRES_MIN);
|
||||
s_expires_def = s_cfg.getIntValue("registrar","expires_def",EXPIRES_DEF);
|
||||
|
|
Loading…
Reference in New Issue