[asterisk-commits] rizzo: branch rizzo/astobj2 r51280 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Jan 19 01:58:42 MST 2007
Author: rizzo
Date: Fri Jan 19 02:58:42 2007
New Revision: 51280
URL: http://svn.digium.com/view/asterisk?view=rev&rev=51280
Log:
merge from trunk 50132 and 50378 (fix for missing braces)
- handle re-invites properly in sip_hangup()
- Add some invitestate status changes just to be sure
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=51280&r1=51279&r2=51280
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Fri Jan 19 02:58:42 2007
@@ -3703,8 +3703,8 @@
sip_pvt_unlock(p);
return 0;
}
- /* If the call is not UP, we need to send CANCEL instead of BYE */
- if (p->invitestate < INV_COMPLETED) {
+ /* In case of re-invites, the call might be UP even though we have an incomplete invite transaction */
+ if (p->invitestate < INV_COMPLETED && p->owner->_state != AST_STATE_UP) {
needcancel = TRUE;
if (option_debug > 3)
ast_log(LOG_DEBUG, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
@@ -4055,7 +4055,7 @@
case AST_CONTROL_BUSY:
if (ast->_state != AST_STATE_UP) {
transmit_response(p, "486 Busy Here", &p->initreq);
- p->invitestate = INV_TERMINATED;
+ p->invitestate = INV_COMPLETED;
sip_alreadygone(p);
ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
break;
@@ -4065,7 +4065,7 @@
case AST_CONTROL_CONGESTION:
if (ast->_state != AST_STATE_UP) {
transmit_response(p, "503 Service Unavailable", &p->initreq);
- p->invitestate = INV_TERMINATED;
+ p->invitestate = INV_COMPLETED;
sip_alreadygone(p);
ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
break;
@@ -13803,6 +13803,7 @@
/* At this point we only support REPLACES */
transmit_response_with_unsupported(p, "420 Bad extension (unsupported)", req, required);
ast_log(LOG_WARNING,"Received SIP INVITE with unsupported required extension: %s\n", required);
+ p->invitestate = INV_COMPLETED;
if (!p->lastinvite)
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
return -1;
@@ -13817,6 +13818,7 @@
/* If pedantic is on, we need to check the tags. If they're different, this is
in fact a forked call through a SIP proxy somewhere. */
transmit_response(p, "482 Loop Detected", req);
+ p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
return 0;
}
@@ -13857,6 +13859,7 @@
transmit_response(p, "500 Server Internal Error", req);
append_history(p, "Xfer", "INVITE/Replace Failed. Out of memory.");
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+ p->invitestate = INV_COMPLETED;
return -1;
}
@@ -13936,6 +13939,7 @@
sip_pvt_unlock(p->refer->refer_call);
ast_channel_unlock(p->refer->refer_call->owner);
}
+ p->invitestate = INV_COMPLETED;
return -1;
}
}
@@ -13987,8 +13991,10 @@
/* This is a new invite */
/* Handle authentication if this is our first invite */
res = check_user(p, req, SIP_INVITE, e, XMIT_RELIABLE, sin);
- if (res == AUTH_CHALLENGE_SENT)
+ if (res == AUTH_CHALLENGE_SENT) {
+ p->invitestate = INV_COMPLETED; /* Needs to restart in another INVITE transaction */
return 0;
+ }
if (res < 0) { /* Something failed in authentication */
if (res == AUTH_FAKE_AUTH) {
ast_log(LOG_NOTICE, "Sending fake auth rejection for user %s\n", get_header(req, "From"));
@@ -13997,6 +14003,7 @@
ast_log(LOG_NOTICE, "Failed to authenticate user %s\n", get_header(req, "From"));
transmit_response_reliable(p, "403 Forbidden", req);
}
+ p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
ast_string_field_free(p, theirtag);
return 0;
@@ -14007,6 +14014,7 @@
if (process_sdp(p, req)) {
/* Unacceptable codecs */
transmit_response_reliable(p, "488 Not acceptable here", req);
+ p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
if (option_debug)
ast_log(LOG_DEBUG, "No compatible codecs for this SIP call.\n");
@@ -14036,6 +14044,7 @@
if (res < 0) {
ast_log(LOG_NOTICE, "Failed to place call for user %s, too many calls\n", p->username);
transmit_response_reliable(p, "480 Temporarily Unavailable (Call limit) ", req);
+ p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
}
return 0;
@@ -14056,6 +14065,7 @@
else
transmit_response_reliable(p, "404 Not Found", req);
update_call_counter(p, DEC_CALL_LIMIT);
+ p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
return 0;
} else {
@@ -14255,6 +14265,7 @@
/* No bridged peer with T38 enabled*/
}
}
+ /* Respond to normal re-invite */
if (sendok)
transmit_response_with_sdp(p, "200 OK", req, XMIT_CRITICAL);
@@ -15361,7 +15372,7 @@
case SIP_ACK:
/* Make sure we don't ignore this */
if (seqno == p->pendinginvite) {
- p->invitestate = INV_CONFIRMED;
+ p->invitestate = INV_TERMINATED;
p->pendinginvite = 0;
__sip_ack(p, seqno, FLAG_RESPONSE, 0);
if (find_sdp(req)) {
More information about the asterisk-commits
mailing list