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
|
; Can be one of: base64, hex, hexs, raw
|
||||||
;body_encoding=base64
|
;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
|
; flags: int: Miscellaneous SIP engine flags for broken implementations
|
||||||
; See SIPMessage::Flags and SIPMessage::complete() in the source for gory details
|
; See SIPMessage::Flags and SIPMessage::complete() in the source for gory details
|
||||||
;flags=0
|
;flags=0
|
||||||
|
|
|
@ -709,7 +709,8 @@ public:
|
||||||
void regReq(SIPEvent* e, SIPTransaction* t);
|
void regReq(SIPEvent* e, SIPTransaction* t);
|
||||||
void regRun(const SIPMessage* message, SIPTransaction* t);
|
void regRun(const SIPMessage* message, SIPTransaction* t);
|
||||||
void options(SIPEvent* e, 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);
|
bool buildParty(SIPMessage* message, const char* host = 0, int port = 0, const YateSIPLine* line = 0);
|
||||||
inline void addTcpTransport(YateSIPTCPTransport* trans) {
|
inline void addTcpTransport(YateSIPTCPTransport* trans) {
|
||||||
if (!trans)
|
if (!trans)
|
||||||
|
@ -832,6 +833,26 @@ private:
|
||||||
RefPointer<SIPTransaction> m_tr;
|
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
|
class YateSIPConnection : public Channel, public SDPSession, public YateSIPPartyHolder
|
||||||
{
|
{
|
||||||
friend class SipHandler;
|
friend class SipHandler;
|
||||||
|
@ -1114,6 +1135,7 @@ static bool s_1xx_formats = true;
|
||||||
static bool s_rtp_preserve = false;
|
static bool s_rtp_preserve = false;
|
||||||
static bool s_auth_register = true;
|
static bool s_auth_register = true;
|
||||||
static bool s_reg_async = true;
|
static bool s_reg_async = true;
|
||||||
|
static bool s_gen_async = true;
|
||||||
static bool s_multi_ringing = false;
|
static bool s_multi_ringing = false;
|
||||||
static bool s_refresh_nosdp = true;
|
static bool s_refresh_nosdp = true;
|
||||||
static bool s_update_target = false;
|
static bool s_update_target = false;
|
||||||
|
@ -4591,14 +4613,14 @@ bool YateSIPEndPoint::incoming(SIPEvent* e, SIPTransaction* t)
|
||||||
done = conn->doInfo(t);
|
done = conn->doInfo(t);
|
||||||
conn->deref();
|
conn->deref();
|
||||||
if (!done)
|
if (!done)
|
||||||
done = generic(e,t);
|
done = generic(e,t,415);
|
||||||
}
|
}
|
||||||
else if (t->getDialogTag()) {
|
else if (t->getDialogTag()) {
|
||||||
done = true;
|
done = true;
|
||||||
t->setResponse(481);
|
t->setResponse(481);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
done = generic(e,t);
|
done = generic(e,t,415);
|
||||||
if (!done)
|
if (!done)
|
||||||
t->setResponse(415);
|
t->setResponse(415);
|
||||||
}
|
}
|
||||||
|
@ -4820,11 +4842,10 @@ void YateSIPEndPoint::options(SIPEvent* e, SIPTransaction* t)
|
||||||
t->setResponse(200);
|
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());
|
String meth(t->getMethod());
|
||||||
meth.toLower();
|
meth.toLower();
|
||||||
String user;
|
|
||||||
Lock mylock(s_globalMutex);
|
Lock mylock(s_globalMutex);
|
||||||
const String* auth = s_cfg.getKey("methods",meth);
|
const String* auth = s_cfg.getKey("methods",meth);
|
||||||
if (!auth)
|
if (!auth)
|
||||||
|
@ -4832,12 +4853,24 @@ bool YateSIPEndPoint::generic(SIPEvent* e, SIPTransaction* t)
|
||||||
bool autoAuth = auth->toBoolean(true);
|
bool autoAuth = auth->toBoolean(true);
|
||||||
mylock.drop();
|
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);
|
Message m("sip." + meth);
|
||||||
const SIPMessage* message = e->getMessage();
|
|
||||||
String host;
|
String host;
|
||||||
int portNum = 0;
|
int portNum = 0;
|
||||||
message->getParty()->getAddr(host,portNum,false);
|
message->getParty()->getAddr(host,portNum,false);
|
||||||
URI uri(message->uri);
|
URI uri(message->uri);
|
||||||
|
String user;
|
||||||
YateSIPLine* line = plugin.findLine(host,portNum,uri.getUser());
|
YateSIPLine* line = plugin.findLine(host,portNum,uri.getUser());
|
||||||
if (line) {
|
if (line) {
|
||||||
// message comes from line we have registered to
|
// message comes from line we have registered to
|
||||||
|
@ -7803,6 +7836,7 @@ bool SipHandler::received(Message &msg)
|
||||||
case BodyRaw:
|
case BodyRaw:
|
||||||
binBody.append(body);
|
binBody.append(body);
|
||||||
ok = true;
|
ok = true;
|
||||||
|
break;
|
||||||
case BodyHex:
|
case BodyHex:
|
||||||
ok = binBody.unHexify(body,body.length());
|
ok = binBody.unHexify(body,body.length());
|
||||||
break;
|
break;
|
||||||
|
@ -8096,6 +8130,7 @@ void SIPDriver::initialize()
|
||||||
s_tcpMaxpkt = getMaxpkt(s_cfg.getIntValue("general","tcp_maxpkt",4096),4096);
|
s_tcpMaxpkt = getMaxpkt(s_cfg.getIntValue("general","tcp_maxpkt",4096),4096);
|
||||||
s_lineKeepTcpOffline = s_cfg.getBoolValue("general","line_keeptcpoffline",!Engine::clientMode());
|
s_lineKeepTcpOffline = s_cfg.getBoolValue("general","line_keeptcpoffline",!Engine::clientMode());
|
||||||
s_defEncoding = s_cfg.getIntValue("general","body_encoding",SipHandler::s_bodyEnc,SipHandler::BodyBase64);
|
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_sipt_isup = s_cfg.getBoolValue("sip-t","isup",false);
|
||||||
s_expires_min = s_cfg.getIntValue("registrar","expires_min",EXPIRES_MIN);
|
s_expires_min = s_cfg.getIntValue("registrar","expires_min",EXPIRES_MIN);
|
||||||
s_expires_def = s_cfg.getIntValue("registrar","expires_def",EXPIRES_DEF);
|
s_expires_def = s_cfg.getIntValue("registrar","expires_def",EXPIRES_DEF);
|
||||||
|
|
Loading…
Reference in New Issue