Add the text body of generic requests to the Yate message.

Check for looping in generic requests and generated messages.


git-svn-id: http://voip.null.ro/svn/yate@2095 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2008-07-24 14:22:19 +00:00
parent d612da3632
commit 0205f0b6da
1 changed files with 25 additions and 0 deletions

View File

@ -1850,6 +1850,14 @@ bool YateSIPEndPoint::generic(SIPEvent* e, SIPTransaction* t)
}
if (user)
m.addParam("username",user);
String tmp(message->getHeaderValue("Max-Forwards"));
int maxf = tmp.toInteger(s_maxForwards);
if (maxf > s_maxForwards)
maxf = s_maxForwards;
tmp = maxf-1;
m.addParam("antiloop",tmp);
m.addParam("ip_host",message->getParty()->getPartyAddr());
m.addParam("ip_port",String(message->getParty()->getPartyPort()));
m.addParam("sip_uri",t->getURI());
@ -1859,6 +1867,13 @@ bool YateSIPEndPoint::generic(SIPEvent* e, SIPTransaction* t)
m.addParam("xsip_dlgtag",t->getDialogTag());
copySipHeaders(m,*message,false);
// add the body if it's a string one
MimeStringBody* strBody = YOBJECT(MimeStringBody,message->body);
if (strBody) {
m.addParam("xsip_type",strBody->getType());
m.addParam("xsip_body",strBody->text());
}
int code = 0;
if (Engine::dispatch(m)) {
const String* ret = m.getParam("code");
@ -4349,6 +4364,15 @@ bool SipHandler::received(Message &msg)
uri = uri.matchString(1);
if (!(method && uri))
return false;
int maxf = msg.getIntValue("antiloop",s_maxForwards);
if (maxf <= 0) {
Debug(&plugin,DebugMild,"Blocking looping request '%s %s' [%p]",
method,uri.c_str(),this);
msg.setParam("error","looping");
return false;
}
YateSIPLine* line = plugin.findLine(msg.getValue("line"));
if (line && !line->valid()) {
msg.setParam("error","offline");
@ -4356,6 +4380,7 @@ bool SipHandler::received(Message &msg)
}
SIPMessage* sip = new SIPMessage(method,uri);
plugin.ep()->buildParty(sip,msg.getValue("host"),msg.getIntValue("port"),line);
sip->addHeader("Max-Forwards",String(maxf));
copySipHeaders(*sip,msg,"sip_");
const char* type = msg.getValue("xsip_type");
const char* body = msg.getValue("xsip_body");