Author: rco
Date: 2008-10-16 10:58:40 +0200 (Thu, 16 Oct 2008)
New Revision: 1120
Modified:
branches/1.0.0/core/plug-in/sipctrl/SipCtrlInterface.cpp
branches/1.0.0/core/plug-in/sipctrl/parse_header.cpp
branches/1.0.0/core/plug-in/sipctrl/sip_parser.cpp
branches/1.0.0/core/plug-in/sipctrl/sip_parser.h
branches/1.0.0/core/plug-in/sipctrl/trans_layer.cpp
Log:
fixes SEMS-44.
Modified: branches/1.0.0/core/plug-in/sipctrl/SipCtrlInterface.cpp
===================================================================
--- branches/1.0.0/core/plug-in/sipctrl/SipCtrlInterface.cpp 2008-10-16
08:54:04 UTC (rev 1119)
+++ branches/1.0.0/core/plug-in/sipctrl/SipCtrlInterface.cpp 2008-10-16
08:58:40 UTC (rev 1120)
@@ -497,16 +497,18 @@
req.port = int2str(ntohs(((sockaddr_in*)(&msg->local_ip))->sin_port));
req.r_uri = c2stlstr(msg->u.request->ruri_str);
- if(msg->contact){
+ if(get_contact(msg)){
sip_nameaddr na;
- const char* c = msg->contact->value.s;
- if(parse_nameaddr(&na,&c,msg->contact->value.len) < 0){
- DBG("Contact parsing failed\n");
+ const char* c = get_contact(msg)->value.s;
+ if(parse_nameaddr(&na,&c,get_contact(msg)->value.len) < 0){
+ WARN("Contact parsing failed:\n");
+ WARN("\tcontact =
'%.*s'\n",get_contact(msg)->value.len,get_contact(msg)->value.s);
+ WARN("\trequest = '%.*s'\n",msg->len,msg->buf);
}
else {
req.from_uri = c2stlstr(na.addr);
- req.contact = c2stlstr(msg->contact->value);
+ req.contact = c2stlstr(get_contact(msg)->value);
}
}
@@ -559,12 +561,13 @@
reply.code = msg->u.reply->code;
reply.reason = c2stlstr(msg->u.reply->reason);
- if(msg->contact){
+ if(get_contact(msg)){
- const char* c = msg->contact->value.s;
+ // parse the first contact
+ const char* c = get_contact(msg)->value.s;
sip_nameaddr na;
- int err = parse_nameaddr(&na,&c,msg->contact->value.len);
+ int err = parse_nameaddr(&na,&c,get_contact(msg)->value.len);
if(err < 0) {
ERROR("Contact nameaddr parsing failed\n");
@@ -572,8 +575,13 @@
}
// 'Contact' header?
- reply.next_request_uri = c2stlstr(na.addr);
- reply.contact = c2stlstr(msg->contact->value);
+ reply.next_request_uri = c2stlstr(na.addr);
+
+ list<sip_header*>::iterator c_it = msg->contacts.begin();
+ reply.contact = c2stlstr((*c_it)->value);
+ for(;c_it!=msg->contacts.end(); ++c_it){
+ reply.contact += "," + c2stlstr((*c_it)->value);
+ }
}
reply.callid = c2stlstr(msg->callid->value);
@@ -584,12 +592,6 @@
reply.dstip = get_addr_str(((sockaddr_in*)(&msg->local_ip))->sin_addr);
//FIXME: IPv6
reply.port = int2str(ntohs(((sockaddr_in*)(&msg->local_ip))->sin_port));
- //if( (get_cseq(msg)->method == sip_request::INVITE)
- // && (msg->u.reply->code >= 200)
- // && (msg->u.reply->code < 300) ){
- // tl->send_200_ack(msg);
- //}
-
prepare_routes_uac(msg->record_route, reply.route);
for (list<sip_header*>::iterator it = msg->hdrs.begin();
Modified: branches/1.0.0/core/plug-in/sipctrl/parse_header.cpp
===================================================================
--- branches/1.0.0/core/plug-in/sipctrl/parse_header.cpp 2008-10-16
08:54:04 UTC (rev 1119)
+++ branches/1.0.0/core/plug-in/sipctrl/parse_header.cpp 2008-10-16
08:58:40 UTC (rev 1120)
@@ -112,7 +112,7 @@
} break;
case 'm': { // Contact
h->type = sip_header::H_CONTACT;
- msg->contact = h;
+ msg->contacts.push_back(h);
} break;
// case 'e': // Content-Encoding
// {} break;
@@ -209,7 +209,7 @@
case 'O':
if(!lower_cmp(h->name.s+2,CONTACT_lc+2,CONTACT_len-2)){
h->type = sip_header::H_CONTACT;
- msg->contact = h;
+ msg->contacts.push_back(h);
}
break;
Modified: branches/1.0.0/core/plug-in/sipctrl/sip_parser.cpp
===================================================================
--- branches/1.0.0/core/plug-in/sipctrl/sip_parser.cpp 2008-10-16 08:54:04 UTC
(rev 1119)
+++ branches/1.0.0/core/plug-in/sipctrl/sip_parser.cpp 2008-10-16 08:58:40 UTC
(rev 1120)
@@ -46,7 +46,7 @@
cseq(NULL),
via1(NULL),via_p1(NULL),
callid(NULL),
- contact(NULL),
+ contacts(),
route(),
record_route(),
content_type(NULL),
@@ -73,7 +73,7 @@
cseq(NULL),
via1(NULL),via_p1(NULL),
callid(NULL),
- contact(NULL),
+ contacts(),
route(),
record_route(),
content_type(NULL),
Modified: branches/1.0.0/core/plug-in/sipctrl/sip_parser.h
===================================================================
--- branches/1.0.0/core/plug-in/sipctrl/sip_parser.h 2008-10-16 08:54:04 UTC
(rev 1119)
+++ branches/1.0.0/core/plug-in/sipctrl/sip_parser.h 2008-10-16 08:58:40 UTC
(rev 1120)
@@ -111,7 +111,8 @@
sip_via_parm* via_p1;
sip_header* callid;
- sip_header* contact;
+
+ list<sip_header*> contacts;
list<sip_header*> route;
list<sip_header*> record_route;
sip_header* content_type;
@@ -130,6 +131,8 @@
int parse_method(int* method, const char* beg, int len);
int parse_sip_msg(sip_msg* msg);
+#define get_contact(msg) (msg->contacts.empty() ? NULL :
(*msg->contacts.begin()))
+
#endif
/** EMACS **
Modified: branches/1.0.0/core/plug-in/sipctrl/trans_layer.cpp
===================================================================
--- branches/1.0.0/core/plug-in/sipctrl/trans_layer.cpp 2008-10-16 08:54:04 UTC
(rev 1119)
+++ branches/1.0.0/core/plug-in/sipctrl/trans_layer.cpp 2008-10-16 08:58:40 UTC
(rev 1120)
@@ -653,7 +653,7 @@
+ copy_hdr_len(req->callid)
+ cseq_len(get_cseq(req)->num_str,cancel_str)
+ copy_hdrs_len(req->route)
- + copy_hdr_len(req->contact);
+ + copy_hdrs_len(req->contacts);
request_len += 2/* CRLF end-of-headers*/;
@@ -673,7 +673,7 @@
copy_hdr_wr(&c,req->callid);
cseq_wr(&c,get_cseq(req)->num_str,cancel_str);
copy_hdrs_wr(&c,req->route);
- copy_hdr_wr(&c,req->contact);
+ copy_hdrs_wr(&c,req->contacts);
*c++ = CR;
*c++ = LF;
@@ -1156,14 +1156,14 @@
{
// Set request URI
// TODO: use correct R-URI instead of just 'Contact'
- if(!reply->contact) {
+ if(!get_contact(reply)) {
DBG("Sorry, reply has no Contact header: could not send ACK\n");
return;
}
sip_nameaddr na;
- const char* c = reply->contact->value.s;
- if(parse_nameaddr(&na,&c,reply->contact->value.len) < 0){
+ const char* c = get_contact(reply)->value.s;
+ if(parse_nameaddr(&na,&c,get_contact(reply)->value.len) < 0){
DBG("Sorry, reply's Contact parsing failed: could not send ACK\n");
return;
}
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev