- fixed various bugs including missing body in new requests.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@672 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Raphael Coeffic 19 years ago
parent dc4fa2cab2
commit 2f920da7c2

@ -279,52 +279,6 @@ string AmSipDialog::getContactHdr()
return res;
}
#if 0
string AmSipDialog::getContactHdr()
{
if(!contact_uri.empty())
return contact_uri;
string res = "Contact: <sip:";
if(user.empty() || !AmConfig::PrefixSep.empty())
res += CONTACT_USER_PREFIX;
if(!AmConfig::PrefixSep.empty())
res += AmConfig::PrefixSep;
if(!user.empty())
res += user;
res += "@";
if(sip_ip.empty())
res += "!!"; // Ser will replace that...
else {
#ifdef SUPPORT_IPV6
if(sip_ip.find('.') != string::npos)
res += sip_ip;
else
res += "[" + sip_ip + "]";
#else
res += sip_ip;
#endif
}
if(!sip_port.empty())
res += ":" + sip_port;
res += ">\n";
// save contact_uri for subsequent contact header
// only if sip_ip is known
if (!sip_ip.empty())
contact_uri = res;
return res;
}
#endif
int AmSipDialog::reply(const AmSipRequest& req,
unsigned int code,
const string& reason,
@ -345,7 +299,7 @@ int AmSipDialog::reply(const AmSipRequest& req,
reply.reason = reason;
reply.serKey = req.serKey;
reply.local_tag = local_tag;
reply.hdrs = hdrs;
reply.hdrs = m_hdrs;
if ((req.method!="CANCEL")&&
!((req.method=="BYE")&&(code<300)))
reply.contact = getContactHdr();

@ -145,20 +145,9 @@ int SipCtrlInterface::send(const AmSipRequest &req, string &serKey)
// Max-Forwards
//string from = req.from;
//if(!req.from_tag.empty())
// from += ";tag=" + req.from_tag;
//msg->from = new sip_header(0,"From",stl2cstr(from));
//msg->hdrs.push_back(msg->from);
char* c = (char*)req.from.c_str();
int err = parse_headers(msg,&c);
//msg->to = new sip_header(0,"To",stl2cstr(req.to));
//msg->hdrs.push_back(msg->to);
DBG("req.to == '%s'\n",req.to.c_str());
c = (char*)req.to.c_str();
err = err || parse_headers(msg,&c);
@ -180,7 +169,6 @@ int SipCtrlInterface::send(const AmSipRequest &req, string &serKey)
if(!req.contact.empty()){
DBG("req.contact == '%s'\n",req.contact.c_str());
c = (char*)req.contact.c_str();
err = parse_headers(msg,&c);
if(err){
@ -188,9 +176,6 @@ int SipCtrlInterface::send(const AmSipRequest &req, string &serKey)
delete msg;
return -1;
}
//msg->contact = new sip_header(0,"Contact",stl2cstr(req.contact));
//msg->hdrs.push_back(msg->contact);
}
msg->hdrs.push_back(new sip_header(0,"Max-Forwards","10")); // FIXME
@ -224,6 +209,33 @@ int SipCtrlInterface::send(const AmSipRequest &req, string &serKey)
msg->hdrs.pop_back();
}
}
if(!req.hdrs.empty()) {
char *c = (char*)req.hdrs.c_str();
err = parse_headers(msg,&c);
if(err){
ERROR("Additional headers parsing failed\n");
ERROR("Faulty headers were: <%s>\n",req.hdrs.c_str());
delete msg;
return -1;
}
}
if(!req.body.empty()){
if(req.content_type.empty()){
ERROR("Body in request without content type\n");
}
else {
msg->content_type = new sip_header(0,"Content-Type",stl2cstr(req.content_type));
msg->hdrs.push_back(msg->content_type);
msg->body = stl2cstr(req.body);
}
}
tl->send_request(msg);
delete msg;
@ -259,13 +271,21 @@ int SipCtrlInterface::send(const AmSipReply &rep)
return -1;
}
string hdrs = rep.hdrs;
hdrs += "Content-Type: " + rep.content_type + "\r\n";
string hdrs = rep.hdrs + rep.contact;
if(!rep.body.empty()) {
if(rep.content_type.empty()){
ERROR("Reply does not contain a Content-Type whereby body is not empty\n");
return -1;
}
hdrs += "Content-Type: " + rep.content_type + "\r\n";
}
return tl->send_reply(get_trans_bucket(h),(sip_trans*)t,
rep.code,stl2cstr(rep.reason),
stl2cstr(rep.local_tag), stl2cstr(rep.contact),
stl2cstr(rep.hdrs), stl2cstr(rep.body));
stl2cstr(rep.local_tag),
stl2cstr(hdrs), stl2cstr(rep.body));
}
#define DBG_PARAM(p)\

@ -64,8 +64,8 @@ void trans_layer::register_transport(udp_trsp* trsp)
int trans_layer::send_reply(trans_bucket* bucket, sip_trans* t,
int reply_code, const cstring& reason,
const cstring& to_tag, const cstring& contact,
const cstring& hdrs, const cstring& body)
const cstring& to_tag, const cstring& hdrs,
const cstring& body)
{
// Ref.: RFC 3261 8.2.6, 12.1.1
//
@ -132,11 +132,11 @@ int trans_layer::send_reply(trans_bucket* bucket, sip_trans* t,
// We do not send Contact for
// 100 provisional replies
//
if((reply_code > 100) && contact.len){
//if((reply_code > 100) && contact.len){
reply_len += contact_len(contact);
add_contact = true;
}
//reply_len += contact_len(contact);
//add_contact = true;
//}
reply_len += hdrs.len;
@ -198,9 +198,9 @@ int trans_layer::send_reply(trans_bucket* bucket, sip_trans* t,
}
}
if(add_contact){
contact_wr(&c,contact);
}
//if(add_contact){
//contact_wr(&c,contact);
//}
memcpy(c,hdrs.s,hdrs.len);
c += hdrs.len;

@ -101,8 +101,8 @@ class trans_layer
*/
int send_reply(trans_bucket* bucket, sip_trans* t,
int reply_code, const cstring& reason,
const cstring& to_tag, const cstring& contact,
const cstring& hdrs, const cstring& body);
const cstring& to_tag, const cstring& hdrs,
const cstring& body);
/**
* Sends a UAC request.

Loading…
Cancel
Save