[asterisk-commits] trunk r20844 - /trunk/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Apr 17 01:15:43 MST 2006
Author: oej
Date: Mon Apr 17 03:15:38 2006
New Revision: 20844
URL: http://svn.digium.com/view/asterisk?rev=20844&view=rev
Log:
Clean up handle_response_invite
Modified:
trunk/channels/chan_sip.c
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=20844&r1=20843&r2=20844&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Apr 17 03:15:38 2006
@@ -1078,6 +1078,7 @@
static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e);
static void handle_request_info(struct sip_pvt *p, struct sip_request *req);
static int handle_request_options(struct sip_pvt *p, struct sip_request *req);
+static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
/*----- RTP interface functions */
static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active);
@@ -9728,7 +9729,7 @@
}
/*! \brief Handle SIP response in dialogue */
-static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int ignore, int seqno)
+static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno)
{
int outgoing = ast_test_flag(&p->flags[0], SIP_OUTGOING);
@@ -9747,39 +9748,39 @@
switch (resp) {
case 100: /* Trying */
- if (!ignore)
+ if (!ast_test_flag(req, SIP_PKT_IGNORE))
sip_cancel_destroy(p);
break;
case 180: /* 180 Ringing */
- if (!ignore)
+ if (!ast_test_flag(req, SIP_PKT_IGNORE))
sip_cancel_destroy(p);
- if (!ignore && p->owner) {
+ if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
ast_queue_control(p->owner, AST_CONTROL_RINGING);
if (p->owner->_state != AST_STATE_UP)
ast_setstate(p->owner, AST_STATE_RINGING);
}
if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
process_sdp(p, req);
- if (!ignore && p->owner) {
+ if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
/* Queue a progress frame only if we have SDP in 180 */
ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
}
}
break;
case 183: /* Session progress */
- if (!ignore)
+ if (!ast_test_flag(req, SIP_PKT_IGNORE))
sip_cancel_destroy(p);
/* Ignore 183 Session progress without SDP */
if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
process_sdp(p, req);
- if (!ignore && p->owner) {
+ if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
/* Queue a progress frame */
ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
}
}
break;
case 200: /* 200 OK on invite - someone's answering our call */
- if (!ignore)
+ if (!ast_test_flag(req, SIP_PKT_IGNORE))
sip_cancel_destroy(p);
p->authtries = 0;
if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp"))
@@ -9798,7 +9799,7 @@
should we care about resolving the contact
or should we just send it?
*/
- if (!ignore)
+ if (!ast_test_flag(req, SIP_PKT_IGNORE))
ast_set_flag(&p->flags[0], SIP_PENDINGBYE);
}
@@ -9806,7 +9807,7 @@
build_route(p, req, 1);
}
- if (!ignore && p->owner) {
+ if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
if (p->owner->_state != AST_STATE_UP) {
ast_queue_control(p->owner, AST_CONTROL_ANSWER);
} else { /* RE-invite */
@@ -9816,7 +9817,7 @@
/* It's possible we're getting an 200 OK after we've tried to disconnect
by sending CANCEL */
/* First send ACK, then send bye */
- if (!ignore)
+ if (!ast_test_flag(req, SIP_PKT_IGNORE))
ast_set_flag(&p->flags[0], SIP_PENDINGBYE);
}
/* If I understand this right, the branch is different for a non-200 ACK only */
@@ -9832,7 +9833,7 @@
/* Then we AUTH */
ast_string_field_free(p, theirtag); /* forget their old tag, so we don't match tags when getting response */
- if (!ignore) {
+ if (!ast_test_flag(req, SIP_PKT_IGNORE)) {
char *authenticate = (resp == 401 ? "WWW-Authenticate" : "Proxy-Authenticate");
char *authorization = (resp == 401 ? "Authorization" : "Proxy-Authorization");
if ((p->authtries == MAX_AUTHTRIES) || do_proxy_auth(p, req, authenticate, authorization, SIP_INVITE, 1)) {
@@ -9848,14 +9849,14 @@
/* First we ACK */
transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, 0);
ast_log(LOG_WARNING, "Received response: \"Forbidden\" from '%s'\n", get_header(&p->initreq, "From"));
- if (!ignore && p->owner)
+ if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner)
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
ast_set_flag(&p->flags[0], SIP_ALREADYGONE);
break;
case 404: /* Not found */
transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, 0);
- if (p->owner && !ignore)
+ if (p->owner && !ast_test_flag(req, SIP_PKT_IGNORE))
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
ast_set_flag(&p->flags[0], SIP_ALREADYGONE);
break;
@@ -10151,15 +10152,15 @@
switch(resp) {
case 100: /* 100 Trying */
if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
break;
case 183: /* 183 Session Progress */
if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
break;
case 180: /* 180 Ringing */
if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
break;
case 200: /* 200 OK */
p->authtries = 0; /* Reset authentication counter */
@@ -10177,7 +10178,7 @@
}
}
} else if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
else if (sipmethod == SIP_REGISTER)
res = handle_response_register(p, resp, rest, req, ignore, seqno);
break;
@@ -10187,7 +10188,7 @@
break;
case 401: /* Not www-authorized on SIP method */
if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
else if (sipmethod == SIP_REFER)
handle_response_refer(p, resp, rest, req, ignore, seqno);
else if (p->registry && sipmethod == SIP_REGISTER)
@@ -10199,7 +10200,7 @@
break;
case 403: /* Forbidden - we failed authentication */
if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
else if (p->registry && sipmethod == SIP_REGISTER)
res = handle_response_register(p, resp, rest, req, ignore, seqno);
else {
@@ -10211,13 +10212,13 @@
if (p->registry && sipmethod == SIP_REGISTER)
res = handle_response_register(p, resp, rest, req, ignore, seqno);
else if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
else if (owner)
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
break;
case 407: /* Proxy auth required */
if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
else if (sipmethod == SIP_REFER)
handle_response_refer(p, resp, rest, req, ignore, seqno);
else if (p->registry && sipmethod == SIP_REGISTER)
@@ -10237,7 +10238,7 @@
break;
case 491: /* Pending */
if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
else {
ast_log(LOG_DEBUG, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
@@ -10245,7 +10246,7 @@
break;
case 501: /* Not Implemented */
if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
else if (sipmethod == SIP_REFER)
handle_response_refer(p, resp, rest, req, ignore, seqno);
else
@@ -10358,7 +10359,7 @@
switch(resp) {
case 200:
if (sipmethod == SIP_INVITE) {
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
} else if (sipmethod == SIP_CANCEL) {
ast_log(LOG_DEBUG, "Got 200 OK on CANCEL\n");
/* Wait for 487, then destroy */
@@ -10375,7 +10376,7 @@
if (sipmethod == SIP_REFER)
handle_response_refer(p, resp, rest, req, ignore, seqno);
else if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
else if (sipmethod == SIP_BYE) {
char *auth, *auth2;
@@ -10390,12 +10391,12 @@
case 481: /* Call leg does not exist */
if (sipmethod == SIP_INVITE) {
/* Re-invite failed */
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
}
break;
case 501: /* Not Implemented */
if (sipmethod == SIP_INVITE)
- handle_response_invite(p, resp, rest, req, ignore, seqno);
+ handle_response_invite(p, resp, rest, req, seqno);
else if (sipmethod == SIP_REFER)
handle_response_refer(p, resp, rest, req, ignore, seqno);
break;
More information about the asterisk-commits
mailing list