From 5320c6b76a52fcbdf6c534ed94e51fa5ffdebd03 Mon Sep 17 00:00:00 2001 From: Olle Johansson Date: Mon, 17 Apr 2006 14:00:44 +0000 Subject: - Add supported header - Send cause codes as well git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20908 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 7d7114b8f..4b581917e 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -4314,6 +4314,7 @@ static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg copy_header(resp, req, "CSeq"); add_header(resp, "User-Agent", global_useragent); add_header(resp, "Allow", ALLOWED_METHODS); + add_header(resp, "Supported", SUPPORTED_EXTENSIONS); if (msg[0] == '2' && (p->method == SIP_SUBSCRIBE || p->method == SIP_REGISTER)) { /* For registration responses, we also need expiry and contact info */ @@ -4448,8 +4449,12 @@ static int __transmit_response(struct sip_pvt *p, const char *msg, struct sip_re add_header_contentLength(&resp, 0); /* If we are cancelling an incoming invite for some reason, add information about the reason why we are doing this in clear text */ - if (msg[0] != '1' && p->owner && p->owner->hangupcause) { + if (p->method == SIP_INVITE && msg[0] != '1' && p->owner && p->owner->hangupcause) { + char buf[10]; + add_header(&resp, "X-Asterisk-HangupCause", ast_cause2str(p->owner->hangupcause)); + snprintf(buf, sizeof(buf), "%d", p->owner->hangupcause); + add_header(&resp, "X-Asterisk-HangupCauseCode", buf); } add_blank_header(&resp); return send_response(p, &resp, reliable, seqno); @@ -5905,10 +5910,12 @@ static int transmit_request_with_auth(struct sip_pvt *p, int sipmethod, int seqn } /* If we are hanging up and know a cause for that, send it in clear text to make debugging easier. */ - if (sipmethod == SIP_BYE) { - if (p->owner && p->owner->hangupcause) { - add_header(&resp, "X-Asterisk-HangupCause", ast_cause2str(p->owner->hangupcause)); - } + if (sipmethod == SIP_BYE && p->owner && p->owner->hangupcause) { + char buf[10]; + + add_header(&resp, "X-Asterisk-HangupCause", ast_cause2str(p->owner->hangupcause)); + snprintf(buf, sizeof(buf), "%d", p->owner->hangupcause); + add_header(&resp, "X-Asterisk-HangupCauseCode", buf); } add_header_contentLength(&resp, 0); -- cgit v1.2.3