[Asterisk-cvs] asterisk/channels chan_sip.c,1.469,1.470
markster at lists.digium.com
markster at lists.digium.com
Tue Aug 17 10:34:37 CDT 2004
Update of /usr/cvsroot/asterisk/channels
In directory localhost.localdomain:/tmp/cvs-serv11334/channels
Modified Files:
chan_sip.c
Log Message:
Fix broken 100 Trying on REFER and also send NOTIFY as per RFC 3515
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.469
retrieving revision 1.470
diff -u -d -r1.469 -r1.470
--- chan_sip.c 17 Aug 2004 01:57:16 -0000 1.469
+++ chan_sip.c 17 Aug 2004 14:20:43 -0000 1.470
@@ -3854,13 +3854,13 @@
return send_request(p, &req, 1, p->ocseq);
}
-/*--- transmit_notify: Notify user of messages waiting in voicemail ---*/
+/*--- transmit_notify_with_mwi: Notify user of messages waiting in voicemail ---*/
/* Notification only works for registred peers with mailbox= definitions
* in sip.conf
* We use the SIP Event package message-summary
* MIME type defaults to "application/simple-message-summary";
*/
-static int transmit_notify(struct sip_pvt *p, int newmsgs, int oldmsgs)
+static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs)
{
struct sip_request req;
char tmp[256];
@@ -3889,6 +3889,41 @@
return send_request(p, &req, 1, p->ocseq);
}
+/*--- transmit_notify_with_sipfrag: Notify a transferring party of the status of trasnfer ---*/
+/* Apparently the draft SIP REFER structure was too simple, so it was decided that the
+ * status of transfers also needed to be sent via NOTIFY instead of just the 202 Accepted
+ * that had worked heretofore.
+ */
+static int transmit_notify_with_sipfrag(struct sip_pvt *p, int cseq)
+{
+ struct sip_request req;
+ char tmp[256];
+ char tmp2[256];
+ char clen[20];
+ initreqprep(&req, p, "NOTIFY", NULL);
+ snprintf(tmp, sizeof(tmp), "refer;id=%d", cseq);
+ add_header(&req, "Event", tmp);
+ add_header(&req, "Subscription-state", "terminated;reason=noresource");
+ add_header(&req, "Content-Type", "message/sipfrag;version=2.0");
+
+ strncpy(tmp, "SIP/2.0 200 OK", sizeof(tmp) - 1);
+ snprintf(clen, sizeof(clen), "%d", (int)(strlen(tmp)));
+ add_header(&req, "Content-Length", clen);
+ add_line(&req, tmp);
+ add_line(&req, tmp2);
+
+ if (!p->initreq.headers) {
+ /* Use this as the basis */
+ copy_request(&p->initreq, &req);
+ parse(&p->initreq);
+ if (sip_debug_test_pvt(p))
+ ast_verbose("%d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
+ determine_firstline_parts(&p->initreq);
+ }
+
+ return send_request(p, &req, 1, p->ocseq);
+}
+
static int transmit_register(struct sip_registry *r, char *cmd, char *auth, char *authheader);
/*--- sip_reregister: Update registration with SIP Proxy---*/
@@ -6707,7 +6742,6 @@
{
struct ast_channel *chan1, *chan2;
struct sip_dual *d;
- struct sip_pvt *p;
struct sip_request req;
int ext;
int res;
@@ -6720,9 +6754,6 @@
ast_do_masquerade(chan1);
ast_mutex_unlock(&chan1->lock);
res = ast_park_call(chan1, chan2, 0, &ext);
- /* Finally send the accepted */
- p = chan2->pvt->pvt;
- transmit_response(p, "202 Accepted", &req);
/* Then hangup */
ast_hangup(chan2);
ast_log(LOG_DEBUG, "Parked on extension '%d'\n", ext);
@@ -7132,8 +7163,6 @@
if (transfer_to) {
ast_moh_stop(transfer_to);
if (!strcmp(p->refer_to, ast_parking_ext())) {
- /* We send a 100 Trying */
- transmit_response(p, "100 Trying", req);
/* Must release c's lock now, because it will not longer
be accessible after the transfer! */
*nounlock = 1;
@@ -7153,9 +7182,10 @@
}
p->gotrefer = 1;
}
+ transmit_response(p, "202 Accepted", req);
+ transmit_notify_with_sipfrag(p, seqno);
/* Always increment on a BYE */
if (!nobye) {
- transmit_response(p, "202 Accepted", req);
transmit_request_with_auth(p, "BYE", 0, 1, 1);
p->alreadygone = 1;
}
@@ -7485,7 +7515,7 @@
build_callid(p->callid, sizeof(p->callid), p->ourip);
/* Send MWI */
p->outgoing = 1;
- transmit_notify(p, newmsgs, oldmsgs);
+ transmit_notify_with_mwi(p, newmsgs, oldmsgs);
sip_scheddestroy(p, 15000);
return 0;
}
More information about the svn-commits
mailing list