Relay proper SIP responses on calling side.
authorMark Michelson <mmichelson@digium.com>
Mon, 4 Jun 2012 22:12:19 +0000 (22:12 +0000)
committerMark Michelson <mmichelson@digium.com>
Mon, 4 Jun 2012 22:12:19 +0000 (22:12 +0000)
Revision 351130 broke corect HANGUPCAUSE setting
for the 404 case in chan_sip. Other cases were also
potentially broken. This patch fixes the relaying
of causes to be what they used to be.

(closes issue ASTERISK-19914)
Reported by Pavel Troller
Tested by Walter Doekes (via a reviewboard test to be committed later)
Patches:
chan_sip.diff uploaded by Pavel Troller (license #6302)
........

Merged revisions 368498 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 368499 from http://svn.asterisk.org/svn/asterisk/branches/10

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368500 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 8456b0b..5ee1e4b 100644 (file)
@@ -21340,7 +21340,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                ast_log(LOG_WARNING, "Received response: \"Forbidden\" from '%s'\n", sip_get_header(&p->initreq, "From"));
                if (!req->ignore && p->owner) {
                        ast_set_hangupsource(p->owner, ast_channel_name(p->owner), 0);
-                       ast_queue_hangup_with_cause(p->owner, AST_CAUSE_CONGESTION);
+                       ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
                }
                break;
 
@@ -21348,7 +21348,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
                if (p->owner && !req->ignore) {
                        ast_set_hangupsource(p->owner, ast_channel_name(p->owner), 0);
-                       ast_queue_hangup_with_cause(p->owner, AST_CAUSE_CONGESTION);
+                       ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
                }
                break;
 
@@ -21358,7 +21358,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                ast_log(LOG_WARNING, "Re-invite to non-existing call leg on other UA. SIP dialog '%s'. Giving up.\n", p->callid);
                xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
                if (p->owner) {
-                       ast_queue_hangup_with_cause(p->owner, AST_CAUSE_CONGESTION);
+                       ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
                }
                break;
 
@@ -21373,7 +21373,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                append_history(p, "Identity", "SIP identity is required. Not supported by Asterisk.");
                ast_log(LOG_WARNING, "SIP identity required by proxy. SIP dialog '%s'. Giving up.\n", p->callid);
                if (p->owner && !req->ignore) {
-                       ast_queue_hangup_with_cause(p->owner, AST_CAUSE_CONGESTION);
+                       ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
                }
                break;
 
@@ -21407,7 +21407,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                } else {
                        /* We can't set up this call, so give up */
                        if (p->owner && !req->ignore) {
-                               ast_queue_hangup_with_cause(p->owner, AST_CAUSE_CONGESTION);
+                               ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
                        }
                }
                break;
@@ -21415,7 +21415,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
                if (p->owner && !req->ignore) {
                        if (ast_channel_state(p->owner) != AST_STATE_UP) {
-                               ast_queue_hangup_with_cause(p->owner, AST_CAUSE_CONGESTION);
+                               ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
                        } else {
                                /* This is a re-invite that failed. */
                                /* Reset the flag after a while
@@ -21439,7 +21439,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
        case 501: /* Not implemented */
                xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
                if (p->owner) {
-                       ast_queue_hangup_with_cause(p->owner, AST_CAUSE_CONGESTION);
+                       ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
                }
                break;
        }
@@ -22363,7 +22363,7 @@ static void handle_response(struct sip_pvt *p, int resp, const char *rest, struc
                                default:
                                        /* Send hangup */       
                                        if (owner && sipmethod != SIP_BYE)
-                                               ast_queue_hangup_with_cause(p->owner, AST_CAUSE_PROTOCOL_ERROR);
+                                               ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
                                        break;
                                }
                                /* ACK on invite */